package com.uas.account.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

public class BaseDao {

	@Autowired
	protected JdbcTemplate jdbcTemplate;

	protected int count(String sql, Object... args) {
		return jdbcTemplate.queryForObject(!sql.startsWith("select") ? ("select count(1) " + sql) : sql, Integer.class, args);
	}

	protected Long generateId(String sequenceName) {
		return jdbcTemplate.queryForObject("select " + sequenceName + ".nextval from dual", Long.class);
	}
}
