Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJB QL

 
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
 
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.
 
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
    Bookmark Topic Watch Topic
  • New Topic