1 2 Previous Next 17 Replies Latest reply on Dec 2, 2003 5:01 AM by ongtw

    New EJB-QL compiler (ORDER BY and DynamicQL)

    Dain Sundstrom Master

      The new EJB-QL compiler is finished and checked in tip. The new compiler is a complete rewrite in JavaCC, and is much faster, easier to maintain, and has error messages. I was surprised by the number of errors I found in the old parser. You guys haven't been pushing the engine enough, so to give you incentive to test the new engine I've added several new features.


      Error messages:
      This is not really a feature but as we didn't have them before it feels like a feature.

      JBossQL:
      I actually wrote two compilers a spec compliant EJB-QL compiler and JBossQL compiler. JBossQL is a superset of EJB-QL which adds support for ORDER BY. To use JBossQL you override ejb-ql declaration in your jbosscmp-jdbc.xml file with a jboss-ql element (i.e. just copy the query element from your ejb-jar.xml file, change ejb-ql to jboss-ql and add the order by clause. The BNF for order by follows:

       JBossQL := select_clause from_clause [where_clause] [order_by_clause]
       order_by_clause := ORDER BY order_by_path_expression (, order_by_path_expression)*
       order_by_path_expression := ( numeric_valued_path | string_valued_path | datetime_valued_path ) [ASC | DESC]
      

      dynamic-ql:
      The new compiler is eye-blink fast, so I added a new query type dynamic-ql. With dynamic-ql you can generate a JBossQL query and pass it along with the parameters to the engine to be compiled and execute at runtime. To use this query you add an ejbSelect method to your bean with the following signature:
       <return-type> ejbSelect<some-name>(String jbossQL, Object[] args)
      

      You must declare the query type in your ejb-jar.xml (required by the spec; just leave the ejb-ql element empty) and in your jbosscmp-jdbc.xml file override the impl with an empty <dynamic-ql/> element.

      For more info specifying the queries, see the jbosscmp-jdbc_3_0.dtd

        1 2 Previous Next