FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/HibernateInheritance/src/EnterPoint.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
HibernateInheritance
/
src
/
EnterPoint.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
47 lines (37 loc) · 1.14 KB
Breadcrumbs
java-code-example
/
HibernateInheritance
/
src
/
EnterPoint.java
Copy path
File metadata and controls
executable file
·
47 lines (37 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import
java
.
util
.
List
;
import
org
.
apache
.
log4j
.
BasicConfigurator
;
import
org
.
hibernate
.
Session
;
import
org
.
hibernate
.
SessionFactory
;
import
org
.
hibernate
.
cfg
.
Configuration
;
import
database
.
Boy
;
import
database
.
Girl
;
import
database
.
Parent
;
public
class
EnterPoint
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
BasicConfigurator
.
configure
();
Configuration
config
=
new
Configuration
();
config
.
configure
(
"hibernate.cfg.xml"
);
SessionFactory
sessions
=
config
.
buildSessionFactory
();
Session
session
=
sessions
.
openSession
();
Girl
girl
=
new
Girl
();
girl
.
setId
(
1
);
girl
.
setName
(
"Olga"
);
girl
.
setGirlSkills
(
"nitting"
);
Boy
boy
=
new
Boy
();
boy
.
setId
(
1
);
boy
.
setName
(
"Kolya"
);
boy
.
setBoySkills
(
"struglle"
);
session
.
beginTransaction
();
session
.
save
(
boy
);
session
.
save
(
girl
);
session
.
getTransaction
().
commit
();
session
.
close
();
session
=
sessions
.
openSession
();
List
<
Parent
>
parentList
=
session
.
createCriteria
(
Parent
.
class
).
list
();
for
(
Parent
value
:
parentList
){
System
.
out
.
println
(
"Value:"
+
value
.
toString
());
}
session
.
close
();
sessions
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL