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.  [ 2 posts ] 
Author Message
 Post subject: Migration from hibernate2 to hibernate3
PostPosted: Tue Oct 03, 2006 9:31 am 
Newbie

Joined: Tue Oct 03, 2006 9:22 am
Posts: 11
Hey,

I'm trying to migrate an existing application from hibernate2 to hibernate3, and as I understand it one of the things that have changed is that everything is lazy loaded, but I have a short example that I just cant wrap my brain around.

In my dao I have the following :
public Supplier getSupplier(int id) {
Supplier rv =(Supplier) getHibernateTemplate().load(Supplier.class, new Integer(id));
System.out.println(rv.getName());
return rv;
}

How come the System.out.println line throws an LazyInitializationException ?

Shouldnt the session be open still at this point ? Or did I miss something essential in my migration ?

The really weird part is that when I run
public Collection getSuppliers() {
return getHibernateTemplate().loadAll(Supplier.class);
}

and loop that collection in my jsp-pages, everything is loaded as I expected it to be.

Hibernate version: 3.1.3

/Steen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 10:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
getHibernateTemplate().load


This is not the Hibernate API. Remove the useless wrapper, use Hibernate directly, and read the API documentation.


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