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

EJB QL

 
Sandeep Prabhakar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ranchers,
I have one doubt.
Can we select more than one cmp field in the EJB QL

For example If the abstract Person has firstName and lastName as CMP fields, can we have query such as

select p.firstName,p.lastName from Person p.

If this is allowed, I guess that some kind of separator must be used.
Ranchers, please share any details that you know about this.

Cheers,
Sandeep
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming this is not possible because the ejbSelect methods can only return one value: a CMP field, a CMR field as a single entity or a group of CMR fields as a Collection. So, it doesn't seem logical to allow EJB-QL to return multiple fields from the SELECT.

Please correct if I am wrong, I haven't looked this up in the spec.
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sandeep MP:

select p.firstName,p.lastName from Person p.



Please read the EJB-QL specs. ****ONLY ONE **** cmp field can be returned from query. The return type of the SELECT clause can be one of the following:
1. The abstract schema of the entity bean that contains the select method.
2. The abstract schema of a related entity bean.
3. A persistent field

I am wondering why will anybody select just one field, when YOU can get whole LocalPerson interface object.

Cheers

Nishant
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic