Hello togehter,
I've a problem with inheritance and filter in hibernate. I've two classes element1 and element2 they have both there own table in the database. The search over all these elements in element3 is OK . Now I try to filter only the active elements in element3 as a list. The active field is in element1. Then I get this error:
Code:
WARN - SQL Error: 1054, SQLState: 42S22
ERROR - Unknown column 'element20_.element1_active' in 'where clause'
org.hibernate.exception.SQLGrammarException: could not initialize a collection
For the error it is OK, because element1_active is not in the element2 table. But why he is not looking in the element1 tabel / class? Or do I make something wrong?
Code:
@Entity
@Table(name="element1")
@Inheritance(strategy = InheritanceType.JOINED)
@Embeddable
public class Element1 {
private int id;
private String text;
private boolean active;
....
}
@Entity
@Table(name="element2")
public class Element2 extends Elemen1 {
private Element3 element3;
private boolean alert;
private String email;
private String comment;
....
}
@OneToMany(mappedBy="element3")
@OrderBy(clause = "id asc")
@IndexColumn(name = "id")
@Filter(name="element2active", condition="elelment1_active = :active")
@LazyCollection(value = LazyCollectionOption.FALSE)
@NotFound(action = NotFoundAction.IGNORE)
public List<Element2> getElement2() {
return element2;
}
public void setElement2(List<Element2> element2) {
this.element2 = element2;
}
Regards XYC1111