Sometimes we may need to have some conditional statement in Spring config XML file depending upon some variables value. Think of a situation when you are using JPA in your application and your application may have two persistence units in Spring XML config file and you need to connect to one of them depending upon…

Posted in Spring Core

Conditional Statement in Spring Config

In this tutorial I will show you how we can use @PostConstruct and @PreDestroy annotation in Spring framework. @PostConstruct and @PreDestroy annotations are generally considered best practices for receiving life cycle callbacks in a modern Spring application. Using these annotations means that our beans are not coupled to Spring specific interfaces. Sometimes we need to…

Posted in Spring Core Spring JDBC

Spring @PostConstruct and @PreDestroy Example

This tutorials will show you how we can concurrently execute different operations using Java utility class called java.util.concurrent.Executors in Spring framework. Spring supports XML as well as Programmatic configuration of beans but, here we will use XML based metadata configuration. If you already have an idea on how to create a maven project in Eclipse…

Posted in Java Spring Core

How to concurrently execute tasks using Java in Spring

With this example I will show you how depends-on (@DependsOn annoattion) works in Spring application. Depends-on is basically used when you have a dependency on another bean without which you cannot proceed with the execution of your operations in current bean. Or if you need to initialize any bean before another bean, depends-on does this…

Posted in Spring Core

Depends-on in Spring

Stored Procedure This tutorial will show you how you can call stored procedure using Spring StoredProcedure. I assume you have a basic idea about stored procedure and what a stored procedure does and what are the advantages of using stored procedure in database server. Related Posts: Sometimes you may need to call a stored procedure…

Posted in MySQL Spring JDBC

Call Stored Procedure Using Spring StoredProcedure

Simple Jdbc Call This tutorial will show you how you can call or execute stored procedure using Spring SimpleJdbcCall. SimpleJdbcCall API provides flexible methods to invoke stored procedure. You can use DataSource directly with SimpleJdbcCall or you can create JdbcTemplate using DataSource and use JdbcTemplate with SimpleJdbcCall API for calling the stored procedures. You can…

Posted in MySQL Spring JDBC

Call Stored Procedure using Spring SimpleJdbcCall

This tutorial will show you how you can insert a large dataset or perform batch insert into a database at once using Spring JdbcTemplate. Sometimes you need to insert or update large number of records in the database. It’s not a good idea to insert multiple records into database one by one in a traditional…

Posted in Spring JDBC

Batch Insert using Spring JdbcTemplate

In this tutorial I will show you how to integrate REST using Jersey 2.6, Spring 3 and Grizzly web server. So I will use here Grizzly web server so we don’t need to use any other external webserver. I had been googling for many times but I did not get any satisfactory example on REST…

Posted in REST Spring Core

Spring 3, REST using Jersey 2.6 and Grizzly integration example

With this tutorial we will see how to use Aspect Oriented Programming in Spring Framework. AOP is used in the Spring Framework to provide declarative enterprise services. It is also used to allow users to implement custom aspects, complementing their use of OOP with AOP. We will demonstrate how to create and apply some central…

Posted in Spring AOP

Spring AOP (Aspect Oriented Programming) Example

Introduction This tutorial shows how to integrate Spring 3, Struts 2 and Hibernate 3 in the following example. In this example, Struts 2 will be used as a web framework and Spring 3 will be used as a core service. We will use ORM (Object Relational Mapping) framework Hibernate for our persistent layer to interact…

Posted in Hibernate Spring Core Struts

Integrate Spring 3, Struts 2 and Hibernate 3