use of org.datanucleus.store.rdbms.mapping.column.BlobImpl in project datanucleus-rdbms by datanucleus.
the class OracleBitSetMapping method performSetPostProcessing.
/**
* Retrieve the empty BLOB created by the insert statement and write out the current BLOB field value to the Oracle BLOB object
* @param sm the current StateManager
*/
public void performSetPostProcessing(DNStateManager sm) {
Object value = sm.provideField(mmd.getAbsoluteFieldNumber());
if (value == null) {
return;
}
// Generate the contents for the BLOB
byte[] bytes = new byte[0];
try {
if (mmd.isSerialized()) {
// Serialised field so just perform basic Java serialisation for retrieval
if (!(value instanceof Serializable)) {
throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
}
BlobImpl b = new BlobImpl(value);
bytes = b.getBytes(0, (int) b.length());
} else if (value instanceof java.util.BitSet) {
bytes = ArrayConversionHelper.getByteArrayFromBooleanArray(ArrayConversionHelper.getBooleanArrayFromBitSet((java.util.BitSet) value));
} else {
// Fall back to just perform Java serialisation for storage
if (!(value instanceof Serializable)) {
throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
}
BlobImpl b = new BlobImpl(value);
bytes = b.getBytes(0, (int) b.length());
}
} catch (SQLException e) {
throw new NucleusDataStoreException(Localiser.msg("055001", "Object", "" + value, mmd, e.getMessage()), e);
} catch (IOException e1) {
// Do nothing
}
if (columnMappings[0] instanceof ColumnMappingPostSet) {
((ColumnMappingPostSet) columnMappings[0]).setPostProcessing(sm, bytes);
}
}
use of org.datanucleus.store.rdbms.mapping.column.BlobImpl in project datanucleus-rdbms by datanucleus.
the class OracleArrayMapping method performSetPostProcessing.
public void performSetPostProcessing(DNStateManager sm) {
if (containerIsStoredInSingleColumn()) {
if (columnMappings[0] instanceof ColumnMappingPostSet) {
// Create the value to put in the BLOB
Object value = sm.provideField(mmd.getAbsoluteFieldNumber());
if (value == null) {
return;
}
byte[] bytes = new byte[0];
try {
if (mmd.isSerialized()) {
// Serialised field so just perform basic Java serialisation for retrieval
if (!(value instanceof Serializable)) {
throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
}
BlobImpl b = new BlobImpl(value);
bytes = b.getBytes(0, (int) b.length());
} else if (value instanceof boolean[]) {
bytes = ArrayConversionHelper.getByteArrayFromBooleanArray((boolean[]) value);
} else if (value instanceof char[]) {
bytes = ArrayConversionHelper.getByteArrayFromCharArray((char[]) value);
} else if (value instanceof double[]) {
bytes = ArrayConversionHelper.getByteArrayFromDoubleArray((double[]) value);
} else if (value instanceof float[]) {
bytes = ArrayConversionHelper.getByteArrayFromFloatArray((float[]) value);
} else if (value instanceof int[]) {
bytes = ArrayConversionHelper.getByteArrayFromIntArray((int[]) value);
} else if (value instanceof long[]) {
bytes = ArrayConversionHelper.getByteArrayFromLongArray((long[]) value);
} else if (value instanceof short[]) {
bytes = ArrayConversionHelper.getByteArrayFromShortArray((short[]) value);
} else if (value instanceof Boolean[]) {
bytes = ArrayConversionHelper.getByteArrayFromBooleanObjectArray((Boolean[]) value);
} else if (value instanceof Byte[]) {
bytes = ArrayConversionHelper.getByteArrayFromByteObjectArray((Byte[]) value);
} else if (value instanceof Character[]) {
bytes = ArrayConversionHelper.getByteArrayFromCharObjectArray((Character[]) value);
} else if (value instanceof Double[]) {
bytes = ArrayConversionHelper.getByteArrayFromDoubleObjectArray((Double[]) value);
} else if (value instanceof Float[]) {
bytes = ArrayConversionHelper.getByteArrayFromFloatObjectArray((Float[]) value);
} else if (value instanceof Integer[]) {
bytes = ArrayConversionHelper.getByteArrayFromIntObjectArray((Integer[]) value);
} else if (value instanceof Long[]) {
bytes = ArrayConversionHelper.getByteArrayFromLongObjectArray((Long[]) value);
} else if (value instanceof Short[]) {
bytes = ArrayConversionHelper.getByteArrayFromShortObjectArray((Short[]) value);
} else if (value instanceof BigDecimal[]) {
bytes = ArrayConversionHelper.getByteArrayFromBigDecimalArray((BigDecimal[]) value);
} else if (value instanceof BigInteger[]) {
bytes = ArrayConversionHelper.getByteArrayFromBigIntegerArray((BigInteger[]) value);
} else if (value instanceof byte[]) {
bytes = (byte[]) value;
} else if (value instanceof java.util.BitSet) {
bytes = ArrayConversionHelper.getByteArrayFromBooleanArray(ArrayConversionHelper.getBooleanArrayFromBitSet((java.util.BitSet) value));
} else {
// Fall back to just perform Java serialisation for storage
if (!(value instanceof Serializable)) {
throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
}
BlobImpl b = new BlobImpl(value);
bytes = b.getBytes(0, (int) b.length());
}
} catch (SQLException e) {
throw new NucleusDataStoreException(Localiser.msg("055001", "Object", "" + value, mmd, e.getMessage()), e);
} catch (IOException e1) {
// Do nothing
}
// Update the BLOB
((ColumnMappingPostSet) columnMappings[0]).setPostProcessing(sm, bytes);
}
}
}
Aggregations