I was wondering if there is a way to have a filter annotation with a hard coded values. I am joining two tables called itemRate and ratemaster. Rate master has a composite key of application rateid and ratekind id. The rate kind id can be 1 of 3 id's (primary, component, item rate).
My Item Rate table knows the application and references two different columns item_rate and rate (which is the primary rate),
My question is, is there a way with hibernate to hard code a filter so when i call getRate()
it will filter on all rates with a rate kind id of 0 and when i call getItemRate()
it will filter on all rates with a ratekind id of 2?
I tried doing something like this to get the rate masters with a rate kind of 0:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumns({
@JoinColumn(name = "CIITM_RATE", nullable = false , updatable = false, insertable = false, referencedColumnName = "RATE"),
@JoinColumn(name = "CIITM_APPLICATION", nullable = false , updatable = false, insertable = false, referencedColumnName = "APPLICATION") })
@FilterJoinTable(name = "kindId", condition="RATEKINDID = 0")
public Ciratemaster getRateMaster() {
return rateMaster;
}
and this to get rate masters with rate kinds of 2:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumns({
@JoinColumn(name = "CIITM_ITEM_RATE", nullable = false , updatable = false, insertable = false, referencedColumnName = "RATE"),
@JoinColumn(name = "CIITM_APPLICATION", nullable = false , updatable = false, insertable = false, referencedColumnName = "APPLICATION") })
@FilterJoinTable(name = "kindId", condition="RATEKINDID = 2")
public Ciratemaster getItemRateMaster() {
return itemRateMaster;
}
I tried searching hibernate website and other sites and nothing has really worked. I always come up with the error that it fetched more than 1 result when it shouldn't
Thanks in advance.