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 com.inventory.system.dao; import com.inventory.system.model.Admin; import com.inventory.system.model.AuditTrail; import com.inventory.system.utils.HibernateBDUtil; import java.util.Date; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.Transaction; import org.springframework.stereotype.Repository; /** * * @author Abiodun.Ayeola */ @Repository("auditTrailDAO") public class AuditTrailDAOImpl extends AdminDAOImpl implements AuditTrailDAO { @Override public AuditTrail addTrail(AuditTrail trail) { Session session = HibernateBDUtil.getSessionFactory().openSession(); Transaction tx = null; try { tx = session.beginTransaction(); session.saveOrUpdate(trail); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); ex.printStackTrace(); } } finally { session.close(); } return trail; } @Override public List<AuditTrail> fetchAuditTrail() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<AuditTrail> fetchAuditByDateRange(Date fromDate, Date toDate) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Admin findUserByUsername(String username) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }