Hello folks,
I am trying to do an attribute override, but it does not seem to work. Let me show my case.
I have a basic device entity such as this one:
Code:
@MappedSuperclass
public abstract class BasicDeviceData{
@Id
@GeneratedValue
private Long id;
@Column(nullable = false, unique = true)
private String uuid;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String state;
...
For each one of the devices I have entities such as:
Code:
@Entity
@Table
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class DeviceTypeX extends BasicDeviceData {
@Column(nullable = false)
private Long regionId;
.... much more data...
Then, for each deviceType, I have a history table that has all device information with a timestamp:
Code:
@Entity
@Table
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@AttributeOverride(name = "uuid", column = @Column(unique = false))
public class DeviceTypeXHistory extends DeviceTypeX {
@Column(nullable = false)
private Date timeStamp;
My problem is that I cannot have a unique constraint in "DeviceTypeXHistory" history. I tried using "@AttributeOverride" to remove that constraint, but it is not working. Is there any way to remove/override that constraint declaration that I am getting by inheritance in DeviceTypeXHistory table?
I am using the following:
Hibernate version: 5.2.12.Final
Spring-data-jpa: 1.11.8.RELEASE
Java: jdk1.8.0_66