package DAO;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import Bean.HibernateSessionFactory;
import Bean.User;
public class UserDAO {
public static void insertUser(User user) {
Transaction tx = null;
try {
Session session = HibernateSessionFactory.getSessionFactory()
.openSession();
tx = session.beginTransaction();
session.save(user);
tx.commit();
} catch (HibernateException e) {
e.printStackTrace();
tx.rollback();
}
HibernateSessionFactory.closeSession();
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import Bean.HibernateSessionFactory;
import Bean.User;
public class UserDAO {
public static void insertUser(User user) {
Transaction tx = null;
try {
Session session = HibernateSessionFactory.getSessionFactory()
.openSession();
tx = session.beginTransaction();
session.save(user);
tx.commit();
} catch (HibernateException e) {
e.printStackTrace();
tx.rollback();
}
HibernateSessionFactory.closeSession();
}//add