Need of Spring Data JDBC



Before discussing the topic in detail lets first understand Why do we need this persistence framework, that too when more than 50% of developers use persistence APIs like JPA, to be more precise Hibernate and other JPA implementation. Literally speaking Hibernate and others are great frameworks, they are powerful, have a lot of features like Lazy loading, first and second level cache, dirty checking, etc. But the problem with some of them is that, they increase the complexity of the code on the project side which often gets really confusing. Now the question is how can we reduce this complexity and what are the available alternatives? There are of course many other frameworks available in the market but all come with some or more issues and they leave a lot of work for us if we want to deal with objects, like we have to do mapping by ourselves. Thus here Spring Data JDBC comes into the picture. Spring Data JDBC is simple and easy because there is no session, no caching, and no dirty checking no such concept. When we save an entity use save() method it will execute insert or update, If you do not call explicitly save() method, it does not(There is neither dirty tracking nor session). One important thing to note here is that Spring Data JDBC doesnt support schema generation unlike Hibernate.

Advertisements