top.springdatajpa.zujijpa.utils.JpaHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zuji-jpa Show documentation
Show all versions of zuji-jpa Show documentation
To solve complex dynamic SQL
package top.springdatajpa.zujijpa.utils;
import lombok.experimental.UtilityClass;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import java.util.List;
/**
*
* JPA Helper
*
*
* @author azheng
* @since 2019-10-10
*/
@UtilityClass
public class JpaHelper {
public Page castPage(Page> pageList, PageRequest page, Class toClass){
List result = EntityUtils.cast(pageList.getContent(), toClass);
return new PageImpl(result, page, pageList.getTotalElements());
}
}