-->
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.  [ 3 posts ] 
Author Message
 Post subject: @lob useage
PostPosted: Wed Mar 19, 2008 1:01 pm 
Newbie

Joined: Wed Mar 19, 2008 12:37 pm
Posts: 2
Hibernate version: 3

Mapping documents: using annonations

A question on the @Lob annotation.

I am using the @Lob annotation on a byte variable in my POJO.

The Java Persistence with Hibernate nook by C Bauer & G King state that this annotation provides lazy loading by definition without the need for interception.

However, when i look at the tomcat log I can still see the blob being fetched, not to mention the performance of my application ;)


code:

@Entity
public class File{

@Lob
@Basic (fetch = FetchType.LAZY) // don't think this should be necessary
private byte[] content;

.....

}

This File class is then contained in another POJO with an association where the fetchType is set to EAGER.

@Entity
public class Climas{

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(...)
private Set<File> file;


}

Does this EAGER fetch override the lazy @Lob or am i doing something else wrong?

I have read on a number of forums that i need to instrument the code for this to work but the book doesn't seem to agree & thus i am a bit confused ..

Cheers in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 5:56 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
the eager fetch hasn't got anything to do with it I think

In the jpa book I 've read that all simple properties (= all columns, including @Lob's) are always eager fetched.

There are 2 ways to avoid this:
- Enable lazy property fetching, which is probably a bad idea
- Split of the Clob property into it's own table/class and map it with a lazy @OneToOne

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 6:53 am 
Newbie

Joined: Wed Mar 19, 2008 12:37 pm
Posts: 2
cheers ge0ffrey ill give option two a try tomorrow sounds like it should do just the job though :)


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