java - org.hibernate.PersistentObjectException: detached entity passed to persist: com.horariolivre.entity.Key -
in spring application, trying persist in database follow entity:
@entity @table(name = "usuario") public class usuario implements java.io.serializable { private static final long serialversionuid = -7283129128268761582l; private int id; private string login; private string senha; private string primeironome; private string ultimonome; private tipo tipo; private list<atributo> atributo; private confighorariolivre config; private list<autorizacao> autorizacao; public usuario() { } public usuario(string login, string senha) { this.setlogin(login); this.setsenha(senha); } public usuario(string login, string senha, string primeironome, string ultimonome, tipo tipo, list<atributo> atributos) { this.setlogin(login); this.setsenha(senha); this.setprimeironome(primeironome); this.setultimonome(ultimonome); this.tipo = tipo; this.atributo = atributos; this.config = new confighorariolivre(); this.autorizacao = new arraylist<autorizacao>(); } @id @column(name = "id", unique = true, nullable = false) @generatedvalue(strategy=generationtype.auto) public int getid() { return id; } public void setid(int id) { this.id = id; } @column(name = "login") public string getlogin() { return login; } public void setlogin(string login) { this.login = login; } @column(name = "senha") public string getsenha() { return senha; } public void setsenha(string senha) { this.senha = senha; } @column(name = "primeiro_nome") public string getprimeironome() { return primeironome; } public void setprimeironome(string primeironome) { this.primeironome = primeironome; } @column(name = "ultimo_nome") public string getultimonome() { return ultimonome; } public void setultimonome(string ultimonome) { this.ultimonome = ultimonome; } @onetoone(cascade=cascadetype.all, fetch=fetchtype.eager) @joincolumn(name="fk_tipo") public tipo gettipo() { return tipo; } public void settipo(tipo tipo) { this.tipo = tipo; } @onetomany(cascade=cascadetype.all) @jointable(name="atributo_usuario", joincolumns={@joincolumn(name="fk_usuario")}, inversejoincolumns={@joincolumn(name="fk_atributo")}) @lazycollection(lazycollectionoption.false) public list<atributo> getatributo() { return atributo; } public void setatributo(list<atributo> atributo) { this.atributo = atributo; } @onetoone(cascade=cascadetype.all) @joincolumn(name="fk_config") public confighorariolivre getconfig() { return config; } public void setconfig(confighorariolivre config) { this.config = config; } @onetomany(cascade=cascadetype.all) @jointable(name="autorizacao_usuario", joincolumns={@joincolumn(name="fk_usuario")}, inversejoincolumns={@joincolumn(name="fk_autorizacao")}) @lazycollection(lazycollectionoption.false) public list<autorizacao> getautorizacao() { return autorizacao; } public void setautorizacao(list<autorizacao> autorizacao) { this.autorizacao = autorizacao; } }
and facing error:
org.hibernate.persistentobjectexception: detached entity passed persist: com.horariolivre.entity.key @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:141) @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:842) @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:835) @ org.hibernate.engine.spi.cascadingaction$7.cascade(cascadingaction.java:315) @ org.hibernate.engine.internal.cascade.cascadetoone(cascade.java:387) @ org.hibernate.engine.internal.cascade.cascadeassociation(cascade.java:330) @ org.hibernate.engine.internal.cascade.cascadeproperty(cascade.java:208) @ org.hibernate.engine.internal.cascade.cascade(cascade.java:165) @ org.hibernate.event.internal.abstractsaveeventlistener.cascadebeforesave(abstractsaveeventlistener.java:424) @ org.hibernate.event.internal.abstractsaveeventlistener.performsaveorreplicate(abstractsaveeventlistener.java:263) @ org.hibernate.event.internal.abstractsaveeventlistener.performsave(abstractsaveeventlistener.java:192) @ org.hibernate.event.internal.abstractsaveeventlistener.savewithgeneratedid(abstractsaveeventlistener.java:135) @ org.hibernate.event.internal.defaultpersisteventlistener.entityistransient(defaultpersisteventlistener.java:208) @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:151) @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:78) @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:852) @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:826) @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:830) @ com.horariolivre.dao.atributohome.persist(atributohome.java:37) @ com.horariolivre.dao.atributohome$$fastclassbycglib$$97541e8a.invoke(<generated>) @ org.springframework.cglib.proxy.methodproxy.invoke(methodproxy.java:204) @ org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint(cglibaopproxy.java:698) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:150) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept(cglibaopproxy.java:631) @ com.horariolivre.dao.atributohome$$enhancerbycglib$$26066f50.persist(<generated>) @ com.horariolivre.service.usuarioservice.cadastra(usuarioservice.java:58) @ com.horariolivre.controller.usuariocontroller.cadastra_usuario(usuariocontroller.java:87) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:219) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:745) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:686) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:80) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936) @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:838) @ javax.servlet.http.httpservlet.service(httpservlet.java:647) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:57) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:343) @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:260) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:953) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1023) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:310) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:744) abr 09, 2014 7:49:30 org.hibernate.engine.jdbc.batch.internal.abstractbatchimpl release info: hhh000010: on release of batch still contained jdbc statements abr 09, 2014 7:49:30 org.apache.catalina.core.standardwrappervalve invoke grave: servlet.service() servlet [dispatcher] in context path [/horariolivre2] threw exception [request processing failed; nested exception org.springframework.orm.hibernate4.hibernateoptimisticlockingfailureexception: batch update returned unexpected row count update [0]; actual row count: 0; expected: 1; nested exception org.hibernate.stalestateexception: batch update returned unexpected row count update [0]; actual row count: 0; expected: 1] root cause org.hibernate.stalestateexception: batch update returned unexpected row count update [0]; actual row count: 0; expected: 1 @ org.hibernate.jdbc.expectations$basicexpectation.checkbatched(expectations.java:81) @ org.hibernate.jdbc.expectations$basicexpectation.verifyoutcome(expectations.java:73) @ org.hibernate.engine.jdbc.batch.internal.nonbatchingbatch.addtobatch(nonbatchingbatch.java:59) @ org.hibernate.persister.entity.abstractentitypersister.update(abstractentitypersister.java:3215) @ org.hibernate.persister.entity.abstractentitypersister.updateorinsert(abstractentitypersister.java:3117) @ org.hibernate.persister.entity.abstractentitypersister.update(abstractentitypersister.java:3446) @ org.hibernate.action.internal.entityupdateaction.execute(entityupdateaction.java:140) @ org.hibernate.engine.spi.actionqueue.execute(actionqueue.java:362) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:354) @ org.hibernate.engine.spi.actionqueue.executeactions(actionqueue.java:276) @ org.hibernate.event.internal.abstractflushingeventlistener.performexecutions(abstractflushingeventlistener.java:328) @ org.hibernate.event.internal.defaultflusheventlistener.onflush(defaultflusheventlistener.java:52) @ org.hibernate.internal.sessionimpl.flush(sessionimpl.java:1233) @ org.hibernate.internal.sessionimpl.managedflush(sessionimpl.java:403) @ org.hibernate.engine.transaction.internal.jdbc.jdbctransaction.beforetransactioncommit(jdbctransaction.java:101) @ org.hibernate.engine.transaction.spi.abstracttransactionimpl.commit(abstracttransactionimpl.java:175) @ org.springframework.orm.hibernate4.hibernatetransactionmanager.docommit(hibernatetransactionmanager.java:554) @ org.springframework.transaction.support.abstractplatformtransactionmanager.processcommit(abstractplatformtransactionmanager.java:755) @ org.springframework.transaction.support.abstractplatformtransactionmanager.commit(abstractplatformtransactionmanager.java:724) @ org.springframework.transaction.interceptor.transactionaspectsupport.committransactionafterreturning(transactionaspectsupport.java:475) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:270) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept(cglibaopproxy.java:631) @ com.horariolivre.dao.atributohome$$enhancerbycglib$$26066f50.persist(<generated>) @ com.horariolivre.service.usuarioservice.cadastra(usuarioservice.java:58) @ com.horariolivre.controller.usuariocontroller.cadastra_usuario(usuariocontroller.java:87) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:219) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:745) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:686) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:80) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936) @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:838) @ javax.servlet.http.httpservlet.service(httpservlet.java:647) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118) @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.session.sessionmanagementfilter.dofilter(sessionmanagementfilter.java:103) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:154) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.savedrequest.requestcacheawarefilter.dofilter(requestcacheawarefilter.java:45) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:199) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:110) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:57) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:50) @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342) @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192) @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160) @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:343) @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:260) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:953) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1023) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:310) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:744)
that atribute key located in class atributo:
@entity @table(name = "atributo") public class atributo implements java.io.serializable { private static final long serialversionuid = 6084758898903241369l; private int id; private key key; private value value; public atributo() { } public atributo(key key, value value) { this.key = key; this.value = value; } public atributo(string key, string value) { this.key = new key(key); this.value = new value(value); } @id @column(name = "id") @generatedvalue(strategy=generationtype.auto) public int getid() { return id; } public void setid(int id) { this.id = id; } @onetoone(cascade=cascadetype.all, fetch=fetchtype.eager) @joincolumn(name="key") public key getkey() { return key; } public void setkey(key key) { this.key = key; } @onetoone(cascade=cascadetype.all, fetch=fetchtype.eager) @joincolumn(name="value") public value getvalue() { return value; } public void setvalue(value value) { this.value = value; } }
the saving operation handled way:
public boolean cadastra(string login, string senha, string primeironome, string ultimonome, string tipousuario, string[] campo, string[] valor) { tipo tipo_usuario = tipo.findbynome(tipousuario); list<atributo> lista_atributos = new arraylist<atributo>(); for(int i=0; i<campo.length; i++) { key chave = key.findbynome(campo[i]); value conteudo = new value(valor[i]); value.persist(conteudo); lista_atributos.add(new atributo(chave, conteudo)); atributo.persist(lista_atributos.get(i)); } return this.usuario.persist(new usuario(login, senha, primeironome, ultimonome, tipo_usuario, lista_atributos)); }
someone can point direction right way persist entity?
ps.: full code of project can found here:
your service methods not transactional. transactions opened before each dao methods , committed after. since hibernate session attached current transaction session closed after returning dao method. results in detached entities in service layer. fix add @transactional
service methods:
@transactional public boolean cadastra(string login, string senha, string primeironome, string ultimonome, string tipousuario, string[] campo, string[] valor) { ... }
Comments
Post a Comment