-->
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.  [ 3 posts ] 
Author Message
 Post subject: Read and write in the same transaction problem
PostPosted: Fri Feb 15, 2008 1:16 pm 
Newbie

Joined: Mon Jul 30, 2007 1:59 pm
Posts: 6
Hy guys,

I use Hibernate with Spring management of transactions. Pojos and home classes generated with Hibernate Tools.

I would like to make that :
1. Begin transaction
2. Create data in DB (in fact in transaction)
3. Read data created/existing in transaction and in DB
4. Rollback the transaction

The goal is to emulate the running of a process of my application (for example to verify if it works well). After the step 4 the database has to be unchanged (like before step 1).

In the transaction I use home classes and also HQL queries and create data, read data, eventually delete data.

It seems that when I read data in transaction (step 3) I can effectively find some data but not some other, I will explain in the following...

So in step 2 I write data, A and B are 2 tables with a many-to-many relation linking them. In step 3 I read data, I use an HQL query to find A instances which have been written in step 2, followed by a A.getB() to get B instances. But my problem is that A.getB() returns nothing (nothing is an empty array).

Whereas when I make a true "commit" between step 2 and step 3 everithing works well, but it's not a good solution for me because it's no more a fictive process when there were a commit...

So, can somebody say me if it is a cache problem. If yes what could I do to solve it ? If no, what could it be or what could I do ?


Last edited by ahuut on Mon Feb 18, 2008 12:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 18, 2008 12:10 pm 
Newbie

Joined: Mon Jul 30, 2007 1:59 pm
Posts: 6
I edited the post to try to make it more comprehensible.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 18, 2008 2:38 pm 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Can you post the actual code between openSession and session.close()?

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


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

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.