-->
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.  [ 4 posts ] 
Author Message
 Post subject: Lazy initialization of byte[] properties
PostPosted: Sat Feb 28, 2004 4:02 pm 
Newbie

Joined: Thu Feb 12, 2004 9:48 am
Posts: 12
Location: Campina Grande, PB, Brazil
Quote:
Hi, everyone.

I'm using hibernate v. 2.1. and I'm implementing a mailing system, with message sending/receiving - just like an usual e-mailing system. The message entity has a set of attachments, which has some properties like filename and mimetype, and a property called contents. This property (contents) returns or sets a byte[] from a blob. Because this system is web driven, it's a strong requirement that the contents of an attachment be loaded on demand, i.e. just when the user clicks on an attachment. Is there a way to make a single property lazy-instantiatable, as we can do with collections? I want to do that because I'm retrieving the messages with its attachments, but I don't want to retrieve the attachment's contents, which would decrease the performance in a situation like, say, listing all the messages.

Thanks anticipatedly,
julioaragao


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 6:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
http://www.hibernate.org/41.html - or use a Blob as property, they are lazy loading by definition.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 7:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Another solution is to use a custom type that retrieves the property using direct JDBC.

We've decided NOT to implement lazy-property-fetching. I implemented lazy component fetching and ended up throwing away that code. It was a bit too messy.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 5:05 pm 
Beginner
Beginner

Joined: Fri Feb 20, 2004 6:15 pm
Posts: 38
May I ask why you chose not to implement lazy property fetching? Is it because Hibernate's architecture makes it too hard to do this, or you think it's bad design?


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