1 Reply Latest reply on Jun 16, 2009 9:02 AM by wolfgangknauf

    JPA query question!

    ericmacau

      Hello,

      How can I define a QL for getting Entity from Collections?

      class User {

      List addresses;
      }

      class Address {
      protected String state;
      }


      how can I retrieve all the User if the user's state is 'MA' or 'NY'?

      how can I define the NamedQuery for that?

      Best regards,
      Eric

        • 1. Re: JPA query question!
          wolfgangknauf

          Hi Eric,

          I think it should be this:

          @NamedQuery (name="findUsersByState", query="select o from User o where o.adresses.state in ('MA', 'NY')")
          @Entity()
          public class User implements Serializable
          {
           ...


          Hope this helps

          Wolfgang