Hmmm... I was a bit puzzled at first... The query seemed to be a valid query. However, I found that the problem is that the "creationEvent.sources" is a Map collection where the LabeledExtract is the key and the used quantity is the value part. Unfortunately it seems like the expression "creationEvent.sources" only goes to the value part (used quantity). That is why Hibernate complains with the error "could not resolve property: name of: component[usedQuantity,dummy]"
Hibernate has an index() function which can be used to get to the key part of the map (WHERE index(lbe) ...) but it seems like it only retrieves the ID of the LabeledExtract and not the name and other properties. Now, all this can solved with a subquery magic using a custom-built restriction. Replace the itemQuery.restrict() call with something like this: itemQuery.restrict( new Restriction() { public String toQl(Query query, DbControl dc) { return "index(lbe) IN " + "(SELECT l.id FROM LabeledExtractData l " + " WHERE l.name = 'uci_tissues_fb_3.s1.e1.lbe1')"; } public Collection<? extends QueryElement> getChildren() { return null; } }); Of course, this needs to be polished up a bit to be used for real. If you need to go up to samples you must do that in the subquery, but that is easier: WHERE l.parent.parent.name = ... This assumes that you always use non-pooled items. If you have pooled items nothing will work, since the number of hops to get to the sample may be different for different paths. In that case you'll probably have to start at the sample level and then follow each path down to the hybridizations. /Nicklas Bob MacCallum wrote: > Hi, > > The following isn't working, even though some very similar code in > net.sf.basedb.core.LabeledExtract works fine (I assume). I'm just restricting > on a hard-coded "name" at the moment for testing: > > ItemQuery<net.sf.basedb.core.Hybridization> itemQuery = > Hybridization.getQuery(); > itemQuery.include(Include.SHARED); > itemQuery.setDistinct(true); > itemQuery.join(Hql.innerJoin("creationEvent.sources", > Item.LABELEDEXTRACT.getAlias())); > itemQuery.restrict( > Restrictions.eq( > Hql.property(Item.LABELEDEXTRACT.getAlias(), "name"), > Expressions.string("uci_tissues_fb_3.s1.e1.lbe1") > ) > ); > ... = itemQuery.list(dc); > > > [java] Exception in thread "main" net.sf.basedb.core.BaseException: > could not resolve property: name of: component[usedQuantity,dummy] [SELECT > DISTINCT hyb FROM net.sf.basedb.core.data.HybridizationData hyb INNER JOIN > hyb.creationEvent.sources lbe WHERE (lbe.name = > :P1555286c83a454f1a9e048f5efbcde73)] > [java] at > net.sf.basedb.core.HibernateUtil.createQuery(HibernateUtil.java:1349) > [java] at > net.sf.basedb.core.AbstractEntityQuery.getMainHqlQuery(AbstractEntityQuery.java:349) > [java] at net.sf.basedb.core.ItemQuery.list(ItemQuery.java:93) > > > If I print out the query it looks like this > > [java] ItemQuery: SELECT DISTINCT hyb.null FROM > net.sf.basedb.core.data.HybridizationData hyb INNER JOIN > creationEvent.sources lbe WHERE (lbe.name = > :P1555286c83a454f1a9e048f5efbcde73(uci_tissues_fb_3.s1.e1.lbe1)) > > > Once we get this working, we want to join all the way to Sample - do you think > that will be possible? > > many thanks, > > Bob. > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ basedb-devel mailing list basedb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basedb-devel