-->
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.  [ 2 posts ] 
Author Message
 Post subject: one-to-many association/ Delete problem
PostPosted: Tue Apr 17, 2007 6:40 pm 
Newbie

Joined: Tue Apr 17, 2007 6:25 pm
Posts: 1
Hi All,

I have a object "Application" that has a collection of configuration entries (configEntry). I only access the configuration entries through the Application object so I don't need a bidirectional association.

<hibernate-mapping>
<class name="applications.model.Application" table="applications" lazy="false">
<id name="key" column="app_id" type="string"/>
<property name="name" type="string"/>
<property name="description" type="string"/>
<set name="configEntries" cascade="all-delete-orphan" table="appConfigEntries" lazy="false">
<key column="app_id"/>
<one-to-many class="applications.model.AppConfigEntry" />
</set>
</class>

</hibernate-mapping>

<hibernate-mapping>
<class name="applications.model.AppConfigEntry" table="appConfigEntries" lazy="false" >

<id name="id" column="app_config_entry_id" type="int">
<generator class="increment" />
</id>

<property name="configKey" type="string">
<meta attribute="field-description">The option key</meta>
</property>

<property name="configValue" type="string">
<meta attribute="field-description">The value of the user</meta>
</property>
</class>
</hibernate-mapping>


The problem is that when I remove a configuration entry from the Application collection the hibernate removes the association but the child object ( configuration entry ) remains in the data base.

In other words... hibernate only sets the attribute app_id of the object configEntry to null... what I want is that the hibernate removes the entire object "configEntry".

Can someone help me on this?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 12:27 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi vhbramos,

Try this

<set name="configEntries" cascade="all,delete-orphan" table="appConfigEntries" lazy="false">
<key column="app_id"/>
<one-to-many class="applications.model.AppConfigEntry" />
</set>

_________________
Dharmendra Pandey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.