I'm really struggling with my composite-id mapping. It seems to be loading everything, but the Violations list never gets populated with anything. It's always empty. It also seems to be hitting the database a lot for the same information. Could someone please help?
Policy.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Business.Policy, Business" table="policy">
<composite-id>
<key-property name="PolicyNum" column="policy_num" />
<key-property name="PolicySym" column="policy_sym" />
<key-property name="PolicyMod" column="policy_mod" />
<key-property name="PolicyMco" column="policy_mco" />
</composite-id>
<property name="EffectiveDate" column="eff_date" />
<property name="PrimaryState" column="prim_state_code" />
<bag name="Violations" inverse="true" lazy="false" cascade="all">
<key>
<column name="policy_num" not-null="true" />
<column name="policy_sym" not-null="true" />
<column name="policy_mod" not-null="true" />
<column name="policy_mco" not-null="true" />
</key>
<one-to-many class="Business.Violation, Business" />
</bag>
</class>
</hibernate-mapping>
Violation.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Business.Violation, Business" table="violation">
<id name="ViolationId" type="System.Int32" column="violation_seq" unsaved-value="0">
<generator class="identity" />
</id>
<property name="PersonId" column="person_seq" not-null="true" />
<property name="CovPartTypeCode" column="cov_part_type_code" not-null="true" />
<property name="PolicyNum" column="policy_num" insert="false" update="false" />
<property name="PolicySym" column="policy_sym" insert="false" update="false" />
<property name="PolicyMod" column="policy_mod" insert="false" update="false" />
<property name="PolicyMco" column="policy_mco" insert="false" update="false" />
<property name="ViolationNum" column="violation_num" />
<property name="ViolationDate" column="date" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="ViolationTypeCode" column="acc_violation_type_code" />
<property name="Description" column="descript" />
<property name="Amount" column="amt" />
<property name="ModifiedUserId" column="modified_user_id" not-null="true" />
<property name="ModifiedDate" column="modified_date" not-null="true" />
<property name="ClaimStatus" column="claim_status" />
<many-to-one name="Policy" class="Business.Policy, Business" not-null="true">
<column name="policy_num" />
<column name="policy_sym" />
<column name="policy_mod" />
<column name="policy_mco" />
</many-to-one>
</class>
</hibernate-mapping>