[jboss-user] [EJB 3.0] - Re: EJB3 PersistanceManager confusion
do-not-reply at jboss.com
Wed Sep 6 11:30:07 EDT 2006
Because you're specifying:
Debtor deb1 = new Debtor();
...the entity manager will see this as "detached" - in other words, an object that is already persisted in the database (because it has a primary key), but is not currently managed by the entity manager.
The "persist" method is used to perform an SQL Insert for a *new* object; one without a PK.
So you can either:
1) Use EntityManager.merge() to synchronize these values with the database
2) Don't specify a PK; don't set the ID.
...depending on your PK Generation strategy.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969774#3969774
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969774
More information about the jboss-user