-->
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: Oracle data corruption with one-to-one mapping
PostPosted: Wed Jul 14, 2004 1:39 am 
Newbie

Joined: Wed Jul 14, 2004 1:18 am
Posts: 2
On doing a saveOrUpdate of an object whose class participates in a one-to-one mapping, Hibernate is attempting to store a garbage value into a foreign key field (of type Integer) in the corresponding table row. Sometimes the value is a huge integer--other times, it is some weird poison value that even breaks SQL*Plus when I try to view it. The result is an Oracle 2291 error (integrity constraint violated, parent key not found). From looking at the Hibernate debug log, the value seems to be reported to be correct (zero) prior to the insert.

I've stripped out Spring, DbUnit, and various other things to try to get a simple test case. (I'm still using JUnit.) There are 5 classes, 375 lines of Java. This is still too big to post here, but the complete project is at http://www.lexonics.com/hibernateProblem.tar.gz. Download, unzip, and untar, and type "maven" to run.

The Hibernate version is 2.1.4. The mapping documents are included in the download. The Java code is in the file ZotTest.java. The stack trace is in the debug level log file hibernate.log. The database is Oracle, probably some 8.x version.

If I comment out the setPublishDate call, the test appears to run successfully, but another column (VERSION) has a garbage value.

I would appreciate any help you can give me. The xdoclet tags for the one-to-one mapping are set up correctly (as far as I know!).

Thank you.


Top
 Profile  
 
 Post subject: Re: Oracle data corruption with one-to-one mapping
PostPosted: Wed Jul 14, 2004 4:45 pm 
Newbie

Joined: Wed Jul 14, 2004 1:18 am
Posts: 2
I think the problem was simply the omission of 'type="date"' on the java.util.Date properties in my persistent classes (to tell Hibernate that the Oracle column was of type DATE).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 6:00 am 
Beginner
Beginner

Joined: Wed Sep 07, 2005 9:57 am
Posts: 20
Hi,

we had the same problem (ORA-02291: integrity constraint) with an Oracle 8 DB and at first fooled around with different Oracle JDBC-Drivers. We found one which worked around this problem but would not handle BLOBs properly - we only managed to do this with a newer Oracle 10 driver.

Anyway, at first in our mapping we had a property:

<property name="when" column="when" type="timestamp" not-null="true" />

and this would result in the integrity constraint.

When we changed this to

<property name="when" column="when" type="date" not-null="true" />

it worked but only inserted the date and not the time in the column (Oracle Type 'Date')

We than changed it to

<property name="when" column="when" type="time" not-null="true" />

and it still worked plus it inserted the date and time into the column.


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.