Hi, I try to use a User/UserRole relation and took the seam-space as example
I have a UserRole entity with some predefined rolenames in database UserRole class: @Entity | @Name("userroles") | public class UserRole implements Serializable { | | /** | * | */ | private static final long serialVersionUID = -8632996340533021763L; | private Long id; | private Integer version; | private String name; | | @Id @GeneratedValue | public Long getId() { | return id; | } | | public void setId(Long id) { | this.id = id; | } | | @Version | public Integer getVersion() { | return version; | } | | @SuppressWarnings("unused") | private void setVersion(Integer version) { | this.version = version; | } | | @Length(max=20) | public String getName() { | return name; | } | | public void setName(String name) { | this.name = name; | } | } and a User class as counterpart @Entity | @Name("user") | @Table(name = "user", catalog = "oats") | public class User implements java.io.Serializable { | | /** | * | */ | private static final long serialVersionUID = 1L; | private long id; | private Long version; | private String userName; | private String email; | private Set<UserRole> userRoles; | | public User() { | } | | public User(long id) { | this.id = id; | } | | @Id @GeneratedValue | public long getId() { | return this.id; | } | | public void setId(long id) { | this.id = id; | } | | @Column(name = "version") | public Long getVersion() { | return this.version; | } | | public void setVersion(Long version) { | this.version = version; | } | | @Column(name = "username", unique = true) | @NotEmpty | public String getUserName() { | return this.userName; | } | | public void setUserName(String username) { | this.userName = username; | } | | @Column(name = "email") | @Email(message="Email") | @NotEmpty | public String getEmail() { | return this.email; | } | | public void setEmail(String email) { | this.email = email; | } | | @ManyToMany | @JoinTable(name = "userroles", joinColumns = @JoinColumn(name = "USER_ID"), inverseJoinColumns = @JoinColumn(name = "ROLE_ID")) | public Set<UserRole> getUserRoles() { | return userRoles; | } | | public void setUserRoles(Set<UserRole> userroles) { | this.userRoles = userroles; | } | | } Than I have a wizard(with a4j:include) to create new users with the predefined userroles. (user data are based on existing values from database) first step: <div class="navPanel"> | <h:outputLabel for="gpid" value="GP-Id"></h:outputLabel> | <h:inputText id="gpid" value="#{user.userName}"></h:inputText> | <a4j:commandButton value="Next >>" action="#{register.searchGpId}"/> | </div> @Begin | public String searchGpId() { | String query = "from Csy20oats y20 where y20gpnum like '" +user.getUserName() +"'"; | userSearchResults = entitymanager.createQuery(query).getResultList(); | return "next"; | } these results are displayed in a datatable and one record can be used to select user data <div class="navPanel"> | | <rich:scrollableDataTable | rows="10" | id="userresultdatatable" | var="data" | value="#{register.userSearchResults}"> | <rich:column width="50px"> | <f:facet name="header"><h:outputText value="GP-Id"></h:outputText></f:facet> | <h:outputText value="#{data.y20gpnum}"></h:outputText> | </rich:column> | <rich:column width="150px"> | <f:facet name="header"><h:outputText value="Name"></h:outputText></f:facet> | <h:outputText value="#{data.y21kname}"></h:outputText> | </rich:column> | <rich:column width="75px"> | <f:facet name="header"><h:outputText value="Aktion"></h:outputText></f:facet> | <a:commandLink id="userselectlink" action="#{register.selectUser(data)}" value="Ausweahlen"></a:commandLink> | </rich:column> | | </rich:scrollableDataTable> | </div> | public String selectUser(Csy20oats selectedUser) { | setAllFields(selectedUser); | return "next"; | } | | @SuppressWarnings("unchecked") | private void setAllFields(Csy20oats selectedUser) { | List<Csy20oats> rs = entitymanager.createQuery("from Csy20oats y20 where y20.y20gpnum=" +selectedUser.getY20gpnum()).getResultList(); | userroles = new HashSet<UserRole>(); | for(Csy20oats y20 : rs){ | if(y20.getY20y20s0().substring(0, 1).toLowerCase().equals("k")){ | UserRole ur = (UserRole)entitymanager.createQuery("from UserRole ur where ur.name = 'akzeptanz'").getSingleResult(); | //this.user.getUserRoles().add(ur); | userroles.add(ur); | }else if(y20.getY20y20s0().substring(0, 1).toLowerCase().equals("d")){ | UserRole ur = (UserRole)entitymanager.createQuery("from UserRole ur where ur.name = 'beherbergung'").getSingleResult(); | //this.user.getUserRoles().add(ur); | userroles.add(ur); | }else if(y20.getY20y20s0().substring(0, 1).toLowerCase().equals("s")){ | UserRole ur = (UserRole)entitymanager.createQuery("from UserRole ur where ur.name = 'gemeinde'").getSingleResult(); | //this.user.getUserRoles().add(ur); | userroles.add(ur); | } | } | } | in last step I can edit and save the data <div class="navPanel"> | | <h:outputLabel value="Name" for="username"></h:outputLabel> | <h:inputText id="username" value="#{user.userName}"></h:inputText> | <br/> | <h:outputLabel value="E-Mail" for="email"></h:outputLabel> | <h:inputText id="email" value="#{user.email}"></h:inputText> | <br/> | <rich:spacer height="2" id="userspacer"></rich:spacer> | <rich:separator lineType="dashed"></rich:separator> | | <a:commandButton value="Registrieren" action="#{register.register}"/> | | </div> | @End | public String register() | { | this.user.setUserRoles(userroles); | try { | entitymanager.persist(this.user); | } catch (Exception e) { | e.printStackTrace(); | } | return "next"; | } | I think it's exact the same as in seamspace but I get the following error: 09:11:10,472 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session | org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: de.oats.model.UserRole | at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219) | at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397) | at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78) | at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755) | at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1143) | at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26) | at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) | at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) | at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) | at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) | at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) | at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515) | at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86) | at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177) | at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382) | at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135) | at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87) | at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140) | at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52) | at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:582) | at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:325) | at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:226) | at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184) | at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280) | at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) | at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) | at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) | at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281) | at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) | at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179) | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) | at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) | at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) | at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) | at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580) | at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) | at java.lang.Thread.run(Thread.java:619) | 09:11:10,492 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for [EMAIL PROTECTED] | java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: de.oats.model.UserRole | at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:626) | at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524) | at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86) | at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177) | at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382) | at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135) | at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87) | at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140) | at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52) | at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:582) | at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:325) | at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:226) | at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184) | at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280) | at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) | at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) | at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) | at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281) | at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) | at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179) | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) | at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) | at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) | at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) | at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580) | at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) | at java.lang.Thread.run(Thread.java:619) | Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: de.oats.model.UserRole | at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219) | at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397) | at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78) | at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755) | at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1143) | at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26) | at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) | at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) | at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) | at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) | at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) | at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515) | ... 53 more | 09:11:10,612 ERROR [SeamPhaseListener] uncaught exception | java.lang.IllegalStateException: Could not commit transaction | at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592) | at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:325) | at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:226) | at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184) | at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280) | at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) | at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) | at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) | at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281) | at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68) | at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) | at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) | at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179) | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) | at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) | at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) | at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) | at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580) | at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) | at java.lang.Thread.run(Thread.java:619) | Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state | at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1394) | at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135) | at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87) | at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140) | at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52) | at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:582) | ... 43 more | Caused by: java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: de.oats.model.UserRole | at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:626) | at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:524) | at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:247) | at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86) | at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177) | at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1382) | ... 48 more | Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: de.oats.model.UserRole | at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219) | at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397) | at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78) | at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755) | at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1143) | at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26) | at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) | at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) | at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) | at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) | at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) | at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) | at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515) | ... 53 more If I use ManyToMany(cascade=CascadeType.PERSIST) there is no error but new UserRole entries are created(I don' want new roles) What's diffrent in seam-space example OR better, what can I do prevent this error? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098700#4098700 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098700 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user