Search code examples
springspring-bootspring-jdbcspring-data-jdbc

Is it a must to use spring-data-jdbc when using JdbcTemplate?


I am planning to use Spring JdbcTemplate to access my database. Is it a must to use spring-data-jdbc when using JdbcTemplate? The reason I am asking is I don't need "entity"(POJO) for my table in my application. Would it add some overheads if I use spring-data-jdbc?


Solution

  • You can use the JdbcTemplate without Spring Data JDBC without a problem. JdbcTemplate existed for many years before Spring Data JDBC was conceived.

    Spring Data JDBC does involve an overhead. It extracts data from POJOs, creates queries and transforms the result back to POJOs. Of course all that takes resources. If you don't need/benefit from it don't use it.

    You can also start with JdbcTemplate and later start using Spring Data JDBC without a problem if the need arises.