Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Bug #58 (closed)

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

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

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)

  // in summary:
  // if you had a method like this
  (Image) iQuery.queryUnique(
     "from Image i where i.id = ?",
     new Object[]{ imgId }
  );

  // it will now be
  (Image) iQuery.findAllByQuery(
     "from Image i where i.id = :id",
     new Parameters().addId( imgId )
  ).get(0);

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.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.62934 sec.)

We're Hiring!