mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#883 Soft-delete when using fetch (not including soft deleted children)
This commit is contained in:
@@ -70,6 +70,8 @@ public class SqlTreeBuilder {
|
||||
|
||||
private final boolean disableLazyLoad;
|
||||
|
||||
private final SpiQuery.TemporalMode temporalMode;
|
||||
|
||||
private SqlTreeNode rootNode;
|
||||
|
||||
/**
|
||||
@@ -85,7 +87,7 @@ public class SqlTreeBuilder {
|
||||
this.subQuery = false;
|
||||
this.queryDetail = queryDetail;
|
||||
this.predicates = predicates;
|
||||
|
||||
this.temporalMode = SpiQuery.TemporalMode.CURRENT;
|
||||
this.includeJoin = null;
|
||||
this.manyWhereJoins = null;
|
||||
this.alias = null;
|
||||
@@ -104,6 +106,7 @@ public class SqlTreeBuilder {
|
||||
this.rawNoId = false;
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.query = request.getQuery();
|
||||
this.temporalMode = SpiQuery.TemporalMode.of(query);
|
||||
this.disableLazyLoad = query.isDisableLazyLoading();
|
||||
this.subQuery = Type.SUBQUERY.equals(query.getType()) || Type.ID_LIST.equals(query.getType());
|
||||
this.includeJoin = query.getM2mIncludeJoin();
|
||||
@@ -278,13 +281,13 @@ public class SqlTreeBuilder {
|
||||
// Optional many property for lazy loading query
|
||||
BeanPropertyAssocMany<?> lazyLoadMany = (query == null) ? null : query.getLazyLoadMany();
|
||||
boolean withId = !rawNoId && !subQuery && (query == null || query.isWithId());
|
||||
return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, SpiQuery.TemporalMode.of(query), disableLazyLoad);
|
||||
return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, temporalMode, disableLazyLoad);
|
||||
|
||||
} else if (prop instanceof BeanPropertyAssocMany<?>) {
|
||||
return new SqlTreeNodeManyRoot(prefix, (BeanPropertyAssocMany<?>) prop, props, myList, disableLazyLoad);
|
||||
return new SqlTreeNodeManyRoot(prefix, (BeanPropertyAssocMany<?>) prop, props, myList, temporalMode, disableLazyLoad);
|
||||
|
||||
} else {
|
||||
return new SqlTreeNodeBean(prefix, prop, props, myList, disableLazyLoad);
|
||||
return new SqlTreeNodeBean(prefix, prop, props, myList, temporalMode, disableLazyLoad);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
* Construct for leaf node.
|
||||
*/
|
||||
SqlTreeNodeBean(String prefix, BeanPropertyAssoc<?> beanProp, SqlTreeProperties props,
|
||||
List<SqlTreeNode> myChildren, boolean disableLazyLoad) {
|
||||
List<SqlTreeNode> myChildren, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) {
|
||||
|
||||
this(prefix, beanProp, beanProp.getTargetDescriptor(), props, myChildren, true, null, SpiQuery.TemporalMode.CURRENT, disableLazyLoad);
|
||||
this(prefix, beanProp, beanProp.getTargetDescriptor(), props, myChildren, true, null, temporalMode, disableLazyLoad);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -544,7 +544,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
public SqlJoinType appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
|
||||
SqlJoinType sqlJoinType = appendFromAsJoin(ctx, joinType);
|
||||
if (desc.isSoftDelete()) {
|
||||
if (temporalMode != SpiQuery.TemporalMode.SOFT_DELETED && desc.isSoftDelete()) {
|
||||
// add the soft delete predicate to the join clause
|
||||
ctx.append("and ").append(desc.getSoftDeletePredicate(ctx.getTableAlias(prefix))).append(" ");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.DbReadContext;
|
||||
import com.avaje.ebeaninternal.server.deploy.DbSqlContext;
|
||||
@@ -12,8 +13,9 @@ final class SqlTreeNodeManyRoot extends SqlTreeNodeBean {
|
||||
|
||||
private final BeanPropertyAssocMany<?> manyProp;
|
||||
|
||||
SqlTreeNodeManyRoot(String prefix, BeanPropertyAssocMany<?> prop, SqlTreeProperties props, List<SqlTreeNode> myList, boolean disableLazyLoad) {
|
||||
super(prefix, prop, props, myList, disableLazyLoad);
|
||||
SqlTreeNodeManyRoot(String prefix, BeanPropertyAssocMany<?> prop, SqlTreeProperties props, List<SqlTreeNode> myList,
|
||||
SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) {
|
||||
super(prefix, prop, props, myList, temporalMode, disableLazyLoad);
|
||||
this.manyProp = prop;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user