Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it true about EJB QL Where clause...

 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From HFEJB page 435:

Is it true about EJB QL Where clause?
C. The number of input parameters must equal the number of parameters for the finder or selector method.

I think yes.
The book says, NO, but no explanation is given.

Any comments please? Thanks.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When HFEJB doesn't provide the answer where do you have to go look at ? IN the spec of course

Section 11.2.6.4:

11.2.6.4 Input Parameters
The following rules apply to input parameters. Input parameters can only be used in the WHERE clause of a query.
  • Input parameters are designated by the question mark (?) prefix followed by an integer. For example: ?1.
  • Input parameters are numbered starting from 1.
  • The number of distinct input parameters in an EJB QL query must not exceed the number of input parameters for the finder or select method. It is not required that the EJB QL query use all of the input parameters for the finder or select method.
  • An input parameter evaluates to the abstract schema type of the corresponding parameter defined in the signature of the finder or select method with which the query is associated. It is the responsibility of the container to map the input parameter to the appropriate abstract schema type value.

  • Note that if an input parameter value is null, comparison operations or arithmetic operations involving the input parameter will return an unknown value. See Section 11.2.10.


    Basically, the number of input parameters cannot exceed the number of parameters in the finder/select method. If input parameters are missing, the corresponding finder argument is just not taken into account. You should try for yourself and see what unfolds.
     
    Devender Thareja
    Ranch Hand
    Posts: 187
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you so much Valentin!!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic