Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package DAO; import Modelo.Administrador; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; /** * * @author rae */ public class AdministradorDAOImpl implements AdministradorDAO { private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } @Override public void create(Administrador administrador) { Session session = this.sessionFactory.openSession(); Transaction tx = session.beginTransaction(); session.persist(administrador); tx.commit(); session.close(); } }