2 Replies Latest reply on Jul 20, 2002 2:02 PM by dsundstrom

    Dependent value class and finder query

    philc

      I think I'm in a dead end. I want to make a ejb query on a dependent value class field and I don't think it is supported. The ejbql in ejb-jar.xml is:


      <query-method>
      <method-name>findActive</method-name>
      <method-params>
      <method-param>long</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql>
      [CDATA[SELECT OBJECT(c)
      FROM Orders c
      WHERE ( c.state = 'ACT'
      OR c.timestamp.value > ?1 )]]>
      </ejb-ql>


      The important part is "c.timestamp.value". "timestamp" is a dependent value class field where value is the persisted dvc property.

      <dependent-value-class>
      com.bcbcbc.UnixTimeStamp

      <property-name>value</property-name>
      <column-name>TIMESTAMP</column-name>

      </dependent-value-class>

      I'm trying to access timestamp.value just like you would access a CMR field, but it does not work. I anybody know how to do this another way I would love to know how, if it's impossible then make it a feature request.

      By the way I'm still running 3.0RC3. I will upgrade soon...

      The exception I get at deployment is this:

      10:51:58,038 DEBUG [findActive] EJB-QL: SELECT OBJECT(c) FROM Orders c WHERE ( c.state = 'ACT' OR c.timestamp.value > 1019740000 )
      10:51:58,045 ERROR [EjbModule] Starting failed
      org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.UnknownPathException: In path field is not a cmr field: at line 1, column 70. Encountered: "timestamp" after: "c.")
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:44)
      [... more stack ...]
      Caused by: org.jboss.ejb.plugins.cmp.ejbql.UnknownPathException: In path field is not a cmr field: at line 1, column 70. Encountered: "timestamp" after: "c."
      at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParserTokenManager.throwUnknownPath(EJBQLParserTokenManager.java:32)

      Thanks...

        • 1. Re: Dependent value class and finder query
          philc

          I also looked at the source of the exception in the addPath method of EJBQLParser.jtt. It seem like the only CMR fields are allowed to have a dots after them. Is it possible to add DVC field to the possibilities?

          I imagine other parts of the code need to be changed for DVC fields to be accessed by query methods.

          Is it a lot of work?

          • 2. Re: Dependent value class and finder query
            dsundstrom

            This won't be that difficult. The tokenizer and ASTPath objects will need to be expanded to support properties. The real challenge is modifying the JDBCEJBQLCompiler because it assumes that a cmp-field is the last element in a path

            Eventually, I will add this, but it is a low priority. If you do want to add it you will need to modify the JBossQLParser.jtt, as the EJBQLParser is the spec compliant parser and this is an extension.

            You can use DeclaredSQl in the meantime.