File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33720
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic