-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Filter inheritance problem
PostPosted: Wed Aug 03, 2011 12:25 pm 
Newbie

Joined: Wed Aug 03, 2011 12:19 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.