mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
No effective change - tidy whitespace in DtoMeta etc
This commit is contained in:
1 parent
5b07309f51
commit
c1d7e77d85
3 files changed
+1
-40
No files matched your search
@@ -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) ?";
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 "";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user