Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

generated value for a foreignkey which is non id

$
0
0
I have the mappings like below in the order

Code:

<hibernate-mapping>
<class name="Map" table="maps" lazy="true">
        <id name="id" type="java.lang.Long" column="mapid">
                        <generator class="native" />
        </id>
               
        <set name="preferences" table="preferences" lazy="false" inverse="true" cascade="all-delete-orphan" fetch="select">
                <key column="mapid" not-null="true"/>
                <one-to-many class="Preferences" />
        </set>
               
</hibernate-mapping>



<hibernate-mapping>                                       
        <class name="Preferences" table="preferences" >
       
                <id name="preferenceId" type="java.lang.Long">
                        <column name="preferenceid" />
                        <generator class="native" />
                </id>
               
                <set name="subPreferences" table="sub_preferences" lazy="false" inverse="true" cascade="all-delete-orphan" fetch="select">
                <key column="preferenceId" not-null="true"/>
                <one-to-many class="Preferences" />
                </set>
        </class>
</hibernate-mapping>

<hibernate-mapping>                                       
        <class name="SubPreferences" table="sub_preferences" >
       
                <id name="subpreferenceId" type="java.lang.Long">
                        <column name="subpreferenceid" />
                        <generator class="native" />
                </id>
                <property name="preferenceid" type="java.lang.Long"  not-null="true">
                        <column name="preferenceid"  />
                </property>
        </class>
</hibernate-mapping>


first two entities inserted properly but the third entity is not being inserted and neither giving error. Can any one help what the wrong with this? and how do i resolve this.

Viewing all articles
Browse latest Browse all 297

Trending Articles