/*
 * 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 sikd.ikonsol.ejb.session;

import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import sikd.ikonsol.ejb.dao.PemdaWilayahDao;
import sikd.ikonsol.model.PemdaWilayah;
import sikd.sikd5.sikd5ejb.session.util.MyBatisConnectionFactory;
import sikd.sikd5.sikd5ejb.session.util.MyBatisConnectionFactoryIKonsol;

/**
 *
 * @author Imam Bhoim
 */
@Stateless
public class PemdaWilayahEjbHomeImpl implements PemdaWilayahEjbHome {

     private SqlSessionFactory sqlSessionFactory;
    private SqlSession session = null;

    private PemdaWilayahDao dao;

    @PostConstruct
    public void init() {
        try {
            System.out.println("-------- Load MyBatis Factory IKonsol ------- ");
            sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactoryIkonsol();
            dao = new PemdaWilayahDao(sqlSessionFactory);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    
    @Override
    public List<PemdaWilayah> findAll() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
       return dao.findAll();
    }

    @Override
    public PemdaWilayah findByID(int id) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public PemdaWilayah createNew() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    return new PemdaWilayah();
    }

    @Override
    public PemdaWilayah save(PemdaWilayah obj) {
       // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    return dao.save(obj);
    }

    @Override
    public PemdaWilayah findByKode(String kode) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public PemdaWilayah update(PemdaWilayah obj) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void delete(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
     dao.deleteByID(id);
    }

    @Override
    public List<PemdaWilayah> findListById(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.findListById(id);
    }
    
}
