[jboss-user] [JBoss Seam] - Re: Queries with optional arguments

damianharvey do-not-reply at jboss.com
Tue Nov 6 05:08:20 EST 2007


I haven't looked into the delegate/criteria stuff but my lazy-man's way of doing this is:
  | List<Customer> customers = entityManager.createQuery("select c from Customer as c "+
  |     " where c.customerId >= :minCustomerId"+
  |     " and c.customerId <= :maxCustomerId")
  |     .setParameter("minCustomerId", selectedCustomer==null?Long.MIN_VALUE:selectedCustomer.customerId)
  |     .setParameter("maxCustomerId", selectedCustomer==null?Long.MAX_VALUE:selectedCustomer.customerId)
  |     .getResultList();
  | 
Cheers,

Damian.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102142#4102142

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102142



More information about the jboss-user mailing list