I'm having this situation in Hibernate where there is a parent-child relationship between two classes, but there is no such relationship in the database, since the child class represents a view, not a table.
Now, the problem is that for Hibernate to be happy the Inheritance annotation needs to be provided, otherwise Hibernate will consider some default value and try to look for a non-existent "dtype" column.
I have tried to use TABLE_PER_CLASS as the strategy (the default is SINGLE_TABLE), but in this case Hibernate does some kind of union with the view associated with the child class, which doesn't make sense here, and some error is raised about a column that doesn't exist -- a column that exists in both the table and the view, but any way.
The question would be how to properly model this in terms of annotations or, alternatively, how to ask for the parent entity without producing an underlying query that involves the child. (The second question was asked here. I didn't give that a try yet because I'm hoping for a better solution.)
Edit: to better illustrate the explanation, here is a piece of code equivalent to my setup:
@Entity
@Table(name = "PARENT")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ParentEntity implements Serializable {
// ...
}
@Entity
@Table(name = "PARENT_VIEW")
public class ChildEntity extends ParentEntity implements Serializable {
// ...
}