Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF-EJB: doubt regarding EJB-QL

 
Stefan Guilhen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

HF-EJB(page 406) says that you can use a CMP field, but not a CMR field with the dot notation, as the SELECT type. So SELECT m.title or SELECT m.genre are both OK while SELECT m.director is not.

However, the specification (page 232) uses the following to define the SELECT clause:

SELECT [DISTINCT] { single_valued_path_expression |OBJECT (identification_variable)}

But what is a single_valued_path_expression? Page 226 states that:

single_valued_path_expression ::=
{single_valued_navigation | identification_variable}.cmp_field | single_valued_navigation
single_valued_navigation ::=
identification_variable.[single_valued_cmr_field.]* single_valued_cmr_field

Following this definition of single_valued_path_expression, SELECT m.director FROM MovieSchema m should work, shouldn't it? Because m.director is a single_valued_navigation that is also a single_valued_path_expression.

Am I missing something here? I must be, because I really didn't find anything in the specification saying that cmr fields cannot be used as a SELECT type.

Thanks,
Stefan
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
The anz there in path expression itself

"identification_variable.[single_valued_cmr_field.]* single_valued_cmr_field"

so u can use like this in SELECT....

select m.director.name from OBJECT.. so on


binoj v
 
Stefan Guilhen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Binoj, thanks for your reply

Originally posted by Binoj Viswanathan:
hi,
The anz there in path expression itself

"identification_variable.[single_valued_cmr_field.]* single_valued_cmr_field"

so u can use like this in SELECT....

select m.director.name from OBJECT.. so on


binoj v


I am sorry, but I dont see the answer there. My understanding of single_valued_navigation is that it is composed by an identification_variable followed by one or more cmr field navigations. So I think that a single_valued_navigation is a chain in which the first element is an identification_variable and all following elements are cmr fields.

If my reading of this is correct, m.director (considering director a cmr field) is a single_valued_navigation, but I dont see how

m.director.name fits in "identification_variable.[single_valued_cmr_field.]* single_valued_cmr_field"

since name is a cmp field of director.

Of course m.director.name is a single_valued_expression because it is a single_valued_navigation followed by a cmp_field, so your example is indeed correct. What really confuses me is that a single_valued_expression can be either {single_valued_navigation or identification_variable} followed by a cmp_field OR a single_valued_navigation alone. As I stated previously I believe that m.director is a single_valued_navigation and so it is also a single_valued_expression. In this case, it should be ok to include m.director in the SELECT clause of an EJB-QL expression.

If you could point the flaw in my understanding I would be very happy.

Thanks again,
Stefan
 
Will St Hubert
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefank,

I completely agree with you and I have the same understanding. m.director should valid for the Select clause based on the definition in the spec.

single_valued_path_expression ::=
{single_valued_navigation | identification_variable}.cmp_field |
single_valued_navigation
single_valued_navigation ::=
identification_variable.[single_valued_cmr_field.]* single_valued_cmr_field

m.director is a single_valued_navigation and also a single_valued_path_expression.

If anyone sees this differently please advise ???

Thx.

Will
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
The definitions U hav givn for single_valued_path_expression, single_valued_navigation r perfectli right as per EJB 2.0 spec. But they shdnt b used for the SELECT clause,but can onli b used for FROM/WHERE clauses. Since Since finder methods must always return EJB that owns the finder. i.e. the SELECT target of finder method shd evaluate to type of EJB that owns it.

if u want reali du like "SELECT m.director .....", u can du but 0nli with select methods

binoj
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i wud like2 add one more pt here.....

This select method works onli if its cald from remote biz method. if its cald from home biz method it wil trow Exce..n

pls pt out if im wrong....


binoj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic