Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

hibernate creating duplicate ForeignKey index

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have the database schema built on mySQL. When I try to insert into the database, hibernate for some reason wants to create the foreign key index. this results in a duplicate foreign key index. Can someone tell me how I configure hibernate to use the foreign key index that already exists in the database?
Thanks in advance ....
Here are my mapping docs;

<hibernate-mapping>
<class name="Profile" table="profiles">
<id name="id" type="int" column="id" >
<generator class="native"/>
</id>
<property name="clientName">
<column name="client_name" />
</property>
<property name="lastUpdateDate">
<column name="last_update_date" />
</property>
<set name="includedAccounts"
inverse="true"
lazy="false"
cascade="save-update">
<key column="profile_id" not-null="true"/>
<one-to-many class="Account"/>
</set>
<set name="notificationEmails"
inverse="true"
lazy="false"
cascade="save-update">
<key column="profile_id" not-null="true"/>
<one-to-many class="Email"/>
</set>
</class>
</hibernate-mapping>
----------------------------------------------------------------------------------
<hibernate-mapping>
<class name="Account" table="accounts">
<id name="id" type="int" column="id" >
<generator class="native"/>
</id>

<property name="AcctID">
<column name="acct_id" not-null="true"/>
</property>

<many-to-one name="profile"
column="profile_id"
not-null="true"
cascade="save-update"
class="Profile"/>

<set name="reports"
inverse="true"
lazy="true"
cascade="save-update">
<key column="acct_id" not-null="true"/>
<one-to-many class="Report"/>
</set>
</class>
</hibernate-mapping>
----------------------------------------------------------------------------------
<hibernate-mapping>
<class name="Report" table="reports">
<id name="id" type="int" column="id" >
<generator class="native"/>
</id>
<property name="reportDate">
<column name="report_date"/>
</property>
<property name="reportData" type="text">
<column name="report_data"/>
</property>
<many-to-one name="acct"
column="acct_id"
not-null="true"
cascade="save-update"
class="Account"/>
</class>
</hibernate-mapping>
----------------------------------------------------------------------------------
<hibernate-mapping>
<class name="Email" table="emails">
<id name="id" type="int" column="id" >
<generator class="native"/>
</id>
<property name="emailAddress">
<column name="email"/>
</property>
<many-to-one name="profile"
column="profile_id"
not-null="true"
cascade="save-update"
class="Profile"/>
</class>
</hibernate-mapping>
----------------------------------------------------------------------------------
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Vijay, please don't post duplicate threads. We already have a thread discussion going on for your problem.

I am going to close this thread.

Mark
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic