EJB-QL - Restrictions with value range
adamk Aug 13, 2010 6:40 AMHello,
i would like to get all records from address table where 'buildingNr' is between 1 and 20. Eclipse generated my AdresseList class with restrictions and now I would like to add this new restriction to it.
@Name("sspAdresseList")
public class SspAdresseList extends EntityQuery<SspAdresse> {
private static final String EJBQL = "select sspAdresse from SspAdresse sspAdresse";
private int hausnrVon;
private int hausnrBis;
private static final String[] RESTRICTIONS = {
"lower(sspAdresse.strasse) like lower(concat(#{sspAdresseList.sspAdresse.strasse},'%'))",
"lower(sspAdresse.hausnr) like lower(concat(#{sspAdresseList.sspAdresse.hausnr},'%'))",
"lower(sspAdresse.hauszusatz) like lower(concat(#{sspAdresseList.sspAdresse.hauszusatz},'%'))",
"lower(sspAdresse.ort) like lower(concat(#{sspAdresseList.sspAdresse.ort},'%'))",
"lower(sspAdresse.ortsteil) like lower(concat(#{sspAdresseList.sspAdresse.ortsteil},'%'))",
//this is my additional restriction
"this.hausnrVon < sspAdresse.hausnr AND sspAdresse.hausnr > this.hausnrBis",
};
private SspAdresse sspAdresse = new SspAdresse();
public SspAdresseList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}
(... all getter and setter ...)
}When i try it out by navigating to the proper mask and filling those 2 fields (min/max) i receive the following exception:
javax.el.ELException: /SspAdresseList.xhtml: Error reading 'resultList' on type org.domain.dummy2.session.SspAdresseList_$$_javassist_seam_3 at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:48) at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280) at org.richfaces.renderkit.html.PanelRenderer.doEncodeBegin(PanelRenderer.java:189) (....) Caused by: java.lang.IllegalArgumentException: there should be exactly one value binding in a restriction: org.jboss.seam.core.Expressions$1@1e20bca at org.jboss.seam.framework.Query.parseEjbql(Query.java:230) at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:175) at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:79) at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:71)
For any suggestions i will be very thankful
Merci
Adam