-->
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.  [ 6 posts ] 
Author Message
 Post subject: Lob is not being lazily loaded
PostPosted: Mon Jul 17, 2006 1:06 pm 
Newbie

Joined: Mon Jul 17, 2006 12:59 pm
Posts: 1
I have a byte[] in an entity that I am annotating with lob and fetch=lazy. Yet when I retrieve it though a session bean, the lob is fully loaded. I've heard that "lazy" is only a hint. It is important that I lazily load this. Is there a more correct way to do this?


In Entity:

Code:
private byte[] data;

@Lob
@Basic(fetch=FetchType.Lazy)
public byte[] getData() {
  return data;
}
...


I am using jboss-4.0.4.GA with a postgres DB


Things I've tried:
I tried using a secondarytable annotation, but the field was still eagerly loaded.

I tried creating a data table and a OneToOne relationship, but when I set this relationship to be lazily loaded, jassist returns an error.

I got it to work with a OneToMany relationship, but that "bugs" me since it is really a one-to-one relationship.

Thanks for the help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 7:11 am 
Newbie

Joined: Thu May 05, 2005 5:54 am
Posts: 17
same here. i am using postgres 8.1 and tomcat 5.5.9.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 4:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
java.sql.Lob is lazy loaded
byte[] is not lazy loaded

to lazy load an array of byte you need to enhance you class (build time enhancement, check the tools section of the hibernate reference doc) and use @Basic(LAZY)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 4:50 am 
Newbie

Joined: Thu May 05, 2005 5:54 am
Posts: 17
I'm sorry but i've been very imprecise in my reply and i gave you wrong informations on my problem. My real situation is that my Lob is a Serializable object not an array of bytes.

@Basic(fetch = FetchType.LAZY)
@Lob()
private Shift shift;

and Shift implements Serializable

does your solution applies also to my situation?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 8:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, same as byte[].
But is you serializable object that big? Is it really slow to load it?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 8:57 am 
Newbie

Joined: Thu May 05, 2005 5:54 am
Posts: 17
It's production data coming from a machine.
In my tests i've reached an extreme of 20MB but usually it should be slightly smaller: 3/4MB and i have 2 or 3 of these blobs to load at the same time (day period). But i cannot exclude that it could become bigger if data "detail" is increased in the future.

Probably the timings for the real scenario could be acceptable. The fact is that i do not really need to load that blob because most of the common statistics are precalculated and saved in the same table of the blob. So the blob itself is there only for making rare particular analisys.


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