0

When updating a Managed Entity data is not directly reflect to DB, so I'm using evict in Hibernate. The exception I'm getting is the detached entity passed to persist.

MobeeAgent agent= agentsList.get(rowIndex);
BeanUtils.copyProperties(agent, doMobeeAgent);
agentsList.set(rowIndex, agent);
((Session)getEntityManager().getDelegate()).evict(agentsList.get(rowIndex));

Regards

Nag.

siebz0r
  • 18,867
  • 14
  • 64
  • 107
nag
  • 647
  • 6
  • 25
  • 43
  • Your question is unreadable. Format your code and indent it properly. Use proper English words and punctuation. – JB Nizet Jun 10 '12 at 07:47

1 Answers1

0

"detached entity passed to persist" means that you're trying to call persist() with an entity that is considered by Hibernate as already existing (because it already has an ID, or a non-zero @Version property). persist() is used to create a new entity. If you want to update and existing entity, merge() must be used.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • thank you Nizet,Im using merge changes will be reflect to Db ,i want to remove change object from first level cache – nag Jun 10 '12 at 14:40