Hi all,
I have a Audited class with a @ManyToOne join between two tables using a non pk column, like this:
Code:
@Audited
@Entity
public class A {
@Id
@GeneratedValue
private long id;
@ManyToOne
@JoinColumn(name = "B_TYPE", referencedColumnName="type")
private B b;
public A() {
}
public long getId() {
return this.id;
}
public B getB() {
return this.b;
}
}
@Audited
@Entity
public class B {
@Id
@GeneratedValue
private long id;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private BType type;
protected B() {
}
public long getId() {
return this.id;
}
public BType getType() {
return this.type;
}
}
When I generate the database schema I get the following:
Code:
create table A_H (
ID number(19,0) not null,
REV number(19,0) not null,
REVTYPE number(3,0),
B_TYPE number(19,0),
primary key (ID, REV)
);
create table A (
ID number(19,0) not null,
B_TYPE varchar2(255 char),
primary key (ID)
);
For the "A" entity, the generated B_TYPE column has different columns types.
For the operational table it's using the non pk column, as mapped with the referencedColumnName, but for the audited table it seems that the pk it's used.
Is there any thing I can do to change this behaviour, so that for both tables, B_TYPE column reference the non pk column?
Thanks