Hibernate version:
1.2.0
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" assembly="Domain" namespace="Domain.Entities">
<class name="Person" table="Person">
<id column="Id" name="Id" unsaved-value="00000000-0000-0000-0000-000000000000" access="nosetter.pascalcase-m-underscore">
<generator class="guid.comb" />
</id>
<bag access="field.pascalcase-m-underscore" name="Fields" table="PersonFields" lazy="true" cascade="save-update">
<key column="PersonId"/>
<composite-element class="Domain.Entities.FilledField, Domain">
<property name="Value" column="Value" type="String" length="255" not-null="false"/>
<many-to-one name="Field" class="Domain.Entities.Field, Domain" column="FieldId" not-null="true"/>
</composite-element>
</bag>
</class>
</hibernate-mapping>
In order to query the fields property of the class person I can write the following hql:
Code:
select p from Person p join p.Fields flds where 'someValue' = flds.Value
Is it possible to write something similar with Criterias ? When you try to call CreateCriteria on a criteria based on person you get an 'Not an association' error.
For example:
Code:
ICriteria criteria = session.CreateCriteria(typeof(Person));
criteria.Add("Fields").Add(Expression.Eq("Value", "someValue"));
I've tried several other things as well, but with the same outcome.
I've found a topic about this on the Hibernate forum, but with no answer.
http://forum.hibernate.org/viewtopic.php?t=943792