-->
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: Selective Loading of objects
PostPosted: Wed Feb 24, 2010 8:30 pm 
Newbie

Joined: Thu Feb 11, 2010 5:53 am
Posts: 5
Hi,

I have a BusinessEntity -> Components relation that I have modelled in Hibernate. In our case, we dont really delete components but just mark one of the columns as true.

What I want is, when I do a get() in hibernate or during lazy loading of my components, to be able to retrieve only the rows that dont have the column deleted set as true.

I can ofcourse discard these at Java level, but if Hibernate provided some funtionality like this, it'd be more cleaner.

-thanks


Top
 Profile  
 
 Post subject: Re: Selective Loading of objects
PostPosted: Thu Feb 25, 2010 7:30 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Hi,

You can do:

Code:
@Entity
@Table(name = "TBL_NAME")
@Where(clause = "DELETED=0")
public class BusinessEntity {
   ........
   ........
}


Regards,
Litty Preeth

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject: Re: Selective Loading of objects
PostPosted: Fri Feb 26, 2010 4:40 am 
Newbie

Joined: Thu Feb 11, 2010 5:53 am
Posts: 5
thank you!


Top
 Profile  
 
 Post subject: Re: Selective Loading of objects
PostPosted: Fri Feb 26, 2010 7:09 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Code:
@Entity
public class BusinessEntity {
    @OneToMany
    @Where(clause="deleted = false")
    private List<Components> enclosed;
}


Consider also this, maybe it fit's more what you require.


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.