Spring Transaction

Spring Programmatic Transaction Management

<p>In this article&comma; we will explore about programmatic transaction management&period; This means that you have manage the transaction with the help of programming&period; That gives you extreme flexibility&comma; but it is difficult to maintain&period;<&sol;p>&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<h2><b>Programmatic transaction management<&sol;b><&sol;h2>&NewLine;<p>It is usually a good idea only if you have a small number of transactional operations&period; For example&comma; if you have a web application that require transactions only for certain update operations&comma; you may not want to set up transactional proxies using Spring or any other technology&period; In this case&comma; using the TransactionTemplate may be a good approach&period; Being able to set the transaction name explicitly is also something that can only be done using the programmatic approach to transaction management&period;<&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border&colon; 1px solid &num;c9e6f2&semi; border-radius&colon; 3px&semi; padding&colon; 16px&semi; line-height&colon; 1&period;45&semi;">&NewLine;<p><span style&equals;"color&colon; red&semi; font-size&colon; x-large&semi; text-align&colon; center&semi;"><b>Popular Tutorials<&sol;b><&sol;span><&sol;p>&NewLine;<ul style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-tutorial&sol;"><em><strong>Spring Tutorial<&sol;strong> <&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-web-mvc-framework-chapter-38&sol;"><strong><em>Spring MVC Web Tutorial <&sol;em><&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;"><strong>Spring Boot Tutorial<&sol;strong> <&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-take-baby-step-to-secure&sol;"><em>Spring Security Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint&sol;"><em>Spring AOP Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;using-spring-jdbc-framework-chapter-32&sol;"><em>Spring JDBC Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-hateoas-hypermedia-driven-restful-web-service&sol;"><em><strong>Spring HATEOAS <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;microservices-with-spring-boot&sol;"><em><strong>Microservices with Spring Boot<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jax-rs-web-service-tutorial&sol;"><strong><em>REST Webservice<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;core-java-baby-step-to-be-best-java-ian&sol;"><em><strong>Core Java <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hibernate-3-on-baby-steps&sol;"><em><strong>Hibernate Tutorial<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-batch-process-with-example&sol;"><strong><em>Spring Batch<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;div>&NewLine;<p>On the other hand&comma; if your application has numerous transactional operations&comma; declarative transaction management is usually worthwhile&period; It keeps transaction management out of business logic&comma; and is not difficult to configure&period; When using the Spring Framework&comma; rather than EJB CMT&comma; the configuration cost of declarative transaction management is greatly reduced&period;<&sol;p>&NewLine;<p>Let us see how above mentioned steps work but before we begin&comma; it is important to have at least one database tables on which we can perform various CRUD operations with the help of transactions&period; Let us take <b>Employee <&sol;b>table&comma; which can be created in MySQL <b>DAVDB <&sol;b>database with the following DDL&colon;<&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">CREATE TABLE Employee&lpar; &NewLine; EMPID INT NOT NULL AUTO&lowbar;INCREMENT&comma; &NewLine; NAME VARCHAR&lpar;26&rpar; NOT NULL&comma; &NewLine; AGE INT NOT NULL&comma; &NewLine; SALARY BIGINT NOT NULL&comma; &NewLine; PRIMARY KEY &lpar;EMPID&rpar; &NewLine;&rpar;&semi; &NewLine;<&sol;pre>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<p>1&period; Create a project with a name <b>SpringTMDemo <&sol;b>and create a package<i><b> com&period;dineshonjava&period;sdnext<&sol;b><&sol;i> under the <b>src <&sol;b>folder in the created project&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2012&sol;12&sol;TransactionManagement-1&period;jpg" border&equals;"0" &sol;><&sol;div>&NewLine;<p><b>2&period;<&sol;b> Add required Spring libraries using <b><i>Add User Libs<&sol;i> <&sol;b>option as explained in the <i>S<b>pring Hello World Example<&sol;b><&sol;i> chapter&period;<br &sol;>&NewLine;3<i><b>&period;<&sol;b><&sol;i> Add other required libraries <b><i>mysql-connector-java&period;jar<&sol;i><&sol;b><br &sol;>&NewLine;4&period;Create DAO interface <i><b>EmpDAO <&sol;b><&sol;i>and list down all the required methods&period; Though it is not required and you can directly write <i><b>EmployeeDaoImpl <&sol;b><&sol;i>class&comma; but as a good practice&comma; let&&num;8217&semi;s do it&period;<br &sol;>&NewLine;<b>EmpDAO&period;java<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;dao&semi; &NewLine; &NewLine;import java&period;util&period;List&semi; &NewLine; &NewLine;import com&period;dineshonjava&period;sdnext&period;domain&period;Employee&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public interface EmpDao &lbrace; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; This is the method to be used to create &NewLine; &ast; a record in the Employee table&period; &NewLine; &ast;&sol; &NewLine; void create&lpar;String name&comma; Integer age&comma; Long salary&rpar;&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; This is the method to be used to list down &NewLine; &ast; a record from the Employee table corresponding &NewLine; &ast; to a passed Employee id&period; &NewLine; &ast;&sol; &NewLine; Employee getEmployee&lpar;Integer empid&rpar;&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; This is the method to be used to list down &NewLine; &ast; all the records from the Employee table&period; &NewLine; &ast;&sol; &NewLine; List listEmployees&lpar;&rpar;&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; This is the method to be used to delete &NewLine; &ast; a record from the Employee table corresponding &NewLine; &ast; to a passed Employee id&period; &NewLine; &ast;&sol; &NewLine; void delete&lpar;Integer empid&rpar;&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; This is the method to be used to update &NewLine; &ast; a record into the Employee table&period; &NewLine; &ast;&sol; &NewLine; void update&lpar;Integer empid&comma; Integer age&rpar;&semi; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p><b>EmployeeDaoImpl&period;java<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;dao&period;impl&semi; &NewLine; &NewLine;import java&period;util&period;List&semi; &NewLine; &NewLine;import org&period;springframework&period;dao&period;DataAccessException&semi; &NewLine;import org&period;springframework&period;jdbc&period;core&period;support&period;JdbcDaoSupport&semi; &NewLine;import org&period;springframework&period;stereotype&period;Component&semi; &NewLine;import org&period;springframework&period;transaction&period;PlatformTransactionManager&semi; &NewLine;import org&period;springframework&period;transaction&period;TransactionDefinition&semi; &NewLine;import org&period;springframework&period;transaction&period;TransactionStatus&semi; &NewLine;import org&period;springframework&period;transaction&period;support&period;DefaultTransactionDefinition&semi; &NewLine; &NewLine;import com&period;dineshonjava&period;sdnext&period;dao&period;EmpDao&semi; &NewLine;import com&period;dineshonjava&period;sdnext&period;domain&period;Employee&semi; &NewLine;import com&period;dineshonjava&period;sdnext&period;jdbc&period;utils&period;EmployeeMapper&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;&commat;Component &NewLine;public class EmployeeDaoImpl extends JdbcDaoSupport implements EmpDao &lbrace; &NewLine;&sol;&sol; &commat;Autowired &NewLine;&sol;&sol; private JdbcTemplate jdbcTemplateObject&semi; &NewLine;&sol;&sol; &NewLine;&sol;&sol; &sol;&ast;&ast; &NewLine;&sol;&sol; &ast; &commat;param jdbcTemplateObject the jdbcTemplateObject to set &NewLine;&sol;&sol; &ast;&sol; &NewLine;&sol;&sol; public void setJdbcTemplateObject&lpar;JdbcTemplate jdbcTemplateObject&rpar; &lbrace; &NewLine;&sol;&sol; this&period;jdbcTemplateObject &equals; jdbcTemplateObject&semi; &NewLine;&sol;&sol; &rcub; &NewLine; &NewLine;private PlatformTransactionManager transactionManage&semi; &NewLine; &NewLine; public void setTransactionManager&lpar; &NewLine; PlatformTransactionManager transactionManager&rpar; &lbrace; &NewLine; this&period;transactionManager &equals; transactionManager&semi; &NewLine; &rcub; &NewLine; &NewLine;&commat;Override &NewLine;public void create&lpar;String name&comma; Integer age&comma; Long salary&rpar; &lbrace; &NewLine; TransactionDefinition def &equals; new DefaultTransactionDefinition&lpar;&rpar;&semi; &NewLine; TransactionStatus status &equals; transactionManager&period;getTransaction&lpar;def&rpar;&semi; &NewLine;try &lbrace; &NewLine; String SQL &equals; "INSERT INTO Employee &lpar;name&comma; age&comma; salary&rpar; VALUES &lpar;&quest;&comma; &quest;&comma; &quest;&rpar;"&semi; &NewLine; getJdbcTemplate&lpar;&rpar;&period;update&lpar;SQL&comma; new Object&lbrack;&rsqb;&lbrace;name&comma; age&comma; salary&rcub; &rpar;&semi; &NewLine; transactionManager&period;commit&lpar;status&rpar;&semi; &NewLine;System&period;out&period;println&lpar;"Created Record Name &equals; " &plus; name &plus; " Age &equals; " &plus; age&plus; " Salary &equals; " &plus; salary&rpar;&semi; &NewLine; &sol;&sol; to simulate the exception&period; &NewLine; throw new RuntimeException&lpar;"simulate Error condition"&rpar; &semi; &NewLine; &rcub; catch &lpar;DataAccessException e&rpar; &lbrace; &NewLine; System&period;out&period;println&lpar;"Error in creating record&comma; rolling back"&rpar;&semi; &NewLine; transactionManager&period;rollback&lpar;status&rpar;&semi; &NewLine; throw e&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine; &NewLine; &commat;Override &NewLine; public Employee getEmployee&lpar;Integer empid&rpar; &lbrace; &NewLine; String SQL &equals; "SELECT &ast; FROM Employee WHERE empid &equals; &quest;"&semi; &NewLine; Employee employee &equals; &lpar;Employee&rpar; getJdbcTemplate&lpar;&rpar;&period;queryForObject&lpar;SQL&comma; new Object&lbrack;&rsqb;&lbrace;empid&rcub;&comma; new EmployeeMapper&lpar;&rpar;&rpar;&semi; &NewLine; return employee&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public List listEmployees&lpar;&rpar; &lbrace; &NewLine; String SQL &equals; "SELECT &ast; FROM Employee"&semi; &NewLine; List employees &equals; &lpar;List&rpar; getJdbcTemplate&lpar;&rpar;&period;query&lpar;SQL&comma; new EmployeeMapper&lpar;&rpar;&rpar;&semi; &NewLine; return null&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public void delete&lpar;Integer empid&rpar; &lbrace; &NewLine; String SQL &equals; "DELETE FROM Employee WHERE empid &equals; &quest;"&semi; &NewLine; getJdbcTemplate&lpar;&rpar;&period;update&lpar;SQL&comma; new Object&lbrack;&rsqb;&lbrace;empid&rcub;&rpar;&semi; &NewLine; System&period;out&period;println&lpar;"Deleted Record with EMPID &equals; " &plus; empid &rpar;&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public void update&lpar;Integer empid&comma; Integer age&rpar; &lbrace; &NewLine; String SQL &equals; "UPDATE Employee SET age &equals; &quest; WHERE empid &equals; &quest;"&semi; &NewLine; getJdbcTemplate&lpar;&rpar;&period;update&lpar;SQL&comma; new Object&lbrack;&rsqb;&lbrace;age&comma; empid&rcub;&rpar;&semi; &NewLine; System&period;out&period;println&lpar;"Updated Record with EMPID &equals; " &plus; empid &rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p>5&period; Create other required Java classes <b>Employee&comma; EmployeeMapper and EmpMainApp<&sol;b> under the <i><b>com&period;dineshonjava&period;sdnext<&sol;b><&sol;i> package&period; You can create rest of the POJO classes if required&period;<br &sol;>&NewLine;<b>Employee&period;java<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;domain&semi; &NewLine; &NewLine; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &NewLine; &ast; &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine;public class Employee &lbrace; &NewLine; &NewLine; private int empid&semi; &NewLine; &NewLine; private String name&semi; &NewLine; &NewLine; private int age&semi; &NewLine; &NewLine; private long salary&semi; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;return the empid &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public int getEmpid&lpar;&rpar; &lbrace; &NewLine; &NewLine; return empid&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;param empid the empid to set &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public void setEmpid&lpar;int empid&rpar; &lbrace; &NewLine; &NewLine; this&period;empid &equals; empid&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;return the name &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public String getName&lpar;&rpar; &lbrace; &NewLine; &NewLine; return name&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;param name the name to set &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public void setName&lpar;String name&rpar; &lbrace; &NewLine; &NewLine; this&period;name &equals; name&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;return the age &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public int getAge&lpar;&rpar; &lbrace; &NewLine; &NewLine; return age&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;param age the age to set &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public void setAge&lpar;int age&rpar; &lbrace; &NewLine; &NewLine; this&period;age &equals; age&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;return the salary &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public long getSalary&lpar;&rpar; &lbrace; &NewLine; &NewLine; return salary&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &NewLine; &ast; &commat;param salary the salary to set &NewLine; &NewLine; &ast;&sol; &NewLine; &NewLine; public void setSalary&lpar;long salary&rpar; &lbrace; &NewLine; &NewLine; this&period;salary &equals; salary&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine; public String toString&lpar;&rpar;&lbrace; &NewLine; &NewLine; return "EMPLOYEE&lbrace;empid- "&plus;this&period;empid&plus;" name- "&plus;this&period;name&plus; &NewLine; &NewLine; " age- "&plus;this&period;age&plus;" salary- "&plus;this&period;salary&plus;"&rcub;"&semi; &NewLine; &NewLine; &rcub; &NewLine; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p><b>EmployeeMapper&period;java<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;jdbc&period;utils&semi; &NewLine; &NewLine;import java&period;sql&period;ResultSet&semi; &NewLine;import java&period;sql&period;SQLException&semi; &NewLine; &NewLine;import org&period;springframework&period;jdbc&period;core&period;RowMapper&semi; &NewLine; &NewLine;import com&period;dineshonjava&period;sdnext&period;domain&period;Employee&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class EmployeeMapper implements RowMapper &lbrace; &NewLine; public Employee mapRow&lpar;ResultSet rs&comma; int rowNum&rpar; throws SQLException &lbrace; &NewLine; Employee employee &equals; new Employee&lpar;&rpar;&semi; &NewLine; employee&period;setEmpid&lpar;rs&period;getInt&lpar;"empid"&rpar;&rpar;&semi; &NewLine; employee&period;setName&lpar;rs&period;getString&lpar;"name"&rpar;&rpar;&semi; &NewLine; employee&period;setAge&lpar;rs&period;getInt&lpar;"age"&rpar;&rpar;&semi; &NewLine; employee&period;setSalary&lpar;rs&period;getLong&lpar;"salary"&rpar;&rpar;&semi; &NewLine; return employee&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<p><b>EmpMainApp&period;java<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;main&semi; &NewLine; &NewLine;import java&period;util&period;List&semi; &NewLine; &NewLine;import org&period;springframework&period;context&period;ApplicationContext&semi; &NewLine;import org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&semi; &NewLine; &NewLine;import com&period;dineshonjava&period;sdnext&period;dao&period;EmpDao&semi; &NewLine;import com&period;dineshonjava&period;sdnext&period;domain&period;Employee&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class EmpMainApp &lbrace; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param args &NewLine; &ast;&sol; &NewLine; public static void main&lpar;String&lbrack;&rsqb; args&rpar; &lbrace; &NewLine; ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi; &NewLine; EmpDao empDao &equals; &lpar;EmpDao&rpar; context&period;getBean&lpar;"employeeDaoImpl"&rpar;&semi; &NewLine; &NewLine; System&period;out&period;println&lpar;"------Records Creation--------" &rpar;&semi; &NewLine; empDao&period;create&lpar;"Raaz"&comma; 25&comma; 50000l&rpar;&semi; &NewLine; &NewLine; System&period;out&period;println&lpar;"------Listing Multiple Records--------" &rpar;&semi; &NewLine; List employees &equals; empDao&period;listEmployees&lpar;&rpar;&semi; &NewLine; for &lpar;Employee employee &colon; employees&rpar; &lbrace; &NewLine; System&period;out&period;print&lpar;employee&rpar;&semi; &NewLine; &rcub; &NewLine; &rcub; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p>6&period; Create Beans configuration file <b>spring&period;xml<&sol;b> under the src folder&period;<&sol;p>&NewLine;<&sol;div>&NewLine;<pre class&equals;"highlight">&lt&semi;beans xmlns&colon;aop&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;aop" xmlns&colon;context&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;context" xmlns&colon;p&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;p" xmlns&colon;><br &sol;>&NewLine;Once you are done with creating source and bean configuration files&comma; let us run the application&period; If everything is fine with your application&comma; this will print the following message&colon;<&sol;p>&NewLine;<p><b>------Records Creation--------<&sol;b><br &sol;>&NewLine;<b>Created Record Name &equals; Raaz Age &equals; 25 Salary &equals; 50000<&sol;b><&sol;p>&NewLine;<div style&equals;"text-align&colon; center&semi;"><b>&lt&semi;&lt&semi;<&sol;b><b><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;transaction-management-in-spring&period;html">Transaction Management<&sol;a><&sol;b><&sol;b><b> &vert;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-30-baby-step-to-learn&period;html">index<&sol;a>&vert; <&sol;b><b><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;using-hibernate-with-spring-chapter-37&period;html">Using Hibernate with Spring<&sol;a><&sol;b><&sol;b><b><&sol;b><b>&gt&semi;&gt&semi;<&sol;b><&sol;div>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;transaction-management-in-spring&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;declarative-transaction-management&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '628'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design PatternsĀ using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago