Skip to content

Instantly share code, notes, and snippets.

@Eragoo
Created November 10, 2019 16:47
Show Gist options
  • Save Eragoo/989534715b2d1276c5fd3370545d5543 to your computer and use it in GitHub Desktop.
Save Eragoo/989534715b2d1276c5fd3370545d5543 to your computer and use it in GitHub Desktop.
package test;
import Entity.StudentsEntity;
import org.hibernate.Session;
public class App {
public static void main(String[] args) {
System.out.println("Hibernate tutorial");
Session session = HibernateSessionFactory.getSessionFactory().openSession();
session.beginTransaction();
StudentsEntity studentsEntity = new StudentsEntity();
short id = 10;
studentsEntity.setId(id);
studentsEntity.setSurname("Ku");
studentsEntity.setName("Eugene");
session.save(studentsEntity);
session.getTransaction().commit();
session.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment