-->
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: session load/refresh return object which is not instantiated
PostPosted: Sat Jan 15, 2011 2:07 pm 
Newbie

Joined: Mon May 24, 2010 3:25 pm
Posts: 6
I'm trying to (eagerly) load user object (with all its internal collections & paramerts), modify it, save it to DB, and then refresh the object - so I can return an updated user object to the client.
The problem: in the code below both load() & refresh() return user object with all user's internal data as null (See the code below)

Any ideas why the user object is not loaded?

SessionFactory sf = ((HibernateEntityManagerFactory) HibernateUtil.getProfoundEMFactory()).getSessionFactory();
Session session = sf.getCurrentSession();
session.beginTransaction();
User user = (User) session.load(User.class, user_id);
if( user != null )
{
// modify user...
session.merge(user);
session.flush();
session.refresh(user);
session.getTransaction().commit();
}

Comment: all my internal collections are setup to eagerly load.
Context for the problem: By now, I have being working with EntityManagerFactory (loaded with name query select, and use merge() to save); However, now I need to use the refresh() method which is available only in SessionFactory to do the practice described above.


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.