Hello,
Do you mean:
1) to build the
where clause dynamically adding new restrictions?
2) or to specify the value of some attributes of the
where clause?
You can code both of them.
1) Using criteria API, you may add the
Restriction you need.
Code:
Criteria criterio = session.createCriteria(XXX.class);
if(name.compareto("")!=0)
criterio.add(Restrictions.eq("name",(Boolean) name) ));
For more information about this:
http://www.hibernate.org/hib_docs/v3/re ... teria.html2) Using .setParameter (and the similar methods)
Code:
String Name;
Name="me";
session.createQuery("from XXX where name=:n")
.setParameter("n", Name)
.list();
For more information about this:
http://www.hibernate.org/hib_docs/v3/re ... e-querying