public int[] internalAdd(ObjectProvider sm, AbstractArrayStore aas, Object element, ManagedConnection conn,
boolean batched, int orderId, boolean executeNow)
throws MappedDatastoreException
{
ExecutionContext ec = sm.getExecutionContext();
SQLController sqlControl = storeMgr.getSQLController();
String addStmt = getAddStmt(aas);
try
{
PreparedStatement ps = sqlControl.getStatementForUpdate(conn, addStmt, false);
boolean notYetFlushedError = false;
try
{
// Insert the join table row
int jdbcPosition = 1;
jdbcPosition = BackingStoreHelper.populateOwnerInStatement(sm, ec, ps, jdbcPosition, aas);
jdbcPosition = BackingStoreHelper.populateElementInStatement(ec, ps, element, jdbcPosition, aas.getElementMapping());
jdbcPosition = BackingStoreHelper.populateOrderInStatement(ec, ps, orderId, jdbcPosition, aas.getOrderMapping());
if (aas.getRelationDiscriminatorMapping() != null)
{
jdbcPosition =
BackingStoreHelper.populateRelationDiscriminatorInStatement(ec, ps, jdbcPosition, aas);
}
// Execute the statement
return sqlControl.executeStatementUpdate(conn, addStmt, ps, executeNow);
}
catch (NotYetFlushedException nfe)
{
notYetFlushedError = true;
throw nfe;
}
finally
{
if (notYetFlushedError)
{
sqlControl.abortStatementForConnection(conn, ps);
}
else
{
sqlControl.closeStatement(conn, ps);
}
}
}
catch (SQLException e)
{