Is there a way to apply filter on map type attribute in a class using annotations? I have done something like below but the filter is not getting applied
Code:
public class EntityA
{
@id
@GeneratedValue
@Column(name="id")
private Long id;
@OneToMany(mappedBy="EntityA")
@MapKeyColumn(name = "entityB_id")
@Filter(name = "percentFilter", condition="MODEL_PERCENT> :percent")
private Map<Long, EntityB> entityBMap;
}
public class EntityB
{
@Column(name = "MODEL_PERCENT")
private BigDecimal modelPercent;
@ManyToOne
@joincolumn(name="entityA_id")
private EntityA entityA;
}
The filter works if i change the map attribute to list as below,
From
Code:
@OneToMany(mappedBy="EntityA")
@MapKeyColumn(name = "entityB_id")
@Filter(name = "percentFilter", condition="MODEL_PERCENT> :percent")
private Map<Long, EntityB> entityBMap;
to
Code:
@OneToMany(mappedBy="EntityA")
@JoinColumn(name = "entityA_id")
@Filter(name = "percentFilter", condition="MODEL_PERCENT> :percent")
private List<EntityB> entityBList;
So i guess i need some help on annotating the map attribute such that the filter works. Any suggestion or sample code would be of great help. Thanks.