Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One - to -one mapping using non primary key

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic