I'm working with Jhipster. I'm not being able to fetch Customers lazily.
I have made a JDL like so...
PROPERTY
id
...
CUSTOMER
id
...
CUSTOMER_PROPERTY
id
customer_id
property_id
value
relationship OneToMany {
Customer to CustomerProperty
}
relationship ManyToOne {
CustomerProperty to Property
}
My Domains
Customer.java
@OneToMany(mappedBy = "customer", fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<CustomerProperty> customerProperties = new HashSet<>();
Property.java no mapping
CustomerProperty.java
@ManyToOne
private Property property;
@ManyToOne
@JsonIgnoreProperties("customerProperties")
private Customer customer;
I have already tried to explicit set fetch = FetchType.LAZY but it keeps bringing the full complete Customer object with all CustomerProperties List
I would like to understand why the fetch it's not working
Debugging is not a good mechanism for evaluation if a collection has been lazily loaded or not. The debugger itself may trigger initialization.
Instead of using debugger use the
org.hibernate.Hibernate.isInitialized(yourCollection)
to verify if it has been initialized after the loading of your entity.
If this method return false but you still suspect that at later point the collection is initialize you should search the error in a possible subsequent call (somewhere else).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.