test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
33
.config/Code/User/History/5ec1824c/OH6B.java
Normal file
33
.config/Code/User/History/5ec1824c/OH6B.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package com.practice;
|
||||
|
||||
import javax.transaction.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();
|
||||
}
|
||||
catch(Exception e){
|
||||
if(tx != null){
|
||||
tx.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
session.close();
|
||||
}
|
||||
Student arqam = new Student(232608, "Arqam Zulfiqar", 2.1);
|
||||
System.out.println("Arqam Made\n");
|
||||
session.save(arqam);
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
System.out.println("Arqam Saved\n");
|
||||
|
||||
HibernateUtil.shutdown();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue