Double orderValue = 0.0d;
// now create some order lines
int numberOfOrderLines = random.nextInt(maximumOrderLinesPerOrder);
for (int i = 0; i < numberOfOrderLines; ++i) {
int orderLineNumber = getNextOrderLineId();
OrderLine orderLine = session.newInstance(OrderLine.class);
orderLine.setId(orderLineNumber);
orderLine.setOrderId(orderid);
long quantity = random.nextInt(maximumQuantityPerOrderLine);
orderLine.setQuantity(quantity);
float unitPrice = ((float)random.nextInt(maximumUnitPrice)) / 4;
orderLine.setUnitPrice(unitPrice);
double orderLineValue = unitPrice * quantity;
orderValue += orderLineValue;
if (getDebug()) System.out.println("For order " + orderid + " orderline " + orderLineNumber +
" order line value " + orderLineValue + " order value " + orderValue);
orderLine.setTotalValue(orderLineValue);
addOrderLine(orderLine);
session.persist(orderLine);
}
order.setValue(orderValue);
session.persist(order);