-->
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: Timing issue when hibernates creates the PK
PostPosted: Tue Mar 15, 2005 9:22 am 
Newbie

Joined: Mon Mar 08, 2004 2:05 pm
Posts: 4
Hibernate version:2.1.7c




I have an application which useses DTOs to carry data from one layer to the other. This is the problem I encounter:

My DTO arrives in the business layer. The DTO contains data to an existing parent and information on a new child:

1. I start a transaction

2 I use the information in the DTO to retrieve the parent from the databes (the parent is linked to the session)

3 I use the DTO to create a new child object and add the child to the collection of the parent

4 I use the information of the parent and child (the actual hibernate classes) to create a new DTO and send it to my client

5. I commit the tansaction. Because of the cascading update function, Hibernate will automtically save the child in the database.

The problem I have is that I cannot correctly fill the DTO in step 4, because one of the attributes i want to send back is the ID. For the child object this ID is not filled out yet. It will only be generated in step 5.
I cannot really change the location of the commit since this is hidden from me it is done automatically in a ancester class (I believe you would have a similar problem if you use cmt in a session bean).

Is there a way around this problem without doing a explict hibernate call (session.flush()), perhaps a configuration option I've missed.


thnaks for your respone


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.