Just Spring Data Access

Book description

JDBC has simplified database access in Java applications, but a few nagging wrinkles remain—namely, persisting Java objects to relational databases. With this book, you’ll learn how the Spring Framework makes that job incredibly easy with dependency injection, template classes, and object-relational-mapping (ORM).

Through sample code, you’ll discover how Spring streamlines the use of JDBC and ORM tools such as Hibernate, the Java Persistence API (JPA), and Java Data Objects (JDO). If you’re a Java developer familiar with Spring (perhaps through O’Reilly’s Just Spring tutorial) and want to advance your data access skills, this book shows you how.

  • Learn how to use Spring’s basic and advanced data access tools
  • Work with Spring’s JdbcTemplate class to separate non-critical code from business code
  • Eliminate placeholder variables in your queries with the NamedParameterJdbcTemplate class
  • Use Spring’s template classes to perform batch executions
  • Operate inserts on database tables without writing any SQL statements
  • Learn about Spring’s support for Hibernate as an object-relational-mapping tool
  • Use JPA as a standards-based ORM—alone or with Spring support
  • Move data from a relational to a non-relational database with JDO

Table of contents

  1. Just Spring Data Access
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Foreword
  4. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Acknowledgments
  5. 1. Basics
    1. Using Plain JDBC
    2. Spring Data Access
    3. Templates
      1. MySQL Database Scripts
      2. Using JdbcTemplate
        1. Configuring a DataSource
        2. Configuring JdbcTemplate
        3. Working with JdbcTemplate
          1. Querying for Single and Multiple Rows
          2. Bind Variables
          3. Mapping Rows to Domain Objects
          4. Fetching List of Trades
        4. Inserting, Deleting, and Updating Rows
        5. Executing Statements
    4. Summary
  6. 2. Advanced Concepts
    1. NamedParameterJdbcTemplate
      1. Using Map
      2. Using SqlParameterSource
    2. Jdbc Batching
      1. Using SqlParameterSourceUtils
      2. Using BatchPreparedStatementSetter
    3. Simple JDBC Classes
      1. SimpleJDBCInsert Class
      2. SimpleJdbcCall Class
    4. In-Memory Databases
    5. Callbacks
      1. PreparedStatement Callback
      2. Callable Statement Callbacks
      3. Row Callbacks
    6. Summary
  7. 3. Hibernate
    1. Two-Minute Hibernate
    2. Using Spring Hibernate
      1. Basic Setup
      2. Hibernate Operations
        1. Finding a Single Row
        2. Finding Multiple Rows
        3. Deleting Single Trade
        4. Deleting Multiple Trades
        5. Spring’s Job Is Done
      3. Using HibernateTemplate
        1. Hibernate Support Classes
    3. Transactions
    4. Summary
  8. 4. Spring JPA
    1. Two-Minute JPA
    2. Using Spring
      1. Standalone Factory
      2. Container Factory
        1. Configuring the Factory
      3. Transactions
      4. Using Plain JPA API
      5. Using JpaTemplate
    3. Support Classes
    4. Summary
  9. 5. Spring JDO
    1. Spring Support
    2. Plain JDO API
      1. Persistent Entity
      2. Persistence DAO
      3. Wiring the Pieces
      4. Bytecode Enhancers
      5. Example Test
    3. Working with JdoTemplate
    4. Support Classes
    5. JDO versus JPA versus Hibernate
    6. Summary
  10. About the Author
  11. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  12. Copyright

Product information

  • Title: Just Spring Data Access
  • Author(s): Madhusudhan Konda
  • Release date: June 2012
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449328382