-->
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: Strange Hibernate bug with parent child entity class
PostPosted: Thu May 29, 2014 3:50 am 
Newbie

Joined: Thu May 29, 2014 3:34 am
Posts: 2
I encountered a strange bug involving parent-child entity mapping to similar parent child tables. I am using hibernate-core-4.1.6.Final. The child table is as below:

SCREEN_REQUEST_DETAILS
----------------------------
ID NUMBER(38,0), NOT NULL, PRIMARY KEY
SCREEN_REQUEST_ID NUMBER(38,0), NOT NULL, FOREIGN KEY to ID column in SCREEN_REQUEST table
CATEGORY_ID NUMBER(38,0), NULL, FOREIGN KEY to CATEGORY_ID column in PLATE_WELL_CATEGORY table
:
:
:
goes the rest

In my java codes, I saved the parent class, ScreenRequest then the child class ScreenRequestDetails using manual flushing. Whenever I try to flush after saving the child class I get the below exception.

Quote:
ORA-02291: integrity constraint (PHARMAPPS.SCREEN_REQ_DET_CAT_FK) violated - parent key not found


Note the above error appears even though the column CATEGORY_ID in the SCREEN_REQUEST_DETAILS table is nullable. If I remove the FK constraint in the database table the problem disappear. I tried to place the following annotation on the getter property in the entity class but in vain.

Code:
@ManyToOne(fetch = FetchType.LAZY, optional=true)
@JoinColumn(name = "CATEGORY_ID", nullable=true)
public PlateWellCategory getPlateWellCategory() {
   return this.platewellCategory;
}


Is nullable foreign key column in a child table supported by Hibernate? Many thanks for any advice and tips!

Warmest regards,
Damon


Top
 Profile  
 
 Post subject: Re: Strange Hibernate bug with parent child entity class
PostPosted: Thu May 29, 2014 11:11 pm 
Newbie

Joined: Thu May 29, 2014 3:34 am
Posts: 2
Problem resolved. It's a stupid error. My Oracle trigger was set onto the wrong column, CATEGORY_ID instead of ID column. Sigh.


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.