insertStatement.setLong(7, workInfo.getPeriod().longValue());
}
insertStatement.setBoolean(8, workInfo.getAtFixedRate());
int result = insertStatement.executeUpdate();
if (result != 1) {
throw new PersistenceException("Could not insert!");
}
} finally {
insertStatement.close();
}
} else {
PreparedStatement insertStatement = c.prepareStatement(insertSQLWithIdentity);
try {
String serializedUserId = serialize(workInfo.getUserId());
String serializedUserKey = serialize(workInfo.getUserInfo());
insertStatement.setString(1, serverUniqueId);
insertStatement.setString(2, workInfo.getKey());
insertStatement.setString(3, serializedUserId);
insertStatement.setString(4, serializedUserKey);
insertStatement.setLong(5, workInfo.getTime().getTime());
if (workInfo.getPeriod() == null) {
insertStatement.setNull(6, Types.NUMERIC);
} else {
insertStatement.setLong(6, workInfo.getPeriod().longValue());
}
insertStatement.setBoolean(7, workInfo.getAtFixedRate());
int result = insertStatement.executeUpdate();
if (result != 1) {
throw new PersistenceException("Could not insert!");
}
} finally {
insertStatement.close();
}
long id;
PreparedStatement identityStatement = c.prepareStatement(identitySQL);
try {
ResultSet seqRS = identityStatement.executeQuery();
try {
seqRS.next();
id = seqRS.getLong(1);
} finally {
seqRS.close();
}
} finally {
identityStatement.close();
}
workInfo.setId(id);
}
} finally {
c.close();
}
} catch (SQLException e) {
throw new PersistenceException(e);
}
}