I have the following three entities described below. I want to be able to query my transaction entity and apply a filter to my text collection inside item so that the texts are locale specific based on the current user's session. How can I do this?
Code:
@Entity
public class Transaction {
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumns({@JoinColumn(name="item_id",insertable=false,updatable=false),@JoinColumn(name="pid",insertable=false,updatable=false)})
public Item getItem() { return this.item }
public void setItem(Item item) { this.item = item; }
}
@Entity
public class Item {
@OneToMany(fetch=FetchType.LAZY,mappedBy="item")
public List<ItemText> getTexts() { return this.texts; }
public void setTexts(List<ItemText> texts) { this.texts = texts; }
}
@Entity
public class ItemText {
@Column(name="language_code",length=10)
public String getLanguageCode() { return this.languageCode; }
public void setLanguageCode(String languageCode) { this.languageCode = languageCode; }
}
If I were to place the necessary filter annotations on my ItemText object, I cannot enable this filter because my query is actually being applied against my Transaction class using
session.createCriteria(Transaction.class).
Any thoughts?