Similar to Hibernate : How override an attribute from mapped super class and Inheritance and @AttributeOverride on @Id field but with a simpler case. I just want to change the name of the class
CREATE TABLE `billing_target` (
`billingTargetID` int(11) NOT NULL,
`targetType` char(5) NOT NULL,
`targetID` int(11) NOT NULL
PRIMARY KEY (`billingTargetID`)
);
CREATE TABLE `Client` (
`clientID` int(11) NOT NULL,
`name` varchar(200),
PRIMARY KEY (`clientID`)
);
Here's my attempt so far
@Data
@Entity
public class BillingTarget implements Serializable {
@Id
@Column(name = "BillingTargetID")
private Integer id;
}
@Data
@Entity
@Table(name = "Client")
@DiscriminatorValue("CLIENT")
@EqualsAndHashCode(callSuper = true)
@AttributeOverride(
name = "id",
column = @Column(name = "ClientID")
)
public class Client extends BillingTarget {
private String name;
}
However, my queries are looking for Client.BillingTargetID
rather than Client.ClientID
Since I @AttributeOverride
it is ignored.
@AttributeOverride or @AttributeOverrides in conjunction with entity inheritance is not supported:
If I make BillingTarget
a @MappedSuperclass
I would get
Caused by: java.lang.NullPointerException at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1745)