package com.hbtest.model;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
import com.hbtest.model.Student;
public class StudentTest {
@Test
public void testStudentSave(){ Student s = new Student();
s.setName("s1");
s.setAge(1);
s.setId(5);
Configuration cfg = new Configuration();
SessionFactory sf = cfg.configure().buildSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
session.save(s);
session.getTransaction().commit();
session.close();
sf.close();
}
}