This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps 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:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Only one named query allowed???

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using annotion to create named queries for an EJB. When I add one annotation it works fine but when I addthe second I get this compile error:

Error(10,2): duplicate annotation javax.persistence.NamedQuery

The annotations at the class level look like this:

@Entity
@NamedQuery(name = "Response.findAll", query = "select o from Response o")
@NamedQuery(name = "Response.searchForText",
query = "select o from Response o where o.question Like :text")

Is ther no way to associate multiple named queries with one EJB?
 
author & internet detective
Posts: 39890
798
Eclipse IDE VI Editor Java
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,

There is a way to add multiple Named Queries to your entity.

@NamedQueries( { @NamedQuery(name = "Response.findAll query = "select o from Response o"), @NamedQuery(name = "Response.searchForText" query = "SELECT o from Response o where o.question like :text")})

Hope this helps
 
Greg Reinl
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does. Thanks.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!