-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
150 lines (134 loc) · 4.5 KB
/
Main.java
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.databasePoject;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import java.awt.*;
import java.util.List;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader(getClass().getResource("startApp.fxml"));
Parent root = loader.load();
StartAppController controller = loader.getController();
primaryStage.setTitle("Recruitment App");
Scene scene = new Scene(root, 300, 300);
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.setOnHidden(e -> {
Platform.exit();
});
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
// SessionFactory factory = new Configuration()
// .configure("com/databasePoject/hibernate.cfg.xml")
// .addAnnotatedClass(Student.class)
// .addAnnotatedClass(University.class)
// .addAnnotatedClass(Declaration.class)
// .addAnnotatedClass(FieldOfStudy.class)
// .buildSessionFactory();
//
// Session session = factory.getCurrentSession();
//create
// try{
// System.out.println("Create");
// Student student = new Student("Krzysiek","Maniak",200);
// session.beginTransaction();
// System.out.println("Save");
// session.save(student);
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//read one
// try{
// System.out.println("Read");
// session.beginTransaction();
// System.out.println("Get");
// Student student = session.get(Student.class, 10);
// System.out.println("Student:" + student.getId() + " " + student.getName());
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//query list
// try{
// System.out.println("Query");
// session.beginTransaction();
// System.out.println("Get");
// List<Student> student = session.createQuery("from Student s where s.name like '%Piotr'").getResultList();
// System.out.println("Student:" + student);
// session.getTransaction().commit();
//after commit session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//update
// try{
// System.out.println("Update");
// session.beginTransaction();
// System.out.println("Get");
// Student student = session.get(Student.class, 10);
// student.setName("Kamilos");
// System.out.println("Student:" + student);
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//update for all
// try{
// System.out.println("Update");
// session.beginTransaction();
//
// session.createQuery("update Student set examsScore='155'").executeUpdate();
//
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//delete
// try{
// System.out.println("Delete");
// session.beginTransaction();
//
// Student student = session.get(Student.class,10);
// session.delete(student);
//
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
//delete by query
// try{
// System.out.println("Delete");
// session.beginTransaction();
//
// session.createQuery("delete from Student where id=2");
//
// session.getTransaction().commit();
// System.out.println("Done");
// }
// finally {
// factory.close();
// }
}
}