-->
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: Excessive lazy-ness in H3?
PostPosted: Sun May 29, 2005 5:58 pm 
Beginner
Beginner

Joined: Fri Mar 19, 2004 7:21 am
Posts: 20
Hi,

Just upgrading to H3.0.5, I have got my app working fine by adding default-lazy="false" to some of my mapping documents.. I am now going through gradually moving to default lazy=true.

But H3 is excessively lazy.. The following code does not even issue a database query at all!!

session = HibernateUtil.currentSession();
aiDocument = (AiDocument) session.load(AiDocument.class,
indexID);
HibernateUtil.closeSession();

When I then try to access any of its properties it gives a lazyinitializationexception. Obviously I can add code to ensure this doesn't happen but I don't understand why this is the default. Here is my mapping document.

<class name="AiDocument"
table="document">

<id name="indexId" column="document_id" type="java.lang.Integer">
<generator class="assigned" />
</id>

<property name="aiClass" column="ai_class" type="java.lang.String" />
<property name="aiSubclass" column="ai_subclass"
type="java.lang.Integer" />
<property name="documentNo" column="document_no"
type="java.lang.Integer" />
<property name="year" column="year" type="java.lang.String" />
<property name="title" column="title" type="java.lang.String" />

</class>

Regards,
Damon.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 29, 2005 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
load is for optimized access (you can create associations and only load one of the sides)

get will hit the db (unless the object is already in the session)

_________________
Max
Don't forget to rate


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.