This content has been marked as final.
Show 1 reply
-
1. Re: how to validate the EJB QL
jobor Nov 24, 2004 2:44 PM (in response to rajdeep_dua)I'm using DynamicQL with a SearchObject (Value Object for searching) the following way. Maybe it gives you a hint for the LIKE. This is working on 3.2.x.
public abstract Collection ejbSelectGeneric(String jbossQl, Object[] args) throws FinderException; /** * @ejb.home-method */ public Collection ejbHomeGetBySearch(SearchObject so) throws FinderException { ArrayList argsList = new ArrayList(); StringBuffer jbossQl = new StringBuffer(); jbossQl.append("SELECT OBJECT(t) "); jbossQl.append("FROM Table_x t "); int bindCount = 0; if (so.getNumberCriterion()) { bindCount++; jbossQl.append((bindCount == 1 ? "WHERE" : "AND") + " t.column1 LIKE ?" + bindCount + " "); argsList.add(so.getColumn1()); } if (so.getTitleCriterion()) { bindCount++; jbossQl.append((bindCount == 1 ? "WHERE" : "AND") + " t.column2 LIKE ?" + bindCount + " "); argsList.add(so.getColumn2()); } jbossQl.append("ORDER BY t.column1 ASC"); Object[] args = argsList.toArray(); return ejbSelectGeneric(jbossQl.toString(), args); }
Johan