| By convention models that annotated with @Subselect are not persistable, but if we extends an @Entity with @Table for creating a @Subselect , Hibernate adds DTYPE column on superclass table and put all of child fields on it. for example I have a simple class:
@Entity
@Table(name = "SIMPLE_FOO")
public class SimpleFoo {
@Id
int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
that I need create subselect for adding calculative fields to it:
@Entity
@Subselect("select f.* , rownum as R_NUM from SIMPLE_FOO f")
public class FooSubselect extends SimpleFoo {
@Column(name = "R_NUM",nullable = false)
int rownum;
public int getRownum() {
return rownum;
}
public void setRownum(int rownum) {
this.rownum = rownum;
}
}
Hibernate adds DTYPE and R_NUM fields on parent Table and prevents working properly |