diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMeta.java b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMeta.java index 9582c160e..cb7ec4797 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMeta.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMeta.java @@ -24,10 +24,8 @@ final class DtoMeta { propMap.put(property.getName().toUpperCase(), property); } int maxArg = 0; - DtoMetaConstructor defaultConstructor = null; DtoMetaConstructor maxArgConstructor = null; - for (DtoMetaConstructor constructor : constructors) { int args = constructor.getArgCount(); constructorMap.put(args, constructor); @@ -56,7 +54,6 @@ final class DtoMeta { if (defaultConstructor != null) { return matchSetters(request); } - String msg = "Unable to map the resultSet columns " + Arrays.toString(cols) + " to the bean type ["+dtoType+"] as the number of columns in the resultSet is less than the constructor" + " (and that there is no default constructor) ?"; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java index 673a122f7..f3cced766 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java @@ -68,8 +68,7 @@ final class DtoMetaBuilder { } private void readConstructors() { - Constructor[] constructors = dtoType.getConstructors(); - for (Constructor constructor : constructors) { + for (Constructor constructor : dtoType.getConstructors()) { try { constructorList.add(new DtoMetaConstructor(typeManager, constructor, dtoType)); } catch (Exception e) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java index 9b4e48341..10ec4d396 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java @@ -95,13 +95,11 @@ public final class CQueryPredicates { } public String bind(DataBind dataBind) throws SQLException { - OrmUpdateProperties updateProperties = query.getUpdateProperties(); if (updateProperties != null) { // bind the update set clause updateProperties.bind(binder, dataBind); } - if (query.isVersionsBetween() && binder.isAsOfStandardsBased()) { // sql2011 based versions between timestamp syntax Timestamp start = query.getVersionStart(); @@ -111,7 +109,6 @@ public final class CQueryPredicates { binder.bindObject(dataBind, end); dataBind.append(", "); } - CQueryPlan queryPlan = request.queryPlan(); if (queryPlan != null) { int asOfTableCount = queryPlan.getAsOfTableCount(); @@ -126,31 +123,25 @@ public final class CQueryPredicates { dataBind.append(", "); } } - if (idValue != null) { // this is a find by id type query... request.descriptor().bindId(dataBind, idValue); dataBind.append(idValue); dataBind.append(", "); } - if (bindParams != null) { // bind named and positioned parameters... binder.bind(bindParams, dataBind, dataBind.log()); } - if (where != null) { where.bind(dataBind); } - if (filterMany != null) { filterMany.bind(dataBind); } - if (having != null) { having.bind(dataBind); } - return dataBind.log().toString(); } @@ -175,7 +166,6 @@ public final class CQueryPredicates { * Convert named parameters into an OrderedList. */ private void buildBindWhereRawSql(boolean buildSql) { - if (!buildSql && bindParams != null && bindParams.requiresNamedParamsPrepare()) { if (query.isNativeSql()) { // convert named params into positioned params @@ -194,7 +184,6 @@ public final class CQueryPredicates { } public void prepare(boolean buildSql) { - DeployParser deployParser = request.createDeployParser(); buildUpdateClause(buildSql, deployParser); buildBindWhereRawSql(buildSql); @@ -206,7 +195,6 @@ public final class CQueryPredicates { whereExprSql = where.buildSql(); } } - BeanPropertyAssocMany manyProperty = request.determineMany(); if (manyProperty != null) { OrmQueryProperties chunk = query.getDetail().getChunk(manyProperty.name(), false); @@ -218,7 +206,6 @@ public final class CQueryPredicates { } } } - // having expression SpiExpressionList havingExpr = query.getHavingExpressions(); if (havingExpr != null) { @@ -227,11 +214,9 @@ public final class CQueryPredicates { havingExprSql = having.buildSql(); } } - if (buildSql) { parsePropertiesToDbColumns(deployParser); } - } /** @@ -239,20 +224,16 @@ public final class CQueryPredicates { * clauses etc. */ private void parsePropertiesToDbColumns(DeployParser deployParser) { - // order by is dependent on the manyProperty (if there is one) String logicalOrderBy = deriveOrderByWithMany(request.manyProperty()); if (logicalOrderBy != null) { dbOrderBy = deployParser.parse(logicalOrderBy); } - // create a copy of the includes required to support the orderBy orderByIncludes = new HashSet<>(deployParser.getIncludes()); - dbWhere = deriveWhere(deployParser); dbFilterMany = deriveFilterMany(deployParser); dbHaving = deriveHaving(deployParser); - // all includes including ones for manyWhere clause predicateIncludes = deployParser.getIncludes(); } @@ -304,7 +285,6 @@ public final class CQueryPredicates { } private String parseOrderBy() { - OrderBy orderBy = query.getOrderBy(); if (orderBy == null) { return null; @@ -317,42 +297,32 @@ public final class CQueryPredicates { * appropriate. */ private String deriveOrderByWithMany(BeanPropertyAssocMany manyProp) { - if (manyProp == null) { return parseOrderBy(); } - String orderBy = parseOrderBy(); - BeanDescriptor desc = request.descriptor(); String orderById = desc.defaultOrderBy(); - if (orderBy == null) { orderBy = orderById; } - // check for default ordering on the many property... String manyOrderBy = manyProp.fetchOrderBy(); if (manyOrderBy != null) { orderBy = orderBy + ", " + CQueryBuilder.prefixOrderByFields(manyProp.name(), manyOrderBy); } - if (request.isFindById()) { // only one master bean so should be fine... return orderBy; } - if (orderBy.startsWith(orderById)) { return orderBy; } - // more than one top level row may be returned so // we need to make sure their is an order by on the // top level first (to ensure master/detail construction). - int manyPos = orderBy.indexOf(manyProp.name()); int idPos = orderBy.indexOf(" " + orderById); - if (manyPos == -1) { // no ordering of the many if (idPos == -1) { @@ -363,7 +333,6 @@ public final class CQueryPredicates { // orderById is already in the order by clause return orderBy; } - if (idPos <= -1 || idPos >= manyPos) { if (idPos > manyPos) { // there was an error with the order by... @@ -371,14 +340,11 @@ public final class CQueryPredicates { msg += "] with an incorrect orderBy [" + orderBy + "]. The id property [" + orderById + "]"; msg += " must come before the many property [" + manyProp.name() + "] in the orderBy."; msg += " Ebean has automatically modified the orderBy clause to do this."; - CoreLog.log.warn(msg); } - // the id needs to come before the manyPropName orderBy = orderBy.substring(0, manyPos) + orderById + ", " + orderBy.substring(manyPos); } - return orderBy; } @@ -439,7 +405,6 @@ public final class CQueryPredicates { } String getLogWhereSql() { - if (dbWhere == null && dbFilterMany == null) { return ""; }