[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-4015) one-to-one: foreign key: save Problem

Gail Badner (JIRA) noreply at atlassian.com
Wed Nov 23 06:20:19 EST 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4015?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gail Badner closed HHH-4015.
----------------------------


> one-to-one: foreign key: save Problem
> -------------------------------------
>
>                 Key: HHH-4015
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4015
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.6
>            Reporter: Sandeep Vaid
>            Assignee: Gail Badner
>            Priority: Critical
>
>  I have one-to-one relationship between  class A and class B
>         
>         <class name="A" table="TEMPA" >
> 	     <id name="aaId" type="string" column="AID" length="10"> 
> 	      <generator class="assigned"></generator>
> 	    </id>
> 	 <one-to-one name="b" class="B" constrained="true"  outer-join="false" cascade="save-update" />
>        </class>
> 	   
> 	   
>        <class name="B" table="TEMPB" lazy="true">
> 	 <id name="baId" type="string" column="BID" length="10"> 
> 	   <generator class="foreign">
> 	    <param name="property">a</param>
> 	    </generator>
> 	  </id>
> 	
> 	<one-to-one name="a" class="A" />
>       </class>
>       
>     Problem 1: When i try to save A, it fires :
>     	  insert into HBLEARN1.TEMPB (BID) values ('1')
>     	  and throws error :
>     	  The insert or update value of the FOREIGN KEY "TEMPB.CC1246876555824" is not equal to any value of the 
>     	  parent key of the parent table.  SQLSTATE=23503
>     	  
>     	  Why it is first trying to save 'B' instead of 'A' first ?
>     	  
>    Problem 2: With this mapping, if i set <property name="hibernate.hbm2ddl.auto">create</property> in hibernate.cfg.xml,
>         It generates TEMPA whose aaId is the foreign key referencing TEMPB. This is also incorrect..

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list