Polishing.
Add missing generic type argument, pre initialize collection in Meta and make use of try-with-resources in NamedQuery. Closes: #3408
This commit is contained in:
@@ -49,7 +49,7 @@ public final class JSqlParserUtils {
|
||||
.map(Column::new) //
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ExpressionList countExpression = new ExpressionList(countColumns);
|
||||
ExpressionList<Expression> countExpression = new ExpressionList<>(countColumns);
|
||||
|
||||
return new Function() //
|
||||
.withName("count") //
|
||||
@@ -66,7 +66,7 @@ public final class JSqlParserUtils {
|
||||
public static Function getJSqlLower(String column) {
|
||||
|
||||
List<Expression> expressions = Collections.singletonList(new Column(column));
|
||||
ExpressionList lowerParamExpression = new ExpressionList(expressions);
|
||||
ExpressionList<Expression> lowerParamExpression = new ExpressionList<>(expressions);
|
||||
|
||||
return new Function() //
|
||||
.withName("lower") //
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Meta {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> values = Collections.emptyMap();
|
||||
private Map<String, Object> values = new LinkedHashMap<>(2);
|
||||
|
||||
public Meta() {}
|
||||
|
||||
@@ -100,10 +100,6 @@ public class Meta {
|
||||
|
||||
Assert.hasText(key, "Meta key must not be 'null' or blank");
|
||||
|
||||
if (values == Collections.EMPTY_MAP) {
|
||||
values = new LinkedHashMap<>(2);
|
||||
}
|
||||
|
||||
if (value == null || (value instanceof String stringValue && !StringUtils.hasText(stringValue))) {
|
||||
this.values.remove(key);
|
||||
}
|
||||
|
||||
@@ -107,9 +107,8 @@ final class NamedQuery extends AbstractJpaQuery {
|
||||
* See DATAJPA-617, we have to use a dedicated em for the lookups to avoid a
|
||||
* potential rollback of the running tx.
|
||||
*/
|
||||
EntityManager lookupEm = em.getEntityManagerFactory().createEntityManager();
|
||||
|
||||
try {
|
||||
try (EntityManager lookupEm = em.getEntityManagerFactory().createEntityManager()) {
|
||||
lookupEm.createNamedQuery(queryName);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -118,8 +117,6 @@ final class NamedQuery extends AbstractJpaQuery {
|
||||
LOG.debug(String.format("Did not find named query %s", queryName));
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
lookupEm.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user