factory = new ConcurrentKafkaListenerContainerFactory<>();
+ factory.setConsumerFactory(consumerFactory());
+ factory.getContainerProperties().setPollTimeout(1500);
+ return factory;
+ }
+
+
+}
diff --git a/docs/spring/cs67b1d6ac-70a7-11ef-9560-acde48001122.java b/docs/spring/cs67b1d6ac-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..24ae15f6
--- /dev/null
+++ b/docs/spring/cs67b1d6ac-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2009-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.type;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.ZonedDateTime;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.Mockito.*;
+
+class ZonedDateTimeTypeHandlerTest extends BaseTypeHandlerTest {
+
+ private static final TypeHandler TYPE_HANDLER = new ZonedDateTimeTypeHandler();
+ private static final ZonedDateTime ZONED_DATE_TIME = ZonedDateTime.now();
+
+ @Override
+ @Test
+ public void shouldSetParameter() throws Exception {
+ TYPE_HANDLER.setParameter(ps, 1, ZONED_DATE_TIME, null);
+ verify(ps).setObject(1, ZONED_DATE_TIME);
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultFromResultSetByName() throws Exception {
+ when(rs.getObject("column", ZonedDateTime.class)).thenReturn(ZONED_DATE_TIME);
+ assertEquals(ZONED_DATE_TIME, TYPE_HANDLER.getResult(rs, "column"));
+ verify(rs, never()).wasNull();
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultNullFromResultSetByName() throws Exception {
+ when(rs.getObject("column", ZonedDateTime.class)).thenReturn(null);
+ assertNull(TYPE_HANDLER.getResult(rs, "column"));
+ verify(rs, never()).wasNull();
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultFromResultSetByPosition() throws Exception {
+ when(rs.getObject(1, ZonedDateTime.class)).thenReturn(ZONED_DATE_TIME);
+ assertEquals(ZONED_DATE_TIME, TYPE_HANDLER.getResult(rs, 1));
+ verify(rs, never()).wasNull();
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultNullFromResultSetByPosition() throws Exception {
+ when(rs.getObject(1, ZonedDateTime.class)).thenReturn(null);
+ assertNull(TYPE_HANDLER.getResult(rs, 1));
+ verify(rs, never()).wasNull();
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultFromCallableStatement() throws Exception {
+ when(cs.getObject(1, ZonedDateTime.class)).thenReturn(ZONED_DATE_TIME);
+ assertEquals(ZONED_DATE_TIME, TYPE_HANDLER.getResult(cs, 1));
+ verify(cs, never()).wasNull();
+ }
+
+ @Override
+ @Test
+ public void shouldGetResultNullFromCallableStatement() throws Exception {
+ when(cs.getObject(1, ZonedDateTime.class)).thenReturn(null);
+ assertNull(TYPE_HANDLER.getResult(cs, 1));
+ verify(cs, never()).wasNull();
+ }
+
+}
diff --git a/docs/spring/cs67fb4d14-70a7-11ef-9560-acde48001122.java b/docs/spring/cs67fb4d14-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..3e51476b
--- /dev/null
+++ b/docs/spring/cs67fb4d14-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,22 @@
+package com.huifer.rmi.rpc.client;
+
+import com.huifer.rmi.rpc.HelloService;
+
+/**
+ * Title : ClientDemo
+ * Description :
+ *
+ * @author huifer
+ * @date 2019-06-11
+ */
+public class ClientDemo {
+
+ public static void main(String[] args) {
+ RpcClientProxy rpcClientProxy = new RpcClientProxy();
+ HelloService helloService = rpcClientProxy
+ .clientProxy(HelloService.class, "localhost", 8888);
+ String jkl = helloService.hello("hello-rpc");
+ System.out.println(jkl);
+ }
+
+}
diff --git a/docs/spring/cs684bda7c-70a7-11ef-9560-acde48001122.java b/docs/spring/cs684bda7c-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..0a553448
--- /dev/null
+++ b/docs/spring/cs684bda7c-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,14 @@
+package com.huifer.jdk.jvm;
+
+public class SonPojo extends FatherPojo {
+
+ private int age;
+
+ public SonPojo() {
+ }
+
+ public SonPojo(int age) {
+ super();
+ this.age = age;
+ }
+}
diff --git a/docs/spring/cs689fe48c-70a7-11ef-9560-acde48001122.java b/docs/spring/cs689fe48c-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..9730e280
--- /dev/null
+++ b/docs/spring/cs689fe48c-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,20 @@
+package com.huifer.design.singleton.nw;
+
+import java.io.Serializable;
+
+public class SerializableSingleton implements Serializable {
+
+ private static final SerializableSingleton singleton = new SerializableSingleton();
+
+ private SerializableSingleton() {
+ }
+
+
+ public static SerializableSingleton getInstance() {
+ return singleton;
+ }
+
+ private Object readResolve() {
+ return singleton;
+ }
+}
diff --git a/docs/spring/cs68ee6918-70a7-11ef-9560-acde48001122.java b/docs/spring/cs68ee6918-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..c83db1af
--- /dev/null
+++ b/docs/spring/cs68ee6918-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,17 @@
+package com.github.huifer.simple.shiro.boot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+@SpringBootApplication
+ @EnableJpaRepositories(basePackages = {"com.github.huifer.simple.shiro.boot.repo"})
+@EntityScan(basePackages = {"com.github.huifer.simple.shiro.boot.entity"})
+public class ShiroApp {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ShiroApp.class);
+ }
+
+}
diff --git a/docs/spring/cs693c2ae0-70a7-11ef-9560-acde48001122.java b/docs/spring/cs693c2ae0-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..2b548ac2
--- /dev/null
+++ b/docs/spring/cs693c2ae0-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,123 @@
+package com.huifer.ssm.pojo;
+
+public class UserWithBLOBs extends User {
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user.ssl_cipher
+ *
+ * @mbg.generated
+ */
+ private byte[] sslCipher;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user.x509_issuer
+ *
+ * @mbg.generated
+ */
+ private byte[] x509Issuer;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user.x509_subject
+ *
+ * @mbg.generated
+ */
+ private byte[] x509Subject;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user.authentication_string
+ *
+ * @mbg.generated
+ */
+ private String authenticationString;
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user.ssl_cipher
+ *
+ * @return the value of user.ssl_cipher
+ * @mbg.generated
+ */
+ public byte[] getSslCipher() {
+ return sslCipher;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user.ssl_cipher
+ *
+ * @param sslCipher the value for user.ssl_cipher
+ * @mbg.generated
+ */
+ public void setSslCipher(byte[] sslCipher) {
+ this.sslCipher = sslCipher;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user.x509_issuer
+ *
+ * @return the value of user.x509_issuer
+ * @mbg.generated
+ */
+ public byte[] getX509Issuer() {
+ return x509Issuer;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user.x509_issuer
+ *
+ * @param x509Issuer the value for user.x509_issuer
+ * @mbg.generated
+ */
+ public void setX509Issuer(byte[] x509Issuer) {
+ this.x509Issuer = x509Issuer;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user.x509_subject
+ *
+ * @return the value of user.x509_subject
+ * @mbg.generated
+ */
+ public byte[] getX509Subject() {
+ return x509Subject;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user.x509_subject
+ *
+ * @param x509Subject the value for user.x509_subject
+ * @mbg.generated
+ */
+ public void setX509Subject(byte[] x509Subject) {
+ this.x509Subject = x509Subject;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user.authentication_string
+ *
+ * @return the value of user.authentication_string
+ * @mbg.generated
+ */
+ public String getAuthenticationString() {
+ return authenticationString;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user.authentication_string
+ *
+ * @param authenticationString the value for user.authentication_string
+ * @mbg.generated
+ */
+ public void setAuthenticationString(String authenticationString) {
+ this.authenticationString = authenticationString == null ? null : authenticationString.trim();
+ }
+}
\ No newline at end of file
diff --git a/docs/spring/cs6988b824-70a7-11ef-9560-acde48001122.java b/docs/spring/cs6988b824-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..81d1aa77
--- /dev/null
+++ b/docs/spring/cs6988b824-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2009-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.executor;
+
+import org.apache.ibatis.transaction.Transaction;
+import org.junit.jupiter.api.Test;
+
+class ReuseExecutorTest extends BaseExecutorTest {
+
+ @Test
+ void dummy() {
+ }
+
+ @Override
+ @Test
+ public void shouldFetchPostWithBlogWithCompositeKey() throws Exception {
+ super.shouldFetchPostWithBlogWithCompositeKey();
+ }
+
+ @Override
+ protected Executor createExecutor(Transaction transaction) {
+ return new ReuseExecutor(config, transaction);
+ }
+}
diff --git a/docs/spring/cs69da4036-70a7-11ef-9560-acde48001122.java b/docs/spring/cs69da4036-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..cfe6a177
--- /dev/null
+++ b/docs/spring/cs69da4036-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2009-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.jdbc;
+
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.StringTypeHandler;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class NullTest {
+
+ @Test
+ void shouldGetTypeAndTypeHandlerForNullStringType() {
+ assertEquals(JdbcType.VARCHAR, Null.STRING.getJdbcType());
+ assertTrue(Null.STRING.getTypeHandler() instanceof StringTypeHandler);
+ }
+
+}
diff --git a/docs/spring/cs6a1f02f2-70a7-11ef-9560-acde48001122.java b/docs/spring/cs6a1f02f2-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..8da51f25
--- /dev/null
+++ b/docs/spring/cs6a1f02f2-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,13 @@
+package com.huifer.design.adapter.ChaTou;
+
+/**
+ * 描述:
+ * 全球标准
+ *
+ * @author huifer
+ * @date 2019-03-13
+ */
+public interface QqCha {
+ void method();
+
+}
diff --git a/docs/spring/cs6a76b862-70a7-11ef-9560-acde48001122.java b/docs/spring/cs6a76b862-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..c1b0bae0
--- /dev/null
+++ b/docs/spring/cs6a76b862-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,7 @@
+package com.huifer.kafka.core.excephandler;
+
+public interface ExceptionHandler {
+ public boolean support(Throwable t);
+
+ public void handle(Throwable t, String message);
+}
diff --git a/docs/spring/cs6acd6856-70a7-11ef-9560-acde48001122.java b/docs/spring/cs6acd6856-70a7-11ef-9560-acde48001122.java
new file mode 100644
index 00000000..dcc790c1
--- /dev/null
+++ b/docs/spring/cs6acd6856-70a7-11ef-9560-acde48001122.java
@@ -0,0 +1,641 @@
+/**
+ * Copyright 2009-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.executor;
+
+import org.apache.ibatis.builder.StaticSqlSource;
+import org.apache.ibatis.cache.Cache;
+import org.apache.ibatis.cache.decorators.LoggingCache;
+import org.apache.ibatis.cache.decorators.ScheduledCache;
+import org.apache.ibatis.cache.decorators.SerializedCache;
+import org.apache.ibatis.cache.decorators.SynchronizedCache;
+import org.apache.ibatis.cache.impl.PerpetualCache;
+import org.apache.ibatis.domain.blog.*;
+import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
+import org.apache.ibatis.executor.keygen.SelectKeyGenerator;
+import org.apache.ibatis.mapping.*;
+import org.apache.ibatis.scripting.xmltags.DynamicSqlSource;
+import org.apache.ibatis.scripting.xmltags.TextSqlNode;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.TypeHandlerRegistry;
+
+import java.util.*;
+
+class ExecutorTestHelper {
+
+ static final Cache authorCache;
+
+ static {
+ authorCache =
+ new SynchronizedCache(
+ new SerializedCache(
+ new LoggingCache(
+ new ScheduledCache(
+ new PerpetualCache("author_cache")))));
+
+ }
+
+ static MappedStatement prepareInsertAuthorMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "insertAuthor", new StaticSqlSource(config, "INSERT INTO author (id,username,password,email,bio,favourite_section) values(?,?,?,?,?,?)"), SqlCommandType.INSERT)
+ .parameterMap(
+ new ParameterMap.Builder(
+ config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).build());
+ add(new ParameterMapping.Builder(config, "favouriteSection", registry.getTypeHandler(Section.class)).jdbcType(JdbcType.VARCHAR).build());
+ }
+ }).build())
+ .cache(authorCache).build();
+ }
+
+ static MappedStatement prepareInsertAuthorMappedStatementWithAutoKey(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "insertAuthor", new StaticSqlSource(config, "INSERT INTO author (username,password,email,bio,favourite_section) values(?,?,?,?,?)"), SqlCommandType.INSERT)
+ .parameterMap(
+ new ParameterMap.Builder(config, "defaultParameterMap", Author.class, new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).build());
+ add(new ParameterMapping.Builder(config, "favouriteSection", registry.getTypeHandler(Section.class)).jdbcType(JdbcType.VARCHAR).build());
+ }
+ }).build())
+ .cache(authorCache)
+ .keyGenerator(Jdbc3KeyGenerator.INSTANCE)
+ .keyProperty("id")
+ .build();
+ }
+
+ static MappedStatement prepareInsertAuthorProc(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "insertAuthorProc", new StaticSqlSource(config, "{call insertAuthor(?,?,?,?)}"), SqlCommandType.INSERT)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
+ }
+ }).build())
+ .cache(authorCache).build();
+ }
+
+ static MappedStatement prepareUpdateAuthorMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "updateAuthor", new StaticSqlSource(config, "UPDATE author SET username = ?, password = ?, email = ?, bio = ? WHERE id = ?"), SqlCommandType.UPDATE)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).build());
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build())
+ .cache(authorCache).build();
+ }
+
+ static MappedStatement prepareDeleteAuthorMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "deleteAuthor", new StaticSqlSource(config, "DELETE FROM author WHERE id = ?"), SqlCommandType.DELETE)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build())
+ .cache(authorCache)
+ .build();
+ }
+
+ static MappedStatement prepareSelectOneAuthorMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+
+ final ResultMap rm = new ResultMap.Builder(config, "defaultResultMap", Author.class, new
+ ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "favouriteSection", "favourite_section", registry.getTypeHandler(Section.class)).build());
+ }
+ }).build();
+
+ return new MappedStatement.Builder(config, "selectAuthor", new StaticSqlSource(config, "SELECT * FROM author WHERE id = ?"), SqlCommandType.SELECT)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build())
+ .resultMaps(new ArrayList() {
+ {
+ add(rm);
+ }
+ })
+ .cache(authorCache).build();
+ }
+
+ static MappedStatement prepareSelectAllAuthorsAutoMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "selectAuthorAutoMap", new StaticSqlSource(config, "SELECT * FROM author ORDER BY id"), SqlCommandType.SELECT)
+ .resultMaps(new ArrayList() {
+ {
+ add(new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "favouriteSection", "favourite_section", registry.getTypeHandler(Section.class)).build());
+ add(new ResultMapping.Builder(config, null, "not_exists", Object.class).build());
+ }
+ }).build());
+ }
+ }).fetchSize(1000).timeout(2000).build();
+ }
+
+ static MappedStatement prepareSelectOneAuthorMappedStatementWithConstructorResults(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "selectAuthor", new StaticSqlSource(config, "SELECT * FROM author WHERE id = ?"), SqlCommandType.SELECT)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build())
+ .resultMaps(new ArrayList() {
+ {
+ add(new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, null, "id", registry.getTypeHandler(Integer.class)).javaType(int.class).flags(new ArrayList() {
+ {
+ add(ResultFlag.CONSTRUCTOR);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "favouriteSection", "favourite_section", registry.getTypeHandler(Section.class)).build());
+ }
+ }).build());
+ }
+ })
+ .cache(authorCache)
+ .build();
+ }
+
+ static MappedStatement prepareSelectTwoSetsOfAuthorsProc(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "selectTwoSetsOfAuthors", new StaticSqlSource(config, "{call selectTwoSetsOfAuthors(?,?)}"), SqlCommandType.SELECT)
+ .statementType(StatementType.CALLABLE)
+ .parameterMap(new ParameterMap.Builder(
+ config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id1", registry.getTypeHandler(int.class)).build());
+ add(new ParameterMapping.Builder(config, "id2", registry.getTypeHandler(int.class)).build());
+ }
+ }).build())
+ .resultMaps(new ArrayList() {
+ {
+ ResultMap map = new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ add(map);
+ add(map);
+ }
+ }).build();
+ }
+
+ static MappedStatement prepareSelectAuthorViaOutParams(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "selectAuthorViaOutParams", new StaticSqlSource(config, "{call selectAuthorViaOutParams(?,?,?,?,?)}"), SqlCommandType.SELECT)
+ .statementType(StatementType.CALLABLE)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
+ add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
+ }
+ }).build())
+ .resultMaps(new ArrayList<>())
+ .cache(authorCache).build();
+ }
+
+ static MappedStatement prepareSelectDiscriminatedPost(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final ResultMap discriminatorResultMap = new ResultMap.Builder(config, "postResultMap", HashMap.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "subject", "subject", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "body", "body", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ config.addResultMap(discriminatorResultMap);
+ return new MappedStatement.Builder(config, "selectPosts", new StaticSqlSource(config, "SELECT * FROM post"), SqlCommandType.SELECT)
+ .resultMaps(new ArrayList() {
+ {
+ add(new ResultMap.Builder(config, "defaultResultMap", HashMap.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "blog_id", "blog_id", registry.getTypeHandler(int.class)).build());
+ }
+ })
+ .discriminator(new Discriminator.Builder(
+ config, new ResultMapping.Builder(config, "section", "section", registry.getTypeHandler(String.class)).build(),
+ new HashMap() {
+ {
+ put("NEWS", discriminatorResultMap.getId());
+ put("VIDEOS", discriminatorResultMap.getId());
+ put("PODCASTS", discriminatorResultMap.getId());
+ //NEWS left out on purpose.
+ }
+ }).build()).build());
+
+ }
+ }).build();
+ }
+
+ static MappedStatement createInsertAuthorWithIDof99MappedStatement(final Configuration config) {
+ return new MappedStatement.Builder(config, "insertAuthor", new StaticSqlSource(config, "INSERT INTO author (id,username,password,email,bio) values(99,'someone','******','someone@apache.org',null)"), SqlCommandType.INSERT)
+ .statementType(StatementType.STATEMENT)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList<>()).build())
+ .cache(authorCache)
+ .build();
+ }
+
+ static MappedStatement createSelectAuthorWithIDof99MappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ return new MappedStatement.Builder(config, "selectAuthor", new StaticSqlSource(config, "SELECT * FROM author WHERE id = 99"), SqlCommandType.SELECT)
+ .statementType(StatementType.STATEMENT)
+ .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class, new ArrayList<>()).build())
+ .resultMaps(new ArrayList() {
+ {
+ add(new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
+ }
+ }).build());
+ }
+ }).build();
+ }
+
+ static MappedStatement prepareComplexSelectBlogMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final SqlSource sqlSource = new StaticSqlSource(config, "SELECT b.id, b.author_id, b.title, a.username, a.password, a.email, a.bio" +
+ " FROM blog b" +
+ " INNER JOIN author a ON b.author_id = a.id" +
+ " WHERE b.id = ?");
+ final ParameterMap parameterMap = new ParameterMap.Builder(config, "defaultParameterMap", int.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build();
+ final ResultMap resultMap = new ResultMap.Builder(config, "defaultResultMap", Blog.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "title", "title", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.id", "author_id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "author.username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.bio", "bio", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "posts", "id", registry.getTypeHandler(int.class)).javaType(List.class).nestedQueryId("selectPostsForBlog").build());
+ }
+ }).build();
+
+ return new MappedStatement.Builder(config, "selectBlogById", sqlSource, SqlCommandType.SELECT)
+ .parameterMap(parameterMap)
+ .resultMaps(new ArrayList() {
+ {
+ add(resultMap);
+ }
+ }).build();
+ }
+
+ static MappedStatement prepareSelectBlogByIdAndAuthor(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final SqlSource sqlSource = new StaticSqlSource(config, "SELECT b.id, b.author_id, b.title, a.username, a.password, a.email, a.bio" +
+ " FROM blog b" +
+ " INNER JOIN author a ON b.author_id = a.id" +
+ " WHERE b.id = ? and a.id = ?");
+ final ParameterMap parameterMap = new ParameterMap.Builder(config, "defaultParameterMap", Map.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "blogId", registry.getTypeHandler(int.class)).build());
+ add(new ParameterMapping.Builder(config, "authorId", registry.getTypeHandler(int.class)).build());
+ }
+ }).build();
+ final ResultMap resultMap = new ResultMap.Builder(config, "defaultResultMap", Blog.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "title", "title", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.id", "author_id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "author.username", "username", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.password", "password", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.email", "email", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "author.bio", "bio", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "posts", "id", registry.getTypeHandler(int.class)).javaType(List.class).nestedQueryId("selectPostsForBlog").build());
+ }
+ }).build();
+
+ return new MappedStatement.Builder(config, "selectBlogByIdAndAuthor", sqlSource, SqlCommandType.SELECT)
+ .parameterMap(parameterMap)
+ .resultMaps(new ArrayList() {
+ {
+ add(resultMap);
+ }
+ }).build();
+
+ }
+
+ static MappedStatement prepareSelectPostsForBlogMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final SqlSource sqlSource = new StaticSqlSource(config, "SELECT p.id, p.created_on, p.blog_id, p.section, p.subject, p.body, pt.tag_id," +
+ " t.name as tag_name, c.id as comment_id, c.name as comment_name, c.comment" +
+ " FROM post p" +
+ " INNER JOIN post_tag pt ON pt.post_id = p.id" +
+ " INNER JOIN tag t ON pt.tag_id = t.id" +
+ " LEFT OUTER JOIN comment c ON c.post_id = p.id" +
+ " WHERE p.blog_id = ?");
+ final ParameterMap parameterMap = new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build();
+ final ResultMap tagResultMap = new ResultMap.Builder(config, "tagResultMap", Tag.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "tag_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "tag_name", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ final ResultMap commentResultMap = new ResultMap.Builder(config, "commentResultMap", Comment.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "comment_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "comment_name", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "comment", "comment", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ config.addResultMap(tagResultMap);
+ config.addResultMap(commentResultMap);
+ final ResultMap postResultMap = new ResultMap.Builder(config, "defaultResultMap", Post.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "blog", "blog_id", registry.getTypeHandler(int.class)).javaType(Blog.class).nestedQueryId("selectBlogById").build());
+ add(new ResultMapping.Builder(config, "createdOn", "created_on", registry.getTypeHandler(Date.class)).build());
+ add(new ResultMapping.Builder(config, "section", "section", registry.getTypeHandler(Section.class)).build());
+ add(new ResultMapping.Builder(config, "subject", "subject", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "body", "body", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "tags").nestedResultMapId(tagResultMap.getId()).build());
+ add(new ResultMapping.Builder(config, "comments").nestedResultMapId(commentResultMap.getId()).build());
+ }
+ }).build();
+ return new MappedStatement.Builder(config, "selectPostsForBlog", sqlSource, SqlCommandType.SELECT)
+ .parameterMap(parameterMap)
+ .resultMaps(new ArrayList() {
+ {
+ add(postResultMap);
+ }
+ }).build();
+ }
+
+ static MappedStatement prepareSelectPostMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final SqlSource sqlSource = new StaticSqlSource(config, "SELECT p.id, p.created_on, p.blog_id, p.section, p.subject, p.body, pt.tag_id," +
+ " t.name as tag_name, c.id as comment_id, c.name as comment_name, c.comment" +
+ " FROM post p" +
+ " LEFT OUTER JOIN post_tag pt ON pt.post_id = p.id" +
+ " LEFT OUTER JOIN tag t ON pt.tag_id = t.id" +
+ " LEFT OUTER JOIN comment c ON c.post_id = p.id" +
+ " WHERE p.id = ?");
+ final ParameterMap parameterMap = new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build();
+ final ResultMap tagResultMap = new ResultMap.Builder(config, "tagResultMap", Tag.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "tag_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "tag_name", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ final ResultMap commentResultMap = new ResultMap.Builder(config, "commentResultMap", Comment.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "comment_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "comment_name", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "comment", "comment", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ config.addResultMap(tagResultMap);
+ config.addResultMap(commentResultMap);
+ final ResultMap postResultMap = new ResultMap.Builder(config, "", Post.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "blog", "blog_id", registry.getTypeHandler(int.class)).javaType(Blog.class).nestedQueryId("selectBlogById").build());
+ add(new ResultMapping.Builder(config, "createdOn", "created_on", registry.getTypeHandler(Date.class)).build());
+ add(new ResultMapping.Builder(config, "section", "section", registry.getTypeHandler(Section.class)).build());
+ add(new ResultMapping.Builder(config, "subject", "subject", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "body", "body", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "tags").nestedResultMapId(tagResultMap.getId()).build());
+ add(new ResultMapping.Builder(config, "comments").nestedResultMapId(commentResultMap.getId()).build());
+ }
+ }).build();
+
+
+ return new MappedStatement.Builder(config, "selectPostsForBlog", sqlSource, SqlCommandType.SELECT)
+ .parameterMap(parameterMap)
+ .resultMaps(new ArrayList() {
+ {
+ add(postResultMap);
+ }
+ }).build();
+ }
+
+
+ static MappedStatement prepareSelectPostWithBlogByAuthorMappedStatement(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final SqlSource sqlSource = new StaticSqlSource(config, "SELECT p.id, p.created_on, p.blog_id, p.author_id, p.section, p.subject, p.body, pt.tag_id," +
+ " t.name as tag_name, c.id as comment_id, c.name as comment_name, c.comment" +
+ " FROM post p" +
+ " LEFT OUTER JOIN post_tag pt ON pt.post_id = p.id" +
+ " LEFT OUTER JOIN tag t ON pt.tag_id = t.id" +
+ " LEFT OUTER JOIN comment c ON c.post_id = p.id" +
+ " WHERE p.id = ?");
+ final ParameterMap parameterMap = new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
+ new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build();
+ final ResultMap tagResultMap = new ResultMap.Builder(config, "tagResultMap", Tag.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "tag_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "tag_name", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ final ResultMap commentResultMap = new ResultMap.Builder(config, "commentResultMap", Comment.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "comment_id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "name", "comment_name", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "comment", "comment", registry.getTypeHandler(String.class)).build());
+ }
+ }).build();
+ config.addResultMap(tagResultMap);
+ config.addResultMap(commentResultMap);
+ final ResultMap postResultMap = new ResultMap.Builder(config, "postResultMap", Post.class, new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class))
+ .flags(new ArrayList() {
+ {
+ add(ResultFlag.ID);
+ }
+ }).build());
+
+ add(new ResultMapping.Builder(config, "blog").nestedQueryId("selectBlogByIdAndAuthor").composites(new ArrayList() {
+ {
+ add(new ResultMapping.Builder(config, "authorId", "author_id", registry.getTypeHandler(int.class)).build());
+ add(new ResultMapping.Builder(config, "blogId", "blog_id", registry.getTypeHandler(int.class)).build());
+ }
+ }).build());
+ add(new ResultMapping.Builder(config, "createdOn", "created_on", registry.getTypeHandler(Date.class)).build());
+ add(new ResultMapping.Builder(config, "section", "section", registry.getTypeHandler(Section.class)).build());
+ add(new ResultMapping.Builder(config, "subject", "subject", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "body", "body", registry.getTypeHandler(String.class)).build());
+ add(new ResultMapping.Builder(config, "tags").nestedResultMapId(tagResultMap.getId()).build());
+ add(new ResultMapping.Builder(config, "comments").nestedResultMapId(commentResultMap.getId()).build());
+ }
+ }).build();
+
+
+ return new MappedStatement.Builder(config, "selectPostsForBlog", sqlSource, SqlCommandType.SELECT)
+ .parameterMap(parameterMap)
+ .resultMaps(new ArrayList() {
+ {
+ add(postResultMap);
+ }
+ }).build();
+ }
+
+
+ static MappedStatement prepareInsertAuthorMappedStatementWithBeforeAutoKey(final Configuration config) {
+ final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
+ final ResultMap rm = new ResultMap.Builder(config, "keyResultMap", Integer.class, new ArrayList<>())
+ .build();
+
+ MappedStatement kms = new MappedStatement.Builder(config, "insertAuthor!selectKey", new StaticSqlSource(config, "SELECT 123456 as id FROM SYSIBM.SYSDUMMY1"), SqlCommandType.SELECT)
+ .keyProperty("id")
+ .resultMaps(new ArrayList() {
+ {
+ add(rm);
+ }
+ })
+ .build();
+ config.addMappedStatement(kms);
+ return new MappedStatement.Builder(config, "insertAuthor", new DynamicSqlSource(config, new TextSqlNode("INSERT INTO author (id,username,password,email,bio,favourite_section) values(#{id},#{username},#{password},#{email},#{bio:VARCHAR},#{favouriteSection})")), SqlCommandType.INSERT)
+ .parameterMap(
+ new ParameterMap.Builder(config, "defaultParameterMap", Author.class, new ArrayList() {
+ {
+ add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(Integer.class)).build());
+ add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
+ add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).build());
+ add(new ParameterMapping.Builder(config, "favouriteSection", registry.getTypeHandler(Section.class)).jdbcType(JdbcType.VARCHAR).build());
+ }
+ }).build())
+ .cache(authorCache)
+ .keyGenerator(new SelectKeyGenerator(kms, true))
+ .keyProperty("id")
+ .build();
+ }
+
+
+}