[Sorry for double post, but I didn't do it)
I am willing to paypal $30.00 to whoever can come up with a nice simple criteria query in c# or java code block for the following (nhibernate mapping files below)
The spec states the following:
Quote:
· findQualifiers: This collection of findQualifier elements can be used to alter the default behavior of search functionality.
FindQualifiersQuote:
· orLikeKeys: when a bag container contains multiple keyedReference elements (i.e., categoryBag or identifierBag), any keyedReference filters that come from the same namespace (e.g. have the same tModelRefKey value) are OR’d together rather than AND’d. This allows one to say “any of these four values from this namespace, and any of these two values from this namespace”.
· orAllKeys: this changes the behavior to OR keys rather than AND them. This qualifier negates any AND treatment as well as the effect of orLikeKeys.
· andAllKeys: this changes the behavior to AND keys rather than OR them.
I have a function which takes a name (from tmodel) and an categoryBag which is an array of categories each having the following properties
TmodelKeyRef
KeyName
KeyValue
It also takes a string representing one of the above findQualifiers.
If findQualifier is
andAllKeys I need to return any tmodels having
ALL of the categories specified
If
orAllKeys tmodels having
ANY of the categories specified will do
and if
orLikeKeys (my biggest headache) then I need to return tmodels having at least one matching category for each unique tmodelKeyRef specified in the categoryBag.
Hope this is easily digestible, but if not I am more than willing to elaborate.
Tmodel.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Data.Hibernate" namespace="Data.Hibernate.Domain">
<class name="Tmodel" table="tmodel">
<id name="TmodelKey" type="string">
<column name="tmodel_key" length="41" />
<generator class="uuid.hex">
<param name="format">P</param>
<param name="seperator">-</param>
</generator>
</id>
<property name="AuthorizedName" type="string">
<column name="authorized_name" not-null="true"/>
</property>
<property name="PublisherId" type="string">
<column name="publisher_id" length="20"/>
</property>
<property name="Operator" type="string">
<column name="operator" not-null="true"/>
</property>
<property name="Name" type="string">
<column name="name" not-null="true"/>
</property>
<property name="OverviewUrl" type="string">
<column name="overview_url"/>
</property>
<property name="DeletionDate" type="DateTime">
<column name="deletion_date" />
</property>
<property name="LastUpdate" type="DateTime">
<column name="last_update" not-null="true"/>
</property>
<bag name="TmodelCategories" inverse="true" cascade="all-delete-orphan" lazy="true">
<key>
<column name="tmodel_key" length="41" not-null="true"/>
</key>
<one-to-many class="TmodelCategory" />
</bag>
<bag name="TmodelDocDescrs" inverse="true" cascade="all-delete-orphan" lazy="true">
<key>
<column name="tmodel_key" length="41" not-null="true"/>
</key>
<one-to-many class="TmodelDocDescr" />
</bag>
<bag name="TmodelDescrs" inverse="true" cascade="all-delete-orphan" lazy="true">
<key>
<column name="tmodel_key" length="41" not-null="true"/>
</key>
<one-to-many class="TmodelDescr" />
</bag>
<bag name="TmodelIdentifiers" inverse="true" cascade="all-delete-orphan" lazy="true">
<key>
<column name="tmodel_key" length="41" not-null="true"/>
</key>
<one-to-many class="TmodelIdentifier" />
</bag>
</class>
</hibernate-mapping>
TmodelCategories.hbm.xml
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Data.Hibernate" namespace="Data.Hibernate.Domain">
<class name="TmodelCategory" table="tmodel_category">
<id name="TmodelCategoryId" type="int">
<column name="tmodel_category_id" />
<generator class="native" />
</id>
<many-to-one name="Tmodel" class="Tmodel" fetch="select">
<column name="tmodel_key" length="41" not-null="true"/>
</many-to-one>
<property name="TmodelKeyRef" type="string">
<column name="tmodel_key_ref"/>
</property>
<property name="KeyName" type="string">
<column name="key_name"/>
</property>
<property name="KeyValue" type="string">
<column name="key_value" not-null="true"/>
</property>
</class>
</hibernate-mapping>