-->
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: Hibernate - Junit and Transactions
PostPosted: Tue Mar 19, 2013 6:43 am 
Newbie

Joined: Tue Mar 19, 2013 6:38 am
Posts: 1
Hello.

I have a beginners question:

Imagine a relation between folder and files. A folder contains one or more files or some subfolders.

I am creating a folder using a service implementation which uses a folderDao to create the object. This works fine. The database is populated as desired.

If I am creating a folder and then I am creating a file which is related to this folder as child this works fine within one junit test method, too. The database is populated correctly after this.

BUT if I am creating a folder and then a file which is related to that folder as described above and then I want to fetch this folder object again, the reference to the file of this folder is alway null (within one junit test-method)-call. If i am doing this in two junit-testmethods (First create folder and file, Second fetch the folder and its property file) it is fine!

Does anyone can give me a hint, why this behaves like that? I am assuming, that only after a flush into the database the objects and the relations are filled correctly? Is this the right way?

Thank you a lot.

Best regards.


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.