Posts

Showing posts from October, 2023

Spring – ORM Framework

                Spring – ORM Framework Spring-ORM  is a technique or a Design Pattern used to access a relational database from an object-oriented language. ORM (Object Relation Mapping) covers many persistence technologies. They are as follows: JPA(Java Persistence API):  It is mainly used to persist data between Java objects and relational databases. It acts as a bridge between object-oriented domain models and relational database systems. JDO(Java Data Objects):  It is one of the standard ways to access persistent data in databases, by using plain old Java objects (POJO) to represent persistent data. Hibernate –  It is a Java framework that simplifies the development of Java applications to interact with the database. Oracle Toplink, and iBATIS:  Oracle TopLink is a mapping and persistence framework for Java development.

Spring – RowMapper Interface with Example

  RowMapper Example | Fetching records by Spring JdbcTemplate we can use RowMapper interface to fetch the records from the database using  query()  method of  JdbcTemplate  class. In the execute of we need to pass the instance of RowMapper now. Syntax of query method using RowMapper public T query(String sqlQuery, RowMapper<T> rowMapper) RowMapper Interface RowMapper  interface allows to map a row of the relations with the instance of user-defined class. It iterates the ResultSet internally and adds it into the collection. So we don't need to write a lot of code to fetch the records as ResultSetExtractor. Advantage of RowMapper over ResultSetExtractor RowMapper saves a lot of code becuase it internally adds the data of ResultSet into the collection. Method of RowMapper interface It defines only one method mapRow that accepts ResultSet instance and int as the parameter list. Syntax of the method is given below: public T mapRow(ResultSet rs, int rowNumb...