Results 1 to 2 of 2

Thread: Session Closing not allowing Hibernate.initialize()

  1. #1
    Join Date
    Sep 2004
    Posts
    6

    Default Session Closing not allowing Hibernate.initialize()

    in my code, i'm doing the following. Im extending HibernateDaoSupport

    Code:
    Person p = null;
    		
    		List list = getHibernateTemplate().find(PERSON_WITH_ADDRESS-PHONE, person.getPersonOid());
    		if (list.size() > 0) {
    			System.out.println("Im here");
    			p = (Person) list.get(0);
    
    			Hibernate.initialize(p.getAddresses());
    			Hibernate.initializep.getPhones());
    		}
    
    		return p;
    It appears that my Session is being closed after the find query runs? How do I do this kind of initialization with Spring?
    / mike

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You can either use a Hibernate callback (to put the initialization part) or use the lazy loading filter/interceptor which keeps the session opened during the request/thread life-time.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. OpenSessionInView + CMT Session usage
    By alesj in forum Data
    Replies: 7
    Last Post: Aug 16th, 2005, 02:32 AM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •