Saturday March 25, 2006 Hibernate Query Wizard for Netbeans 5.0
Hibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inheritance, polymorphism and association.
HQL Wizard for NetBeans 5.0 helps to create selects in HQL. The wizard is part of hibernate plugin based on xdoclet. The project pages are on nbxdoclet website. The HQL wizard can be open be using code completion of hibernate bean's (POJO) facade class.
The wizard is shown bellow:
Detailed steps how to create the query in the example:
After click to Ok button code, shown bellow, is generated to facade class:
public java.util.List getFiatForTown(java.lang.String addressTown) {
Session session = store.HibernateUtil.currentSession();
org.hibernate.Query query = session.createQuery(
" select user " +
" from " +
" User as user " +
" join user.address as address " +
" join user.car as car " +
" where " +
" address.town = ? " +
" and (car.type = \"fiat\" " +
" OR (user.age < 50 " +
" AND user.age > 20) " +
" ) ");
query.setParameter(0,addressTown);
return query.list();
}
The wizard read the information about entities (POJO) from xdoclet tags. It it not so difficult to implement reading of EJB30 annotations. I'm not sure if someone wants to use it with annotations. Is this wizard handy? Please give me feedback and report bugs to nbxdoclet's bug tracing system.
Posted by xzajo ( Mar 25 2006, 09:25:57 PM CET ) Permalink Comments [30]