java - How to solve Hibernate's LazyInitializationException -
CustomerEntity has been mapped to the table in the table Queries: But when I This is because the default hibernate loads more than one unit How can I recover this exception occurs when you try to access a lazy-loading collection or field when This is some of the solution possible. Go ways: For information about other session management strategies, try reading. Customer . There are multiple connections to
order and
addresses in this now I retrieve the customer with the order with the next code:
DetachedCriteria criteria = DetachedCriteria.forClass (CustomerEntity.class); Criterion Add (restriction. Eq ("id", patient id)); Criteria.createCriteria ("Order", CriteriaSpecification.LEFT_JOIN) .add (Restrictions.and (Restrictions.isNull ("deletedDate"), Restrictions.or (Restrictions.isNull ("old"), Restrictions.eq ("old", BoolType .false)))); Customer Interval Customer = Quarriage search criteria);
public
customer.getAddresses Trying to apply () The next exception is thrown:
org.hibernate.LazyInitializationException: Failed to initialize a collection of the role lazily: No, no session or session Closed
the customer unit its
addresses without modifying it?
session is not available. When application loads backend of the data and closes the session, you pass this data, for example, the frontend where there is no truth Already
session-per-request which is suitable for a typical web application. Information in question can be useful to you
Comments
Post a Comment