*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Groovy
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: 134
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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Would this help ?



[My Blog]
All roads lead to JavaRanch
liliya woland
Ranch Hand

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Apr 11, 2006
Posts: 134
Oh! I DID get the right result - one object per call! That worked! Thank you!
 
Consider Paul's rocket mass heater.
 
subject: .withCriteria returns an array. Any way to get one object only?
 
Similar Threads
Primitive vs Wrapper
How to use AWT/Swing w/o window?
hibernate withCriteria
Using Objects in Static Recurring Processes
Inter-Servlet Communication