All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codingapi.springboot.fast.jpa.repository.DynamicRepository Maven / Gradle / Ivy

There is a newer version: 3.3.0.dev1
Show newest version
package com.codingapi.springboot.fast.jpa.repository;

import com.codingapi.springboot.fast.jpa.JpaQueryContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.repository.NoRepositoryBean;

import java.util.List;

@NoRepositoryBean
@SuppressWarnings("unchecked")
public interface DynamicRepository extends BaseRepository {

    default List dynamicListQuery(String sql, Object... params) {
        return (List) JpaQueryContext.getInstance().getJPAQuery().listQuery(getEntityClass(), sql, params);
    }

    default  List dynamicListQuery(Class clazz, String sql, Object... params) {
        return (List) JpaQueryContext.getInstance().getJPAQuery().listQuery(clazz, sql, params);
    }

    default Page dynamicPageQuery(String sql, String countSql, PageRequest request, Object... params) {
        return (Page) JpaQueryContext.getInstance().getJPAQuery().pageQuery(getEntityClass(), sql, countSql, request, params);
    }

    default Page dynamicPageQuery(String sql, PageRequest request, Object... params) {
        return (Page) JpaQueryContext.getInstance().getJPAQuery().pageQuery(getEntityClass(), sql, request, params);
    }

    default  Page dynamicPageQuery(Class clazz, String sql, String countSql, PageRequest request, Object... params) {
        return (Page) JpaQueryContext.getInstance().getJPAQuery().pageQuery(clazz, sql, countSql, request, params);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy