[英]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.