• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / mybatis-3 / 2686

01 Feb 2025 09:55PM UTC coverage: 87.093% (-0.1%) from 87.217%
2686

Pull #3379

github

web-flow
Merge c97c5c598 into 3d71c862a
Pull Request #3379: Resolve type handler based on `java.lang.reflect.Type` instead of `Class` and respect runtime JDBC type

3825 of 4663 branches covered (82.03%)

515 of 579 new or added lines in 36 files covered. (88.95%)

28 existing lines in 6 files now uncovered.

9912 of 11381 relevant lines covered (87.09%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/main/java/org/apache/ibatis/type/ConflictedTypeHandler.java
1
/*
2
 *    Copyright 2009-2025 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 org.apache.ibatis.type;
17

18
import java.sql.CallableStatement;
19
import java.sql.PreparedStatement;
20
import java.sql.ResultSet;
21
import java.sql.SQLException;
22
import java.util.HashSet;
23
import java.util.Set;
24
import java.util.stream.Collectors;
25

26
import org.apache.ibatis.executor.ExecutorException;
27

28
public class ConflictedTypeHandler implements TypeHandler<Object> {
29

30
  private final Class<?> javaType;
31
  private final JdbcType jdbcType;
32
  private final Set<TypeHandler<?>> conflictedTypeHandlers = new HashSet<>();
1✔
33

34
  public ConflictedTypeHandler(Class<?> javaType, JdbcType jdbcType, TypeHandler<?> existing, TypeHandler<?> added) {
35
    super();
1✔
36
    this.javaType = javaType;
1✔
37
    this.jdbcType = jdbcType;
1✔
38
    if (existing instanceof ConflictedTypeHandler) {
1!
NEW
39
      conflictedTypeHandlers.addAll(((ConflictedTypeHandler) existing).getConflictedTypeHandlers());
×
40
    } else {
41
      conflictedTypeHandlers.add(existing);
1✔
42
    }
43
    conflictedTypeHandlers.add(added);
1✔
44
  }
1✔
45

46
  private Set<TypeHandler<?>> getConflictedTypeHandlers() {
NEW
47
    return conflictedTypeHandlers;
×
48
  }
49

50
  @Override
51
  public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
NEW
52
    throw exception();
×
53
  }
54

55
  @Override
56
  public Object getResult(ResultSet rs, String columnName) throws SQLException {
NEW
57
    throw exception();
×
58
  }
59

60
  @Override
61
  public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
NEW
62
    throw exception();
×
63
  }
64

65
  @Override
66
  public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
NEW
67
    throw exception();
×
68
  }
69

70
  private ExecutorException exception() {
71
    // TODO:
NEW
72
    return new ExecutorException(
×
73
        "Multiple type-aware handlers are registered and being looked up without type; javaType=" + javaType
74
            + ", jdbcType=" + jdbcType + ", type handlers="
NEW
75
            + conflictedTypeHandlers.stream().map(x -> x.getClass().getName()).collect(Collectors.joining(",")));
×
76
  }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc