01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package org.jfox.petstore.entity;
08:
09: import java.io.Serializable;
10: import javax.persistence.Column;
11: import javax.persistence.Entity;
12:
13: import org.jfox.entity.annotation.MappingColumn;
14: import org.jfox.entity.annotation.ParameterMap;
15: import org.jfox.petstore.dao.ItemDAOImpl;
16:
17: /**
18: * IineItem is a order line item.
19: */
20: @Entity
21: public class LineItem implements Serializable {
22:
23: @Column(name="orderid")
24: long orderId;
25:
26: @Column(name="linenum")
27: int lineNumber;
28:
29: @Column(name="itemid")
30: String itemId;
31:
32: @Column(name="unitprice")
33: double unitPrice;
34:
35: @Column(name="quantity")
36: int quantity;
37:
38: @MappingColumn(namedQuery=ItemDAOImpl.GET_ITEM,params={@ParameterMap(name="id",value="$this.getItemId()")})
39: Item item;
40:
41: public long getOrderId() {
42: return orderId;
43: }
44:
45: public void setOrderId(long orderId) {
46: this .orderId = orderId;
47: }
48:
49: public int getLineNumber() {
50: return lineNumber;
51: }
52:
53: public void setLineNumber(int lineNumber) {
54: this .lineNumber = lineNumber;
55: }
56:
57: public String getItemId() {
58: return itemId;
59: }
60:
61: public void setItemId(String itemId) {
62: this .itemId = itemId;
63: }
64:
65: public double getUnitPrice() {
66: return unitPrice;
67: }
68:
69: public void setUnitPrice(double unitPrice) {
70: this .unitPrice = unitPrice;
71: }
72:
73: public int getQuantity() {
74: return quantity;
75: }
76:
77: public void setQuantity(int quantity) {
78: this .quantity = quantity;
79: }
80:
81: public Item getItem() {
82: return item;
83: }
84:
85: public void setItem(Item item) {
86: this .item = item;
87: }
88:
89: public static class Helper {
90: public static double getTotalPrice(LineItem lineItem) {
91: return lineItem.getUnitPrice() * lineItem.getQuantity();
92: }
93: }
94: }
|