2 Replies Latest reply on Dec 6, 2006 11:40 AM by Eric Anderson

    Problem with named query...

    Eric Anderson Newbie

      I am getting the following error when deploying because of a named query. It seems that hibernate is not following the mapping correctly?

      org.hibernate.QueryException: could not resolve property: serviceCode of: org.usiis.model.ProviderUsers [select o from org.usiis.model.Users o Where o.providerUsersList.providerId = :providerId AND o.providerUsersList.providerUserServicesList.serviceCode = :serviceCode AND (o.providerUsersList.providerUserServicesList.
      dateEnd <= :endDate OR o.providerUsersList.providerUserServicesList.dateStarted is null)order by o.username ]
      


      BEANs

      Users
      
      @Entity
      @NamedQueries({
      
      
      @NamedQuery(name = "Users.findAllInactiveByProviderIdServiceCodeDate",
       query = "select o from Users o Where o.providerUsersList.providerId = :providerId " +
       "AND o.providerUsersList.providerUserServicesList.serviceCode = :serviceCode " +
       "AND (o.providerUsersList.providerUserServicesList.dateEnd <= :endDate " +
       "OR o.providerUsersList.providerUserServicesList.dateStarted is null)" +
       "order by o.username ")
      
      
       @Id
       @Column(name="USER_ID", nullable = false)
       private Long userId;
       @OneToMany(mappedBy = "users")
       private List<ProviderUsers> providerUsersList;
      
      
      



      ProviderUsers

       @Id
       @Column(name="PROVIDER_USER_ID", nullable = false)
       private Long providerUserId;
       @Column(name="PROVIDER_ID")
       private String providerId;
       @OneToMany(mappedBy = "providerUsers")
       private List<ProviderUserServices> providerUserServicesList;
      
      


      ProviderUserServices

       @Column(name="DATE_END")
       private Timestamp dateEnd;
       @Column(name="DATE_REQUESTED", nullable = false)
       private Timestamp dateRequested;
       @Column(name="DATE_STARTED")
       private Timestamp dateStarted;
       @Column(name="SERVICE_CODE", nullable = false)
       private Long serviceCode;
       @Id
       @Column(name="USER_SERVICES_ID", nullable = false)
       private Long userServicesId;
      



      Why does hibernate want to associate serviceCode with ProviderUsers when it is in ProviderUserServices in the query? Is this a bug with hibernate?