import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-import org.mxchange.jcore.model.contact.BaseContact;
import org.mxchange.jcore.model.contact.Contact;
+import org.mxchange.jcore.model.contact.UserContact;
+import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
/**
* A shop customer class.
*
* @author Roland Haeder<roland@mxchange.org>
*/
-@Entity (name = "Customer")
+@Entity (name = "customer")
@Table (name = "customer")
public class ShopCustomer implements Customer {
*/
private static final long serialVersionUID = 4_328_454_581_751L;
- /**
- * Customer id
- */
- @Id
- @Column (name = "id", nullable = false, length = 20)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long customerId;
-
/**
* Id number from "contacts" table
*/
- @JoinColumn (table = "contacts", referencedColumnName = "customer_contact_id", name = "id", nullable = false, updatable = false, unique = true)
- @OneToOne (optional = false, targetEntity = BaseContact.class, orphanRemoval = true)
+ @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
+ @OneToOne (targetEntity = UserContact.class, optional = false)
private Contact contact;
/**
/**
* "created" timestamp
*/
- @Basic(optional = false)
+ @Basic (optional = false)
@Temporal (TemporalType.TIMESTAMP)
@Column (name = "customer_created", nullable = false)
private Calendar customerCreated;
+ /**
+ * Customer id
+ */
+ @Id
+ @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ private Long customerId;
+
/**
* "locked" timestamp
*/
/**
* Account status
*/
- @Column (name = "customer_status", nullable = false)
- private String customerStatus;
+ @Basic (optional = false)
+ @Column (name = "customer_account_status", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private CustomerAccountStatus customerAccountStatus;
+
+ /**
+ * Default constructor
+ */
+ public ShopCustomer () {
+ }
@Override
public void copyAll (final Customer customer) {
this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
this.setCustomerNumber(customer.getCustomerNumber());
this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
- this.setCustomerStatus(customer.getCustomerStatus());
+ this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
this.setCustomerCreated(customer.getCustomerCreated());
this.setCustomerLocked(customer.getCustomerLocked());
}
this.customerCreated = customerCreated;
}
+ @Override
+ public Long getCustomerId () {
+ return this.customerId;
+ }
+
+ @Override
+ public void setCustomerId (final Long customerId) {
+ this.customerId = customerId;
+ }
+
@Override
public Calendar getCustomerLocked () {
return this.customerLocked;
}
@Override
- public String getCustomerStatus () {
- return this.customerStatus;
- }
-
- @Override
- public void setCustomerStatus (final String customerStatus) {
- this.customerStatus = customerStatus;
+ public CustomerAccountStatus getCustomerAccountStatus () {
+ return this.customerAccountStatus;
}
@Override
- public Long getCustomerId () {
- return this.customerId;
- }
-
- @Override
- public void setCustomerId (final Long customerId) {
- this.customerId = customerId;
+ public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
+ this.customerAccountStatus = customerAccountStatus;
}
}