1 Reply Latest reply on Apr 29, 2002 8:37 PM by Dain Sundstrom

    EJB-QL syntax: CMP field comparison of type BigDecimal in WH

    Jeffrey Jeffrey Newbie

      What's the EJB-QL syntax for doing BigDecimal comparison in ejb-finder methods?

      I've a Entity Bean (Order) with CMP field of type BigDecimal (Price). The JBOSS CMP engine maps it to Oracle DB with column type of Number(38,15). My ejb-finder method is to find purchase orders with price greater than a given decimal number. I've tried the EJB-QL statement:

      SELECT DISTINCT OBJECT (o) FROM OrderSchema AS o WHERE o.price >= ?1

      with input parameter of either type java.math.BigDecimal or double. But I always get the following parsing exception:

      org.jboss.deployment.DeploymentException: Could not deploy file:/home/jboss-3.0.0RC1/server/default/deploy/mex001.jar; - nested throwable is:
      boss.deployment.DeploymentException: Error compiling ejbql; - nested throw
      s: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.price" a
      1, column 58.
      Was expecting one of:
      "NOT" ...
      "(" ...
      <COLLECTION_VALUED_PATH> ...
      <STRING_VALUED_PATH> ...
      "CONCAT" ...
      "SUBSTRING" ...
      <BOOLEAN_VALUED_PATH> ...
      <DATETIME_VALUED_PATH> ...
      <ENTITY_VALUED_PATH> ...
      <IDENTIFICATION_VARIABLE> ...
      <NUMERIC_VALUED_PATH> ...
      "LENGTH" ...
      "LOCATE" ...
      "ABS" ...
      "SQRT" ...
      "+" ...
      "-" ...
      <INTEGER_LITERAL> ...
      <FLOATING_POINT_LITERAL> ...
      <NUMERIC_VALUED_PARAMETER> ...

      at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:409)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:665)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:507)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:470)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(Reflect
      nDispatcher.java:284)
      ....

      It looks like the parser couldn't recognize "o.price" as a floating point value. What's the right EJB-QL syntax for non-basic-type CMP fields like o.price of type BigDecimal here? I'm using JBOSS 3.0 RC1. Any help is appreciated.

      --- Jeff