-->
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.  [ 4 posts ] 
Author Message
 Post subject: ORA-02291 Exception and save
PostPosted: Tue Feb 17, 2004 12:01 pm 
Newbie

Joined: Tue Feb 17, 2004 11:34 am
Posts: 8
Hi All. Can you help me? I dont find my case in forum.

This is my problem:
I have class and joined-subclass
and when I use saveOrUpdate is caused:
SQL exception: Could not synchronize database state with session ORA-02291 (integrity constraint violated -parent key not found)
Is only when I use Oracle (with mysql all ok)
My mapping:
Code:
  <class name="Global" table="GLOBAL" >
      <id name="id" type="long" column="GLOBAL_ID" unsaved-value="-1">
         <generator class="native"/>
      </id>
      <many-to-one name="contact" column="GLOBAL_CONTACT_ID"/>

        <joined-subclass name="Case" table="CASE" >
      <key column="GLOBAL_ID"/>
      <property name="name" column="NAME" type="string"/>
        </joined-subclass>

And code:
Code:
session.saveOrUpdate(Case);


Envirement:
Hibernate 2.0.3
Oracle 8.1

I dont find what is wrong...
Sorry I cant write full hibernate log but it write what first insert Global and second insert Case(with right GLOBAL_ID)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 2:02 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You must give more info,
What is your DB schema (constaints), the exact Hibernate SQL etc

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 12:47 am 
Newbie

Joined: Tue Feb 17, 2004 11:34 am
Posts: 8
emmanuel wrote:
You must give more info,
What is your DB schema (constaints), the exact Hibernate SQL etc

Ok. I understand.
My DB schema after schema-export:

Code:
CREATE TABLE SCOTT.GLOBAL (
    GLOBAL_ID      NUMBER(19,0) NOT NULL,
    CONTACT_ID   NUMBER(19,0),
    PRIMARY KEY(GLOBAL_ID)
)
GO
ALTER TABLE SCOTT.GLOBAL
    ADD CONSTRAINT FKEE5418878391FD86
    FOREIGN KEY(CONTACT_ID)
    REFERENCES SCOTT.CONTACT(CONTACT_ID)
GO

CREATE TABLE SCOTT.CASE (
    GLOBAL_ID   NUMBER(19,0) NOT NULL,
    NAME        char,
    PRIMARY KEY(GLOBAL_ID)
)
GO
ALTER TABLE SCOTT.CASE
    ADD CONSTRAINT FK1B15F7B4F3F68A5C
    FOREIGN KEY(GLOBAL_ID)
    REFERENCES SCOTT.GLOBAL(GLOBAL_ID)
GO



Hibernate log:
[code]
11:35:20,593 DEBUG SessionImpl:413 - opened session
11:35:20,593 DEBUG JDBCTransaction:36 - begin
11:35:20,609 DEBUG Cascades:208 - unsaved-value: -1
11:35:20,609 DEBUG SessionImpl:1201 - saveOrUpdate() unsaved instance with id: -1
11:35:20,609 DEBUG BatcherImpl:166 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:35:20,609 DEBUG SessionFactoryImpl:526 - prepared statement get: select hibernate_sequence.nextval from dual
11:35:20,609 DEBUG SessionFactoryImpl:536 - preparing statement
11:35:20,609 DEBUG SequenceGenerator:70 - Sequence identifier generated: 203
11:35:20,609 DEBUG BatcherImpl:173 - done closing: 0 open PreparedStatements, 0 open ResultSets
11:35:20,609 DEBUG SessionFactoryImpl:554 - closing statement
11:35:20,609 DEBUG SessionImpl:656 - saving [com.organization.Case#203]
11:35:20,609 DEBUG Cascades:208 - unsaved-value: -1
11:35:20,625 DEBUG SessionImpl:2011 - flushing session
11:35:20,625 DEBUG SessionImpl:2113 - Flushing entities and processing referenced collections
11:35:20,625 DEBUG AbstractEntityPersister:216 - com.organization.Case.messageBlob is dirty
11:35:20,625 DEBUG SessionImpl:2209 - Updating entity: [com.organization.Case#203]
11:35:20,625 DEBUG SessionImpl:2397 - Processing unreferenced collections
11:35:20,625 DEBUG SessionImpl:2408 - Scheduling collection removes/(re)creates/updates
11:35:20,625 DEBUG SessionImpl:2023 - Flushed: 1 insertions, 1 updates, 0 deletions to 1 objects
11:35:20,625 DEBUG SessionImpl:2028 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
11:35:20,625 DEBUG SessionImpl:2058 - executing flush
11:35:20,625 DEBUG NormalizedEntityPersister:479 - Inserting entity: com.organization.Case#203
11:35:20,625 DEBUG BatcherImpl:166 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:35:20,625 DEBUG SessionFactoryImpl:526 - prepared statement get: insert into GLOBAL ( CONTACT_ID, GLOBAL_ID ) values ( ?, ?)
11:35:20,625 DEBUG SessionFactoryImpl:536 - preparing statement
11:35:20,625 DEBUG BatcherImpl:166 - about to open: 1 open PreparedStatements, 0 open ResultSets
11:35:20,625 DEBUG SessionFactoryImpl:526 - prepared statement get: insert into CASE (NAME, GLOBAL_ID) values (?, ?)
11:35:20,625 DEBUG SessionFactoryImpl:536 - preparing statement
11:35:20,625 DEBUG NormalizedEntityPersister:361 - Dehydrating entity: com.organization.Case#203

11:35:20,625 DEBUG Cascades:208 - unsaved-value: -1
11:35:20,625 DEBUG LongType:44 - binding '183' to parameter: 1
11:35:20,640 DEBUG LongType:44 - binding '203' to parameter: 2

11:35:20,640 DEBUG StringType:44 - binding 'name' to parameter: 1
11:35:20,640 DEBUG LongType:44 - binding '203' to parameter: 2
11:35:20,687 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: ORA-02291:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 4:00 am 
Newbie

Joined: Tue Feb 17, 2004 11:34 am
Posts: 8
And what wrong with Oracle? or Hibernate?
Why worked for Mysql?


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