• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Ticket
  • Next Ticket →

Ticket #58 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

QueryUnique Broken!

Reported by: brain Owned by: jmoore
Priority: critical Milestone: 3.0-M2
Component: API Version: 3.0-M1
Keywords: iteration1 Cc: callan

Description

Changes in r655 seem to have removed the adhoc query abilities of the QueryUnique? method.

Change History

Changed 3 years ago by jmoore

  • status changed from new to closed
  • resolution set to fixed

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);

Changed 3 years ago by callan

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?

Changed 3 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.

Download in other formats:

  • Comma-delimited Text
  • Tab-delimited Text
  • RSS Feed

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/