Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

problem with @FieldResult, mapping does not seem to work  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to execute the following query:

I expect an id and a lastname to be returned from the query, However only an id is returned.
It seems that the fieldresult annotation does not work.
If I use a different query: select id, lastname from employee, I get the lastname returned.
Below is the complete entity.

Does anyone have an idea what could be wrong?
thanks.
 
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the CodeRanch!

Why you haven't mapped the "lastName" column in the entity as with the "firstName" in the first place?
 
niels maes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.

It is just an example to try out the @field_result annotation.
I'm trying out all annotations, originally the mapping was as in your suggestion.
I deliberately changed the mapping/the query to be able to test the field_result annotation.
But I don't understand why it doesn't work.
 
Vijitha Kumara
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried this myself (may be later I'll try). But I think persistence provider has no idea of the field being a persistent field. You can verify this perhaps by persisting an entity of this with this code?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!