我有一个简单的JPA查询,它像这样使用(ProcessDetailCategory是一个字符串值枚举):
List<ProcessDetail> currentProcessDetails = processDetailRepository.findByProcessIdAndProcessDetailCategoryAndProcessFileNotNull(process.getId(), ProcessDetailCategory.LIST_ELEMENT);
我已启用查询日志记录:
logging.level.org.hibernate.SQL: DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder: TRACE
spring.jpa.show-sql: true
日志说
Hibernate: select processdet0_.id as id1_66_, processdet0_.process_id as process_4_66_, processdet0_.process_detail_category as process_2_66_, processdet0_.process_file_id as process_3_66_, processdet0_.url_link as url_link5_66_ from process_details processdet0_ where processdet0_.process_id=? and processdet0_.process_detail_category=? and (processdet0_.process_file_id is not null)
格式化:
HIBERNATE:
SELECT processdet0_.id AS id1_66_,
processdet0_.process_id AS process_4_66_,
processdet0_.process_detail_category AS process_2_66_,
processdet0_.process_file_id AS process_3_66_,
processdet0_.url_link AS url_link5_66_
FROM process_details processdet0_
WHERE processdet0_.process_id = ?
AND processdet0_.process_detail_category = ?
AND ( processdet0_.process_file_id IS NOT NULL )
当我在数据库上手动运行此查询时,我得到结果,但是JPA查询未返回任何结果。不,我不是在查询错误的数据库,其他一切都很好。