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 be.facet.it.dojo.customershibernate.repository; import be.facet.it.dojo.customershibernate.domain.Product; import org.hibernate.Session; /** * * @author Beheerder */ public class ProductRepository extends AbstractRepository<Product> { @Override public void save(Product entity) { Session session = this.startTransaction(); session.save(entity); this.stopTransaction(session); } @Override public Product fetchById(long id) { Session session = this.sessionFactory.openSession(); Product product = session.get(Product.class, id); session.close(); return product; } }