I have an entity (store) which is inherited from it's superclass (location). Stores and locations have it's own tables (InheritanceType "joined").
The location has an attribute (active).
In another entity, I have a list of stores (OneToMany-relationship). These list should only contain the active stores. I annotated it with
@Where(clause="active = 'Y'")
But It does not work:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'stores0_.active' in 'where clause'
because the table "stores" does not have the "active"-property, it's parent has (which is an own table). Is there a parent selector for the where-annotation or is there better solution?
Location:
@Entity
@Table(name = "locations")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Location {
[..]
@Column(name = "active")
@Type(type = "yes_no")
private Boolean isActive;
Store:
@Entity
@Table(name = "store")
@PrimaryKeyJoinColumn(name="id", referencedColumnName= "id")
public class Store extends Location {
[..]
@ManyToOne()
@JoinColumn(name = "shop_id")
private Shop shop;
Shop:
@Entity
@Table(name = "shop")
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
public class Shop extends Location {
[...]
@Where(clause="active = 'Y'")
@OneToMany(mappedBy ="shop")
private List<Store> stores;