* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-@Entity (name = "category")
-@Table (name = "category")
+@Entity (name = "product_category")
+@Table (name = "product_category")
@SuppressWarnings ("PersistenceUnitPresent")
public class ProductCategory implements Category {
/**
* Parent category
*/
- @JoinColumn (name = "parent_id")
+ @JoinColumn (name = "category_parent_id", referencedColumnName = "category_id")
@OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.REFRESH)
private Category parentCategory;
/**
* Constructor which accepts all database fields
* <p>
- * @param categoryId Id number of database record
* @param categoryTitle Category categoryTitle
* @param parentCategory Parent category
* @param categoryShownInStatistics Whether this category is shown in any
* statistics
*/
- public ProductCategory (final Long categoryId, final String categoryTitle, final Category parentCategory, final Boolean categoryShownInStatistics) {
+ public ProductCategory (final String categoryTitle, final Category parentCategory, final Boolean categoryShownInStatistics) {
// Set all here
- this.categoryId = categoryId;
this.categoryTitle = categoryTitle;
this.parentCategory = parentCategory;
this.categoryShownInStatistics = categoryShownInStatistics;
}
@Override
+ @Deprecated
public void copyAll (final Category category) {
// Copy all data
this.setParentCategory(category.getParentCategory());
* @author Roland Häder<roland@mxchange.org>
* TODO: Find a better name
*/
-@Entity (name = "products")
-@Table (name = "products")
+@Entity (name = "generic_products")
+@Table (name = "generic_products")
@SuppressWarnings ("PersistenceUnitPresent")
public class GenericProduct implements Product {
/**
* Availability of product
*/
+ @Basic (optional = false)
@Column (name = "product_availability", nullable = false)
private Boolean productAvailability;
/**
* Product productCategory
*/
- @JoinColumn (name = "category_id", nullable = false, updatable = false)
+ @JoinColumn (name = "product_category_id", referencedColumnName = "category_id", nullable = false, updatable = false)
@OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.REFRESH, optional = false)
private Category productCategory;
/**
* Constructor will all required data
* <p>
- * @param productId Id number of product
* @param productTitle Name of product
* @param productPrice Price
* @param productCategory Category instance
* @param productAvailability Availability (selectable by customer)
*/
- public GenericProduct (final Long productId, final String productTitle, final Float productPrice, final Category productCategory, final Boolean productAvailability) {
+ public GenericProduct (final String productTitle, final Float productPrice, final Category productCategory, final Boolean productAvailability) {
// Set all here
- this.productId = productId;
this.productTitle = productTitle;
this.productPrice = productPrice;
this.productCategory = productCategory;
}
@Override
+ @Deprecated
public void copyAll (final Product product) {
// Copy all
this.setProductAvailability(product.getProductAvailability());
return false;
}
- final Product other = (Product) object;
+ final Product product = (Product) object;
- if (!Objects.equals(this.getProductTitle(), other.getProductTitle())) {
+ if (!Objects.equals(this.getProductId(), product.getProductId())) {
+ return false;
+ } else if (!Objects.equals(this.getProductPrice(), product.getProductPrice())) {
+ return false;
+ } else if (!Objects.equals(this.getProductTitle(), product.getProductTitle())) {
return false;
}
- return Objects.equals(this.getProductId(), other.getProductId());
- }
-
- @Override
- public int hashCode () {
- int hash = 7;
- hash = 23 * hash + Objects.hashCode(this.getProductId());
- hash = 23 * hash + Objects.hashCode(this.getProductTitle());
- return hash;
+ return true;
}
@Override
this.productTitle = productTitle;
}
+ @Override
+ public int hashCode () {
+ int hash = 7;
+
+ hash = 23 * hash + Objects.hashCode(this.getProductId());
+ hash = 23 * hash + Objects.hashCode(this.getProductPrice());
+ hash = 23 * hash + Objects.hashCode(this.getProductTitle());
+
+ return hash;
+ }
+
}