Hi, I'm running some junit tests of my code using glassfish and toplink and i've come across a problem.
I have the following tables which represent some entities in one of 3 particular states
request->processing->processed
within my code i select relevant entities and move them from each table, depending upon the actions taken. This seems to work fine... until i created some unit tests for the code.
between each test i reset the db to a consistent state and now i'm getting an exception.
I get the following error:
"unable to persist detached entity" caused by an [i]EntityExistsException[/i] during the second test when it tries to move an entity from the request to the processing table. I'm guessing this is caused by the EM caching the entity from the previous test and not realising i've deleted it. I've tried calling [i]em.clear()[/i] on the EM but it seems to have no effect. Is this the correct behaviour? Can i clear the cache?
Secondly i thought i would try merge, but this doesn't do anything - again it seems that it compares the [i]new[/i] object to the cached one, determines they are the same and doesn't perform an insert...
Is there any way around this without calling em.remove()?
[Message sent by forum member 'jsl123' (jsl123)]
http://forums.java.net/jive/thread.jspa?messageID=216151