2 Replies Latest reply on Aug 4, 2007 5:53 AM by alexg79

    Accessing collections from queries

    alexg79

      Please help, I've asked a similar question several times and it's never been answered!

      Suppose I have an entity like:

      @Entity
      class Delivery {
       private long id;
       private Map<Date, Integer> amounts;
      
       @Id @GeneratedValue
       public long getId() {
       return id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
      
       @CollectionOfElements
       public Map<Date, Integer> getAmounts() {
       return amounts;
       }
      
       public void setAmounts(Map<Date, Integer> amounts) {
       this.amounts = amounts;
       }
      
      }

      How can I access the "amounts" property in queries?
      I'd like to create an aggregate query that gives me a sum of delivered amounts per delivery. How do I do that?
      How can I even retrieve the value of "amounts" from a Criteria Query using a Projection?