Reputation: 11576
I am trying to develop a application where I have a common DAO as EntityDao.
That class has a method executeNamedQuery as follows.
public List executeNamedQuery(String queryName) {
Query query = getHibernateUtil().getCurrentSession().getNamedQuery(queryName);
list = query.list();
return list;
}
I have several named query in different classes. One example is given as follows.
@NamedQueries({
@NamedQuery(
name = "BookList",
query = "FROM Book AS B WHERE cntrl1=:CNTRL_1"
)
})
Aslo some of the queries does not have that where clause, or some of those have a where clause but does not have CNTRL_1 as named parameter.
I have a common CNTRL_1 value that I want to set from common EntityDao executeNativeQuery method with setParameter. But before that I want to determine is there any named parameter exists with name CNTRL_1 or not in the named query.
How to do that? Please help.
Upvotes: 5
Views: 2716