Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
std_hibernate
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
std_hibernate
Commits
861f7763
Commit
861f7763
authored
Oct 31, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zmiany w wygenerowanych klasach
parent
5af14f61
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
21 deletions
+27
-21
AbstractEntity.java
src/main/java/hr/model/AbstractEntity.java
+8
-0
Country.java
src/main/java/hr/model/Country.java
+1
-1
Department.java
src/main/java/hr/model/Department.java
+4
-4
Employee.java
src/main/java/hr/model/Employee.java
+1
-1
Job.java
src/main/java/hr/model/Job.java
+4
-5
JobHistory.java
src/main/java/hr/model/JobHistory.java
+7
-8
Location.java
src/main/java/hr/model/Location.java
+1
-1
Region.java
src/main/java/hr/model/Region.java
+1
-1
No files found.
src/main/java/hr/model/AbstractEntity.java
0 → 100644
View file @
861f7763
package
hr
.
model
;
/** Wspólna nadklasa dla wszystkich klas encji w tym pakiecie. Miejsce na dodatkowe metody. */
abstract
class
AbstractEntity
{
public
String
hello
()
{
return
"hello"
;
}
}
src/main/java/hr/model/Country.java
View file @
861f7763
...
@@ -4,7 +4,7 @@ import jakarta.persistence.*;
...
@@ -4,7 +4,7 @@ import jakarta.persistence.*;
@Entity
@Entity
@Table
(
name
=
"countries"
)
@Table
(
name
=
"countries"
)
public
class
Country
{
public
class
Country
extends
AbstractEntity
{
@Id
@Id
@Column
(
name
=
"country_id"
,
nullable
=
false
,
length
=
2
)
@Column
(
name
=
"country_id"
,
nullable
=
false
,
length
=
2
)
private
String
countryId
;
private
String
countryId
;
...
...
src/main/java/hr/model/Department.java
View file @
861f7763
...
@@ -8,7 +8,7 @@ import java.util.Set;
...
@@ -8,7 +8,7 @@ import java.util.Set;
@Entity
@Entity
@Table
(
name
=
"departments"
)
@Table
(
name
=
"departments"
)
public
class
Department
{
public
class
Department
extends
AbstractEntity
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ColumnDefault
(
"nextval('departments_seq')"
)
@ColumnDefault
(
"nextval('departments_seq')"
)
...
@@ -26,7 +26,7 @@ public class Department {
...
@@ -26,7 +26,7 @@ public class Department {
private
hr
.
model
.
Location
location
;
private
hr
.
model
.
Location
location
;
@OneToMany
(
mappedBy
=
"department"
)
@OneToMany
(
mappedBy
=
"department"
)
private
Set
<
Integer
>
employees
=
new
LinkedHashSet
<>();
private
Set
<
Employee
>
employees
=
new
LinkedHashSet
<>();
public
Integer
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
...
@@ -60,11 +60,11 @@ public class Department {
...
@@ -60,11 +60,11 @@ public class Department {
this
.
location
=
location
;
this
.
location
=
location
;
}
}
public
Set
<
Integer
>
getEmployees
()
{
public
Set
<
Employee
>
getEmployees
()
{
return
employees
;
return
employees
;
}
}
public
void
setEmployees
(
Set
<
Integer
>
employees
)
{
public
void
setEmployees
(
Set
<
Employee
>
employees
)
{
this
.
employees
=
employees
;
this
.
employees
=
employees
;
}
}
...
...
src/main/java/hr/model/Employee.java
View file @
861f7763
...
@@ -7,7 +7,7 @@ import java.time.LocalDate;
...
@@ -7,7 +7,7 @@ import java.time.LocalDate;
@Entity
@Entity
@Table
(
name
=
"employees"
)
@Table
(
name
=
"employees"
)
public
class
Employee
{
public
class
Employee
extends
AbstractEntity
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
SEQUENCE
,
generator
=
"employees_id_gen"
)
@GeneratedValue
(
strategy
=
GenerationType
.
SEQUENCE
,
generator
=
"employees_id_gen"
)
@SequenceGenerator
(
name
=
"employees_id_gen"
,
sequenceName
=
"employees_seq"
,
initialValue
=
207
,
allocationSize
=
1
)
@SequenceGenerator
(
name
=
"employees_id_gen"
,
sequenceName
=
"employees_seq"
,
initialValue
=
207
,
allocationSize
=
1
)
...
...
src/main/java/hr/model/Job.java
View file @
861f7763
...
@@ -8,9 +8,8 @@ import java.util.Set;
...
@@ -8,9 +8,8 @@ import java.util.Set;
@Entity
@Entity
@Table
(
name
=
"jobs"
)
@Table
(
name
=
"jobs"
)
public
class
Job
{
public
class
Job
extends
AbstractEntity
{
@Id
@Id
@SequenceGenerator
(
name
=
"jobs_id_gen"
,
sequenceName
=
"employees_seq"
,
initialValue
=
207
,
allocationSize
=
1
)
@Column
(
name
=
"job_id"
,
nullable
=
false
,
length
=
10
)
@Column
(
name
=
"job_id"
,
nullable
=
false
,
length
=
10
)
private
String
jobId
;
private
String
jobId
;
...
@@ -24,7 +23,7 @@ public class Job {
...
@@ -24,7 +23,7 @@ public class Job {
private
BigDecimal
maxSalary
;
private
BigDecimal
maxSalary
;
@OneToMany
(
mappedBy
=
"job"
)
@OneToMany
(
mappedBy
=
"job"
)
private
Set
<
Integer
>
employees
=
new
LinkedHashSet
<>();
private
Set
<
Employee
>
employees
=
new
LinkedHashSet
<>();
public
String
getJobId
()
{
public
String
getJobId
()
{
return
jobId
;
return
jobId
;
...
@@ -58,11 +57,11 @@ public class Job {
...
@@ -58,11 +57,11 @@ public class Job {
this
.
maxSalary
=
maxSalary
;
this
.
maxSalary
=
maxSalary
;
}
}
public
Set
<
Integer
>
getEmployees
()
{
public
Set
<
Employee
>
getEmployees
()
{
return
employees
;
return
employees
;
}
}
public
void
setEmployees
(
Set
<
Integer
>
employees
)
{
public
void
setEmployees
(
Set
<
Employee
>
employees
)
{
this
.
employees
=
employees
;
this
.
employees
=
employees
;
}
}
...
...
src/main/java/hr/model/JobHistory.java
View file @
861f7763
...
@@ -6,22 +6,21 @@ import java.time.LocalDate;
...
@@ -6,22 +6,21 @@ import java.time.LocalDate;
@Entity
@Entity
@Table
(
name
=
"job_history"
)
@Table
(
name
=
"job_history"
)
public
class
JobHistory
{
public
class
JobHistory
extends
AbstractEntity
{
@SequenceGenerator
(
name
=
"job_history_id_gen"
,
sequenceName
=
"employees_seq"
,
initialValue
=
207
,
allocationSize
=
1
)
@EmbeddedId
@EmbeddedId
private
JobHistoryId
id
;
private
JobHistoryId
id
;
@MapsId
(
"employeeId"
)
@MapsId
(
"employeeId"
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@JoinColumn
(
name
=
"employee_id"
,
nullable
=
false
)
@JoinColumn
(
name
=
"employee_id"
,
nullable
=
false
)
private
Integer
employee
;
private
Employee
employee
;
@Column
(
name
=
"end_date"
,
nullable
=
false
)
@Column
(
name
=
"end_date"
,
nullable
=
false
)
private
LocalDate
endDate
;
private
LocalDate
endDate
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@JoinColumn
(
name
=
"job_id"
,
nullable
=
false
)
@JoinColumn
(
name
=
"job_id"
,
nullable
=
false
)
private
hr
.
model
.
Job
job
;
private
Job
job
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JoinColumn
(
name
=
"department_id"
)
@JoinColumn
(
name
=
"department_id"
)
...
@@ -35,11 +34,11 @@ public class JobHistory {
...
@@ -35,11 +34,11 @@ public class JobHistory {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
Integer
getEmployee
()
{
public
Employee
getEmployee
()
{
return
employee
;
return
employee
;
}
}
public
void
setEmployee
(
Integer
employee
)
{
public
void
setEmployee
(
Employee
employee
)
{
this
.
employee
=
employee
;
this
.
employee
=
employee
;
}
}
...
@@ -51,11 +50,11 @@ public class JobHistory {
...
@@ -51,11 +50,11 @@ public class JobHistory {
this
.
endDate
=
endDate
;
this
.
endDate
=
endDate
;
}
}
public
hr
.
model
.
Job
getJob
()
{
public
Job
getJob
()
{
return
job
;
return
job
;
}
}
public
void
setJob
(
hr
.
model
.
Job
job
)
{
public
void
setJob
(
Job
job
)
{
this
.
job
=
job
;
this
.
job
=
job
;
}
}
...
...
src/main/java/hr/model/Location.java
View file @
861f7763
...
@@ -5,7 +5,7 @@ import org.hibernate.annotations.ColumnDefault;
...
@@ -5,7 +5,7 @@ import org.hibernate.annotations.ColumnDefault;
@Entity
@Entity
@Table
(
name
=
"locations"
)
@Table
(
name
=
"locations"
)
public
class
Location
{
public
class
Location
extends
AbstractEntity
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ColumnDefault
(
"nextval('locations_seq')"
)
@ColumnDefault
(
"nextval('locations_seq')"
)
...
...
src/main/java/hr/model/Region.java
View file @
861f7763
...
@@ -7,7 +7,7 @@ import jakarta.persistence.Table;
...
@@ -7,7 +7,7 @@ import jakarta.persistence.Table;
@Entity
@Entity
@Table
(
name
=
"regions"
)
@Table
(
name
=
"regions"
)
public
class
Region
{
public
class
Region
extends
AbstractEntity
{
@Id
@Id
@Column
(
name
=
"region_id"
,
nullable
=
false
)
@Column
(
name
=
"region_id"
,
nullable
=
false
)
private
Integer
id
;
private
Integer
id
;
...
...
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