Commit 564ef422 by Patryk Czarnik

Poprawienie klas encji na jakarta itp

parent 57326e78
<?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">
<class>sklep.model.Customer</class>
<class>sklep.model.OrderProduct</class>
<class>sklep.model.OrderProductPK</class>
<class>sklep.model.Order</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>
......@@ -2,8 +2,13 @@ package sklep.model;
import java.io.Serializable;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Pattern;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* The persistent class for the customers database table.
......@@ -16,7 +21,8 @@ public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="customer_email")
@Column(name="customer_email", updatable=false)
@Email
private String customerEmail;
private String address;
......@@ -30,10 +36,12 @@ public class Customer implements Serializable {
private String phoneNumber;
@Column(name="postal_code")
@Pattern(regexp="\\d{2}-\\d{3}")
private String postalCode;
//bi-directional many-to-one association to Order
@OneToMany(mappedBy="customer")
@JsonIgnore
private List<Order> orders;
public Customer() {
......
......@@ -2,8 +2,14 @@ package sklep.model;
import java.io.Serializable;
import jakarta.persistence.*;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Min;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* The persistent class for the order_products database table.
......@@ -19,21 +25,26 @@ public class OrderProduct implements Serializable {
private OrderProductPK id;
@Column(name="actual_price")
@DecimalMin("0.01")
private BigDecimal actualPrice;
@Column(name="actual_vat")
@DecimalMin("0.00")
@DecimalMax("0.99")
private BigDecimal actualVat;
@Min(1)
private Integer quantity;
//bi-directional many-to-one association to Order
@ManyToOne
@JoinColumn(name="order_id")
@JoinColumn(name="order_id", insertable=false, updatable=false)
@JsonIgnore
private Order order;
//uni-directional many-to-one association to Product
@ManyToOne
@JoinColumn(name="product_id")
@JoinColumn(name="product_id", insertable=false, updatable=false)
private Product product;
public OrderProduct() {
......
......@@ -2,6 +2,8 @@ package sklep.model;
import java.io.Serializable;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
......@@ -22,11 +24,16 @@ public class Product implements Serializable {
private String description;
@NotNull
@DecimalMin("0.01")
private BigDecimal price;
@Column(name="product_name")
@NotBlank
private String productName;
@DecimalMin("0.00")
@DecimalMax("0.99")
private BigDecimal vat;
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