Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.OneToMany;
- @Entity
- public class Brand {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private int id;
- private String brand;
- @OneToMany(mappedBy="brand")
- private List<Product> products;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getBrand() {
- return brand;
- }
- public void setBrand(String brand) {
- this.brand = brand;
- }
- public List<Product> getProducts() {
- return products;
- }
- public void setProducts(List<Product> products) {
- this.products = products;
- }
- }
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.OneToMany;
- @Entity
- public class Category {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private int id;
- private String country;
- @OneToMany(mappedBy="category")
- private List<Product> products;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getCountry() {
- return country;
- }
- public void setCountry(String country) {
- this.country = country;
- }
- public List<Product> getProducts() {
- return products;
- }
- public void setProducts(List<Product> products) {
- this.products = products;
- }
- }
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.OneToMany;
- @Entity
- public class Size {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private int id;
- private int size;
- @OneToMany(mappedBy="size")
- private List<Product> products;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public int getSize() {
- return size;
- }
- public void setSize(int size) {
- this.size = size;
- }
- public List<Product> getProducts() {
- return products;
- }
- public void setProducts(List<Product> products) {
- this.products = products;
- }
- }
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.ManyToOne;
- import javax.persistence.OneToMany;
- @Entity
- public class Product {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- private String name;
- private double price;
- @ManyToOne(fetch = FetchType.LAZY)
- private Category category;
- @ManyToOne(fetch = FetchType.LAZY)
- private Brand brand;
- @ManyToOne(fetch = FetchType.LAZY)
- private Size size;
- @OneToMany(mappedBy="product")
- private List<Order> orders;
- public List<Order> getOrders() {
- return orders;
- }
- public void setOrders(List<Order> orders) {
- this.orders = orders;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public double getPrice() {
- return price;
- }
- public void setPrice(double price) {
- this.price = price;
- }
- public Category getCategory() {
- return category;
- }
- public void setCategory(Category category) {
- this.category = category;
- }
- public Brand getBrand() {
- return brand;
- }
- public void setBrand(Brand brand) {
- this.brand = brand;
- }
- public Size getSize() {
- return size;
- }
- public void setSize(Size size) {
- this.size = size;
- }
- }
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.ManyToOne;
- import javax.persistence.OneToMany;
- @Entity
- public class Usr {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- private String username;
- private String email;
- private String password;
- @ManyToOne(fetch = FetchType.LAZY)
- private Role role;
- @OneToMany(mappedBy="usr")
- private List<Order> orders;
- public List<Order> getOrders() {
- return orders;
- }
- public void setOrders(List<Order> orders) {
- this.orders = orders;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public Role getRole() {
- return role;
- }
- public void setRole(Role role) {
- this.role = role;
- }
- }
- package entity;
- import java.util.List;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.OneToMany;
- @Entity
- public class Role {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- private String role;
- @OneToMany(mappedBy="role")
- private List<Usr> usrs;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getRole() {
- return role;
- }
- public void setRole(String role) {
- this.role = role;
- }
- public List<Usr> getUsrs() {
- return usrs;
- }
- public void setUsrs(List<Usr> usrs) {
- this.usrs = usrs;
- }
- }
- package entity;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.ManyToOne;
- @Entity
- public class Order {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- @ManyToOne(fetch = FetchType.LAZY)
- private Usr usr;
- @ManyToOne(fetch = FetchType.LAZY)
- private Product product;
- public Usr getUsr() {
- return usr;
- }
- public void setUsr(Usr usr) {
- this.usr = usr;
- }
- public Product getProduct() {
- return product;
- }
- public void setProduct(Product product) {
- this.product = product;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement