Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]NHibernate version 1.0.4.0[/b]
[b]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="BusinessObjects.TestModule.TestPaper, BusinessObjects.TestModule" table="testpaper">
<id name="ID" column="ID" type="Int32">
<generator class="native"></generator>
</id>
<property name="Name" column="NAME" type="String" length="45" not-null="true"/>
<property name="Description" column="DESCRIPTION" type="String" not-null="true"/>
<property name="Status" column="STATUS" type="Boolean" not-null="true"/>
<property name="CreatedOn" column="CREATED_ON" type="DateTime" not-null="true"/>
<property name="ModifiedOn" column="MODIFIED_ON" type="DateTime" not-null="true"/>
<many-to-one name="CreatedBy" column="Created_By" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<many-to-one name="ModifiedBy" column="Modified_By" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<property name="DtpSubmittedOn" column="DTP_Submitted_On" type="DateTime" not-null="false"/>
<property name="ProofReadOn" column="ProofRead_ON" type="DateTime" not-null="false"/>
<many-to-one name="ProofReader" column="Proof_Reader" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<many-to-one name="DtpAllocated" column="DTP" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<property name="TestPhaseInt" column="Current_Phase" type="int" not-null="true"/>
<many-to-one name="Template" column="Template_ID" class="BusinessObjects.TestModule.Template, BusinessObjects.TestModule" not-null="true"/>
</class>
</hibernate-mapping>[/b]
I am firing this Criteria Query
ICriteria criteria = session.CreateCriteria(typeof(Testpaper));
criteria.Add(Expression.Like(Name, "new", MatchMode.Start));
return criteria.List();
and it gives me wierd results like sometimes it shows me 1 row twice and somtimes it has 20 repeats.
If i remove the template mapping ( <many-to-one name="Template" column="Template_ID" class="BusinessObjects.TestModule.Template, BusinessObjects.TestModule" not-null="true"/>
) then it shows correct results.
Template mapping file is
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="BusinessObjects.TestModule.Template, BusinessObjects.TestModule" table="template">
<id name="ID" column="ID" type="Int32">
<generator class="native"></generator>
</id>
<property name="Name" column="NAME" type="String" length="45" not-null="true"/>
<property name="Description" column="DESCRIPTION" type="String" not-null="true"/>
<property name="Status" column="STATUS" type="Boolean" not-null="true"/>
<property name="CreatedOn" column="CREATED_ON" type="DateTime" not-null="true"/>
<property name="ModifiedOn" column="MODIFIED_ON" type="DateTime" not-null="true"/>
<many-to-one name="CreatedBy" column="Created_By" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<many-to-one name="ModifiedBy" column="Modified_By" class="BusinessObjects.UserModule.User, BusinessObjects.UserModule" not-null="true"/>
<bag name="TemplateStructures" table="template_structure" outer-join="true" inverse="true" cascade="all-delete-orphan">
<key column="TEMPLATE_ID" />
<one-to-many class="BusinessObjects.TestModule.TemplateStructure, BusinessObjects.TestModule" />
</bag>
</class>
</hibernate-mapping>
Can some one tell me whats happening.
If i remove all the template entries from database it shows correct result so i have a feeling it might be a join problem
Thanx