5

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.

Partha Sarathi Ghosh
  • 10,936
  • 20
  • 59
  • 84

1 Answers1

3

Did you try getNamedParameters() already?

Betlista
  • 10,327
  • 13
  • 69
  • 110