Hi there,
Apologies if answered before, had a look but could not find it.
I have a m2m relationship between two tables business and rewards_shceme, these are setup via annotation in two classes Business and RewardsScheme. They generate a third table called biz_rwd_jn to hold the mappings.
I have been trying to get the following hql to work to no avail;
Code:
String temp = "Business_1";
Session session = HibernateUtil.getSession();
String hql = "from Business where name = :busName";
Query query = session.createQuery(hql);
query.setString("busName",temp);
Object obj = query.uniqueResult();
Business business = (Business)obj;
hql = "from RewardsScheme s join s.business where s.business = :biz";
query.setParameter("biz", business);
List obj1 = query.list();
s.business is the List of business held in the RewardScheme class i.e.
Code:
@ManyToMany
@JoinTable(name = "biz_rwd_jn",
joinColumns = {@JoinColumn(name = "rwdSch_id")},
inverseJoinColumns = {@JoinColumn(name = "business_id")}
)
public List<Business> getBusiness() {
return business;
}
public void setBusiness(List<Business> business) {
this.business = business;
}
public void addBusiness(Business business) {
this.business.add(business);
}
Am going a bit nuts with this , its does retrieve the correct unique Business object ok but keeps giving me the following error when trying to get the RewardsScheme objects
Quote:
Exception in thread "main" org.hibernate.QueryParameterException: could not locate named parameter [biz]
Any ideas ?
Thanks,
Mully