[jboss-user] [JBoss Seam] - Persist problem with Seam 1.1.0 and selectitems-1.1.1beta4
frehan
do-not-reply at jboss.com
Thu Feb 22 16:00:44 EST 2007
hi!
I have a simple registration page where users can register. When they register they can select user roles. USer and role has relationship many-to-many. I use selectitems-1.1.1beta4 to display a selectionbox where the user can select 0-n roles.
I also use a Seam-managed persistence context since it is required by selectitems.
My action looks like this:
@In(create=true)
private EntityManager entityManager;
@In(required = false) @Valid
private User user;
When I try to call entityManager.persist(user) I get the following strange error:
at java.lang.Thread.run(Thread.java:595)
Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=Transaction
Impl:XidImpl[FormatId=257, GlobalId=lia/192, BranchQual=, localId=192] status=ST
ATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException
: org.hibernate.AssertionFailure: null id in se.camitz.par.User ent
ry (don't flush the Session after an exception occurs))
I says my Id is null.
My user class has an autogenereated id so it should work:
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="Id")
public Integer getId() {
return id;
}
The interesting thing is that if I create a new User object in my action and copy all values to the new object and call entityManager.persist(newUser) then it works fine!
User newUser = new User();
newUser.setName(user.getName());
newUser.setRoles(user.getRoles());
....
entityManager.persist(newUser)
Any ideas someone???
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020800#4020800
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020800
More information about the jboss-user
mailing list