Hi Juan, thanks for sending this to users@ :-) The code does look ok to me
My best guess is for you to change your references to "products" (the field) to "getProducts()" (the getter). It's possible that the getter is required in order for DataNucleus to resolve the field. If that doesn't work, I'll have another think. Dan PS: as a side-note, your "if(!products.isEmpty())2 guard is redundant; if the products collection is empty then the for loop will be iterated zero times. On 23 June 2014 16:30, Juan Martin Buireo <[email protected]> wrote: > Hi, I am with an app and I want to do something. I have the following > structure of the objects: > Invoice class : has some properties and a List<InvoiceProduct> > InvoiceProduct class: has some properties (such as quantity and a Product ) > Product class: has some properties of the product. > What I want to do is that when I create an Invoice the value subtotal is in > 0. And when I start adding products to the invoice the subtotal value > changes (this is the sum of all products * quantity). > I tried making only a getter on Invoice class like this: > > @MemberOrder(sequence = "6") > public double getSubtotal() { > double total = 0; > if(!products.isEmpty()) { > for(InvoiceProduct ip: products) { > total += (ip.getQuantity() * ip.getProduct().getPrice()); > } > } > return total; > } > > But after adding items, the subtotal remains 0. What am I doing bad? > Thanks > PS: the picture of what i have now http://imgur.com/rNIaPEW >
