Java Persistence with MyBatis 3


Java Persistence with MyBatis 3
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
$12.74
save 15%!
Print + free eBook + free PacktLib access to the book: $44.98    Print cover: $29.99
$29.99
save 33%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters

Detailed instructions on how to use MyBatis with XML and Annotation-based SQL Mappers An in-depth discussion on how to map complex SQL query results such as One-To-Many and Many-To-Many using MyBatis ResultMaps Step-by-step instructions on how to integrate MyBatis with a Spring framework

Book Details

Language : English
Paperback : 132 pages [ 235mm x 191mm ]
Release Date : June 2013
ISBN : 1782166807
ISBN 13 : 9781782166801
Author(s) : K. Siva Prasad Reddy
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Preface
Chapter 1: Getting Started with MyBatis
Chapter 2: Bootstrapping MyBatis
Chapter 3: SQL Mappers Using XML
Chapter 4: SQL Mappers using Annotations
Chapter 5: Integration with Spring
Index
  • Chapter 1: Getting Started with MyBatis
    • What is MyBatis?
    • Why MyBatis?
      • Eliminates a lot of JDBC boilerplate code
      • Low learning curve
      • Works well with legacy databases
      • Embraces SQL
      • Supports integration with Spring and Guice frameworks
      • Supports integration with third-party cache libraries
      • Better performance
    • Installing and configuring MyBatis
      • Creating a STUDENTS table and inserting sample data
      • Creating a Java project and adding mybatis-3.2.2.jar to the classpath
      • Creating the mybatis-config.xml and StudentMapper.xml configuration files
      • Creating the MyBatisSqlSessionFactory singleton class
      • Creating the StudentMapper interface and the StudentService classes
      • Creating a JUnit test for testing StudentService
        • How it works
    • Sample domain model
    • Summary
    • Chapter 2: Bootstrapping MyBatis
      • Configuring MyBatis using XML
        • Environment
        • DataSource
        • TransactionManager
        • Properties
        • typeAliases
        • typeHandlers
        • Settings
        • Mappers
      • Configuring MyBatis Using Java API
        • Environment
        • DataSource
        • TransactionFactory
        • typeAliases
        • typeHandlers
        • Settings
        • Mappers
      • Customizing MyBatis logging
      • Summary
      • Chapter 3: SQL Mappers Using XML
        • Mapper XMLs and Mapper interfaces
        • Mapped statements
          • The INSERT statement
            • Autogenerated keys
          • The UPDATE statement
          • The DELETE statement
          • The SELECT statement
        • ResultMaps
          • Simple ResultMaps
          • Extending ResultMaps
          • One-to-one mapping
          • One-to-one mapping using nested ResultMap
          • One-to-one mapping using nested Select
          • One-to-many mapping
          • One-to-many mapping with nested ResultMap
          • One-to-many mapping with nested select
        • Dynamic SQL
          • The If condition
          • The choose, when, and otherwise conditions
          • The where condition
          • The trim condition
          • The foreach loop
          • The set condition
        • MyBatis recipes
          • Handling enumeration types
          • Handling the CLOB/BLOB types
          • Passing multiple input parameters
          • Multiple results as a map
          • Paginated ResultSets using RowBounds
          • Custom ResultSet processing using ResultSetHandler
          • Cache
        • Summary
        • Chapter 4: SQL Mappers using Annotations
          • Mapper interfaces using annotations
          • Mapped statements
            • @Insert
              • Autogenerated keys
            • @Update
            • @Delete
            • @Select
          • Result maps
            • One-to-one mapping
            • One-to-many mapping
          • Dynamic SQL
            • @InsertProvider
            • @UpdateProvider
            • @DeleteProvider
          • Summary
          • Chapter 5: Integration with Spring
            • Configuring MyBatis in a Spring application
              • Installation
              • Configuring MyBatis beans
            • Working with SqlSession
            • Working with mappers
              • <mybatis:scan/>
              • @MapperScan
            • Transaction management using Spring
            • Summary

            K. Siva Prasad Reddy

            K. Siva Prasad Reddy is a Senior Software Engineer living in Hyderabad, India, and having more than seven years of experience in developing enterprise applications with Java and JavaEE technologies. Siva is a Sun Certified Java Programmer and has a lot of experience in server-side technologies such as Java, JavaEE, Spring, Hibernate, MyBatis, JSF, PrimeFaces, and WebServices (SOAP/REST). Siva is also the author of Java Persistence with MyBatis 3, Packt Publishing. Siva normally shares the knowledge he has acquired on his blog at www.sivalabs.in. If you want to find out more about his work, you can follow him on Twitter (@sivalabs) and GitHub (https://github.com/sivaprasadreddy).
            Sorry, we don't have any reviews for this title yet.

            Code Downloads

            Download the code and support files for this book.


            Submit Errata

            Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


            Errata

            - 3 submitted: last submission 04 Feb 2014

            Errata type: Typo | Page number: 66

            The line "In this approach, the  <association>  element's  select attribute is set to the statement ID  findCoursesByTutor  that triggers a  separate SQL query to load the courses' details. "

            Should be "In this approach, the  <collection>  element's  select attribute is set to the statement ID  findCoursesByTutor  that triggers a  separate SQL query to load the courses' details." 

            Errata type: Typo | Page number: 106

            In the bullet list, the titles 'annotations' and 'marker-interface' are interchanged.

            Errata type: Code related | Page number: 23

            The following line in the testCreateStudent() function: 

            student.setEmail("student_"+id+"gmail.com"); 

            should be :

            student.setEmail("student_"+id+"@gmail.com"); 

            Sample chapters

            You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

            Frequently bought together

            Java Persistence with MyBatis 3 +    Learning Anime Studio =
            50% Off
            the second eBook
            Price for both: €24.00

            Buy both these recommended eBooks together and get 50% off the cheapest eBook.

            What you will learn from this book

            Simplify database persistence layer implementation Install and configure MyBatis using XML and Java API Map One-To-Many and Many-To-Many results using XML and Annotated Mappers Use TypeAliases and Custom Type Handlers Handle pagination and custom SQL ResultSet processing Build Dynamic Queries using XML and SqlProvider annotations Use Spring’s Annotation-based Transaction Handling with MyBatis

            In Detail

            Storing and retrieving data to and from relational databases is a very common requirement, and is a crucial part of many applications. Even though Java provides a JDBC API for database access, it is not very effective and involves writing the boilerplate code again and again. Getting data out of a database, populating into Java objects, and persisting data from Java objects into a database using JDBC involves a lot of repetitive coding and is a very tedious process. MyBatis takes the simplest approach of leveraging the existing knowledge and power of Java and SQL yet provides powerful features to make data persistence implementation easy. Java Persistence with MyBatis 3 is a practical, hands-on guide that provides you with a number of clear step-by-step exercises, which will help you to understand how MyBatis works and how to use it for your real application needs. With MyBatis, you will learn how to use the MyBatis framework effectively through simple instructions. Java Persistence with MyBatis 3 will highlight the cumbersome process of data persistence using plain JDBC and will also show you how easy it is to implement the same using MyBatis. You will also take a deeper look into the implementation of MyBatis with XML and Annotation-based Mappers, and finally learn how to integrate MyBatis with a Spring framework. You will learn how to map Complex SQL query results to Java beans using XML and Annotation-based Mappers, including One-To-Many and Many-To-Many relationships. You will also learn how to use TypeAliases and Custom Type Handlers, and build dynamic queries using XML and SqlProvider annotations. It progresses to detailed instructions on integrating MyBatis with Spring and leveraging Spring’s Annotation-based transaction handling mechanism, which further simplifies the usage of MyBatis.With Java Persistence with MyBatis 3, you will learn how to use the MyBatis framework effectively through simple instructions.

            Approach

            This book will have a practical approach, thus making it easy for the readers to understand and learn with step-by-step instructions.

            Who this book is for

            This book is for Java developers who would like to learn all about the MyBatis framework and are looking for a practical guide to get started. The prerequisites required for this book are basic Java and SQL skills. No prior knowledge of MyBatis is expected.

            Code Download and Errata
            Packt Anytime, Anywhere
            Register Books
            Print Upgrades
            eBook Downloads
            Video Support
            Contact Us
            Awards Voting Nominations Previous Winners
            Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
            Resources
            Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software