1 Reply Latest reply on Nov 1, 2005 1:13 PM by oglueck

    Syntax for @NamedQuery using EJB3

    res2681

      I want to have multiple queries in my entity and I dont know the way to do it, heres an example


      @NamedQuery(name="night.lessRecentThan", queryString="select n from Night n where n.date <= :date")
      @NamedQuery(name="night.moreRecentThan", queryString="select n from Night n where n.date >= :date")

      This gives me an error saying duplicate annotation, but when I drop the second @NamedQuery I get other errors relating to these queries.

      So if someone could show me how to use the annotation with multiple queries I would be greatful.

        • 1. Re: Syntax for @NamedQuery using EJB3

          like so:

          @NamedQueries({
           @NamedQuery(name="night.lessRecentThan", queryString="select n from Night n where n.date <= :date"),
           @NamedQuery(name="night.moreRecentThan", queryString="select n from Night n where n.date >= :date")
          })