Ao executar esse método o update é realizado porém o hibernate retorno o seguinte erro:
public ArrayList<Acerto> aprovarAcerto(ArrayList<Acerto> acertos)
throws Exception {
try {
this.session = HibernateUtil.getSessionFactory().openSession();
this.tx = this.session.beginTransaction();
for (Acerto acerto : acertos) {
acerto.setCdStatus((Status) this.session.createCriteria(
Status.class).add(
Restrictions.eq("cdStatus", cdStatus2)).uniqueResult());
session.update(acerto);
}
session.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
throw new Exception();
} finally {
this.session.close();
}
return acertos;
}
09:05:17.853 ERROR org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: model.Status.tpjustifCollection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: model.Status.tpjustifCollection, 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.toArray(PersistentBag.java:280)
at java.util.ArrayList.<init>(Unknown Source)
at flex.messaging.io.ArrayCollection.<init>(ArrayCollection.java:44)
at flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:460)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:180)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:248)
at flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:571)
at flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:523)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:198)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:248)
at flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:571)
at flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:523)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:198)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.io.amf.Amf3Output.writeObjectArray(Amf3Output.java:823)
at flex.messaging.io.amf.Amf3Output.writeAMFArray(Amf3Output.java:436)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:184)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.io.ArrayCollection.writeExternal(ArrayCollection.java:97)
at flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:561)
at flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:467)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:180)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.messages.AbstractMessage.writeExternal(AbstractMessage.java:353)
at flex.messaging.messages.AsyncMessage.writeExternal(AsyncMessage.java:140)
at flex.messaging.messages.AcknowledgeMessage.writeExternal(AcknowledgeMessage.java:93)
at flex.messaging.messages.AcknowledgeMessageExt.writeExternal(AcknowledgeMessageExt.java:55)
at flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:561)
at flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:523)
at flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:112)
at flex.messaging.io.amf.Java15Amf3Output.writeObject(Java15Amf3Output.java:58)
at flex.messaging.io.amf.Amf0Output.writeObject(Amf0Output.java:198)
at flex.messaging.io.amf.Java15Amf0Output.writeObject(Java15Amf0Output.java:69)
at flex.messaging.io.amf.AmfMessageSerializer.writeObject(AmfMessageSerializer.java:195)
at flex.messaging.io.amf.AmfMessageSerializer.writeBody(AmfMessageSerializer.java:185)
at flex.messaging.io.amf.AmfMessageSerializer.writeMessage(AmfMessageSerializer.java:141)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:179)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:315)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)