Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
javab_20230928
Commits
564ef422
Commit
564ef422
authored
Oct 19, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Poprawienie klas encji na jakarta itp
parent
57326e78
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
persistence.xml
PC27-SklepHibernate/src/main/java/META-INF/persistence.xml
+11
-1
Customer.java
PC27-SklepHibernate/src/main/java/sklep/model/Customer.java
+9
-1
OrderProduct.java
...klepHibernate/src/main/java/sklep/model/OrderProduct.java
+13
-2
Product.java
PC27-SklepHibernate/src/main/java/sklep/model/Product.java
+7
-0
No files found.
PC27-SklepHibernate/src/main/java/META-INF/persistence.xml
View file @
564ef422
<?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>
PC27-SklepHibernate/src/main/java/sklep/model/Customer.java
View file @
564ef422
...
...
@@ -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
()
{
...
...
PC27-SklepHibernate/src/main/java/sklep/model/OrderProduct.java
View file @
564ef422
...
...
@@ -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
()
{
...
...
PC27-SklepHibernate/src/main/java/sklep/model/Product.java
View file @
564ef422
...
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment