Hi! First of all I want to mention that OJB does a lot of work for me and is a great project!
Many problems i had with user aliases i solved for my own, but now i can't find a way out :( Here's my problem: I have 2 Object-Classes ItemImpl and PropertyImpl (one item has many named properties, ItemImpl 1--M PropertyImpl) Here is my classdescr: <class-descriptor class="ItemImpl" table="ITEMS" > <field-descriptor id="1" name="id" column="ID" jdbc-type="BIGINT" nullable="false" primarykey="true" autoincrement="true" sequence-name="IT_SEQ" /> <collection-descriptor name="allProperties" element-class-ref="PropertyImpl" orderby="id" sort="ASC" proxy="true" > <inverse-foreignkey field-id-ref="4"/> </collection-descriptor> <collection-descriptor name="allDetailItemProperties" element-class-ref="PropertyImpl" orderby="id" sort="ASC" proxy="true" > <inverse-foreignkey field-id-ref="5"/> </collection-descriptor> </class-descriptor> <class-descriptor class="PropertyImpl" table="PROPERTIES" > <field-descriptor id="1" name="id" column="ID" jdbc-type="BIGINT" nullable="false" primarykey="true" autoincrement="true" sequence-name="P_SEQ" /> <field-descriptor id="4" name="itemId" column="IT_ID" jdbc-type="BIGINT" nullable="false" /> <field-descriptor id="5" name="itemIdReferenced" column="IT_ID_REF" jdbc-type="BIGINT" nullable="false" /> <field-descriptor id="6" name="name" column="NAME" jdbc-type="VARCHAR" nullable="false" length="4000" /> <field-descriptor id="7" name="value" column="VALUE" jdbc-type="VARCHAR" nullable="false" length="4000" /> <reference-descriptor name="item" class-ref="ItemImpl" proxy="true"> <foreignkey field-id-ref="4"/> </reference-descriptor> <reference-descriptor name="itemReferenced" class-ref="ItemImpl" proxy="true"> <foreignkey field-id-ref="5"/> </reference-descriptor> </class-descriptor> Of course PropertyImpl has one reference to its corresponding ItemImpl object, but PropertyImpl has another reference to ItemImpl because a property of an item can point to another parent item, e.g. a persons property named myHome points to a separate home item. Now I want to query all home items (maybe distinct), which where referenced from a person item matching some property-criterias. I defined a Criteria-Tree like this: ############################# Criteria rootCrit = new Criteria(); rootCrit.addEqualTo("allDetailItemProperties.name", "myHome"); Criteria propCrit1 = new Criteria(); propCrit1.setAlias("prop1", "allProperties"); propCrit1.addEqualTo("allDetailItemProperties.item.allProperties.name", "firstName"); propCrit1.addEqualTo("allDetailItemProperties.item.allProperties.value", "Jack"); rootCrit.addAndCriteria(propCrit1); Criteria propCrit2 = new Criteria(); propCrit2.setAlias("prop2", "allProperties"); propCrit2.addEqualTo("allDetailItemProperties.item.allProperties.name", "hairColor"); propCrit2.addEqualTo("allDetailItemProperties.item.allProperties.value", "black"); rootCrit.addAndCriteria(propCrit2); Collection result = PersistenceBrokerFactory.defaultPersistenceBroker (). getCollectionByQuery(new QueryByCriteria(ItemImpl.class, rootCrit)); ############################# This works fine, but if the selected homes have to satisfy another criteria of a detail item, e.g. all homes that have a red chrysler car in their garage, additional aliases in the path segment "allDetailItemProperties" have to be used. I didn't got it working, i tried it that way: ############################# Criteria rootCrit = new Criteria(); rootCrit.setAlias("detail1", "allDetailItemProperties"); rootCrit.addEqualTo("allDetailItemProperties.name", "myHome"); Criteria propCrit1 = new Criteria(); propCrit1.setAlias("prop1", "allProperties"); propCrit1.addEqualTo("allDetailItemProperties.item.allProperties.name", "firstName"); propCrit1.addEqualTo("allDetailItemProperties.item.allProperties.value", "Jack"); rootCrit.addAndCriteria(propCrit1); Criteria propCrit2 = new Criteria(); propCrit2.setAlias("prop2", "allProperties"); propCrit2.addEqualTo("allDetailItemProperties.item.allProperties.name", "hairColor"); propCrit2.addEqualTo("allDetailItemProperties.item.allProperties.value", "black"); rootCrit.addAndCriteria(propCrit2); Criteria rootCrit2 = new Criteria(); root2Crit.setAlias("detail2", "allDetailItemProperties"); root2Crit.addEqualTo("allDetailItemProperties.name", "carsHome"); Criteria propCrit3 = new Criteria(); propCrit3.setAlias("prop3", "allProperties"); propCrit3.addEqualTo("allDetailItemProperties.item.allProperties.name", "manufactory"); propCrit3.addEqualTo("allDetailItemProperties.item.allProperties.value", "chrysler"); rootCrit2.addAndCriteria(propCrit3); Criteria propCrit4 = new Criteria(); propCrit4.setAlias("prop4", "allProperties"); propCrit4.addEqualTo("allDetailItemProperties.item.allProperties.name", "color"); propCrit4.addEqualTo("allDetailItemProperties.item.allProperties.value", "red"); rootCrit2.addAndCriteria(propCrit4); rootCrit.addAndCriteria(rootCrit2); Collection result = PersistenceBrokerFactory.defaultPersistenceBroker (). getCollectionByQuery(new QueryByCriteria(ItemImpl.class, rootCrit)); ############################# When i apply the alias to the root-criteria it seems that the portions "allDetailItemProperties" of the attribute paths of propCrit1..4 get their own ITEMS-table joined instead of using the alias of the parent Criteria (rootCrit) Maybe there is a way to configure the aliases with use of the class UserAlias, I tried everything without success. Please help! thx in advance, Georg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]