Build robust and reliable persistence solutions for your enterprise Java application - Get to grips with Hibernate and its configuration manager, mappings, types, session APIs, queries, and much more
- Integrate Hibernate and Spring as part of your enterprise Java stack development
- Work with Spring IoC (Inversion of Control), Spring AOP, transaction management, web development, and unit testing considerations and features
- Covers advanced and useful features of Hibernate in a practical way
In Detail Spring is the leading platform to build and run enterprise Java applications. Spring's Hibernate integration makes it easy to mix and match persistence methodologies simplifying your Hibernate applications. You can incorporate lots of Inversion of Control (IoC) convenience features to address many typical Hibernate integration issues, making this integration all the more favorable for your application.
This easy-to-use book will turn the complex-sounding integration into a straightforward walk-through. Persistence is important for creating a data access-based transactions tier, central to financial, insurance, and banking applications. You will be able to enhance your applications using the most common, advanced, and optional features of Hibernate.
This book starts with the philosophy and the brief history of persistence. It provides an introduction to how persistence frameworks and technologies came into the development scene and what problems they are aimed to solve.
The book continues with a discussion about Hibernate as the most popular persistence framework in Java. First, you will learn how to get Hibernate and add it to a project and how to configure it before it can be used. Next, you will get an in-depth knowledge about Hibernate and understand the essential concepts behind persistence with Hibernate and more. When Hibernate has been fully discussed, you will get to know Spring as another popular framework in Java, and have a look at essential features of Spring and its added value for Hibernate-based projects. Finally the book will provide a comprehensive discussion about using Hibernate with Spring and the problems that are solved with Spring.
What you will learn from this book?
- Learn the philosophy, the history, and the usage of Persistence
- Solve problems related to Persistence by gaining a complete understanding of Hibernate
- Know your competitors and gear yourself to knock down your competition using Hibernate exhaustively
- Get to know the role of Spring in Persistence and learn to configure Hibernate and Spring
- Use the essential, most commonly-used Hibernate features such as Transparent persistence, Object-Relational mappings, Object-oriented query language, and more
- Exploit the optional and advanced Hibernate features to enhance your applications
- Learn and integrate common Spring features that are a part and parcel of every Java project
- Make the most out of the Spring features that are related to persistence, particularly to Hibernate
- Develop sophisticated web applications using Spring Persistence with Hibernate and successfully test them
Here is a brief summary of what each chapter covers:
Chapter 1 - An Introduction to Hibernate and Spring introduces Spring and Hibernate, explaining what persistence is, why it is important, and how it is implemented in Java applications. It provides a theoretical discussion of Hibernate and how Hibernate solves problems related to persistence. Finally, we take a look at Spring and the role of Spring in persistence.
Chapter 2 - Preparing an Application to Use Spring with Hibernate guides you, step by step, down the path of preparing your application to use Hibernate and Spring. The prerequisites to developing with Hibernate and Spring-getting Hibernate and Spring distributions, setting up a database, and adding extra toolsand frameworks to your application-are all discussed here.
Chapter 3 - A Quick Tour of Hibernate with Spring provides a quick tour of developing with Hibernate and Spring. Here, a simple example illustrates the basic concepts behind Hibernate and Spring.
Chapter 4 - Hibernate Configuration shows you how to configure and set up Hibernate. It discusses the basic configuration settings that are always required in any application. (Some optional settings are covered in the book's appendix.)
Chapter 5 - Hibernate Mappings explains basic issues related to persistent objects and their mappings. It starts with basic mapping concepts and then moves on to advanced and practical issues.
Chapter 6 - More on Mappings continues the mapping discussion with some advanced mapping topics. It explains how to map complex objects and create complicated mapping files.
Chapter 7 - Hibernate Types discusses how Hibernate types help to define which Java types are mapped to which SQL database types. It explores the built-in Hibernate types. It also looks at custom type implementation when these built-in types do not satisfy the application's requirements or when you want to change the default behavior of a built-in type.
Chapter 8 - Hibernate Persistence Behavior discusses the life cycle of persistent objects within the application's lifetime. This chapter explains the basic persistence operations provided by the Session API at the heart of the Hibernate API. The chapter also discusses how persistence operations are cascaded between persistent objects and how cascading behavior is defined in mapping files
Chapter 9 - Querying in Hibernate explains the different approaches that Hibernate provides for querying persistent objects. It investigates HQL, a Hibernate-specific query language; native SQL, a database-relevant query language; and the Criteria API, a Hibernate API to express query statements
Chapter 10 - Inversion of Control with Spring starts developing with Spring, introducing the Inversion of Control (IoC) pattern that is implemented at the heart of Spring.
Chapter 11 - Spring AOP investigates Aspect-Oriented Programming(AOP) as another Spring feature. Here, you'll learn what AOP means, how AOP simplifies application architecture, and how to implement AOP in Spring.
Chapter 12 - Transaction Management discusses transaction management. It explains transaction concepts and how transactions are managed in native and Spring-based Hibernate applications. It also discusses caching as a persistence aspect that involves reliability of data manipulation.
Chapter 13 - Integrating Hibernate with Spring explains how Hibernate and Spring are integrated and introduces the Data Access Object (DAO) pattern. It shows how Spring and Hibernate combine to implement this pattern.
Chapter 14 - Web Development with Hibernate and Spring provides a quick discussion of web development with Spring and Hibernate. It does not provide a detailed discussion of web development; instead, it takes Spring and Struts as sample web frameworks to illustrate how you might use Spring and Hibernate to develop web applications.
Chapter 15 - Unit Testing looks into testing persistence code, with a focus on unit testing. It introduces JUnit as an open-source unit-testing framework and discusses which aspects of persistence code with Hibernate require testing.
Appendix Hibernate's Advanced Features looks at some advanced Hibernate topics, including some useful Hibernate properties, the event/listener model implemented by Hibernate, and Hibernate filters.
Approach
Spring Persistence with Hibernate is an easy-to-follow, step-by-step, and example-rich guide to using Spring and Hibernate to build robust and effective Java applications. Furthermore, the book can be used as reference in areas where developers need help. All the topics explained in the book are demonstrated with practical examples and uncomplicated figures.
Who this book is written for?
The book is primarily for Spring developers and users who want to persist using the popular Hibernate persistence framework. Java, Hibernate, JPA, Spring, and open source developers in general will also find the book useful.