我正在与Jhipster合作.我无法懒洋洋地获取客户.
我已经像这样制作了一个JDL …
PROPERTY
id
...
CUSTOMER
id
...
CUSTOMER_PROPERTY
id
customer_id
property_id
value
relationship OneToMany {
Customer to CustomerProperty
}
relationship ManyToOne {
CustomerProperty to Property
}
我的网域
客户.java
@OneToMany(mappedBy = "customer",fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<CustomerProperty> customerProperties = new HashSet<>();
Property.java
没有映射
CustomerProperty.java
@ManyToOne
private Property property;
@ManyToOne
@JsonIgnoreProperties("customerProperties")
private Customer customer;
我已经尝试过显式设置fetch = FetchType.LAZY,但是它始终将完整的Customer对象与所有CustomerProperties列表一起使用
我想了解为什么提取失败
最佳答案
调试不是评估集合是否已延迟加载的好方法.调试器本身可能会触发初始化.
与其使用调试器,不如使用
org.hibernate.Hibernate.isInitialized(yourCollection)
验证您的实体加载后是否已初始化.
如果此方法返回false,但是您仍然怀疑在稍后集合被初始化,则应该在可能的后续调用(其他位置)中搜索错误.