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: Lazy loading individual properties
PostPosted: Wed May 31, 2006 12:24 pm 
Newbie

Joined: Wed May 31, 2006 12:18 pm
Posts: 5
Location: London, UK
Hi,

Is it possible to specify an individual property (like the one below) to be lazy-loaded or to specify a different mapping file for loading and saving? I have a class and corresponding database table which has an image field in it which could be large so I only want to load the image if the user actually wishes to view it.

<property name="FrontElevationPicture" column="HseFrontElevationPicture" type="BinaryBlob" />

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 12:41 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
best bet is to factor that blob into its own entity and declare the class lazy.

Code:
public class MetaData {
   int id;
   FileData fileContents;

   ...
}

public class FileData {
   int id;
   MetaData metaData
   byte[] contents;

   ...
}

<class name="MetaData">
   ...
   <one-to-one name="FileContents" class="FileData" cascade="all-delete-orphan" />
   ...
</class>

<class name="FileData" lazy="true">
   ...
   <one-to-one name="MetaData" class="MetaData" constrained="true" />
   ...
</class>


the above mapping works when you have a separate table for the file contents with a PK->PK,FK link between the two tables.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 7:58 am 
Newbie

Joined: Wed May 31, 2006 12:18 pm
Posts: 5
Location: London, UK
Many thanks Devon, that did the trick!


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.