-->
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: save & list in 1 session
PostPosted: Wed Nov 22, 2006 8:29 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
hi,

I have following code, all executed in a transaction:

Code:
User u = new User("TestName");
dao.addUser(u);
List l = dao.listUsers();


The listUsers returns a list of all existing users but does not contain the one I just added. If I do a listUsers() later on (in another transaction) then it does return a list containing this user.

Anybody know why this is and what to do to solve this problem (without creating a new transaction).

tx a lot,
Stijn


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 8:48 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Have a look at this, if your ids are generated:


http://forum.hibernate.org/viewtopic.php?t=928172

Also look at this:

http://www.hibernate.org/109.html

Post more details if your problem is different.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 9:17 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
JayeshJ,

tx, I do use a composite-id here and implement the equals and hashCode methods but I don't think it's related to the problem. In the topic you mentioned the problem was getting the newly added item from a Set. I am trying to get a list of ALL users and the newly added one is not yet in it.

However, I tried flushing the session within the transaction after saving the new user and then it is present in the list.

tx for your help anyway,
Stijn


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.