Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Cascade deletes causing not null constraint violations.
[Teneo] Cascade deletes causing not null constraint violations. [message #617970] Wed, 30 April 2008 19:19
Alex Black is currently offline Alex BlackFriend
Messages: 15
Registered: July 2009
Junior Member
Hello,
I'm having difficulty deleting child objects on a merge call. I have a
parent object, Lab, which contains a list of Contacts:

------------------------------------------------------------ ---------------------

<xsd:complexType name="Lab">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Entity
@Table(
name="LabTable"
)
</xsd:appinfo>
</xsd:annotation>

<xsd:sequence>

<!--lots of irrelevent stuff--->

<xsd:element maxOccurs="unbounded" minOccurs="0" name="contactList"
type="Contact">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@OneToMany(indexed=false)
@JoinColumn(name="LAB_SK", nullable=false)
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:sequence>

</xsd:complexType>



<xsd:complexType name="Contact">

<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Entity
@Table(
name="ContactTable"
)
</xsd:appinfo>
</xsd:annotation>

<xsd:sequence>

<xsd:element default="0" name="contactSK" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Id
@GeneratedValue(strategy=SEQUENCE, generator="labSequence")
@Column(name=Contact_SK,nullable="false",updatable=false)
</xsd:appinfo>
</xsd:annotation>
</xsd:element>


<!--lots of irrelevent stuff--->


</xsd:sequence>
</xsd:complexType>

------------------------------------------------------------ ---------------------

The Lab is loaded by a client via a web service, so it is completely
serialized and deserialized before it comes back into the system as a
detatched object. The client has monkeyed with the data he pulled down, and
occasionally removes a contact from the contactList. To handle the incoming
changes, I'm using the hibernate merge method:


------------------------------------------------------------ ---------------------
//bunch of deserialization code

outputLab = (Lab)session.merge(inputLab)

//bunch of serialization code
------------------------------------------------------------ ---------------------

Beautifully simple, and works as advertised. My problem is that when
hibernate removes a row from the ContactTable, it nulls out the foreign key
first (summarized SQL):

------------------------------------------------------------ ---------------------

--bunch of selects
update LabTable set lab_sk=null where lab_sk=? and contact_sk=?
delete from ContactTable where contact_sk=?

------------------------------------------------------------ ---------------------


This causes a foreign key not null constraint violation. I have "fixed" the
issue by asking the DBA to drop the not null constraints for the moment
(then repremanding myself sternly for even suggesting the idea), but would
like hibernate to please just delete the row without nulling it.

It appears that the standard hibernate way to do this is to add an
'inverse="true"' to the oneToMany:

http://forum.hibernate.org/viewtopic.php?p=2383090

but I can't figure out how to get a Teneo annotation to do that.

Any thoughts or ideas? Is this the right approach?

Thanks,

-Alex
Previous Topic:thread safety of Teneo
Next Topic:[Announce] EMFT SEARCH 0.7.0 I200804302039 is available
Goto Forum:
  


Current Time: Fri Apr 26 03:45:56 GMT 2024

Powered by FUDForum. Page generated in 0.02483 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top