-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: TransientObjectException: object references an unsaved trans
PostPosted: Tue Jun 08, 2010 5:29 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.