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.
|