Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HOWTO: map _R and _S table in one class
08-12-2014, 06:48 PM, (This post was last modified: 08-16-2014, 05:53 AM by digdas.)
#1
HOWTO: map _R and _S table in one class
Consider the following tables:

Code:
USER_R
  - ID
  - NAME

USER_S
  - ID
  - COUNTRY
  - USER_R_ID

To map these in one class:
Code:
@Entity
@Table(name="USER_R")
@SecondaryTable(name = "USER_S" pkJoinColumns = { @PrimaryKeyJoinColumn(name = "USER_R_ID", referencedColumnName = "id") })
public class User {
private Long id;
private String country;

@Id
@Column(name="ID")
public Long getId() {...}

@Column(name="COUNTRY", table="USER_S")
public String getCountry() { ... }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)