Hi.
I have the web app on Tomcat. On context reloadings since some time I see the lazy loading exception during serialization of the session:
Code:
15:58:43,828 ERROR LazyInitializationException:42 - failed to lazily initialize a collection of role: com.consult.alto.entity.Order.coWorkers, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.consult.alto.entity.Order.coWorkers, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
at org.hibernate.collection.PersistentBag.toString(PersistentBag.java:506)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1379)
I see, that is comes from PersistentBag.toString() method. Is this ok, that it is called during serialization of the object and tries to initialize the collection lazily?
Here is the piece of entity class:
Code:
public class Order extends CommonProperties implements Comparable<Order>, Serializable {
@ManyToMany(fetch = FetchType.LAZY)
@LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name = "Order_employee", joinColumns = @JoinColumn(name = "order_id"), inverseJoinColumns = @JoinColumn(name = "employee_id"))
private List<Employee> coWorkers = new ArrayList<Employee>();
Thanks!