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 ]


      @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 ")
       @Column(name="USER_ID", nullable = false)
       private Long userId;
       @OneToMany(mappedBy = "users")
       private List<ProviderUsers> providerUsersList;


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


       private Timestamp dateEnd;
       @Column(name="DATE_REQUESTED", nullable = false)
       private Timestamp dateRequested;
       private Timestamp dateStarted;
       @Column(name="SERVICE_CODE", nullable = false)
       private Long serviceCode;
       @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?