{"id":917,"date":"2012-02-15T19:18:00","date_gmt":"2012-02-15T19:18:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/mybatis-3-spring-integration-tutorial.html"},"modified":"2012-10-21T23:00:42","modified_gmt":"2012-10-21T23:00:42","slug":"mybatis-3-spring-integration-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html","title":{"rendered":"MyBatis 3 &#8211; Spring integration tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation on database.<\/p>\n<p>We have a domain class for User and a database table to store the User information on database. We will use xml configuration model for our example to define SQL commands that will perform CRUD operation.<\/p>\n<p><strong>Our Domain class<\/strong><\/p>\n<pre class=\"brush: java; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">package com.raistudies.domain;\r\n\r\nimport java.io.Serializable;\r\n\r\npublic class User implements Serializable{\r\n\r\n    private static final long serialVersionUID = 3647233284813657927L;\r\n\r\n    private String id;\r\n    private String name = null;\r\n    private String standard = null;\r\n    private String age;\r\n    private String sex = null;\r\n\r\n    \/\/setter and getter have been omitted to make the code short\r\n\r\n    @Override\r\n    public String toString() {\r\n        return \"User [name=\" + name + \", standard=\" + standard + \", age=\" + age\r\n        + \", sex=\" + sex + \"]\";\r\n    }\r\n}\r\n<\/pre>\n<p>We have five properties in our domain class called User for which have to provide database services.<\/p>\n<p><strong>Our Database Table<\/strong><\/p>\n<p>Following is our database table:<\/p>\n<pre class=\"brush: sql; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">CREATE TABLE `user` (\r\n    `id` varchar(36) NOT NULL,\r\n    `name` varchar(45) DEFAULT NULL,\r\n    `standard` varchar(45) DEFAULT NULL,\r\n    `age` varchar(45) DEFAULT NULL,\r\n    `sex` varchar(45) DEFAULT NULL,\r\n    PRIMARY KEY (`id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8\r\n<\/pre>\n<p><strong>Creating interface for CRUD operations<\/strong><\/p>\n<p>For defining the CRUD database operation using MyBatis 3, we have to specify the methods that will be used to perform CRUD operation. Following is the interface for our example:<\/p>\n<pre class=\"brush: java; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">package com.raistudies.persistence;\r\n\r\nimport java.util.List;\r\n\r\nimport com.raistudies.domain.User;\r\n\r\npublic interface UserService {\r\n\r\n    public void saveUser(User user);\r\n    public void updateUser(User user);\r\n    public void deleteUser(String id);\r\n    public List&lt;User&gt; getAllUser();\r\n}\r\n<\/pre>\n<p>We have four methods here to perform operations create,update , delete and get from database.<\/p>\n<p><strong>XML Mapping file for UserService interface<\/strong><\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE mapper PUBLIC \"-\/\/mybatis.org\/\/DTD Mapper 3.0\/\/EN\"\r\n\"http:\/\/mybatis.org\/dtd\/mybatis-3-mapper.dtd\"&gt;\r\n\r\n&lt;mapper namespace=\"com.raistudies.persistence.UserService\"&gt;\r\n\r\n    &lt;resultMap id=\"result\" type=\"user\"&gt;\r\n        &lt;result property=\"id\" column=\"id\"\/&gt;\r\n        &lt;result property=\"name\" column=\"name\"\/&gt;\r\n        &lt;result property=\"standard\" column=\"standard\"\/&gt;\r\n        &lt;result property=\"age\" column=\"age\"\/&gt;\r\n        &lt;result property=\"sex\" column=\"sex\"\/&gt;\r\n    &lt;\/resultMap&gt;\r\n\r\n    &lt;select id=\"getAllUser\" parameterType=\"int\" resultMap=\"result\"&gt;\r\n        SELECT id,name,standard,age,sex\r\n        FROM user;\r\n    &lt;\/select&gt;\r\n\r\n    &lt;insert id=\"saveUser\" parameterType=\"user\"&gt;\r\n        INSERT INTO user (id,name,standard,age,sex)\r\n        VALUE (#{id},#{name},#{standard},#{age},#{sex})\r\n    &lt;\/insert&gt;\r\n\r\n    &lt;update id=\"updateUser\" parameterType=\"user\"&gt;\r\n        UPDATE user\r\n        SET\r\n        name = #{name},\r\n        standard = #{standard},\r\n        age = #{age},\r\n        sex = #{sex}\r\n        where id = #{id}\r\n    &lt;\/update&gt;\r\n\r\n    &lt;delete id=\"deleteUser\" parameterType=\"int\"&gt;\r\n        DELETE FROM user\r\n        WHERE id = #{id}\r\n    &lt;\/delete&gt;\r\n&lt;\/mapper&gt;\r\n<\/pre>\n<p>You will see a lot of things new here:<\/p>\n<p>The mapping file will contain element <strong>&lt;mapper\/&gt;<\/strong> to define the SQL statement for the services. Here the property \u201c<strong>namespace<\/strong>\u201d defines the interface for which this mapping file has been defined.<\/p>\n<p><strong>&lt;insert\/&gt;<\/strong> tag defines that the operation is of type insert. The value of \u201c<strong>id<\/strong>\u201d property specifies the function name for which the SQL statement is been defined. Here it is \u201c<strong>saveUser<\/strong>\u201c. The property \u201c<strong>parameterType<\/strong>\u201d defines the parameter of the method is of which type. We have used alias for the class User here. The alias will be configured in MyBatis Configuration file later. Then, we have to define the SQL Statement. <strong>#{id}<\/strong> defines that the property \u201c<strong>id<\/strong>\u201d of class User will be passed as a parameter to the SQL query.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><strong>&lt;resultMap\/&gt;<\/strong> tag is used to specify the mapping between the User class and user table. <strong>id<\/strong> of &lt;resultMap\/&gt; is a unique name to the mapping definition. Under this tag, we define the different properties and which column is bounded to which property.<\/p>\n<p><strong>&lt;select\/&gt;<\/strong> tag is used to specify a select SQL statement. The value of \u201c<strong>id<\/strong>\u201d property specifies the function name for which the SQL statement is been defined.<\/p>\n<p>The attribute <strong>resultMap<\/strong> is used to define the return type of the SQL statement as a collection.<\/p>\n<p><strong>MyBatis 3 Configuration file<\/strong><\/p>\n<p>Following is our configuration file for MyBatis:<\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE configuration\r\nPUBLIC \"-\/\/mybatis.org\/\/DTD Config 3.0\/\/EN\"\r\n\"http:\/\/mybatis.org\/dtd\/mybatis-3-config.dtd\"&gt;\r\n\r\n&lt;configuration&gt;\r\n    &lt;settings&gt;\r\n        &lt;!-- changes from the defaults --&gt;\r\n       &lt;setting name=\"lazyLoadingEnabled\" value=\"false\" \/&gt;\r\n    &lt;\/settings&gt;\r\n    &lt;typeAliases&gt;\r\n        &lt;typeAlias type=\"com.raistudies.domain.User\" alias=\"user\"\/&gt;\r\n    &lt;\/typeAliases&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<p>You can see, we have not defined some very important properties here:<\/p>\n<ol>\n<li>Database connection properties.<\/li>\n<li>Transaction related properties.<\/li>\n<li>And also have not defined mappers configuration.<\/li>\n<\/ol>\n<p>MyBatis 3 is very powerful SQL mapping framework with automatic database access class generation using a proxy implementation of the services defined by users. We get realize it\u2019s true power if you integrate MyBatis 3 with Spring framework and use these proxy implementation. It will reduce our database work by 80%. Below, we will see how to integrate MyBatis 3 with Spring 3 framework.&nbsp;Previously, we created the CRUD database service for class User using MyBatis 3. Now, we will integrate the data services implemented using MyBatis with Spring framework.<\/p>\n<p><strong>Tools Used:<\/strong><\/p>\n<ul>\n<li><strong>c3p0-0.9.1.2.jar<\/strong> \u2013 For providing pooled database connection.<\/li>\n<li><strong>mybatis-spring-1.0.0.jar<\/strong> \u2013 For integrating MyBatis with Spring (Provided by MyBatis team)<\/li>\n<li><strong>Spring JDBC and Core library<\/strong><\/li>\n<\/ul>\n<p>To integrate these two frameworks, we have to follow bellow steps:<\/p>\n<p><strong>Step 1: Defining datasource as a Spring bean<\/strong><br \/>\nAs we will use c3po data source provider, we have to define datasource bean in Spring. Following is the configuration snippet:<\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;!-- Declare a datasource that has pooling capabilities --&gt;\r\n&lt;bean id=\"dataSource\" class=\"com.mchange.v2.c3p0.ComboPooledDataSource\"\r\ndestroy-method=\"close\" p:driverClass=\"${app.jdbc.driverClassName}\"\r\np:jdbcUrl=\"${app.jdbc.url}\" p:user=\"${app.jdbc.username}\" p:password=\"${app.jdbc.password}\"\r\np:acquireIncrement=\"10\" p:idleConnectionTestPeriod=\"60\" p:maxPoolSize=\"100\"\r\np:maxStatements=\"50\" p:minPoolSize=\"10\" \/&gt;\r\n<\/pre>\n<p>Here we have created a spring bean with id <strong>dataSource<\/strong> of class <strong>com.mchange.v2.c3p0.ComboPooledDataSource<\/strong> which is provided by c3p0 library for pooled data source.<\/p>\n<p>We have set some properties in the bean. Following is the description of properties defined in bean:<\/p>\n<ul>\n<li><strong>driverClass<\/strong> : Driver class that will be used to connect to database.<\/li>\n<li><strong>jdbcUrl<\/strong> : jdbc url defining the database connection string.<\/li>\n<li><strong>user<\/strong> : username of the database user.<\/li>\n<li><strong>password<\/strong> : password of the database user.<\/li>\n<li><strong>acquireIncrement<\/strong> : how many connections will be created at a time when there will be a shortage of connections.<\/li>\n<li><strong>idleConnectionTestPeriod<\/strong> : after how much delay a connection will be closed if it is no longer in use.<\/li>\n<li><strong>maxPoolSize<\/strong> : Max number of connections that can be created.<\/li>\n<li><strong>maxStatements<\/strong> : Max number of SQL statements to be executed on a connection.<\/li>\n<li><strong>minPoolSize<\/strong> : Minimum number of connections to be created.<\/li>\n<\/ul>\n<p>We have used Spring EL to define many of the property values, that will be bring from properties file.<\/p>\n<p><strong>Defining Transaction Manager in Spring<\/strong><\/p>\n<p>We will user Transaction Manager provided by Spring JDBC framework and for defining transaction levels we will use annotations. Following is the configuration for transaction manager:<\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;!-- Declare a transaction manager --&gt;\r\n&lt;bean id=\"transactionManager\"\r\nclass=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\"\r\np:dataSource-ref=\"dataSource\" \/&gt;\r\n\r\n&lt;!-- Enable annotation style of managing transactions --&gt;\r\n&lt;tx:annotation-driven transaction-manager=\"transactionManager\" \/&gt;\r\n<\/pre>\n<p><strong>Defining MyBatis SqlSessionFactory and MapperScanner<\/strong><\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;!-- define the SqlSessionFactory, notice that configLocation is not needed when you use MapperFactoryBean --&gt;\r\n&lt;bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\"&gt;\r\n    &lt;property name=\"dataSource\" ref=\"dataSource\" \/&gt;\r\n    &lt;property name=\"configLocation\" value=\"WEB-INF\/mybatis\/sqlmap-config.xml\" \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;!-- scan for mappers and let them be autowired --&gt;\r\n&lt;bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\"&gt;\r\n    &lt;property name=\"basePackage\" value=\"${MapperInterfacePackage}\" \/&gt;\r\n&lt;\/bean&gt;\r\n<\/pre>\n<p>The <strong>SqlSessionFactory<\/strong> bean will provide SessionFactory instances of MyBatis. To configure SqlSessionFactory, we need to define two properties. First the data source which will be used by MyBatis to create connection database and MyBatis configuration file name to configure the environment of MyBatis.<\/p>\n<p><strong>MapperScannerConfigurer<\/strong> is used to publish the data service interfaces in defined for MyBatis to configure as Spring Beans. We just have to provide package in which the interfaces and their mapping XML files has been defined. We can specify more than one packages using common separation or semicolon. After that we will be able to get the instances of UserService using @Autowired annotation. We do not have to implement the interface as MyBatis will provide proxy implementation for this.<\/p>\n<p><strong>Spring configuration file as together<\/strong><br \/>\nHere is our <strong>jdbc-context.xml<\/strong> as together:<\/p>\n<pre class=\"brush: xml; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\nxmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\"\r\nxmlns:tx=\"http:\/\/www.springframework.org\/schema\/tx\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\r\nxsi:schemaLocation=\"\r\n\r\nhttp:\/\/www.springframework.org\/schema\/beans\r\n\r\nhttp:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\r\n\r\nhttp:\/\/www.springframework.org\/schema\/tx\r\n\r\nhttp:\/\/www.springframework.org\/schema\/tx\/spring-tx-3.0.xsd\r\n\r\nhttp:\/\/www.springframework.org\/schema\/context\r\n\r\nhttp:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\r\n\r\n\"&gt;\r\n\r\n&lt;context:property-placeholder location=\"\/WEB-INF\/jdbc.properties,\/WEB-INF\/mybatis\/mybatis.properties\" \/&gt;\r\n\r\n    &lt;!-- Enable annotation style of managing transactions --&gt;\r\n    &lt;tx:annotation-driven transaction-manager=\"transactionManager\" \/&gt;\r\n\r\n    &lt;!-- Declare a datasource that has pooling capabilities --&gt;\r\n    &lt;bean id=\"dataSource\" class=\"com.mchange.v2.c3p0.ComboPooledDataSource\"\r\n    destroy-method=\"close\" p:driverClass=\"${app.jdbc.driverClassName}\"\r\n    p:jdbcUrl=\"${app.jdbc.url}\" p:user=\"${app.jdbc.username}\" p:password=\"${app.jdbc.password}\"\r\n    p:acquireIncrement=\"10\" p:idleConnectionTestPeriod=\"60\" p:maxPoolSize=\"100\"\r\n    p:maxStatements=\"50\" p:minPoolSize=\"10\" \/&gt;\r\n\r\n    &lt;!-- Declare a transaction manager --&gt;\r\n    &lt;bean id=\"transactionManager\"\r\n    class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\"\r\n    p:dataSource-ref=\"dataSource\" \/&gt;\r\n\r\n    &lt;!-- define the SqlSessionFactory, notice that configLocation is not needed when you use MapperFactoryBean --&gt;\r\n    &lt;bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\"&gt;\r\n        &lt;property name=\"dataSource\" ref=\"dataSource\" \/&gt;\r\n        &lt;property name=\"configLocation\" value=\"WEB-INF\/mybatis\/sqlmap-config.xml\" \/&gt;\r\n    &lt;\/bean&gt;\r\n\r\n    &lt;!-- scan for mappers and let them be autowired --&gt;\r\n    &lt;bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\"&gt;\r\n        &lt;property name=\"basePackage\" value=\"${MapperInterfacePackage}\" \/&gt;\r\n    &lt;\/bean&gt;\r\n\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p><strong>jdbc.properties file<\/strong><\/p>\n<pre class=\"brush: java; title: Example Code Sample; notranslate\" title=\"Example Code Sample\"># database properties\r\napp.jdbc.driverClassName=com.mysql.jdbc.Driver\r\napp.jdbc.url=jdbc:mysql:\/\/localhost\/mybatis-example\r\napp.jdbc.username=root\r\napp.jdbc.password=password\r\n<\/pre>\n<p><strong>mybatis.properties file<\/strong><\/p>\n<pre class=\"brush: java; title: Example Code Sample; notranslate\" title=\"Example Code Sample\">MapperInterfacePackage=com.raistudies.persistence\r\n<\/pre>\n<p><strong><i>Reference: &nbsp;<\/i><\/strong><a href=\"http:\/\/www.raistudies.com\/spring\/spring-mvc\/creating-crud-service-using-mybatis-3-mapping-framework\/\">Creating CRUD service using MyBatis 3 Mapping Framework \u2013 Part 1<\/a>&nbsp;&amp;&nbsp;<a href=\"http:\/\/www.raistudies.com\/spring\/integrating-mybatis-3-and-spring-frameworks-part-2\/\">Integrating MyBatis 3 and Spring frameworks \u2013 Part 2<\/a>&nbsp;from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a><span class=\"Apple-style-span\" style=\"font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif\"><span class=\"Apple-style-span\" style=\"font-size: 14px;line-height: 18px\"><strong>&nbsp;<\/strong><\/span><\/span>Rahul Mondal at the&nbsp;<a href=\"http:\/\/www.raistudies.com\/\">Rai Studies<\/a>&nbsp;blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation on database. We have a domain class for User and a database table to store the User information on database. We will use xml configuration model &hellip;<\/p>\n","protected":false},"author":307,"featured_media":189,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[338,30],"class_list":["post-917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-mybatis","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MyBatis 3 - Spring integration tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MyBatis 3 - Spring integration tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-15T19:18:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T23:00:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rahul Mondal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rahul Mondal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html\"},\"author\":{\"name\":\"Rahul Mondal\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c1b1c4fb044e95b999a6ee0d3325e846\"},\"headline\":\"MyBatis 3 &#8211; Spring integration tutorial\",\"datePublished\":\"2012-02-15T19:18:00+00:00\",\"dateModified\":\"2012-10-21T23:00:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html\"},\"wordCount\":936,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mybatis-logo.jpg\",\"keywords\":[\"MyBatis\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html\",\"name\":\"MyBatis 3 - Spring integration tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mybatis-logo.jpg\",\"datePublished\":\"2012-02-15T19:18:00+00:00\",\"dateModified\":\"2012-10-21T23:00:42+00:00\",\"description\":\"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mybatis-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mybatis-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/02\\\/mybatis-3-spring-integration-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MyBatis 3 &#8211; Spring integration tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c1b1c4fb044e95b999a6ee0d3325e846\",\"name\":\"Rahul Mondal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g\",\"caption\":\"Rahul Mondal\"},\"sameAs\":[\"http:\\\/\\\/www.raistudies.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Rahul-Mondal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MyBatis 3 - Spring integration tutorial - Java Code Geeks","description":"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"MyBatis 3 - Spring integration tutorial - Java Code Geeks","og_description":"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation","og_url":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-02-15T19:18:00+00:00","article_modified_time":"2012-10-21T23:00:42+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg","type":"image\/jpeg"}],"author":"Rahul Mondal","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Rahul Mondal","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html"},"author":{"name":"Rahul Mondal","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c1b1c4fb044e95b999a6ee0d3325e846"},"headline":"MyBatis 3 &#8211; Spring integration tutorial","datePublished":"2012-02-15T19:18:00+00:00","dateModified":"2012-10-21T23:00:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html"},"wordCount":936,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg","keywords":["MyBatis","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html","name":"MyBatis 3 - Spring integration tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg","datePublished":"2012-02-15T19:18:00+00:00","dateModified":"2012-10-21T23:00:42+00:00","description":"As a first step of this tutorial, Spring MVC 3 CRUD example with MyBatis 3, we will define a MyBatis service that will help us to perform CRUD operation","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mybatis-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/02\/mybatis-3-spring-integration-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"MyBatis 3 &#8211; Spring integration tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c1b1c4fb044e95b999a6ee0d3325e846","name":"Rahul Mondal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14ca0f656bd7d27050a2eb5681d41cba014f0b08eeb4a8265282c70f6c196665?s=96&d=mm&r=g","caption":"Rahul Mondal"},"sameAs":["http:\/\/www.raistudies.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Rahul-Mondal"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/307"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/189"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}