-->
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 do I set lazy="false" globally as a default?
PostPosted: Tue Jan 02, 2007 5:04 pm 
Newbie

Joined: Tue Nov 07, 2006 9:32 pm
Posts: 7
Location: NH
Hibernate version: 3.2

Name and version of the database you are using: Oracle 10G


We never use lazy instantiation. I'm in the process of upgrading from 2.1.6 to 3.2. This has become a nightmare because of the change from the default lazy instantiation value of false to true. Is there a property setting I can change to globally set lazy="false" unless specified? This would make my upgrade path SOOO much simpler.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 5:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
start by reading the hibernate migration guide on the wiki....

and look for default-lazy

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:02 pm 
Newbie

Joined: Tue Nov 07, 2006 9:32 pm
Posts: 7
Location: NH
You know, I found this before, and obviously missed the last line...

*********Migration guide***********
Association fetching strategies

Since it is best practice to map almost all classes and collections using lazy="true", that is now the default. Existing applications will need to explicitly specify lazy="false" on all non-lazy class and collection mappings.

The outer-join attribute is deprecated. Use fetch="join" and fetch="select" instead of outer-join="true" and outer-join="false". Existing applications may continue to use the outer-join attribute, or may use a text search/replace to migrate to use of the fetch attribute.

Beware, this means you have to put lazy="false" on all collection-mappings and classes which previously did not have a "lazy"-attribute.

A quick and dirty alternative for migration is also to put default-lazy="false" on all your hibernate-mapping elements.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:59 pm 
Newbie

Joined: Tue Nov 07, 2006 9:32 pm
Posts: 7
Location: NH
That doesn't really help us in our situation. We are using XDoclet and it creates a single hibernate mapping file per class. So, I have to have a lazy="false" in every class (we don't manipulate the hibernate-mapping element that is created by xdoclet). Why not have a single property that can be set in a properties file? Just seems useful, well, at least better than me editing 75 classes adding lazy="false" to each one...

Also, now I get this in my log files:
ERROR main:(org.hibernate.tuple.entity.PojoEntityTuplizer:136) - Getters of lazy classes cannot be final.

Umm, I get this in about 40 different places. I'm assuming I can't just "ignore" it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 8:31 am 
Beginner
Beginner

Joined: Mon Nov 29, 2004 2:26 pm
Posts: 28
Tridecaphi wrote:
That doesn't really help us in our situation. We are using XDoclet and it creates a single hibernate mapping file per class. So, I have to have a lazy="false" in every class (we don't manipulate the hibernate-mapping element that is created by xdoclet).


You may override the XDoclet template that is used to generate your mappings. Just extract the hibernate.xdt file from the XDoclet JAR and customize it to fit your needs (then include it on the classpath).


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.