View Javadoc
1   /*
2    *    Copyright 2016-2026 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package examples.animal.data;
17  
18  import static examples.animal.data.AnimalDataDynamicSqlSupport.*;
19  import static org.assertj.core.api.Assertions.assertThat;
20  import static org.junit.jupiter.api.Assertions.assertAll;
21  import static org.mybatis.dynamic.sql.SqlBuilder.*;
22  
23  import java.io.InputStream;
24  import java.io.InputStreamReader;
25  import java.sql.Connection;
26  import java.sql.DriverManager;
27  import java.util.List;
28  
29  import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
30  import org.apache.ibatis.jdbc.ScriptRunner;
31  import org.apache.ibatis.mapping.Environment;
32  import org.apache.ibatis.session.Configuration;
33  import org.apache.ibatis.session.SqlSession;
34  import org.apache.ibatis.session.SqlSessionFactory;
35  import org.apache.ibatis.session.SqlSessionFactoryBuilder;
36  import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
37  import org.jspecify.annotations.Nullable;
38  import org.junit.jupiter.api.BeforeEach;
39  import org.junit.jupiter.api.Test;
40  import org.mybatis.dynamic.sql.render.RenderingStrategies;
41  import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
42  
43  class OptionalConditionsAnimalDataTest {
44  
45      private static final String JDBC_URL = "jdbc:hsqldb:mem:aname";
46      private static final String JDBC_DRIVER = "org.hsqldb.jdbcDriver";
47      private static final @Nullable Integer NULL_INTEGER = null;
48  
49      private SqlSessionFactory sqlSessionFactory;
50  
51      @BeforeEach
52      void setup() throws Exception {
53          Class.forName(JDBC_DRIVER);
54          try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
55              assert is != null;
56              try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
57                  InputStreamReader isr = new InputStreamReader(is)) {
58                  ScriptRunner sr = new ScriptRunner(connection);
59                  sr.setLogWriter(null);
60                  sr.runScript(isr);
61              }
62          }
63  
64          UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");
65          Environment environment = new Environment("test", new JdbcTransactionFactory(), ds);
66          Configuration config = new Configuration(environment);
67          config.addMapper(AnimalDataMapper.class);
68          sqlSessionFactory = new SqlSessionFactoryBuilder().build(config);
69      }
70  
71      @Test
72      void testAllIgnored() {
73          try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
74              AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
75              SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
76                      .from(animalData)
77                      .where(id, isGreaterThanWhenPresent(NULL_INTEGER))  // the where clause should not render
78                      .orderBy(id)
79                      .configureStatement(c -> c.setNonRenderingWhereClauseAllowed(true))
80                      .build()
81                      .render(RenderingStrategies.MYBATIS3);
82              List<AnimalData> animals = mapper.selectMany(selectStatement);
83              assertAll(
84                      () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData order by id"),
85                      () -> assertThat(animals).hasSize(65),
86                      () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1),
87                      () -> assertThat(animals).element(1).isNotNull().extracting(AnimalData::id).isEqualTo(2)
88              );
89          }
90      }
91  
92      @Test
93      void testIgnoredBetweenRendered() {
94          try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
95              AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
96              SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
97                      .from(animalData)
98                      .where(id, isEqualTo(3))
99                      .and(id, isNotEqualToWhenPresent(NULL_INTEGER))
100                     .or(id, isEqualToWhenPresent(4))
101                     .orderBy(id)
102                     .build()
103                     .render(RenderingStrategies.MYBATIS3);
104             List<AnimalData> animals = mapper.selectMany(selectStatement);
105             assertAll(
106                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id = #{parameters.p1,jdbcType=INTEGER} or id = #{parameters.p2,jdbcType=INTEGER} order by id"),
107                     () -> assertThat(animals).hasSize(2),
108                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3),
109                     () -> assertThat(animals).element(1).isNotNull().extracting(AnimalData::id).isEqualTo(4)
110             );
111         }
112     }
113 
114     @Test
115     void testIgnoredInWhere() {
116         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
117             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
118             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
119                     .from(animalData)
120                     .where(id, isLessThanWhenPresent(NULL_INTEGER))
121                     .and(id, isEqualToWhenPresent(3))
122                     .or(id, isEqualToWhenPresent(4))
123                     .orderBy(id)
124                     .build()
125                     .render(RenderingStrategies.MYBATIS3);
126             List<AnimalData> animals = mapper.selectMany(selectStatement);
127             assertAll(
128                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id = #{parameters.p1,jdbcType=INTEGER} or id = #{parameters.p2,jdbcType=INTEGER} order by id"),
129                     () -> assertThat(animals).hasSize(2),
130                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3),
131                     () -> assertThat(animals).element(1).isNotNull().extracting(AnimalData::id).isEqualTo(4)
132             );
133         }
134     }
135 
136     @Test
137     void testManyIgnored() {
138         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
139             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
140             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
141                     .from(animalData)
142                     .where(id, isLessThanWhenPresent(NULL_INTEGER), and(id, isGreaterThanOrEqualToWhenPresent(NULL_INTEGER)))
143                     .and(id, isEqualToWhenPresent(NULL_INTEGER), or(id, isEqualTo(3), and(id, isLessThanWhenPresent(NULL_INTEGER))))
144                     .or(id, isEqualToWhenPresent(4), and(id, isGreaterThanOrEqualToWhenPresent(NULL_INTEGER)))
145                     .and(id, isNotEqualToWhenPresent(NULL_INTEGER))
146                     .orderBy(id)
147                     .build()
148                     .render(RenderingStrategies.MYBATIS3);
149             List<AnimalData> animals = mapper.selectMany(selectStatement);
150             assertAll(
151                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id = #{parameters.p1,jdbcType=INTEGER} or id = #{parameters.p2,jdbcType=INTEGER} order by id"),
152                     () -> assertThat(animals).hasSize(2),
153                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3),
154                     () -> assertThat(animals).element(1).isNotNull().extracting(AnimalData::id).isEqualTo(4)
155             );
156         }
157     }
158 
159     @Test
160     void testIgnoredInitialWhere() {
161         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
162             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
163             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
164                     .from(animalData)
165                     .where(id, isLessThanWhenPresent(NULL_INTEGER), and(id, isEqualToWhenPresent(3)))
166                     .or(id, isEqualToWhenPresent(4))
167                     .orderBy(id)
168                     .build()
169                     .render(RenderingStrategies.MYBATIS3);
170             List<AnimalData> animals = mapper.selectMany(selectStatement);
171             assertAll(
172                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id = #{parameters.p1,jdbcType=INTEGER} or id = #{parameters.p2,jdbcType=INTEGER} order by id"),
173                     () -> assertThat(animals).hasSize(2),
174                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3),
175                     () -> assertThat(animals).element(1).isNotNull().extracting(AnimalData::id).isEqualTo(4)
176             );
177         }
178     }
179 
180     @Test
181     void testEqualWhenPresentWithValue() {
182         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
183             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
184             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
185                     .from(animalData)
186                     .where(id, isEqualToWhenPresent(4))
187                     .orderBy(id)
188                     .build()
189                     .render(RenderingStrategies.MYBATIS3);
190             List<AnimalData> animals = mapper.selectMany(selectStatement);
191             assertAll(
192                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id = #{parameters.p1,jdbcType=INTEGER} order by id"),
193                     () -> assertThat(animals).hasSize(1),
194                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(4)
195             );
196         }
197     }
198 
199     @Test
200     void testEqualWhenPresentWithoutValue() {
201         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
202             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
203             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
204                     .from(animalData)
205                     .where(id, isEqualToWhenPresent(NULL_INTEGER))
206                     .and(id, isLessThanOrEqualTo(10))
207                     .orderBy(id)
208                     .build()
209                     .render(RenderingStrategies.MYBATIS3);
210             List<AnimalData> animals = mapper.selectMany(selectStatement);
211             assertAll(
212                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
213                     () -> assertThat(animals).hasSize(10),
214                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
215             );
216         }
217     }
218 
219     @Test
220     void testNotEqualWhenPresentWithValue() {
221         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
222             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
223             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
224                     .from(animalData)
225                     .where(id, isNotEqualToWhenPresent(4))
226                     .and(id, isLessThanOrEqualTo(10))
227                     .orderBy(id)
228                     .build()
229                     .render(RenderingStrategies.MYBATIS3);
230             List<AnimalData> animals = mapper.selectMany(selectStatement);
231             assertAll(
232                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <> #{parameters.p1,jdbcType=INTEGER} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
233                     () -> assertThat(animals).hasSize(9),
234                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
235             );
236         }
237     }
238 
239     @Test
240     void testNotEqualWhenPresentWithoutValue() {
241         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
242             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
243             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
244                     .from(animalData)
245                     .where(id, isNotEqualToWhenPresent(NULL_INTEGER))
246                     .and(id, isLessThanOrEqualTo(10))
247                     .orderBy(id)
248                     .build()
249                     .render(RenderingStrategies.MYBATIS3);
250             List<AnimalData> animals = mapper.selectMany(selectStatement);
251             assertAll(
252                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
253                     () -> assertThat(animals).hasSize(10),
254                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
255             );
256         }
257     }
258 
259     @Test
260     void testGreaterThanWhenPresentWithValue() {
261         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
262             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
263             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
264                     .from(animalData)
265                     .where(id, isGreaterThanWhenPresent(4))
266                     .and(id, isLessThanOrEqualTo(10))
267                     .orderBy(id)
268                     .build()
269                     .render(RenderingStrategies.MYBATIS3);
270             List<AnimalData> animals = mapper.selectMany(selectStatement);
271             assertAll(
272                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id > #{parameters.p1,jdbcType=INTEGER} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
273                     () -> assertThat(animals).hasSize(6),
274                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(5)
275             );
276         }
277     }
278 
279     @Test
280     void testGreaterThanWhenPresentWithoutValue() {
281         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
282             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
283             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
284                     .from(animalData)
285                     .where(id, isGreaterThanWhenPresent(NULL_INTEGER))
286                     .and(id, isLessThanOrEqualTo(10))
287                     .orderBy(id)
288                     .build()
289                     .render(RenderingStrategies.MYBATIS3);
290             List<AnimalData> animals = mapper.selectMany(selectStatement);
291             assertAll(
292                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
293                     () -> assertThat(animals).hasSize(10),
294                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
295             );
296         }
297     }
298 
299     @Test
300     void testGreaterThanOrEqualToWhenPresentWithValue() {
301         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
302             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
303             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
304                     .from(animalData)
305                     .where(id, isGreaterThanOrEqualToWhenPresent(4))
306                     .and(id, isLessThanOrEqualTo(10))
307                     .orderBy(id)
308                     .build()
309                     .render(RenderingStrategies.MYBATIS3);
310             List<AnimalData> animals = mapper.selectMany(selectStatement);
311             assertAll(
312                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id >= #{parameters.p1,jdbcType=INTEGER} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
313                     () -> assertThat(animals).hasSize(7),
314                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(4)
315             );
316         }
317     }
318 
319     @Test
320     void testGreaterThanOrEqualToWhenPresentWithoutValue() {
321         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
322             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
323             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
324                     .from(animalData)
325                     .where(id, isGreaterThanOrEqualToWhenPresent(NULL_INTEGER))
326                     .and(id, isLessThanOrEqualTo(10))
327                     .orderBy(id)
328                     .build()
329                     .render(RenderingStrategies.MYBATIS3);
330             List<AnimalData> animals = mapper.selectMany(selectStatement);
331             assertAll(
332                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
333                     () -> assertThat(animals).hasSize(10),
334                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
335             );
336         }
337     }
338 
339     @Test
340     void testLessThanWhenPresentWithValue() {
341         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
342             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
343             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
344                     .from(animalData)
345                     .where(id, isLessThanWhenPresent(4))
346                     .orderBy(id)
347                     .build()
348                     .render(RenderingStrategies.MYBATIS3);
349             List<AnimalData> animals = mapper.selectMany(selectStatement);
350             assertAll(
351                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id < #{parameters.p1,jdbcType=INTEGER} order by id"),
352                     () -> assertThat(animals).hasSize(3),
353                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
354             );
355         }
356     }
357 
358     @Test
359     void testLessThanWhenPresentWithoutValue() {
360         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
361             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
362             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
363                     .from(animalData)
364                     .where(id, isLessThanWhenPresent(NULL_INTEGER))
365                     .and(id, isLessThanOrEqualTo(10))
366                     .orderBy(id)
367                     .build()
368                     .render(RenderingStrategies.MYBATIS3);
369             List<AnimalData> animals = mapper.selectMany(selectStatement);
370             assertAll(
371                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
372                     () -> assertThat(animals).hasSize(10),
373                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
374             );
375         }
376     }
377 
378     @Test
379     void testLessThanOrEqualToWhenPresentWithValue() {
380         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
381             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
382             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
383                     .from(animalData)
384                     .where(id, isLessThanOrEqualToWhenPresent(4))
385                     .orderBy(id)
386                     .build()
387                     .render(RenderingStrategies.MYBATIS3);
388             List<AnimalData> animals = mapper.selectMany(selectStatement);
389             assertAll(
390                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
391                     () -> assertThat(animals).hasSize(4),
392                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
393             );
394         }
395     }
396 
397     @Test
398     void testLessThanOrEqualToWhenPresentWithoutValue() {
399         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
400             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
401             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
402                     .from(animalData)
403                     .where(id, isLessThanOrEqualToWhenPresent(NULL_INTEGER))
404                     .and(id, isLessThanOrEqualTo(10))
405                     .orderBy(id)
406                     .build()
407                     .render(RenderingStrategies.MYBATIS3);
408             List<AnimalData> animals = mapper.selectMany(selectStatement);
409             assertAll(
410                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
411                     () -> assertThat(animals).hasSize(10),
412                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
413             );
414         }
415     }
416 
417     @Test
418     void testIsInWhenPresentWithValue() {
419         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
420             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
421             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
422                     .from(animalData)
423                     .where(id, isInWhenPresent(4, 5, 6))
424                     .orderBy(id)
425                     .build()
426                     .render(RenderingStrategies.MYBATIS3);
427             List<AnimalData> animals = mapper.selectMany(selectStatement);
428             assertAll(
429                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER},#{parameters.p3,jdbcType=INTEGER}) order by id"),
430                     () -> assertThat(animals).hasSize(3),
431                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(4)
432             );
433         }
434     }
435 
436     @Test
437     void testIsInWhenPresentWithSomeValues() {
438         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
439             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
440             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
441                     .from(animalData)
442                     .where(id, isInWhenPresent(3, NULL_INTEGER, 5))
443                     .orderBy(id)
444                     .build()
445                     .render(RenderingStrategies.MYBATIS3);
446             List<AnimalData> animals = mapper.selectMany(selectStatement);
447             assertAll(
448                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER}) order by id"),
449                     () -> assertThat(animals).hasSize(2),
450                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3)
451             );
452         }
453     }
454 
455     @Test
456     void testIsInWhenPresentWithNoValues() {
457         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
458             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
459             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
460                     .from(animalData)
461                     .where(id, isInWhenPresent())
462                     .and(id, isLessThanOrEqualTo(10))
463                     .orderBy(id)
464                     .build()
465                     .render(RenderingStrategies.MYBATIS3);
466             List<AnimalData> animals = mapper.selectMany(selectStatement);
467             assertAll(
468                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
469                     () -> assertThat(animals).hasSize(10),
470                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
471             );
472         }
473     }
474 
475     @Test
476     void testIsInCaseInsensitiveWhenPresentWithValue() {
477         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
478             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
479             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
480                     .from(animalData)
481                     .where(animalName, isInCaseInsensitiveWhenPresent("mouse", "musk shrew"))
482                     .orderBy(id)
483                     .build()
484                     .render(RenderingStrategies.MYBATIS3);
485             List<AnimalData> animals = mapper.selectMany(selectStatement);
486             assertAll(
487                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) order by id"),
488                     () -> assertThat(animals).hasSize(2),
489                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(4)
490             );
491         }
492     }
493 
494     @Test
495     void testIsInCaseInsensitiveWhenPresentWithSomeValues() {
496         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
497             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
498             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
499                     .from(animalData)
500                     .where(animalName, isInCaseInsensitiveWhenPresent("mouse", null, "musk shrew"))
501                     .orderBy(id)
502                     .build()
503                     .render(RenderingStrategies.MYBATIS3);
504             List<AnimalData> animals = mapper.selectMany(selectStatement);
505             assertAll(
506                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) order by id"),
507                     () -> assertThat(animals).hasSize(2),
508                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(4)
509             );
510         }
511     }
512 
513     @Test
514     void testIsInCaseInsensitiveWhenPresentWithNoValues() {
515         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
516             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
517             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
518                     .from(animalData)
519                     .where(animalName, isInCaseInsensitiveWhenPresent())
520                     .and(id, isLessThanOrEqualTo(10))
521                     .orderBy(id)
522                     .build()
523                     .render(RenderingStrategies.MYBATIS3);
524             List<AnimalData> animals = mapper.selectMany(selectStatement);
525             assertAll(
526                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
527                     () -> assertThat(animals).hasSize(10),
528                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
529             );
530         }
531     }
532 
533     @Test
534     void testIsNotInWhenPresentWithValue() {
535         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
536             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
537             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
538                     .from(animalData)
539                     .where(id, isNotInWhenPresent(4, 5, 6))
540                     .and(id, isLessThanOrEqualTo(10))
541                     .orderBy(id)
542                     .build()
543                     .render(RenderingStrategies.MYBATIS3);
544             List<AnimalData> animals = mapper.selectMany(selectStatement);
545             assertAll(
546                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id not in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER},#{parameters.p3,jdbcType=INTEGER}) and id <= #{parameters.p4,jdbcType=INTEGER} order by id"),
547                     () -> assertThat(animals).hasSize(7),
548                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
549             );
550         }
551     }
552 
553     @Test
554     void testIsNotInWhenPresentWithSomeValues() {
555         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
556             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
557             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
558                     .from(animalData)
559                     .where(id, isNotInWhenPresent(3, NULL_INTEGER, 5))
560                     .and(id, isLessThanOrEqualTo(10))
561                     .orderBy(id)
562                     .build()
563                     .render(RenderingStrategies.MYBATIS3);
564             List<AnimalData> animals = mapper.selectMany(selectStatement);
565             assertAll(
566                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id not in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER}) and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
567                     () -> assertThat(animals).hasSize(8),
568                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
569             );
570         }
571     }
572 
573     @Test
574     void testIsNotInWhenPresentWithNoValues() {
575         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
576             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
577             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
578                     .from(animalData)
579                     .where(id, isNotInWhenPresent())
580                     .and(id, isLessThanOrEqualTo(10))
581                     .orderBy(id)
582                     .build()
583                     .render(RenderingStrategies.MYBATIS3);
584             List<AnimalData> animals = mapper.selectMany(selectStatement);
585             assertAll(
586                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
587                     () -> assertThat(animals).hasSize(10),
588                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
589             );
590         }
591     }
592 
593     @Test
594     void testIsNotInCaseInsensitiveWhenPresentWithValue() {
595         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
596             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
597             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
598                     .from(animalData)
599                     .where(animalName, isNotInCaseInsensitiveWhenPresent("mouse", "musk shrew"))
600                     .and(id, isLessThanOrEqualTo(10))
601                     .orderBy(id)
602                     .build()
603                     .render(RenderingStrategies.MYBATIS3);
604             List<AnimalData> animals = mapper.selectMany(selectStatement);
605             assertAll(
606                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) not in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
607                     () -> assertThat(animals).hasSize(8),
608                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
609             );
610         }
611     }
612 
613     @Test
614     void testIsNotInCaseInsensitiveWhenPresentWithSomeValues() {
615         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
616             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
617             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
618                     .from(animalData)
619                     .where(animalName, isNotInCaseInsensitiveWhenPresent("mouse", null, "musk shrew"))
620                     .and(id, isLessThanOrEqualTo(10))
621                     .orderBy(id)
622                     .build()
623                     .render(RenderingStrategies.MYBATIS3);
624             List<AnimalData> animals = mapper.selectMany(selectStatement);
625             assertAll(
626                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) not in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
627                     () -> assertThat(animals).hasSize(8),
628                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
629             );
630         }
631     }
632 
633     @Test
634     void testIsNotInCaseInsensitiveWhenPresentWithNoValues() {
635         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
636             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
637             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
638                     .from(animalData)
639                     .where(animalName, isNotInCaseInsensitiveWhenPresent())
640                     .and(id, isLessThanOrEqualTo(10))
641                     .orderBy(id)
642                     .build()
643                     .render(RenderingStrategies.MYBATIS3);
644             List<AnimalData> animals = mapper.selectMany(selectStatement);
645             assertAll(
646                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
647                     () -> assertThat(animals).hasSize(10),
648                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
649             );
650         }
651     }
652 
653     @Test
654     void testIsBetweenWhenPresentWithValues() {
655         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
656             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
657             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
658                     .from(animalData)
659                     .where(id, isBetweenWhenPresent(3).and(6))
660                     .orderBy(id)
661                     .build()
662                     .render(RenderingStrategies.MYBATIS3);
663             List<AnimalData> animals = mapper.selectMany(selectStatement);
664             assertAll(
665                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id between #{parameters.p1,jdbcType=INTEGER} and #{parameters.p2,jdbcType=INTEGER} order by id"),
666                     () -> assertThat(animals).hasSize(4),
667                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(3)
668             );
669         }
670     }
671 
672     @Test
673     void testIsBetweenWhenPresentWithFirstMissing() {
674         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
675             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
676             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
677                     .from(animalData)
678                     .where(id, isBetweenWhenPresent(NULL_INTEGER).and(6))
679                     .and(id, isLessThanOrEqualTo(10))
680                     .orderBy(id)
681                     .build()
682                     .render(RenderingStrategies.MYBATIS3);
683             List<AnimalData> animals = mapper.selectMany(selectStatement);
684             assertAll(
685                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
686                     () -> assertThat(animals).hasSize(10),
687                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
688             );
689         }
690     }
691 
692     @Test
693     void testIsBetweenWhenPresentWithSecondMissing() {
694         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
695             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
696             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
697                     .from(animalData)
698                     .where(id, isBetweenWhenPresent(3).and(NULL_INTEGER))
699                     .and(id, isLessThanOrEqualTo(10))
700                     .orderBy(id)
701                     .build()
702                     .render(RenderingStrategies.MYBATIS3);
703             List<AnimalData> animals = mapper.selectMany(selectStatement);
704             assertAll(
705                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
706                     () -> assertThat(animals).hasSize(10),
707                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
708             );
709         }
710     }
711 
712     @Test
713     void testIsBetweenWhenPresentWithBothMissing() {
714         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
715             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
716             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
717                     .from(animalData)
718                     .where(id, isBetweenWhenPresent(NULL_INTEGER).and(NULL_INTEGER))
719                     .and(id, isLessThanOrEqualTo(10))
720                     .orderBy(id)
721                     .build()
722                     .render(RenderingStrategies.MYBATIS3);
723             List<AnimalData> animals = mapper.selectMany(selectStatement);
724             assertAll(
725                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
726                     () -> assertThat(animals).hasSize(10),
727                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
728             );
729         }
730     }
731 
732     @Test
733     void testIsNotBetweenWhenPresentWithValues() {
734         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
735             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
736             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
737                     .from(animalData)
738                     .where(id, isNotBetweenWhenPresent(3).and(6))
739                     .and(id, isLessThanOrEqualTo(10))
740                     .orderBy(id)
741                     .build()
742                     .render(RenderingStrategies.MYBATIS3);
743             List<AnimalData> animals = mapper.selectMany(selectStatement);
744             assertAll(
745                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id not between #{parameters.p1,jdbcType=INTEGER} and #{parameters.p2,jdbcType=INTEGER} and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
746                     () -> assertThat(animals).hasSize(6),
747                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
748             );
749         }
750     }
751 
752     @Test
753     void testIsNotBetweenWhenPresentWithFirstMissing() {
754         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
755             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
756             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
757                     .from(animalData)
758                     .where(id, isNotBetweenWhenPresent(NULL_INTEGER).and(6))
759                     .and(id, isLessThanOrEqualTo(10))
760                     .orderBy(id)
761                     .build()
762                     .render(RenderingStrategies.MYBATIS3);
763             List<AnimalData> animals = mapper.selectMany(selectStatement);
764             assertAll(
765                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
766                     () -> assertThat(animals).hasSize(10),
767                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
768             );
769         }
770     }
771 
772     @Test
773     void testIsNotBetweenWhenPresentWithSecondMissing() {
774         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
775             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
776             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
777                     .from(animalData)
778                     .where(id, isNotBetweenWhenPresent(3).and(NULL_INTEGER))
779                     .and(id, isLessThanOrEqualTo(10))
780                     .orderBy(id)
781                     .build()
782                     .render(RenderingStrategies.MYBATIS3);
783             List<AnimalData> animals = mapper.selectMany(selectStatement);
784             assertAll(
785                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
786                     () -> assertThat(animals).hasSize(10),
787                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
788             );
789         }
790     }
791 
792     @Test
793     void testIsNotBetweenWhenPresentWithBothMissing() {
794         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
795             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
796             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
797                     .from(animalData)
798                     .where(id, isNotBetweenWhenPresent(NULL_INTEGER).and(NULL_INTEGER))
799                     .and(id, isLessThanOrEqualTo(10))
800                     .orderBy(id)
801                     .build()
802                     .render(RenderingStrategies.MYBATIS3);
803             List<AnimalData> animals = mapper.selectMany(selectStatement);
804             assertAll(
805                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
806                     () -> assertThat(animals).hasSize(10),
807                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
808             );
809         }
810     }
811 
812     @Test
813     void testIsLikeWhenPresentWithValue() {
814         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
815             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
816             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
817                     .from(animalData)
818                     .where(animalName, isLikeWhenPresent("%mole"))
819                     .and(id, isLessThanOrEqualTo(10))
820                     .orderBy(id)
821                     .build()
822                     .render(RenderingStrategies.MYBATIS3);
823             List<AnimalData> animals = mapper.selectMany(selectStatement);
824             assertAll(
825                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where animal_name like #{parameters.p1,jdbcType=VARCHAR} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
826                     () -> assertThat(animals).hasSize(2),
827                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(6)
828             );
829         }
830     }
831 
832     @Test
833     void testIsLikeWhenPresentWithoutValue() {
834         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
835             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
836             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
837                     .from(animalData)
838                     .where(animalName, isLikeWhenPresent((String) null))
839                     .and(id, isLessThanOrEqualTo(10))
840                     .orderBy(id)
841                     .build()
842                     .render(RenderingStrategies.MYBATIS3);
843             List<AnimalData> animals = mapper.selectMany(selectStatement);
844             assertAll(
845                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
846                     () -> assertThat(animals).hasSize(10),
847                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
848             );
849         }
850     }
851 
852     @Test
853     void testIsLikeCaseInsensitiveWhenPresentWithValue() {
854         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
855             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
856             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
857                     .from(animalData)
858                     .where(animalName, isLikeCaseInsensitiveWhenPresent("%MoLe"))
859                     .and(id, isLessThanOrEqualTo(10))
860                     .orderBy(id)
861                     .build()
862                     .render(RenderingStrategies.MYBATIS3);
863             List<AnimalData> animals = mapper.selectMany(selectStatement);
864             assertAll(
865                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) like #{parameters.p1,jdbcType=VARCHAR} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
866                     () -> assertThat(animals).hasSize(2),
867                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(6)
868             );
869         }
870     }
871 
872     @Test
873     void testIsLikeCaseInsensitiveWhenPresentWithoutValue() {
874         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
875             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
876             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
877                     .from(animalData)
878                     .where(animalName, isLikeCaseInsensitiveWhenPresent((String) null))
879                     .and(id, isLessThanOrEqualTo(10))
880                     .orderBy(id)
881                     .build()
882                     .render(RenderingStrategies.MYBATIS3);
883             List<AnimalData> animals = mapper.selectMany(selectStatement);
884             assertAll(
885                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
886                     () -> assertThat(animals).hasSize(10),
887                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
888             );
889         }
890     }
891 
892     @Test
893     void testIsNotLikeWhenPresentWithValue() {
894         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
895             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
896             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
897                     .from(animalData)
898                     .where(animalName, isNotLikeWhenPresent("%mole"))
899                     .and(id, isLessThanOrEqualTo(10))
900                     .orderBy(id)
901                     .build()
902                     .render(RenderingStrategies.MYBATIS3);
903             List<AnimalData> animals = mapper.selectMany(selectStatement);
904             assertAll(
905                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where animal_name not like #{parameters.p1,jdbcType=VARCHAR} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
906                     () -> assertThat(animals).hasSize(8),
907                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
908             );
909         }
910     }
911 
912     @Test
913     void testIsNotLikeWhenPresentWithoutValue() {
914         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
915             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
916             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
917                     .from(animalData)
918                     .where(animalName, isNotLikeWhenPresent((String) null))
919                     .and(id, isLessThanOrEqualTo(10))
920                     .orderBy(id)
921                     .build()
922                     .render(RenderingStrategies.MYBATIS3);
923             List<AnimalData> animals = mapper.selectMany(selectStatement);
924             assertAll(
925                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
926                     () -> assertThat(animals).hasSize(10),
927                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
928             );
929         }
930     }
931 
932     @Test
933     void testIsNotLikeCaseInsensitiveWhenPresentWithValue() {
934         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
935             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
936             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
937                     .from(animalData)
938                     .where(animalName, isNotLikeCaseInsensitiveWhenPresent("%MoLe"))
939                     .and(id, isLessThanOrEqualTo(10))
940                     .orderBy(id)
941                     .build()
942                     .render(RenderingStrategies.MYBATIS3);
943             List<AnimalData> animals = mapper.selectMany(selectStatement);
944             assertAll(
945                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) not like #{parameters.p1,jdbcType=VARCHAR} and id <= #{parameters.p2,jdbcType=INTEGER} order by id"),
946                     () -> assertThat(animals).hasSize(8),
947                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
948             );
949         }
950     }
951 
952     @Test
953     void testIsNotLikeCaseInsensitiveWhenPresentWithoutValue() {
954         try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
955             AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
956             SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
957                     .from(animalData)
958                     .where(animalName, isNotLikeCaseInsensitiveWhenPresent((String) null))
959                     .and(id, isLessThanOrEqualTo(10))
960                     .orderBy(id)
961                     .build()
962                     .render(RenderingStrategies.MYBATIS3);
963             List<AnimalData> animals = mapper.selectMany(selectStatement);
964             assertAll(
965                     () -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id <= #{parameters.p1,jdbcType=INTEGER} order by id"),
966                     () -> assertThat(animals).hasSize(10),
967                     () -> assertThat(animals).first().isNotNull().extracting(AnimalData::id).isEqualTo(1)
968             );
969         }
970     }
971 }