Properly handle int[] fields when encountered as unassociated values. We
already do the right thing when we process them as fields of persistent records. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2442 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package com.samskivert.jdbc.depot;
|
package com.samskivert.jdbc.depot;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -278,9 +279,16 @@ public class BindVisitor implements ExpressionVisitor
|
|||||||
protected void writeValueToStatement (Object value)
|
protected void writeValueToStatement (Object value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// setObject handles almost all conversions internally, but enums require special care
|
// TODO: how can we abstract this fieldless marshalling
|
||||||
if (value instanceof ByteEnum) {
|
if (value instanceof ByteEnum) {
|
||||||
|
// byte enums require special conversion
|
||||||
_stmt.setByte(_argIdx++, ((ByteEnum)value).toByte());
|
_stmt.setByte(_argIdx++, ((ByteEnum)value).toByte());
|
||||||
|
} else if (value instanceof int[]) {
|
||||||
|
// int arrays require conversion to byte arrays
|
||||||
|
int[] data = (int[])value;
|
||||||
|
ByteBuffer bbuf = ByteBuffer.allocate(data.length * 4);
|
||||||
|
bbuf.asIntBuffer().put(data);
|
||||||
|
_stmt.setObject(_argIdx++, bbuf.array());
|
||||||
} else {
|
} else {
|
||||||
_stmt.setObject(_argIdx++, value);
|
_stmt.setObject(_argIdx++, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user