I’m trying to figure out how to do a @ManyToOne
mapping with the join column being part of a secondary table of the target entity.
@Entity
@Table(name = "being")
@Inheritance
@DiscriminatorColumn(name = "type")
abstract class Being {
// some unimportant fields
}
@Entity
@SecondaryTable(name = "animal")
abstract class Animal extends Being {
@Column(name = "uuid", table = "animal")
private String uuid;
}
@Entity
@SecondaryTable(name = "cat")
@DiscriminatorValue(value = "CAT")
class Cat extends Animal {
@Column(name = "name", table = "cat")
private String name;
}
@Entity
class Toy {
// @Column(name = "animal_uuid")
// private String animalUuid;
// what mapping can I use here? The following does't work.
@ManyToOne
@JoinColumn(name = "animal_uuid", referencedColumnName = "uuid")
private Cat cat;
}
With this I get an error similar to: Unable to find column with logical name: uuid in org.hibernate.mapping.Table(being) and its related supertables and secondary tables