Examples

There are some examples, each one is based on the same sample database. See ERD.png

Sample Database ERD

Also most of them share the same configuration file: mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <environments default="standalone">
        <environment id="standalone">
            <transactionManager type="JDBC" />
            <dataSource type="UNPOOLED">
                <property name="driver" value="org.hsqldb.jdbcDriver"/>
                <property name="url" value="jdbc:hsqldb:mem:scala"/>
                <property name="username" value="sa"/>
                <property name="password" value=""/>
            </dataSource>
        </environment>
    </environments>
</configuration>

                

Each example is condensed in one single source file with relevant comments.

  • Simple Select without result map: Code
  • Complex Select with nested resultmaps: Code
  • Complex Select with nested selects Code
  • Insert: Code
  • Update: Code
  • Delete: Code

The CRUD example: A little more complete example. Code

Source code

You can browse all the sample code at: Source Code