|
15 | 15 | */ |
16 | 16 | package org.seasar.doma.jdbc.type; |
17 | 17 |
|
| 18 | +import java.sql.CallableStatement; |
18 | 19 | import java.sql.PreparedStatement; |
| 20 | +import java.sql.ResultSet; |
19 | 21 | import java.sql.SQLException; |
| 22 | +import java.sql.Types; |
20 | 23 |
|
21 | 24 | /** |
22 | | - * {@link Object} 用の {@link JdbcType} の実装です。 |
| 25 | + * DB固有の型用の {@link JdbcType} の実装です。 |
23 | 26 | * {@link PreparedStatement#setObject(int, Object, int)} を使って値を設定します。 |
24 | 27 | * |
25 | 28 | * @author nakamura-to |
26 | 29 | * @since 2.4.0 |
27 | 30 | */ |
28 | | -public class PortableObjectType extends ObjectType { |
| 31 | +public class PortableObjectType<T> extends AbstractJdbcType<T> { |
| 32 | + |
| 33 | + private final JdbcType<T> baseType; |
| 34 | + |
| 35 | + public PortableObjectType(JdbcType<T> baseType) { |
| 36 | + super(Types.OTHER); |
| 37 | + this.baseType = baseType; |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public T doGetValue(ResultSet resultSet, int index) |
| 42 | + throws SQLException { |
| 43 | + return baseType.getValue(resultSet, index); |
| 44 | + } |
29 | 45 |
|
30 | 46 | @Override |
31 | 47 | protected void doSetValue(PreparedStatement preparedStatement, int index, |
32 | | - Object value) throws SQLException { |
| 48 | + T value) throws SQLException { |
33 | 49 | preparedStatement.setObject(index, value, this.type); |
34 | 50 | } |
| 51 | + |
| 52 | + @Override |
| 53 | + protected T doGetValue(CallableStatement callableStatement, int index) |
| 54 | + throws SQLException { |
| 55 | + return baseType.getValue(callableStatement, index); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + protected String doConvertToLogFormat(T value) { |
| 60 | + return baseType.convertToLogFormat(value); |
| 61 | + } |
35 | 62 | } |
0 commit comments