-->
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: BY USING ENTITIES OR WITH PROJECTIONS
PostPosted: Thu Jan 24, 2008 6:17 am 
Newbie

Joined: Thu Jan 24, 2008 6:03 am
Posts: 2
Location: Hyderabad
Is There any way to get ...as..

suppose we have a table students in that name,id,courseid, pic are the columns..

We have to get the records from the database only name , id & courseid thatsall, we dont need pic because of blob.

yes, i know its easy to do with create sql query,projections and native sql,but by using those we get an object array in that we have the values..,

But i want an student Object which have only name,id & courseid, if we tried to get the pic from that object it has to return null.

I tried with by using cliterias, and add Entities,Restrictions ..etc but i cant..

Pls Get A way.....

_________________
k@mi icore


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 7:18 am 
Newbie

Joined: Wed Jan 16, 2008 2:53 am
Posts: 5
sorry , it's not clear what problem do you have
when you use sql query it returns a list of object that you want and if you try to us some property that are null maybe make some terrible for you .
form example :
Query query = session.createQuery("from Student s where s.id=" + student.getId());
and before use pic , you can check if it's not null do some action on it


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 8:11 am 
Newbie

Joined: Thu Jan 24, 2008 6:03 am
Posts: 2
Location: Hyderabad
ok ok iknow that we give sql query means we get object array that mean object[] fro that one we have to print by using for loop...,

but we want the students object that mean..

for(i=0;i<=list.size;i++)
{
Students s=(Students)list.get(i);
sys.out.print(s.getId());
sys.out.print(s.getName());
sys.out.print(s.getCourseId());
sys.out.print(s.getPic());

}

if we give like that then it has to print all the values except pic, pic has to be null., that mean we have to restrict that pic property by using projections or sql query& entities etc.. i tried but its not working..

_________________
k@mi icore


Top
 Profile  
 
 Post subject: read the docs
PostPosted: Thu Jan 31, 2008 12:42 pm 
Newbie

Joined: Fri Oct 14, 2005 4:42 pm
Posts: 15
It can be done w/ lazy property fetching. See

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#performance-fetching-lazyproperties

says

Quote:
Hibernate3 supports the lazy fetching of individual properties. This optimization technique is also known as fetch groups...

Lazy property loading requires buildtime bytecode instrumentation! If your persistent classes are not enhanced, Hibernate will silently ignore lazy property settings and fall back to immediate fetching.

For bytecode instrumentation, use the following Ant task...


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.