Hi,
I have the following problem:
I have two tables. Let's call them BASE_TABLE and CHILD_TABLE. They are mapped through Join Inheritance in Java. In other words:
@Inheritance(strategy=InheritanceType.JOINED)
Let's say, the tables look like:
BASE_TABLE (
ID NUMBER(18),
TYPE VARCHAR2(1),
CODE NUMBER(5))
CHILD_TABLE (
ID NUMBER(18),
CODE NUMBER(5),
NAME VARCHAR2(50))
Here's where the problem lies: I have duplicate column names. In my example, this is the CODE column. When mapping to Java classes, I can have something like:
@Entity
@Table(name="BASE_TABLE")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("0")
class BaseEntity {
.
.
.
@Column(name="CODE")
private Integer code;
public Integer getCode_Base() {
return code;
}
public setCode_Base(Integer code) {
this.code = code;
}
}
@Entity
@Table(name="CHILD_TABLE")
@DiscriminatorValue("1")
@PrimaryKeyJoinColumn(name="ID")
class ChildEntity extends BaseEntity {
.
.
.
@Column(name="CODE")
private Integer code;
public Integer getCode() {
return code;
}
public setCode(Integer code) {
this.code = code;
}
}
The trouble is, that TopLink only handles ONE of the CODE columns. When SELECTing, it only selects the CODE column from table BASE_TABLE. When generating DML statements, again it only uses the CODE column from table BASE_TABLE.
I wasn't able to make it use BOTH columns.
Please, help. The DB design cannot be changed at the moment. However, I must find a way to make TopLink Essentials use both CODE columns, not just the one from BASE_TABLE.
Thank you in advance!
Best regards,
Bisser