update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
30
.config/Code/User/History/-45886119/QfQb.java
Normal file
30
.config/Code/User/History/-45886119/QfQb.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package com.practice;
|
||||
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
public class Main{
|
||||
public static void main(String[] args){
|
||||
|
||||
Session session = HibernateUtil.getSessionfactory().openSession();
|
||||
Transaction tx = null;
|
||||
try{
|
||||
tx = session.beginTransaction();
|
||||
Student newStudent = new Student(2340, "hassan", 4);
|
||||
session.save(newStudent);
|
||||
tx.commit();
|
||||
}
|
||||
catch(Exception e){
|
||||
if(tx != null){
|
||||
tx.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
session.close();
|
||||
}
|
||||
|
||||
HibernateUtil.shutdown();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue