
Untitled
By: a guest on
May 28th, 2012 | syntax:
None | size: 0.66 KB | hits: 19 | expires: Never
Filtering a collection using the @Filter hibernate annotation in java
@FilterDefs()
class A{
@OneToMany(mappedBy = "productType", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@Filter(name = "something", condition = "entityType = 'SKU1'")
Set<B> set1 = new HashSet<B>();
@OneToMany(mappedBy = "productType", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@Filter(name = "something", condition = "entityType = 'SKU2'")
Set<B> set2 = new HashSet<B>();
}
class B{
@ManyToOne(cascade = CascadeType.ALL)
private A productType;
@Column(name = "entity_type")
@Enumerated(EnumType.STRING)
private EntityType entityType;
}
session.enableFilter("something");