Bug #58 (closed)
QueryUnique Broken!
Reported by: | bwzloranger | Owned by: | jamoore |
---|---|---|---|
Priority: | critical | Cc: | cxallan |
Sprint: | n.a. | ||
Total Remaining Time: | n.a. |
Description
Changes in r655 seem to have removed the adhoc query abilities of the QueryUnique? method.
Change History (3)
comment:1 Changed 18 years ago by jmoore
- Resolution set to fixed
- Status changed from new to closed
comment:2 Changed 18 years ago by cxallan
Okay, how about something like this:
return (ExperimenterGroup) queryService.queryUnique( "select g from ExperimenterGroup as g join g.groupExperimenterMap as map where map.child = ?", new Object[] { experimenter });
What should be placed in the Parameters object?
comment:3 Changed 18 years ago by jmoore
Change the HQL to this:
"select g from ExperimenterGroup as g join g.groupExperimenterMap as map where map.child.id = :id"
And your parameters are as above:
new Parameters().addId( experimenter.getId() )
Note: See
TracTickets for help on using
tickets.
You may also have a look at Agilo extensions to the ticket.
More like queryUnique gone'' It's been replaced by findByQuery and findAllByQuery. These are intended to take a string identifier for a query. But if the StringQuerySource is configured (as it is by default), then the string identifier can itself be a HQL query.
There are some semantic differences. findByQuery returns an IObject. But there is no way for HQL to specify that there will be a uniqueResult as before. Therefore it's necessary to use the idiom: findAllByQuery().get(0)