}
}
try
{
ManagedConnection mconn = storeMgr.getConnection(ec);
SQLController sqlControl = storeMgr.getSQLController();
try
{
PreparedStatement ps = sqlControl.getStatementForQuery(mconn, textStmt);
try
{
// Provide the primary key field(s) to the JDBC statement
if (cmd.getIdentityType() == IdentityType.DATASTORE)
{
StatementMappingIndex datastoreIdx = mappingDefinition.getMappingForMemberPosition(
StatementClassMapping.MEMBER_DATASTORE_ID);
for (int i=0;i<datastoreIdx.getNumberOfParameterOccurrences();i++)
{
classTable.getDatastoreObjectIdMapping().setObject(ec, ps,
datastoreIdx.getParameterPositionsForOccurrence(i), sm.getInternalObjectId());
}
}
else if (cmd.getIdentityType() == IdentityType.APPLICATION)
{
sm.provideFields(cmd.getPKMemberPositions(),
storeMgr.getFieldManagerForStatementGeneration(sm, ps, mappingDefinition, false));
}
ResultSet rs = sqlControl.executeStatementQuery(mconn, textStmt, ps);
try
{
if (!rs.next())
{
throw new NucleusObjectNotFoundException("No such database row", sm.getInternalObjectId());
}
int jdbcMajorVersion = ((DatabaseAdapter)datastoreContainer.getStoreManager().getDatastoreAdapter()).getDriverMajorVersion();
if (jdbcMajorVersion < 10)
{
// Oracle JDBC drivers version 9 and below use some sh*tty Oracle-specific CLOB type
// we have to cast to that, face west, pray whilst saying ommmmmmmmmmm
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(1);
if (clob != null)
{
clob.putString(1, value); // Deprecated but what can you do
}
}
else
{
// Oracle JDBC drivers 10 and above supposedly use the JDBC standard class for Clobs
java.sql.Clob clob = rs.getClob(1);
if (clob != null)
{
clob.setString(1, value);
}
}
}
finally
{
rs.close();
}
}
finally
{
sqlControl.closeStatement(mconn, ps);
}
}
finally
{
mconn.release();
}
}
catch (SQLException e)
{
throw new NucleusDataStoreException("Update of CLOB value failed: " + textStmt, e);