mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-24 10:02:14 -05:00
in JdbcMapper, return byte[] as ResultSet.getBytes() and not as an array of the columns
This commit is contained in:
parent
e246af935f
commit
6fef6f284f
@ -44,7 +44,7 @@ public class CompileTimeResultSetMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final Types types;
|
public final Types types;
|
||||||
public final TypeMirror collectionType, mapType, mapCollectionType, iteratorType, listIteratorType, finishableType, resultSetType, resultSetIterableType;
|
public final TypeMirror collectionType, mapType, mapCollectionType, iteratorType, listIteratorType, finishableType, resultSetType, resultSetIterableType, byteArrayType;
|
||||||
//IFJAVA8_START
|
//IFJAVA8_START
|
||||||
public final TypeMirror streamType;
|
public final TypeMirror streamType;
|
||||||
//IFJAVA8_END
|
//IFJAVA8_END
|
||||||
@ -69,6 +69,8 @@ public class CompileTimeResultSetMapper {
|
|||||||
|
|
||||||
resultSetIterableType = types.getDeclaredType(elements.getTypeElement(ResultSetIterable.class.getCanonicalName()), types.getWildcardType(null, null));
|
resultSetIterableType = types.getDeclaredType(elements.getTypeElement(ResultSetIterable.class.getCanonicalName()), types.getWildcardType(null, null));
|
||||||
|
|
||||||
|
byteArrayType = types.getArrayType(types.getPrimitiveType(TypeKind.BYTE));
|
||||||
|
|
||||||
//IFJAVA8_START
|
//IFJAVA8_START
|
||||||
streamType = types.getDeclaredType(elements.getTypeElement(Stream.class.getCanonicalName()), types.getWildcardType(null, null));
|
streamType = types.getDeclaredType(elements.getTypeElement(Stream.class.getCanonicalName()), types.getWildcardType(null, null));
|
||||||
//IFJAVA8_END
|
//IFJAVA8_END
|
||||||
@ -96,7 +98,7 @@ public class CompileTimeResultSetMapper {
|
|||||||
//final Class returnType = m.getReturnType();
|
//final Class returnType = m.getReturnType();
|
||||||
final TypeMirror returnTypeMirror = eeMethod.getReturnType();
|
final TypeMirror returnTypeMirror = eeMethod.getReturnType();
|
||||||
//final Class returnType = typeMirrorToClass(returnTypeMirror);
|
//final Class returnType = typeMirrorToClass(returnTypeMirror);
|
||||||
if (returnTypeMirror.getKind() == TypeKind.ARRAY) {
|
if (returnTypeMirror.getKind() == TypeKind.ARRAY && !types.isSameType(returnTypeMirror, byteArrayType)) {
|
||||||
final TypeMirror componentType = ((ArrayType) returnTypeMirror).getComponentType();
|
final TypeMirror componentType = ((ArrayType) returnTypeMirror).getComponentType();
|
||||||
toArray(w, keys, componentType, maxRows, cal, cleaner, reflectionFields);
|
toArray(w, keys, componentType, maxRows, cal, cleaner, reflectionFields);
|
||||||
} else if (types.isAssignable(returnTypeMirror, collectionType)) {
|
} else if (types.isAssignable(returnTypeMirror, collectionType)) {
|
||||||
|
@ -76,7 +76,7 @@ public class CompileTimeRowToObjectMapper {
|
|||||||
} else {
|
} else {
|
||||||
_returnTypeClass = returnTypeClass;
|
_returnTypeClass = returnTypeClass;
|
||||||
// detect if we want an array back
|
// detect if we want an array back
|
||||||
componentType = returnTypeClass.getKind() == TypeKind.ARRAY ? ((ArrayType) returnTypeClass).getComponentType() : null;
|
componentType = returnTypeClass.getKind() == TypeKind.ARRAY && !rsm.types.isSameType(returnTypeClass, rsm.byteArrayType) ? ((ArrayType) returnTypeClass).getComponentType() : null;
|
||||||
|
|
||||||
// detect if returnTypeClass has a constructor that takes a ResultSet, if so, our job couldn't be easier...
|
// detect if returnTypeClass has a constructor that takes a ResultSet, if so, our job couldn't be easier...
|
||||||
boolean resultSetConstructor = false, defaultConstructor = false, paramConstructor = false;
|
boolean resultSetConstructor = false, defaultConstructor = false, paramConstructor = false;
|
||||||
|
@ -223,4 +223,8 @@ public interface PersonDAO extends JdbcMapper {
|
|||||||
ZoneOffset getZoneOffsetStr(long valNo);
|
ZoneOffset getZoneOffsetStr(long valNo);
|
||||||
|
|
||||||
//IFJAVA8_END
|
//IFJAVA8_END
|
||||||
|
|
||||||
|
// test blob
|
||||||
|
@JdbcMapper.SQL("SELECT some_blob FROM val WHERE val_no = {valNo}")
|
||||||
|
byte[] getBlob(long valNo);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
sed -e 's/PersonDAO extends Closeable/PrestoPersonDAO extends PersonDAO/' -e 's@// , sqlParser = SimpleSQLParser.class@ , sqlParser = PrestoSQLParser.class@' ../jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAO.java > src/test/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java
|
sed -e 's/PersonDAO extends JdbcMapper/PrestoPersonDAO extends PersonDAO/' -e 's@// , sqlParser = SimpleSQLParser.class@ , sqlParser = PrestoSQLParser.class@' ../jdbcmapper/src/test/java/com/moparisthebest/jdbc/codegen/PersonDAO.java > src/test/java/com/moparisthebest/jdbc/codegen/PrestoPersonDAO.java
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import java.time.*;
|
|||||||
* Created by mopar on 5/24/17.
|
* Created by mopar on 5/24/17.
|
||||||
*/
|
*/
|
||||||
@JdbcMapper.Mapper(
|
@JdbcMapper.Mapper(
|
||||||
// jndiName = "bob",
|
jndiName = "bob",
|
||||||
// databaseType = JdbcMapper.DatabaseType.ORACLE
|
// databaseType = JdbcMapper.DatabaseType.ORACLE
|
||||||
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
cachePreparedStatements = JdbcMapper.OptionalBool.FALSE
|
||||||
, sqlParser = PrestoSQLParser.class
|
, sqlParser = PrestoSQLParser.class
|
||||||
@ -223,4 +223,8 @@ public interface PrestoPersonDAO extends PersonDAO {
|
|||||||
ZoneOffset getZoneOffsetStr(long valNo);
|
ZoneOffset getZoneOffsetStr(long valNo);
|
||||||
|
|
||||||
//IFJAVA8_END
|
//IFJAVA8_END
|
||||||
|
|
||||||
|
// test blob
|
||||||
|
@JdbcMapper.SQL("SELECT some_blob FROM val WHERE val_no = {valNo}")
|
||||||
|
byte[] getBlob(long valNo);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user