aspose file tools*
The moose likes Object Relational Mapping and the fly likes One - to -one mapping using non primary key 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
Bookmark "One - to -one mapping using non primary key" Watch "One - to -one mapping using non primary key" New topic
Author

One - to -one mapping using non primary key

Ankit Chandrawat
Ranch Hand

Joined: Jan 03, 2008
Posts: 87
Hi,

I have two tables:

Table1 :
{
id:primary key
name:
email:
}

Table2:
Lid: primary key
tname:
email:
}

In both the cases email is neither primary key, nor the foreign. Is it possible to establish one-to-one mapping between both of these tables for the column email. I am using xml for mapping.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Are you using JPA? JPA requires the JoinColumn reference the Id, but some JPA providers allow this.

In EclipseLink this is supported, but possibly not through JPA config, you may need to use a customizer.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Filtering.2C_Complex_Joins


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
Consider Paul's rocket mass heater.
 
subject: One - to -one mapping using non primary key
 
Similar Threads
problem with on to one mapping in hibernate
many-to-many mapping in the hibernate mapping file ?
Hibernate one-to-on id mapping issue
Problem for fetching results from 2 tables which do not have relation...
hibernate and DB triggers