We have a setup of a base entity which is inherited by many other entities. We use the inheritance type InheritanceType.JOINED. In case the child entities have same field name but with a different type, a java.lang.ClassCastException is thrown during the initialization of the session factory (during post init callbacks):
This is working with older Hibernate version 5.6.14 . Simple use case BaseObj.java
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class BaseObj {
@Id
long id;
}
Author.java
@Entity
public class Author extends BaseObj {
String comments;
}
Post.java
@Entity
public class Post extends BaseObj {
@OneToMany(mappedBy = "post")
Set<Comment> comments;
}
Comment.java
@Entitypublic class Comment extends BaseObj {
@ManyToOne Post post;
}
|