When you return the entity back to the client from the bean, it becomes
detached from the entitymanager. When you are passing the entity back to the
bean, the second time, you have the option to call the
mergedEntity = entityManager.merge(entity);
to re-attach the detached entity.
View the or
This means that you entity is not being managed by the entity manager. Try
merging it back in with EntityManager.merge() before persisting the changes.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193191#4193191
Reply to the post :
http://www.jboss.com/in
I see this is an old thread but just in case someone nees a solution... try to
enclose everyting in a UserTransaction. If you take an EJB3 entity outside the
transaction, you cannot re-persist it or iterate over CMRs, etc. You need then
a UserTransaction in the client side.
View the original po
Can you try with id set to null? I have a feeling the the entity manager might
think that your object has already been persisted because it already has an id.
Regards
Felix
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040467#4040467
Reply to the post :
Hi Felix,
No, the table is empty, I try to insert the first record.
I tried with id = 1, but with the same result.
Any idea?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040429#4040429
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=post
Let me guess: An object with the id 0 does already exist since you ran your
code at least once before.
Regards
Felix
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040362#4040362
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode
Please help me this so I can avoid the big head ache...
After a variety of debugging, this is the case:
| ...
| B b = a.getB();
| long id = saveOrUpdate(b); // Autoboxing. Originally an instance of
Long
| entityManager.flush();
| b.setId(id); /