Findbugs fixes

This commit is contained in:
Timo Westkämper 2014-08-31 20:56:28 +03:00
parent fa1cff82d5
commit be3b5a09e4
4 changed files with 15 additions and 19 deletions

View File

@ -70,11 +70,6 @@ public abstract class AbstractSQLQuery<T extends AbstractSQLQuery<T>> extends Pr
protected final QueryMixin<T> queryMixin;
@Nullable
protected Expression<?> union;
protected boolean unionAll;
@SuppressWarnings("unchecked")
public AbstractSQLQuery(QueryMetadata metadata, Configuration conf, PersistenceManager persistenceManager,
boolean detach) {

View File

@ -44,7 +44,7 @@ public final class JPAUtil {
}
}
if (hasParameters) {
Parameter parameter = query.getParameter(Integer.valueOf(key));
Parameter parameter = query.getParameter(Integer.parseInt(key));
Class parameterType = parameter != null ? parameter.getParameterType() : null;
if (parameterType != null && !parameterType.isInstance(val)) {
if (val instanceof Number && Number.class.isAssignableFrom(parameterType)) {

View File

@ -312,7 +312,6 @@ public class SQLInsertClause extends AbstractSQLClause<SQLInsertClause> implemen
context = startContext(connection, metadata, entity);
try {
PreparedStatement stmt = null;
Collection<PreparedStatement> stmts = null;
if (batches.isEmpty()) {
stmt = createStatement(true);
listeners.notifyInsert(entity, metadata, columns, values, subQuery);
@ -321,18 +320,19 @@ public class SQLInsertClause extends AbstractSQLClause<SQLInsertClause> implemen
stmt.executeUpdate();
listeners.preExecute(context);
} else {
stmts = createStatements(true);
Collection<PreparedStatement> stmts = createStatements(true);
if (stmts != null && stmts.size() > 1) {
throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
}
stmt = stmts.iterator().next();
listeners.notifyInserts(entity, metadata, batches);
listeners.preExecute(context);
stmt.executeBatch();
listeners.executed(context);
}
if (stmts != null && stmts.size() > 1) {
throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
}
final Statement stmt2 = stmts != null ? stmts.iterator().next() : stmt;
final Statement stmt2 = stmt;
ResultSet rs = stmt.getGeneratedKeys();
return new ResultSetAdapter(rs) {
@Override

View File

@ -205,7 +205,6 @@ public class SQLMergeClause extends AbstractSQLClause<SQLMergeClause> implements
try {
if (configuration.getTemplates().isNativeMerge()) {
PreparedStatement stmt = null;
Collection<PreparedStatement> stmts = null;
if (batches.isEmpty()) {
stmt = createStatement(true);
listeners.notifyMerge(entity, metadata, keys, columns, values, subQuery);
@ -214,17 +213,19 @@ public class SQLMergeClause extends AbstractSQLClause<SQLMergeClause> implements
stmt.executeUpdate();
listeners.executed(context);
} else {
stmts = createStatements(true);
Collection<PreparedStatement> stmts = createStatements(true);
if (stmts != null && stmts.size() > 1) {
throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
}
stmt = stmts.iterator().next();
listeners.notifyMerges(entity, metadata, batches);
listeners.preExecute(context);
stmt.executeBatch();
listeners.executed(context);
}
if (stmts != null && stmts.size() > 1) {
throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
}
final Statement stmt2 = stmts != null ? stmts.iterator().next() : stmt;
final Statement stmt2 = stmt;
ResultSet rs = stmt.getGeneratedKeys();
return new ResultSetAdapter(rs) {
@Override