2 Replies Latest reply on Jul 16, 2008 12:27 PM by Denis Petrunin

    Mapping of a special Date for CMP and using it for a finder

    Wolf-Dieter Fink Master

      In a CMP2.x Entity we have a special DateTime Object.
      In the jbosscmp-jdbc.xml deploymentdescriptor I add the following Element:

      <user-type-mappings>
       <user-type-mapping>
       <java-type>com.orga.jaf.date.Date</java-type>
       <mapped-type>java.sql.Timestamp</mapped-type>
       <mapper>com.orga.jaf.date.DateMapper</mapper>
       </user-type-mapping>
       <user-type-mapping>
       <java-type>com.orga.jaf.date.DateTime</java-type>
       <mapped-type>java.sql.Timestamp</mapped-type>
       <mapper>com.orga.jaf.date.DateTimeMapper</mapper>
       </user-type-mapping>
       </user-type-mappings>
      

      All getter and setter methods are
      public abstract void setXXX(DateTime date);
      public abstract DateTime getXXX();
      

      This part works as I expected!

      But when I add a finder that has such a DateTime object in the WHERE clause the following Exception is thrown at deploy time:
      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement for EJB 'LcAccount': SELECT OBJECT(o) FROM LcAccount o WHERE o.lcDateFrom = ?2 AND o.account.accountId = ?1; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.lcDateFrom" at line 1, column 43.
      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" ...
       "MOD" ...
       "+" ...
       "-" ...
       <INTEGER_LITERAL> ...
       <FLOATING_POINT_LITERAL> ...
       <NUMERIC_VALUED_PARAMETER> ...
       )
      


      Any ideas?
      Is it not posible to use own datatypes in a finder?