import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
* Customer instance
*/
@Basic (optional = false)
+ @OneToMany
@JoinColumn (name = "customer_id", nullable = false, updatable = false)
private Customer customer;
package org.mxchange.jshopcore.model.product;
import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
/**
* A general product class
*
* @author Roland Haeder<roland@mxchange.org>
*/
+@Entity(name = "product")
+@Table (name = "products")
public abstract class BaseProduct implements Product, Comparable<Product> {
/**
/**
* Availability of product
*/
+ @Column
private Boolean available;
/**
* Product category
*/
+ @Basic(optional = false)
+ @Column(name = "category_id", length = 20, nullable = false)
private Long categoryId;
/**
* Id number of product
*/
+ @Id
+ @GeneratedValue
+ @Column
private Long id;
/**
* Price of product
*/
+ @Basic(optional = false)
+ @Column(nullable = false)
private Float price;
/**
* Title of product
*/
+ @Basic(optional = false)
+ @Column(length = 100, nullable = false)
private String title;
@Override
return -1;
}
+ @Override
+ public void copyAll (final Product product) {
+ // Copy all
+ this.setAvailable(product.getAvailable());
+ this.setCategoryId(product.getCategoryId());
+ this.setPrice(product.getPrice());
+ this.setTitle(product.getTitle());
+ }
+
@Override
public Boolean getAvailable () {
return this.available;
* @author Roland Haeder<roland@mxchange.org>
*/
public interface Product extends Serializable {
+
+ /**
+ * Copies all properties from source product to this.
+ *
+ * @param product Source product
+ */
+ public void copyAll (final Product product);
+
/**
* Getter for id number, suitable for form fields.
*