I wonder whether Hibernate can stores a field into two different columns in two different tables.
Can that be achieved with Hibernate? I know it is quite easily with triggers.
Here is my approach;
@Entity
@Table(name = "A")
@SecondaryTable(name = "B")
public class A {
@Id
@Column(name = "id")
private int id;
// This property in both
@AttributeOverrides({
@AttributeOverride(column = @Column(name = "something", table = "B"), name = "something"),
@AttributeOverride(column = @Column(name = "something", nullable = true), name = "something")})
private int something;
}
Regards.
ssedano.
I’m pretty sure it can’t. I also wonder why you would need such a thing, but you can simply have two fields and always make sure the the second one has the same value as the first one: