使用QueryDSL和Spring的存储库编写java交叉表查询
我已经构建了一个DAL,它使用Spring的存储库通过Hibernate和JPA管理MySQL数据库上的CRUD操作。这是我的存储库定义
package my.dal.repository;
import my.domain.dal.User;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface IUserRepository extends CrudRepository<User, String>, QueryDslPredicateExecutor<User>{
}
有了这个定义,我可以使用QueryDSL谓词执行CRUD操作
通过扩展QueryDslPredicateExecutor
接口和findAll(Predicate)
方法
我面临的问题是,这样我就无法进行跨表查询。实际上,我不能使用QueryDSL的连接功能,因为我没有HibernateQuery
使用Spring存储库和QueryDSL实现连接操作的正确方法是什么
谢谢!
共 (0) 个答案