Created
October 28, 2017 17:48
-
-
Save dnaismyth/7fe0def16462a1437ce32ed42a639dae to your computer and use it in GitHub Desktop.
Base JDBC parent class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.sql.DataSource; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.core.env.Environment; | |
| import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | |
| import org.springframework.stereotype.Repository; | |
| import org.springframework.transaction.annotation.Transactional; | |
| @Repository | |
| @Transactional | |
| public class BaseJDBCRepository { | |
| @Autowired | |
| private Environment environment; | |
| protected NamedParameterJdbcTemplate jdbcTemplate; | |
| @Autowired | |
| public void setDataSource(DataSource dataSource){ | |
| this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); | |
| } | |
| public String readQueryFromProperties(String query){ | |
| return environment.getProperty(query); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment