Spring Programmatic Transactions

Pre-requisite trails Spring Transactions Primer Concept Overview There are predominantly three transaction strategies for spring based transactions – Local Transactions, programmatic transactions and declarative transactions. In this tutorial we look at programmatic transactions. Programmatic transactions give a greater control to the user in setting up the transaction boundaries. It is possible to set up transaction … Read more

Spring Transaction Attributes

What are transaction attributes? Spring transactions allow setting up the propagation behavior, isolation, timeout and read only settings of a transaction. Before we delve into the details, here are some points that need to be kept in mind Isolation level and timeout settings get applied only after the transaction starts. Not all transaction managers specify … Read more

Spring Distributed Transactions

Introduction An understanding of distributed transactions is not required to understand spring transactions, however, we present it here since it would be good to get the complete picture. Many times a transaction spans multiple systems (on separate hosts). For example, a single transaction may involve a messaging system and a database. Distributed transactions must satisfy … Read more

Spring Transactions Primer

What is a Transaction? Transaction is an activity or group of activities that are performed as a single unit of work. The characteristic of a transaction is that either all the activities that are part of the transaction are performed or none are performed. In other words, even if one of the activity fails then … Read more

Spring Hibernate Integration Using Java Persistence API

Prerequisite Trails Spring Hibernate Dao Support Spring Hibernate Integration using SessionFactory Concept Overview JPA (Java Persistence API) – JPA is a persistence framework for Object Relational Mapping. It is based on POJO (Plain Old Java Object). It was born out of the complexity experienced in EJB2. It can be used in both EJB and non-EJB … Read more

Spring Hibernate Integration Using Annotations

Prerequisite Trails Spring Hibernate Dao Support Spring Hibernate Integration using SessionFactory Concept Overview This tutorial shows how to use annotations to wire a LocalSessionFactoryBean into the SessionFactory object of a DAO. The hibernate session is then obtained from this session factory using the getCurrentSession() method. By default the session uses a SpringSessionContext for the hibernate … Read more

Spring Hibernate Integration Using SessionFactory

Prerequisite Trails Spring Hibernate Dao Support Concept Overview In the previous tutorial we saw how HibernateTemplate can be used in a HibernateSupportDao to perform Hibernate based database operations. However, it is possible to directly obtain a Hibernate session using the getSession() method of the Hibernate SessionFactory. Wire a LocalSessionFactoryBean into the DAO as a SessionFactory … Read more

Spring Hibernate Integration Using HibernateDaoSupport

Concept Overview This tutorial explains how spring can be integrated with Hibernate. HibernateTemplate – Spring provides a class called org.springframework.orm.hibernate3.HibernateTemplate that helps in accessing the database via hibernate. One of its main features is mapping of hibernate exceptions to DataAccessExceptions. The main method in HibernateTemplate is the execute method that takes in a hibernate callback. … Read more

Spring JdbcDaoSupport

Concept Overview Spring provides convenient classes to perform functions on the database. It handles creating a connection to a database, performing clean up and handling exceptions. The user creates a datasource and injects it into a jdbctemplate. The jdbctemplate is then injected into the spring Dao. The user can also inject a datasource directly into … Read more

Spring Jdbc Template Named Params

Concept Overview The power of spring lies in its ability to converse freely with various other parts of the application. Spring provides classes and methods to perform functions on the database. It provides template classes that perform common database functions such as opening a connection, closing connection and managing exceptions. The only thing the user … Read more