Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java2b_20250412
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
alx_java2b_20250412
Commits
88e70a7a
Commit
88e70a7a
authored
May 31, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adnotacje jakarta.validation
parent
c17065bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
Customer.java
PC37-SklepSpring/src/main/java/sklep/model/Customer.java
+4
-0
OrderProduct.java
PC37-SklepSpring/src/main/java/sklep/model/OrderProduct.java
+3
-0
Product.java
PC37-SklepSpring/src/main/java/sklep/model/Product.java
+8
-3
No files found.
PC37-SklepSpring/src/main/java/sklep/model/Customer.java
View file @
88e70a7a
package
sklep
.
model
;
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Email
;
import
jakarta.validation.constraints.Pattern
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -10,6 +12,7 @@ import java.util.Set;
...
@@ -10,6 +12,7 @@ import java.util.Set;
public
class
Customer
{
public
class
Customer
{
@Id
@Id
@Column
(
name
=
"customer_email"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"customer_email"
,
nullable
=
false
,
length
=
100
)
@Email
private
String
customerEmail
;
private
String
customerEmail
;
@Column
(
name
=
"customer_name"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"customer_name"
,
nullable
=
false
,
length
=
100
)
...
@@ -22,6 +25,7 @@ public class Customer {
...
@@ -22,6 +25,7 @@ public class Customer {
private
String
address
;
private
String
address
;
@Column
(
name
=
"postal_code"
,
length
=
10
)
@Column
(
name
=
"postal_code"
,
length
=
10
)
@Pattern
(
regexp
=
"[0-9]{2}-[0-9]{3}"
)
private
String
postalCode
;
private
String
postalCode
;
@Column
(
name
=
"city"
,
length
=
100
)
@Column
(
name
=
"city"
,
length
=
100
)
...
...
PC37-SklepSpring/src/main/java/sklep/model/OrderProduct.java
View file @
88e70a7a
package
sklep
.
model
;
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Min
;
import
org.hibernate.annotations.ColumnDefault
;
import
org.hibernate.annotations.ColumnDefault
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -23,6 +25,7 @@ public class OrderProduct {
...
@@ -23,6 +25,7 @@ public class OrderProduct {
@ColumnDefault
(
"1"
)
@ColumnDefault
(
"1"
)
@Column
(
name
=
"quantity"
,
nullable
=
false
)
@Column
(
name
=
"quantity"
,
nullable
=
false
)
@Min
(
1
)
private
Short
quantity
;
private
Short
quantity
;
@Column
(
name
=
"actual_price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
@Column
(
name
=
"actual_price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
...
...
PC37-SklepSpring/src/main/java/sklep/model/Product.java
View file @
88e70a7a
package
sklep
.
model
;
package
sklep
.
model
;
import
jakarta.persistence.*
;
import
org.hibernate.annotations.ColumnDefault
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.*
;
@Entity
@Entity
@Table
(
name
=
"products"
)
@Table
(
name
=
"products"
)
@NamedQuery
(
name
=
"Product.findAll"
,
query
=
"SELECT p FROM Product p ORDER BY p.id"
)
@NamedQuery
(
name
=
"Product.findAll"
,
query
=
"SELECT p FROM Product p ORDER BY p.id"
)
...
@@ -15,12 +15,17 @@ public class Product {
...
@@ -15,12 +15,17 @@ public class Product {
private
Integer
id
;
private
Integer
id
;
@Column
(
name
=
"product_name"
,
nullable
=
false
,
length
=
100
)
@Column
(
name
=
"product_name"
,
nullable
=
false
,
length
=
100
)
@NotBlank
@Size
(
min
=
1
,
max
=
20
)
private
String
productName
;
private
String
productName
;
@Column
(
name
=
"price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
@Column
(
name
=
"price"
,
nullable
=
false
,
precision
=
10
,
scale
=
2
)
@DecimalMin
(
"0.01"
)
@DecimalMax
(
"99999.99"
)
private
BigDecimal
price
;
private
BigDecimal
price
;
@Column
(
name
=
"vat"
,
precision
=
2
,
scale
=
2
)
@Column
(
name
=
"vat"
,
precision
=
2
,
scale
=
2
)
@Min
(
0
)
private
BigDecimal
vat
;
private
BigDecimal
vat
;
@Column
(
name
=
"description"
,
length
=
Integer
.
MAX_VALUE
)
@Column
(
name
=
"description"
,
length
=
Integer
.
MAX_VALUE
)
...
...
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