com.codingapi.springboot.fast.jpa.repository.DynamicRepository Maven / Gradle / Ivy
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);
}
}