Two Laptop Bag*
The moose likes Object Relational Mapping and the fly likes Help with preventing duplicate elements in foreign key column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Help with preventing duplicate elements in foreign key column" Watch "Help with preventing duplicate elements in foreign key column" New topic
Author

Help with preventing duplicate elements in foreign key column

Ahsan Bagwan
Ranch Hand

Joined: Oct 05, 2010
Posts: 157
Using Hibernate 3.1 and have two mapping files m_devotee and m_member with classes M_devotee and M_member. I want to avoid duplicate entries from m_devotee column devotee_id which is referenced as devotee_id foreign key in m_member table.

I'm new to Hibernate and want to know if I'm missing some tags in the mappings.

Here are my files, https://gist.github.com/2e2560e7a04a769848a4

For now, I tried to prevent duplicates by adding code in my dao file. It gives me a ClassCastException. It should also rollback the transaction and return false to the servlet so it does not forward it to other jsp file.



M_devotee object cannot be cast to M_member as seen here.

I'm lost and any help is thoroughly appreciated!
surendra babu k
Greenhorn

Joined: Oct 21, 2011
Posts: 11
Hi....

before creating List you need to create a alias name for M_devote as m
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with preventing duplicate elements in foreign key column
 
Similar Threads
Foreig key must have same number of columns as the referenced primary key
Hibernate joins
issue that should be really simple
mapping One-to-many relationships using NetBeans and Not Hibernate
How to configure a foreign key