-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Help Object graph with cascade and non-cascade association
PostPosted: Thu Jun 23, 2005 10:58 pm 
Newbie

Joined: Thu Jun 23, 2005 10:16 pm
Posts: 3
Hi Folk,

I have really big object graph in which I have many levels of associations.


deepest level are cascade="all-delete-Orphan"

the level below my root object are cascade="none"


I manually Create Update Delete using persistence managers for cascade="none" objects

I am assuming hibernate take care of Create Update Delete opertions for cascade="all-delete-orphans"

I assign FKs for all object.

Its work fine for inserts.

Problem is when I try to update cascade="none" objects lower level cascade="all-delete-orphans" objects are getting deleted.

Is my approch is wrong?
Can somebody help me please

Thanks in advance
mahe





Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 9:54 am 
Newbie

Joined: Thu Jun 23, 2005 10:16 pm
Posts: 3
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>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 9:58 am 
Newbie

Joined: Thu Jun 23, 2005 10:16 pm
Posts: 3
when I update commonapplication object I am losing Phone object I am make sure I call all updated required when I call my last update on commonapplication its deleting some objects.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.