• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem merging EJB3 entity

 
Cloey Tan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across a situation like this, I retrieve an instance of EJB3 entity from the database, pass it to the front end to be updated on its values, then merge it using the EntityManager, entityManager.merge(entityObject), But it doesnt seem to work that way. Does it mean that the entity object is detached? Is there a way to attach it back such that the updated entity object can be merged straight away?
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, moving to EJB.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cloey Tan wrote: then merge it using the EntityManager, entityManager.merge(entityObject), But it doesnt seem to work that way.


You will have to provide more details about what you mean by "it doesn't seem to work" And also the relevant piece of code.

While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.
 
Manuel Alberto Quero
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Cloey,

First of all, I agree with Jaikiran, you should provide a bit more information so we can try to figure out what your problem can be.
Nevertheless, in response to your last question, the entity becomes detached as soon as you pass it to the front-end layer due to it is outside the persistence context. When you use the entityManager entityManager.merge(entityObject) the entity becomes attached/managed back, so you donĀ“t need to perform any previous actions before merging in order to get the entity attached back.
With regard to your problem, I can only think about some entity relationship with the wrong fetch parameter configuration...

Hope it helps,

Manuel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic