Commit 564ef422 by Patryk Czarnik

Poprawienie klas encji na jakarta itp

parent 57326e78
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> <persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="PC27-SklepHibernate"> <persistence-unit name="PC27-SklepHibernate">
<class>sklep.model.Customer</class> <class>sklep.model.Customer</class>
<class>sklep.model.OrderProduct</class> <class>sklep.model.OrderProduct</class>
<class>sklep.model.OrderProductPK</class> <class>sklep.model.OrderProductPK</class>
<class>sklep.model.Order</class> <class>sklep.model.Order</class>
<class>sklep.model.Product</class> <class>sklep.model.Product</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/sklep" />
<property name="javax.persistence.jdbc.user" value="kurs" />
<property name="javax.persistence.jdbc.password" value="abc123" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit> </persistence-unit>
</persistence> </persistence>
...@@ -2,8 +2,13 @@ package sklep.model; ...@@ -2,8 +2,13 @@ package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Pattern;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* The persistent class for the customers database table. * The persistent class for the customers database table.
...@@ -16,7 +21,8 @@ public class Customer implements Serializable { ...@@ -16,7 +21,8 @@ public class Customer implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(name="customer_email") @Column(name="customer_email", updatable=false)
@Email
private String customerEmail; private String customerEmail;
private String address; private String address;
...@@ -30,10 +36,12 @@ public class Customer implements Serializable { ...@@ -30,10 +36,12 @@ public class Customer implements Serializable {
private String phoneNumber; private String phoneNumber;
@Column(name="postal_code") @Column(name="postal_code")
@Pattern(regexp="\\d{2}-\\d{3}")
private String postalCode; private String postalCode;
//bi-directional many-to-one association to Order //bi-directional many-to-one association to Order
@OneToMany(mappedBy="customer") @OneToMany(mappedBy="customer")
@JsonIgnore
private List<Order> orders; private List<Order> orders;
public Customer() { public Customer() {
......
...@@ -2,8 +2,14 @@ package sklep.model; ...@@ -2,8 +2,14 @@ package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Min;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* The persistent class for the order_products database table. * The persistent class for the order_products database table.
...@@ -19,21 +25,26 @@ public class OrderProduct implements Serializable { ...@@ -19,21 +25,26 @@ public class OrderProduct implements Serializable {
private OrderProductPK id; private OrderProductPK id;
@Column(name="actual_price") @Column(name="actual_price")
@DecimalMin("0.01")
private BigDecimal actualPrice; private BigDecimal actualPrice;
@Column(name="actual_vat") @Column(name="actual_vat")
@DecimalMin("0.00")
@DecimalMax("0.99")
private BigDecimal actualVat; private BigDecimal actualVat;
@Min(1)
private Integer quantity; private Integer quantity;
//bi-directional many-to-one association to Order //bi-directional many-to-one association to Order
@ManyToOne @ManyToOne
@JoinColumn(name="order_id") @JoinColumn(name="order_id", insertable=false, updatable=false)
@JsonIgnore
private Order order; private Order order;
//uni-directional many-to-one association to Product //uni-directional many-to-one association to Product
@ManyToOne @ManyToOne
@JoinColumn(name="product_id") @JoinColumn(name="product_id", insertable=false, updatable=false)
private Product product; private Product product;
public OrderProduct() { public OrderProduct() {
......
...@@ -2,6 +2,8 @@ package sklep.model; ...@@ -2,6 +2,8 @@ package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -22,11 +24,16 @@ public class Product implements Serializable { ...@@ -22,11 +24,16 @@ public class Product implements Serializable {
private String description; private String description;
@NotNull
@DecimalMin("0.01")
private BigDecimal price; private BigDecimal price;
@Column(name="product_name") @Column(name="product_name")
@NotBlank
private String productName; private String productName;
@DecimalMin("0.00")
@DecimalMax("0.99")
private BigDecimal vat; private BigDecimal vat;
public Product() { public Product() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment