aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate creating duplicate ForeignKey index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply locked New topic
Author

hibernate creating duplicate ForeignKey index

Vijay Chauhan
Greenhorn

Joined: Nov 28, 2006
Posts: 11
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>
----------------------------------------------------------------------------------
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate creating duplicate ForeignKey index
 
Similar Threads
Hibernate 3 Not Loading Values Into Child Set In JUnit Test
insert does not work
Hibernate Cascade
Hibernate problem - creating duplicate foreign key index
Hibernate- one-to-many association on a foreign key