{
stmt = sm.getInsertStatement(cld);
if (stmt == null)
{
logger.error("getInsertStatement returned a null statement");
throw new PersistenceBrokerException("getInsertStatement returned a null statement");
}
// before bind values perform autoincrement sequence columns
assignAutoincrementSequences(cld, obj);
sm.bindInsert(stmt, cld, obj);
if (logger.isDebugEnabled())
logger.debug("executeInsert: " + stmt);
stmt.executeUpdate();
// after insert read and assign identity columns
assignAutoincrementIdentityColumns(cld, obj);
// Harvest any return values.
harvestReturnValues(cld.getInsertProcedure(), obj, stmt);
}
catch (PersistenceBrokerException e)
{
logger.error("PersistenceBrokerException during the execution of the insert: " + e.getMessage(), e);
throw e;
}
catch(SequenceManagerException e)
{
throw new PersistenceBrokerException("Error while try to assign identity value", e);
}
catch (SQLException e)
{
final String sql = broker.serviceSqlGenerator().getPreparedInsertStatement(cld).getStatement();
throw ExceptionHelper.generateException(e, sql, cld, logger, obj);