Hibernate parameterized query
I have the following method:
public List<Book> searchGroups(String title, String subtitle, String
author) {
Session session = HibernateUtil.getCurrentSession();
Query query = session.createSQLQuery("SELECT * FROM book GROUP BY
title, subtitle, author;").addEntity(Book.class);
return query.list();
}
I'd like to include the title, subtitle and author as search parameters
but only when they're not null. How can I do that? For example if subtitle
and author are null, I'd only like to search by author.
No comments:
Post a Comment