summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-11-23 15:40:44 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-11-23 15:57:23 +0100
commitcd9d62986882b298948dff96f8bc4d18a086f90d (patch)
tree11c95261c2ed6e2e5ea735ba9e76fd33f403626a
parentea3b3f9bf0d803bd98d997b3dd1a6ac845736069 (diff)
downloadJCatalog-cd9d62986882b298948dff96f8bc4d18a086f90d.tar.gz
JCatalog-cd9d62986882b298948dff96f8bc4d18a086f90d.zip
Format files and organize imports
-rw-r--r--src/jpa/Category.java90
-rw-r--r--src/jpa/JPATest.java56
-rw-r--r--src/jpa/Product.java155
-rw-r--r--src/jpa/User.java53
4 files changed, 197 insertions, 157 deletions
diff --git a/src/jpa/Category.java b/src/jpa/Category.java
index 195b6e8..bbd832d 100644
--- a/src/jpa/Category.java
+++ b/src/jpa/Category.java
@@ -1,64 +1,78 @@
package jpa;
import java.io.Serializable;
-import javax.persistence.*;
import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
/**
* The persistent class for the category database table.
*
*/
@Entity
-@Table(name="category")
-@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c")
-public class Category implements Serializable {
- private static final long serialVersionUID = 1L;
+@Table(name = "category")
+@NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c")
+public class Category implements Serializable
+{
+ private static final long serialVersionUID = 1L;
- @Id
- private int id;
+ @Id
+ private int id;
- private String description;
+ private String description;
- private String name;
+ private String name;
- //bi-directional many-to-many association to Product
- @ManyToMany(mappedBy="categories")
- private Set<Product> products;
+ // bi-directional many-to-many association to Product
+ @ManyToMany(mappedBy = "categories")
+ private Set<Product> products;
- public Category() {
- }
+ public Category()
+ {
+ }
- public int getId() {
- return this.id;
- }
+ public int getId()
+ {
+ return this.id;
+ }
- public void setId(int id) {
- this.id = id;
- }
+ public void setId(int id)
+ {
+ this.id = id;
+ }
- public String getDescription() {
- return this.description;
- }
+ public String getDescription()
+ {
+ return this.description;
+ }
- public void setDescription(String description) {
- this.description = description;
- }
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
- public String getName() {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
- public Set<Product> getProducts() {
- return this.products;
- }
+ public Set<Product> getProducts()
+ {
+ return this.products;
+ }
- public void setProducts(Set<Product> products) {
- this.products = products;
- }
+ public void setProducts(Set<Product> products)
+ {
+ this.products = products;
+ }
} \ No newline at end of file
diff --git a/src/jpa/JPATest.java b/src/jpa/JPATest.java
index 5a4749e..1407c6c 100644
--- a/src/jpa/JPATest.java
+++ b/src/jpa/JPATest.java
@@ -19,25 +19,25 @@ public class JPATest
tx.begin();
try
{
-// Product product = manager.find(Product.class, "7");
-// Category newCategory = manager.find(Category.class, 4);
-// product.addCategory(newCategory);
-// manager.persist(product);
-// Collection<Category> categories = product.getCategoryCollection();
-// for (Category category : categories)
-// {
-// System.out.println(category.getName());
-// }
+ // Product product = manager.find(Product.class, "7");
+ // Category newCategory = manager.find(Category.class, 4);
+ // product.addCategory(newCategory);
+ // manager.persist(product);
+ // Collection<Category> categories = product.getCategoryCollection();
+ // for (Category category : categories)
+ // {
+ // System.out.println(category.getName());
+ // }
Product product = new Product();
product.setDescription("Noch ein Testprodukt");
product.setName("Produkt");
manager.persist(product);
-// User user = new User();
-// user.setUsername("bestertester2");
-// System.out.println(DigestUtils.md5("masterkey"));
-// user.setPassword(DigestUtils.md5("masterkey"));
-// manager.persist(user);
-
+ // User user = new User();
+ // user.setUsername("bestertester2");
+ // System.out.println(DigestUtils.md5("masterkey"));
+ // user.setPassword(DigestUtils.md5("masterkey"));
+ // manager.persist(user);
+
tx.commit();
}
catch (Exception ex)
@@ -45,18 +45,18 @@ public class JPATest
ex.printStackTrace(System.err);
tx.rollback();
}
-
-// CategoryManager cm = new CategoryManager();
-// Collection<Category> categories = cm.getCategories();
-// for (Category category : categories)
-// {
-// System.out.println(category.getName());
-// Set<Product> products = category.getProductCollection();
-// for (Product product : products)
-// {
-// System.out.println("\t" + product.getName());
-// }
-//
-// }
+
+ // CategoryManager cm = new CategoryManager();
+ // Collection<Category> categories = cm.getCategories();
+ // for (Category category : categories)
+ // {
+ // System.out.println(category.getName());
+ // Set<Product> products = category.getProductCollection();
+ // for (Product product : products)
+ // {
+ // System.out.println("\t" + product.getName());
+ // }
+ //
+ // }
}
}
diff --git a/src/jpa/Product.java b/src/jpa/Product.java
index baf29ca..8196b73 100644
--- a/src/jpa/Product.java
+++ b/src/jpa/Product.java
@@ -1,105 +1,122 @@
package jpa;
import java.io.Serializable;
-import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.Lob;
+import javax.persistence.ManyToMany;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
/**
* 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;
+@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
- private int id;
+ @Id
+ private int id;
- @Lob
- private String description;
+ @Lob
+ private String description;
- private BigDecimal height;
+ private BigDecimal height;
- private String name;
+ private String name;
- private BigDecimal price;
+ private BigDecimal price;
- private BigDecimal width;
+ private BigDecimal width;
- //bi-directional many-to-many association to Category
- @ManyToMany
- @JoinTable(
- name="product_category"
- , joinColumns={
- @JoinColumn(name="product_id")
- }
- , inverseJoinColumns={
- @JoinColumn(name="category_id")
- }
- )
- private Set<Category> categories;
+ // bi-directional many-to-many association to Category
+ @ManyToMany
+ @JoinTable(name = "product_category", joinColumns = {
+ @JoinColumn(name = "product_id") }, inverseJoinColumns = {
+ @JoinColumn(name = "category_id") })
+ private Set<Category> categories;
- public Product() {
- }
+ public Product()
+ {
+ }
- public int getId() {
- return this.id;
- }
+ public int getId()
+ {
+ return this.id;
+ }
- public void setId(int id) {
- this.id = id;
- }
+ public void setId(int id)
+ {
+ this.id = id;
+ }
- public String getDescription() {
- return this.description;
- }
+ public String getDescription()
+ {
+ return this.description;
+ }
- public void setDescription(String description) {
- this.description = description;
- }
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
- public BigDecimal getHeight() {
- return this.height;
- }
+ public BigDecimal getHeight()
+ {
+ return this.height;
+ }
- public void setHeight(BigDecimal height) {
- this.height = height;
- }
+ public void setHeight(BigDecimal height)
+ {
+ this.height = height;
+ }
- public String getName() {
- return this.name;
- }
+ public String getName()
+ {
+ return this.name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
- public BigDecimal getPrice() {
- return this.price;
- }
+ public BigDecimal getPrice()
+ {
+ return this.price;
+ }
- public void setPrice(BigDecimal price) {
- this.price = price;
- }
+ public void setPrice(BigDecimal price)
+ {
+ this.price = price;
+ }
- public BigDecimal getWidth() {
- return this.width;
- }
+ public BigDecimal getWidth()
+ {
+ return this.width;
+ }
- public void setWidth(BigDecimal width) {
- this.width = width;
- }
+ public void setWidth(BigDecimal width)
+ {
+ this.width = width;
+ }
- public Set<Category> getCategories() {
- return this.categories;
- }
+ public Set<Category> getCategories()
+ {
+ return this.categories;
+ }
- public void setCategories(Set<Category> categories) {
- this.categories = categories;
- }
+ public void setCategories(Set<Category> categories)
+ {
+ this.categories = categories;
+ }
} \ No newline at end of file
diff --git a/src/jpa/User.java b/src/jpa/User.java
index d96d27e..c3e9f75 100644
--- a/src/jpa/User.java
+++ b/src/jpa/User.java
@@ -1,41 +1,50 @@
package jpa;
import java.io.Serializable;
-import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
/**
* The persistent class for the user database table.
*
*/
@Entity
-@Table(name="user")
-@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
-public class User implements Serializable {
- private static final long serialVersionUID = 1L;
+@Table(name = "user")
+@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u")
+public class User implements Serializable
+{
+ private static final long serialVersionUID = 1L;
- @Id
- private String username;
+ @Id
+ private String username;
- private String password;
+ private String password;
- public User() {
- }
+ public User()
+ {
+ }
- public String getUsername() {
- return this.username;
- }
+ public String getUsername()
+ {
+ return this.username;
+ }
- public void setUsername(String username) {
- this.username = username;
- }
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
- public String getPassword() {
- return this.password;
- }
+ public String getPassword()
+ {
+ return this.password;
+ }
- public void setPassword(String password) {
- this.password = password;
- }
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
} \ No newline at end of file