-->
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: Exclude a Column from the select claues using Criteria API
PostPosted: Mon Apr 06, 2009 5:02 am 
Newbie

Joined: Tue Feb 07, 2006 2:02 am
Posts: 12
Hi All,

Hibernate version: 3.2.1


I am trying to fetch records using Hibernate Criteria API.

For example:
Criteria criteria = getSession().createCriteria(Definition.class)

Where Definition pojo object has multiple associations and the sql that is generated has more than 200 columns. From a performance point of view I need to exclude a single disclosure column of type blob from the select statement. Please note that this blob column mapping cannot be removed from the HBM file as it is required in few other cases.

Though there is a way to implement this using projection list, but its very tough to specify all 199 columns in projection list. So instead of adding columns to projection is there a way to exclude one or two columns.

Please let me know if there is any work around..

Note: In case the column exclusion is not supported in the current hibernate version it would help if its available in the future releases.


Thanks,
Hiisi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 5:32 am 
Regular
Regular

Joined: Sun Aug 01, 2004 6:49 pm
Posts: 76
As far as I read the documentation a fetch type might be specified on basic properties: http://www.hibernate.org/hib_docs/annot ... g-property

@Basic(fetch = FetchType.LAZY)

In theory this should avoid fetching the property unless you call the getter.

Did not use this before, so please post your results.

HTH
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 5:45 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
As far as I know, there is no way, to exclude a column using criteria.

But thhart's suggestion could help you. You could set this one excluded column as lazy, so that it is not read in a "normal" criteria.

In the few cases where you need this column you could explicitly load it using another HQL-Query ("select * from ...") or just let hibernate load it lazily if possible (that means, if you call the getter within an open session).

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 4:58 am 
Newbie

Joined: Tue Feb 07, 2006 2:02 am
Posts: 12
Hi,

Thank you so much for the replies. Both replies gave me some input to work on my problem. Looks like we need to use ant task to do run time instrumentation for the single property lazy fetching to work. I am on the process of trying.... :-)

Regards,
Hiisi

_________________
Regards
.....Hiisi.....


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.