Hi Floks
here is hbm.xml files
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi Folk,
I have really big object graph in which I have many levels of associations.
Here is a simplifed Hbm.xml
specficy to my application
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.customer.domain.CommonApplication" table="B_APPLICATION">
<meta attribute="extends" inherit="true">
com.gmacb.B.common.domain.BaseDomainObjectWithAssignedId
</meta>
<id name="id" column="APPLICATION_ID" type="long">
<meta attribute="gen-property">false</meta>
<generator class="assigned"/>
</id>
<version name="version" column="VERSION" type="int">
<meta attribute="gen-property">false</meta>
</version>
<property name="appValidate" column="APP_VALIDATE" type="yes_no"/>
<bag name="softwareResources" lazy="false" cascade="save-update">
<key column="APPLICATION_ID"/>
<one-to-many class="com.customer.domain.SoftwareResource"/>
</bag>
<bag name="agencyApprovals" lazy="false" cascade="save-update">
<key column="APPLICATION_ID"/>
<one-to-many class="com.customer.domain.AgencyApproval"/>
</bag>
<bag name="lenderReferences" lazy="false" >
<key column="APPLICATION_ID"/>
<one-to-many class="com.customer.domain.LenderReference"/>
</bag>
</class>
<class name="com.customer.domain.AgencyApproval" table="B_AGENCY_APPROVAL">
<meta attribute="extends" inherit="true">
com.gmacb.B.common.domain.BaseDomainObjectWithSequenceId
</meta>
<id name="id" type="long" column="ID">
<meta attribute="gen-property">false</meta>
<generator class="sequence">
<param name="sequence">B_APP_SEQUENCE</param>
</generator>
</id>
<property name="dateApproved" column="DATE_APPROVED" type="timestamp"/>
<property name="approvalNumber" column="APPROVAL_NUMBER" type="string" length="50"/>
<property name="applicationId" column="APPLICATION_ID" type="long"/>
</class>
<class name="com.customer.domain.SoftwareResource" table="B_SOFTWARE_RESOURCE">
<meta attribute="extends" inherit="true">
com.gmacb.B.common.domain.BaseDomainObjectWithSequenceId
</meta>
<id name="id" type="long" column="ID">
<meta attribute="gen-property">false</meta>
<generator class="sequence">
<param name="sequence">B_APP_SEQUENCE</param>
</generator>
</id>
<property name="name" column="NAME" type="string" length="50"/>
<property name="applicationId" column="APPLICATION_ID" type="long"/>
</class>
<class name="com.customer.domain.LenderReference" table="B_LENDER_REFERENCE">
<meta attribute="extends" inherit="true">
com.gmacb.B.common.domain.BaseDomainObjectWithSequenceId
</meta>
<id name="id" type="long" column="ID">
<meta attribute="gen-property">false</meta>
<generator class="sequence">
<param name="sequence">B_APP_SEQUENCE</param>
</generator>
</id>
<property name="companyName" column="COMPANY_NAME" type="string" length="100"/>
<property name="referenceType" column="REFERENCE_TYPE" type="string" length="50"/>
<bag name="lenderContacts" lazy="false" >
<key column="LENDER_REF_ID"/>
<one-to-many class="com.customer.domain.LenderContact"/>
</bag>
</class>
<class name="com.customer.domain.LenderContact" table="B_LENDER_CONTACT">
<meta attribute="extends" inherit="true">
com.gmacb.B.common.domain.BaseDomainObjectWithSequenceId
</meta>
<id name="id" type="long" column="ID">
<meta attribute="gen-property">false</meta>
<generator class="sequence">
<param name="sequence">B_APP_SEQUENCE</param>
</generator>
</id>
<property name="lenderRefId" column="LENDER_REF_ID" type="long"/>
<many-to-one name="person" class="com.common.domain.Person" column="PERSON_ID"/>
</class>
</hibernate-mapping>
Common to all applications in the frame work we are building
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- com.common.domain.Person root -->
<class name="com.common.domain.Person" table="B_PERSON" dynamic-insert="true" dynamic-update="true">
<id name="id" type="long" column="ID">
<generator class="sequence">
<param name="sequence">B_person_sequence</param>
</generator>
</id>
<version name="version" column="VERSION" type="integer"/>
<property name="firstName" column="FIRST_NAME" type="string" length="50"/>
<property name="middleInitial" column="MIDDLE_INITIAL" type="string" length="50"/>
<property name="lastName" column="LAST_NAME" type="string" length="50"/>
<component name="contactInfo" class="com.common.domain.ContactInfo">
<set name="phones" table="B_PHONE" lazy="false" cascade="all-delete-orphan">
<key column="PERSON_ID"/>
<one-to-many class="com.common.domain.Phone"/>
</set>
</component>
</class>
<!-- com.common.domain.Phone root -->
<class name="com.common.domain.Phone" table="B_PHONE" dynamic-insert="true" dynamic-update="true">
<id name="id" type="long" column="ID">
<generator class="sequence">
<param name="sequence">B_person_sequence</param>
</generator>
</id>
<version name="version" column="VERSION" type="integer"/>
<property name="phoneNumber" column="PHONE_NUMBER" type="string" length="20" not-null="true"/>
<property name="personId" column="PERSON_ID" type="long"/>
<property name="communicationId" column="COMMUNICATION_ID" type="long"/>
</class>
</hibernate-mapping>