-->
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.  [ 5 posts ] 
Author Message
 Post subject: How can I access an object inside long session
PostPosted: Thu Dec 30, 2004 12:40 pm 
Newbie

Joined: Mon Dec 27, 2004 5:38 pm
Posts: 8
I am trying to use the long session approach to implement application transaction, so my question is how can I reload an obejct asociated with that session:

class 1{
...
session.save(order);
session.disconnect();
request.getSession().setAttribute("longSession", session) ;
.....
}

class 2 {
...
Session session = (Session) request.getSession().getAttribute("longSession") ;
session.reconnect();
// how to get order object again?
// something like session.getObject(order,orderId) or something?
session.flush();
session.close();
request.getSession().removeAttribute("longSession") ;
......
}

Any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 5:56 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
session.refresh?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Doesn't work
PostPosted: Thu Dec 30, 2004 10:30 pm 
Newbie

Joined: Mon Dec 27, 2004 5:38 pm
Posts: 8
session.refresh()
throws an exception because the row doesn't exist yet in the DB.
I am trying with:
in class 2

Item item = (Item) session.get(Item.class, serializedId);

it seems to work, i will let you know soon.


Top
 Profile  
 
 Post subject: sorry
PostPosted: Thu Dec 30, 2004 10:33 pm 
Newbie

Joined: Mon Dec 27, 2004 5:38 pm
Posts: 8
I mean
Order class instead Item
Order order = (Order) session.get(Order.class, serializedId)


Top
 Profile  
 
 Post subject: Finished
PostPosted: Fri Dec 31, 2004 3:31 pm 
Newbie

Joined: Mon Dec 27, 2004 5:38 pm
Posts: 8
Just to complete the idea, it is worknig now, just use get in class 2 and it will work.
Thanks
Luis


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.