// Query q = session.createQuery("select cat.id from Category as cat");
// List result = q.list();
Query q = session.createQuery("from Category as cat where cat.title = :title");
q.setParameter("title", "Another category title", Hibernate.STRING);
List cats = q.list();
tx.commit();
Iterator it = cats.iterator();
while (it.hasNext()) {
Category c = (Category) it.next();
System.out.println("--> " + c.getId());
}