From 25ae0a23d15383df7f84ad51ee8f078c519ed963 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Sun, 22 Nov 2015 17:02:23 +0100 Subject: Get it to run on newest versions --- src/jpa/Product.java | 94 ++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 51 deletions(-) (limited to 'src/jpa/Product.java') diff --git a/src/jpa/Product.java b/src/jpa/Product.java index dc0b3f8..baf29ca 100644 --- a/src/jpa/Product.java +++ b/src/jpa/Product.java @@ -1,51 +1,56 @@ package jpa; import java.io.Serializable; +import javax.persistence.*; import java.math.BigDecimal; -import java.util.Collection; import java.util.Set; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; +/** + * The persistent class for the product database table. + * + */ @Entity +@Table(name="product") +@NamedQuery(name="Product.findAll", query="SELECT p FROM Product p") public class Product implements Serializable { + private static final long serialVersionUID = 1L; + @Id - @GeneratedValue(strategy=GenerationType.SEQUENCE) - private String id; + private int id; + @Lob private String description; - private BigDecimal price; + private BigDecimal height; private String name; - private BigDecimal width; + private BigDecimal price; - private BigDecimal height; + private BigDecimal width; + //bi-directional many-to-many association to Category @ManyToMany @JoinTable( - joinColumns=@JoinColumn(name="product_id"), - inverseJoinColumns=@JoinColumn(name="category_id")) - private Set categoryCollection; - - private static final long serialVersionUID = 1L; + name="product_category" + , joinColumns={ + @JoinColumn(name="product_id") + } + , inverseJoinColumns={ + @JoinColumn(name="category_id") + } + ) + private Set categories; public Product() { - super(); } - public String getId() { + public int getId() { return this.id; } - public void setId(String id) { + public void setId(int id) { this.id = id; } @@ -57,12 +62,12 @@ public class Product implements Serializable { this.description = description; } - public BigDecimal getPrice() { - return this.price; + public BigDecimal getHeight() { + return this.height; } - public void setPrice(BigDecimal price) { - this.price = price; + public void setHeight(BigDecimal height) { + this.height = height; } public String getName() { @@ -73,41 +78,28 @@ public class Product implements Serializable { this.name = name; } - public BigDecimal getWidth() { - return this.width; + public BigDecimal getPrice() { + return this.price; } - public void setWidth(BigDecimal width) { - this.width = width; + public void setPrice(BigDecimal price) { + this.price = price; } - public BigDecimal getHeight() { - return this.height; + public BigDecimal getWidth() { + return this.width; } - public void setHeight(BigDecimal height) { - this.height = height; + public void setWidth(BigDecimal width) { + this.width = width; } - public Collection getCategories() { - return this.getCategoryCollection(); - } - - public Set getCategoryCollection() { - return this.categoryCollection; + public Set getCategories() { + return this.categories; } - public void setCategoryCollection(Set categoryCollection) { - this.categoryCollection = categoryCollection; + public void setCategories(Set categories) { + this.categories = categories; } - public void addCategory(Category category) - { - Set categories = getCategoryCollection(); - if (!categories.contains(category)) - { - categories.add(category); - category.addProduct(this); - } - } -} +} \ No newline at end of file -- cgit v1.2.3-70-g09d2