|Lazy relationship is intiated, when it shouldn't be [message #514862]
||Tue, 16 February 2010 22:52
| Michal Ondrovic
Registered: February 2010
I have a problem with eclipselink 2.0. I have two entities A and B. A has onetomany relation to B and B has manytoone relation to A. Both relationships are lazy. I'm loading the B entity from server's session bean. In this session bean I'm calling entitymanager.find() or entitymanager.createNamedQuery("B.findById") (same result).
Everything works until I add a new B entity to A. After saving is this B entity returned containing the A entity(in lazy relationship). Other B entities related to the A entity, are returned correctly. I can see it in my swing client, when I'm clicking in the list - for old B entites is it fast, for the new one is it much slower. Updating an B entity doesn't cause such behaviour. I tried to play with cascade in onetomany, but this doesn't help me.
The only solution, that I've found is to call entitymanager.clear() after merge A entity (and flush), but I don't think it's good...
When updating A, I set the relation to A in the new B entites, because without this are the new Bs unrelated (in database have null FK).
Can anybody help me?
[Updated on: Tue, 16 February 2010 22:53]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03863 seconds