package com.rizki.mufrizal.aplikasi.inventory.repository.impl;

import com.rizki.mufrizal.aplikasi.inventory.domain.Barang;
import com.rizki.mufrizal.aplikasi.inventory.repository.BarangRepository;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 *
 * @Author Rizki Mufrizal <mufrizalrizki@gmail.com>
 * @Since Mar 18, 2016
 * @Time 10:54:00 PM
 * @Encoding UTF-8
 * @Project Aplikasi-Inventory
 * @Package com.rizki.mufrizal.aplikasi.inventory.repository.impl
 *
 */
@Repository
public class BarangRepositoryImpl implements BarangRepository {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public void simpanBarang(Barang barang) {
        sessionFactory.getCurrentSession().save(barang);
    }

    @Override
    public void editBarang(Barang barang) {
        sessionFactory.getCurrentSession().update(barang);
    }

    @Override
    public void hapusBarang(Barang barang) {
        sessionFactory.getCurrentSession().delete(barang);
    }

    @Override
    public List<Barang> ambilBarangs() {
        return sessionFactory.getCurrentSession().createCriteria(Barang.class).list();
    }

}

@@ -1129,34 +1129,224 @@
 lic 
-List%3CBarang%3E ambilBarangs(
+Integer jumlahBarang() %7B%0A        return sessionFactory.getCurrentSession().createCriteria(Barang.class).list().size();%0A    %7D%0A%0A    @Override%0A    public List%3CBarang%3E ambilBarangs(Integer pageNumber, Integer rowsPerPage
 ) %7B%0A
@@ -1366,32 +1366,49 @@
 n sessionFactory
+%0A                
 .getCurrentSessi
@@ -1403,32 +1403,49 @@
 CurrentSession()
+%0A                
 .createCriteria(
@@ -1453,24 +1453,149 @@
 arang.class)
+%0A                .setFirstResult(rowsPerPage * (pageNumber - 1))%0A                .setMaxResults(rowsPerPage)%0A                
 .list();%0A   

update barang repository impl