2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jshopcore.model.order;
19 import java.util.Calendar;
20 import java.util.List;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
35 import org.mxchange.jshopcore.model.customer.Customer;
36 import org.mxchange.jshopcore.model.customer.ShopCustomer;
39 * An entity class for shop orders
41 * @author Roland Haeder
43 @Entity (name = "orders")
44 @Table (name = "orders")
45 public class ShopOrder implements Orderable {
50 private static final long serialVersionUID = 19_728_938_459_834L;
55 @Basic (optional = false)
56 @Column (name = "access_key", length = 100, nullable = false, unique = true)
57 private String accessKey;
62 @Basic (optional = false)
63 @Temporal (TemporalType.TIMESTAMP)
64 @Column (name = "order_created", nullable = false)
65 private Calendar orderCreated;
70 @JoinColumn (name = "customer_id", nullable = false, updatable = false)
71 @OneToOne (targetEntity = ShopCustomer.class, cascade = CascadeType.MERGE, optional = false)
72 private Customer customer;
75 * Item list, don't save this
78 private List<AddableBasketItem> orderedItems;
84 @GeneratedValue (strategy = GenerationType.IDENTITY)
85 @Column (name = "order_id", length = 20)
89 public String getAccessKey () {
90 return this.accessKey;
94 public void setAccessKey (final String accessKey) {
95 this.accessKey = accessKey;
99 public Calendar getOrderCreated () {
100 return this.orderCreated;
104 public void setOrderCreated (final Calendar orderCreated) {
105 this.orderCreated = orderCreated;
109 public Customer getCustomer () {
110 return this.customer;
114 public void setCustomer (final Customer customer) {
115 this.customer = customer;
119 public Long getOrderId () {
124 public void setOrderId (final Long orderId) {
125 this.orderId = orderId;
129 public List<AddableBasketItem> getOrderedItems () {
130 return this.orderedItems;
134 public void setOrderedItems (final List<AddableBasketItem> orderedItems) {
135 this.orderedItems = orderedItems;