[英]How to fetch @Basic fields in JPQL query
实体定义是:
@Entity
@DynamicInsert
@DynamicUpdate
public class ProductInformation {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Version
private Long version;
private String url;
private String price;
private String bookName;
private String isbn;
@Lob
@Basic(fetch = FetchType.LAZY)
private String sourceFile;
@Lob
@Basic(fetch = FetchType.LAZY)
private String information;
...
}
我使用以下 JPQL 查询加载所有条目:
from ProductInformation
然后在导出过程中访问带有@Basic
注释的字段。 我可以在 SQL 日志中看到以下 output (延迟加载可见):
select productinf0_.id as id1_0_, productinf0_.book_name as book_nam2_0_, productinf0_.isbn as isbn4_0_, productinf0_.price as price5_0_, productinf0_.url as url7_0_, productinf0_.version as version8_0_ from product_information productinf0_
select productinf_.information as informat3_0_, productinf_.source_file as source_f6_0_ from product_information productinf_ where productinf_.id=?
select productinf_.information as informat3_0_, productinf_.source_file as source_f6_0_ from product_information productinf_ where productinf_.id=?
select productinf_.information as informat3_0_, productinf_.source_file as source_f6_0_ from product_information productinf_ where productinf_.id=?
select productinf_.information as informat3_0_, productinf_.source_file as source_f6_0_ from product_information productinf_ where productinf_.id=?
select productinf_.information as informat3_0_, productinf_.source_file as source_f6_0_ from product_information productinf_ where productinf_.id=?
...
有没有办法在 JPQL 查询中@Basic(fetch = FetchType.LAZY)
注释字段?
请参阅 entityGraph 和 LoadGraphs (javax.persistence.loadgraph) 查询提示,它允许您指定要在实体中加载的其他字段,覆盖惰性映射规范。 有关示例,请参见https://www.baeldung.com/jpa-entity-graph
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.