Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_mszczonow_2
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_mszczonow_2
Commits
e9a3f138
Commit
e9a3f138
authored
Jul 25, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Program czytający Employee wg id
parent
08b4106f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
+32
-1
P01_OdczytajWgId.java
src/main/java/programy/P01_OdczytajWgId.java
+31
-0
persistence.xml
src/main/resources/META-INF/persistence.xml
+1
-1
No files found.
src/main/java/programy/P01_OdczytajWgId.java
0 → 100644
View file @
e9a3f138
package
programy
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.EntityManagerFactory
;
import
jakarta.persistence.Persistence
;
import
model.Employee
;
public
class
P01_OdczytajWgId
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Startujemy..."
);
EntityManagerFactory
emf
=
Persistence
.
createEntityManagerFactory
(
"hr_postgresql"
);
EntityManager
em
=
emf
.
createEntityManager
();
System
.
out
.
println
(
"Mam EntityManagera: "
+
em
);
Integer
id
=
103
;
Employee
emp
=
em
.
find
(
Employee
.
class
,
id
);
System
.
out
.
println
(
"Odczytany obiekt: "
+
emp
);
if
(
emp
!=
null
)
{
System
.
out
.
printf
(
"%s %s (%s) zarabia %s\n"
,
emp
.
getFirstName
(),
emp
.
getLastName
(),
emp
.
getJob
().
getJobTitle
(),
emp
.
getSalary
());
}
em
.
close
();
emf
.
close
();
System
.
out
.
println
(
"Koniec"
);
}
}
src/main/resources/META-INF/persistence.xml
View file @
e9a3f138
<?xml version="1.0" encoding="UTF-8"?>
<?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=
"
alx_mszczonow_2
"
transaction-type=
"RESOURCE_LOCAL"
>
<persistence-unit
name=
"
hr_postgresql
"
transaction-type=
"RESOURCE_LOCAL"
>
<class>
model.Country
</class>
<class>
model.Country
</class>
<class>
model.Department
</class>
<class>
model.Department
</class>
<class>
model.Employee
</class>
<class>
model.Employee
</class>
...
...
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