-->
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: lazy initialization of LOBs
PostPosted: Wed Sep 05, 2007 12:06 pm 
Newbie

Joined: Tue Sep 04, 2007 7:30 pm
Posts: 1
Hibernate version: 3.2
MySQL 5.0
Using Annotations to define data mapping

I have a couple of entities that have LOB properties that can be very large (one BLOB and one CLOB). I expected that the data for these properties would not be initialized with the rest of the properties, but that a reference to the data would be available so it could be retrieved when I was ready for it (using a java.sql.Blob or java.sql.Clob instance). However, I am seeing that the LOB data is fully initialized with the rest of the properties.

In reading the description of LOB handling in the book "Java Persistence with Hibernate", they say that these properties are not lazily initialized unless the @Lob annotation is used, and the data type is the java.sql.Clob type. This is how I have my property defined, but it still is not using lazy initialization. Here is the definition of my Clob property within my entity.

@Lob
@Column(name="TEST_CASE_EXECUTION_LOG", length=1048574)
public Clob getTestCaseExecutionLog()
{
return m_testCaseExecutionLog;
}

When using this property, I have tried setting it with a javax.sql.rowset.serial.SerialClob as well as using a Clob created using Hibernate.createClob(). Same behavior with either one.

Can anyone give me any ideas as to how to force these properties to behave the way I want them to? I am getting out of memory exceptions due to the eager loading of all of these Lobs.

Thanks in advance,
Jay


Top
 Profile  
 
 Post subject: Lazy Property Loading
PostPosted: Wed Sep 05, 2007 6:46 pm 
Newbie

Joined: Wed Sep 05, 2007 6:34 pm
Posts: 13
Hi Jay,

I think I found documentation for lazy properties (different from lazy associations):

http://www.hibernate.org/hib_docs/v3/re ... properties

If I understand the above correctly, there are 2 ways to solve this:
1) setting up buildtime bytecode instrumentation
2) using projection of the class <-- preferred?

3) creating a class wrapper around the blob(s)/clob(s) to obfuscate the relation and allow for easier lazy loading <-- not elegant?

I have a similar problem, except I do not run out of memory. Page navigation is just (incredibly) slower.

I would be curious to know which route you decide to take...

Hope this helps,

-- Dan


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.