The moose likes Groovy and the fly likes .withCriteria returns an array. Any way to get one object only? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark ".withCriteria returns an array. Any way to get one object only?" Watch ".withCriteria returns an array. Any way to get one object only?" New topic
Author

.withCriteria returns an array. Any way to get one object only?

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 115
Hi everyone, I'm trying out .withCriteria calls and noticing that I'm getting back arrays. My call is this one:

And I know that this call will not return more then one object, and all I need is just that one object. Could anybody tell me if there is a way to do this to get just one object back?

Thanks in advance!
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

Would this help ?



[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 115
No, it still gave me two objects. Thank you for trying though.
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

Did you check what objects were returned ? Their id ?
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 115
Oh! I DID get the right result - one object per call! That worked! Thank you!
 
 
subject: .withCriteria returns an array. Any way to get one object only?
 
Threads others viewed
Primitive vs Wrapper
Using Objects in Static Recurring Processes
hibernate withCriteria
Inter-Servlet Communication
How to use AWT/Swing w/o window?
developer file tools