-->
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.  [ 1 post ] 
Author Message
 Post subject: primitive-array, why can't I use on-delete with the key tag?
PostPosted: Wed Sep 14, 2005 4:49 pm 
Newbie

Joined: Wed Sep 14, 2005 12:59 am
Posts: 1
I have an object which contains arrays of primitive types, so I am using the primitive-array to map these in hibernate.

example:
<primitive-array name="m_anAvgStateRank" table="AvgStateRank">
<key column="ID"/>
<index type="int"/>
<element type="int" column="AveStateRank" not-null="true" />
</primitive-array>

This object has a parent object and I cannot delete the primitive tables when I delete the parent object. I get a cannot update or delete parent due to foreign key constraint. I was trying to add the on-delete="cascade' attribute to the key tag, but I get a compaint from hibernate stating that it is not allowed with primitive-type. The dtd does not reflect this issue.

Here are my mapping files... any help would be greatly appreciated.

Core.hbm.xml

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



<hibernate-mapping>

<class name="com.SecureCognition.NTV.DataTypes.Core"

table="CORE">



<id name="id" column="CORE_ID" type="long">

<generator class="native"/>

</id>



<property name="name" column="name"/>

<property name="configFile" column="configFile"/>

<property name="bucketFile" column="bucketFile"/>

<property name="thermdefFile" column="thermdefFile"/>

<property name="startDate" column="startDate"/>

<property name="endDate" column="endDate"/>

<property name="verbose" column="verbose"/>

<property name="pid" column="pid"/>

<property name="mnKeepHours" column="mnKeepHours"/>

<property name="mnPauseSecs" column="mnPauseSecs"/>

<property name="mnSlideLength" column="mnSlideLength"/>

<property name="mnWindowLength" column="mnWindowLength"/>



<set name="coreResults" inverse="true" lazy="true" cascade="all,delete-orphan">

<key column="CORE_ID" on-delete="cascade"/>

<one-to-many class="com.SecureCognition.NTV.DataTypes.CoreResult"/>

</set>



</class>

</hibernate-mapping>

CoreResult.hbm.xml

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



<hibernate-mapping >

<class name="com.SecureCognition.NTV.DataTypes.CoreResult"

table="CORERESULT">



<id name="id" column="CORERESULT_ID" type="long">

<generator class="native"/>

</id>



<many-to-one name="core" class="com.SecureCognition.NTV.DataTypes.Core" column="CORE_ID"/>



<property name="m_nTime" column="m_nTime" type="integer"/>

<property name="m_nSize" column="m_nSize" type="integer"/>

<property name="m_nBuckets" column="m_nBuckets" type="integer"/>

<property name="m_nStates" column="m_nStates" type="integer"/>

<property name="m_nTotalEvents" column="m_nTotalEvents" type="integer"/>

<property name="m_nHighState" column="m_nHighState" type="integer"/>

<property name="m_nLowState" column="m_nLowState" type="integer"/>

<property name="m_nConStateSize" column="m_nConStateSize" type="integer"/>

<property name="m_fEntropy" column="m_fEntropy" type="double"/>

<property name="m_fEnergy" column="m_fEnergy" type="double"/>

<property name="m_fTemperature" column="m_fTemperature" type="double"/>

<property name="m_fMProduct" column="m_fMProduct" type="double"/>

<property name="m_fMXProduct" column="m_fMXProduct" type="double"/>

<property name="m_fMXTemp" column="m_fMXTemp" type="double"/>



<property name="m_bClicked" column="m_bClicked" type="boolean"/>

<property name="m_nStatesDisplayed" column="m_nStateDisplayed" type="integer"/>

<property name="m_nLastOffset" column="m_nLastOffset" type="long"/>

<property name="m_nLastSearchOffset" column="m_nLastSearchOffset" type="integer"/>

<property name="m_nRunningSum" column="m_nRunningSum" type="integer"/>

<property name="m_nLastIndex" column="m_nLastIndex" type="integer"/>



<primitive-array name="m_anAvgStateRank" table="AvgStateRank">

<key column="ID"/>

<index type="int"/>

<element type="int" column="AveStateRank" not-null="true" />

</primitive-array>



<primitive-array name="m_anAvgStateIndex" table="AveStateIndex">

<key column="ID"/>

<index type="int"/>

<element type="int" column="AveStateIndex" not-null="true"/>

</primitive-array>



<primitive-array name="m_afAvgStateT" table="AveStateT">

<key column="ID"/>

<index type="double"/>

<element type="double" column="AveStateT" not-null="true"/>

</primitive-array>



<primitive-array name="m_afAvgStateC" table="AveStateC">

<key column="ID"/>

<index type="double"/>

<element type="double" column="AveStateC" not-null="true"/>

</primitive-array>



<primitive-array name="m_afWorkArray" table="WorkArray">

<key column="ID"/>

<index type="double"/>

<element type="double" column="WorkArray" not-null="true"/>

</primitive-array>



<primitive-array name="m_afWork" table="Work">

<key column="ID"/>

<index type="double"/>

<element type="double" column="Work" not-null="true"/>

</primitive-array>



<primitive-array name="m_afStateCounts" table="StateCounts">

<key column="ID"/>

<index type="int"/>

<element type="int" column="StateCounts" not-null="true"/>

</primitive-array>

</class>

</hibernate-mapping>

This mapping does not work due to the foreign key constraint. If I comment out the primitive array mapping, I can delete a Core object and all the CoreResult Objects associated with the Core are deleted. I cannot do the same if I use the primitive-array types.

Rob

P.S. Using Hibernate-3.0 and Mysql 4.1.14


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

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.