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
907e7fbd
Commit
907e7fbd
authored
Oct 19, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Poprawki, aby się kompilowało
parent
564ef422
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
24 deletions
+22
-24
persistence.xml
PC27-SklepHibernate/src/main/java/META-INF/persistence.xml
+1
-1
Customer.java
PC27-SklepHibernate/src/main/java/sklep/model/Customer.java
+0
-7
OrderProduct.java
...klepHibernate/src/main/java/sklep/model/OrderProduct.java
+0
-10
Product.java
PC27-SklepHibernate/src/main/java/sklep/model/Product.java
+0
-6
OdczytajJedenProdukt.java
.../java/sklep/przyklady_hibernate/OdczytajJedenProdukt.java
+21
-0
No files found.
PC27-SklepHibernate/src/main/java/META-INF/persistence.xml
View file @
907e7fbd
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
xmlns=
"http://xmlns.jcp.org/xml/ns/persistence"
xmlns=
"http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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"
>
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=
"
sklep
"
>
<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>
...
...
PC27-SklepHibernate/src/main/java/sklep/model/Customer.java
View file @
907e7fbd
...
@@ -2,13 +2,9 @@ package sklep.model;
...
@@ -2,13 +2,9 @@ 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.
...
@@ -22,7 +18,6 @@ public class Customer implements Serializable {
...
@@ -22,7 +18,6 @@ public class Customer implements Serializable {
@Id
@Id
@Column
(
name
=
"customer_email"
,
updatable
=
false
)
@Column
(
name
=
"customer_email"
,
updatable
=
false
)
@Email
private
String
customerEmail
;
private
String
customerEmail
;
private
String
address
;
private
String
address
;
...
@@ -36,12 +31,10 @@ public class Customer implements Serializable {
...
@@ -36,12 +31,10 @@ 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
()
{
...
...
PC27-SklepHibernate/src/main/java/sklep/model/OrderProduct.java
View file @
907e7fbd
...
@@ -2,14 +2,9 @@ package sklep.model;
...
@@ -2,14 +2,9 @@ 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.
...
@@ -25,21 +20,16 @@ public class OrderProduct implements Serializable {
...
@@ -25,21 +20,16 @@ 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"
,
insertable
=
false
,
updatable
=
false
)
@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
...
...
PC27-SklepHibernate/src/main/java/sklep/model/Product.java
View file @
907e7fbd
...
@@ -2,7 +2,6 @@ package sklep.model;
...
@@ -2,7 +2,6 @@ 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
;
...
@@ -24,16 +23,11 @@ public class Product implements Serializable {
...
@@ -24,16 +23,11 @@ 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
()
{
...
...
PC27-SklepHibernate/src/main/java/sklep/przyklady_hibernate/OdczytajJedenProdukt.java
0 → 100644
View file @
907e7fbd
package
sklep
.
przyklady_hibernate
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.EntityManagerFactory
;
import
jakarta.persistence.Persistence
;
import
sklep.model.Product
;
public
class
OdczytajJedenProdukt
{
public
static
void
main
(
String
[]
args
)
{
EntityManagerFactory
emf
=
Persistence
.
createEntityManagerFactory
(
"sklep"
);
EntityManager
em
=
emf
.
createEntityManager
();
System
.
out
.
println
(
"Mam EntityManagera: "
+
em
);
Product
product
=
em
.
find
(
Product
.
class
,
2
);
System
.
out
.
println
(
"Mam obiekt: "
+
product
);
System
.
out
.
println
(
product
.
getProductName
()
+
" za cenę "
+
product
.
getPrice
());
}
}
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