-->
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: Problems with deleting an object with an array inside
PostPosted: Tue Aug 17, 2010 1:58 pm 
Newbie

Joined: Tue Aug 17, 2010 1:13 pm
Posts: 2
I'm starting to loose my hair due to the following problem...

I am using Hibernate 3.2.2.

I have a class with an array of key-value pairs:
Code:
    <class name="SomeClass" table="someclass">
        <id name="layerID" column="id" access="field">
            <generator class="native"/>
        </id>
        <array name="params" access="field" cascade="all-delete-orphan">
            <key column="params"/>
            <index column="idx"/>
            <one-to-many class="KeyValue"/>
        </array>
    </class>


The KeyValue-Class just contains two strings.
Code:
    <class name="KeyValue" table="parameters">
        <id type="int" column="id">
            <generator class="native"/>
        </id>
       
        <property name="key" access="field" length="32" not-null="true"/>
        <property name="value" access="field" length="128"/>
    </class>


As long as I just write or read SomeClass-objects from/to the database everything is fine.
But when I delete an object, the elements of the array are orphaned but stay in the database.

I have tried almost every possible combination of cascade options (all, delete, all-delete-orphan, etc) and key-settings but I just can not convince Hibernate to delete the elements of the array.

Sure, I could delete any orphaned KeyValue-element manually with an additional SQL/HQL-statement - but I think that is not the way it's meant to be...

Since this is one of the basic features of a database (on delete="cascade" with an foreign key) I'm sure that there is a solution within Hibernate.
But I can not find any valuable information in the Hibernate documentation, so I hope that anyone can give me a hint how to solve this problem.

Thank's in advance,
-Marc-


Top
 Profile  
 
 Post subject: Re: Problems with deleting an object with an array inside
PostPosted: Fri Mar 11, 2011 10:29 am 
Newbie

Joined: Fri Mar 11, 2011 10:21 am
Posts: 1
did anyone resolve this problem?


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.