• Post Reply Bookmark Topic Watch Topic
  • New Topic

Only one named query allowed???  RSS feed

 
Greg Reinl
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?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
 
Shailesh Kini
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!