• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

@NamedQuery : does it have to be declared on an @Entity ?

 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to ejb, and trying to use @NamedQuery.
When you declare @NamedQuery (using annotations, not XML), do you have to declare it on an @Entity class ?

I mean:

I couldn't get the second example to work.
I even tried declaring the NotEntityClass in persistence.xml, but it didn't work - maybe I did it wrong ?
<class>somePackage.NotAnEntity<class>

Is there some way to make it work ?
Thank you.
[ October 03, 2007: Message edited by: Sol Mayer-Orn ]
 
author & internet detective
Posts: 42055
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sol,
@NamedQuery does need to be declared on an @Entity class. As you noted, the alternative is to put it in XML.

As I recall, it goes in the orm.xml file. For example:
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic