Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

BDaoImpl.java 본문

JSP/JSP.sideproject

BDaoImpl.java

GAWON 2023. 6. 23. 12:11
package org.joonzis.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.joonzis.mybatis.config.DBService;
import org.joonzis.vo.BVO;

public class BDaoImpl implements BDao{
	// DAO 객체 생성
	private static BDaoImpl instance = null;
	private BDaoImpl() {}
	public static BDaoImpl getInstance() {
		if(instance == null) {
			instance = new BDaoImpl();
		}
		return instance;
	}
	
	// 필드
	private static SqlSession sqlsession = null;
	private synchronized static SqlSession getSqlSession() {
		if(sqlsession == null) {
			sqlsession = DBService.getFactory().openSession(false);
		}
		return sqlsession;
	}
	
	
	@Override
	public int getTotalRecordCount() {
		return getSqlSession().selectOne("total_count_of_bbs");
	}
	
	@Override
	public List<BVO> getList(Map<String, Integer> map) {
		return getSqlSession().selectList("select_by_map", map);
	}
	@Override
	public BVO getBBS(int b_idx) {
		return getSqlSession().selectOne("bbs_by_idx", b_idx);
	}	
	@Override
	public void getUpdateHit(BVO bvo) {
		getSqlSession().update("update_hit", bvo);
	}
	@Override
	public int getInsertBBS(BVO bvo) {
		int result = getSqlSession().insert("insert_bbs",bvo);
		if(result > 0) {
			getSqlSession().commit();
		}
		return result;
	}
	@Override
	public void updateBBS(BVO bvo) {
		getSqlSession().update("update_bbs",bvo);
	}
	@Override
	public int removeBBS(int b_idx) {
		int result = getSqlSession().delete("delete_bbs",b_idx);
		if(result > 0) {
			getSqlSession().commit();
		}
		return result;
	}
	
}

'JSP > JSP.sideproject' 카테고리의 다른 글

CDaoImpl.java  (0) 2023.06.23
CDao.java  (0) 2023.06.23
BDao.java  (0) 2023.06.23
MemberController.java  (0) 2023.06.23
BBSController.java  (0) 2023.06.23