Skip to content

Instantly share code, notes, and snippets.

@vltsu
Created February 15, 2015 16:07
Show Gist options
  • Save vltsu/d0a489585958d419a962 to your computer and use it in GitHub Desktop.
Save vltsu/d0a489585958d419a962 to your computer and use it in GitHub Desktop.
@Entity
public class Employee {
@Id long empId;
String empName;
...
}
public class DependentId {
String name; // matches name of @Id attribute
long emp; // matches name of @Id attribute and type of Employee PK
}
@Entity
@IdClass(DependentId.class)
public class Dependent {
@Id String name;
// id attribute mapped by join column default
@Id @ManyToOne Employee emp; ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment