Hi all,
I'm using : hibernate 3.5.x as my JPA implementation.
My case is very simple: I have stateless service which call persist method from EntityManager for Object "A" with NO cascade options.
Code:
A objectA = new A();
objectA.setObgectBReference(objectB);
entityManager.persist(objectA);
The problem here is that "objectB" is detached, so obviously exception is thrown
Quote:
TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing
.
I know that I can "find" "objectB" before set it as reference, but there are any other solution for this?
Why should I get the "objectB" from the database(worst case scenario) if I know the ID of this objectB so in order to persist the "objectA" I need only the ID value of objectB.
thank you.
Regards,
Dima