-->
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: Returning a single (object , row, or column)
PostPosted: Wed Aug 09, 2006 11:42 pm 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Hi All

I am using Hibernate version2.

I am currently using HQL , Criteria & createSQLQuery to fetch data.
What I observed is all these return List & never a single object.

From the calling client I have to unnecessarily sift through a list even when I know the underlying query is going to return only 1 instance.

Does any one have a solution to avoid retreiving from a list


Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 8:16 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
From Hibernate API documentation:

Interface Query
Code:
public Object uniqueResult()

Convenience method to return a single instance that matches the query, or null if the query returns no results.
Returns: the single result or null.


I've used it and it works.

Don't forget to rate me if I helped you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 10:23 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
I reckon this is available with Hibernate version 3.

How can I do the same with Hibernate version2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 1:33 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
H2 supported .uniqueResult() (at least later revisions)

Curtis ...

_________________
---- Don't forget to rate! ----


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.