mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#1566 - ENH: Support query.setBaseTable() ... to query against dynamic table (ala manual table partitioning)
This commit is contained in:
1 parent
3207ae1f08
commit
cd8c12a9a8
6 files changed
+97
-7
No files matched your search
@@ -312,7 +312,12 @@ public final class SqlTreeBuilder {
|
||||
// Optional many property for lazy loading query
|
||||
STreePropertyAssocMany lazyLoadMany = (query == null) ? null : query.getLazyLoadMany();
|
||||
boolean withId = !rawNoId && !subQuery && (query == null || query.isWithId());
|
||||
return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, temporalMode, disableLazyLoad, sqlDistinct);
|
||||
|
||||
String baseTable = (query == null) ? null : query.getBaseTable();
|
||||
if (baseTable == null) {
|
||||
baseTable = desc.getBaseTable(temporalMode);
|
||||
}
|
||||
return new SqlTreeNodeRoot(desc, props, myList, withId, includeJoin, lazyLoadMany, temporalMode, disableLazyLoad, sqlDistinct, baseTable);
|
||||
|
||||
} else if (prop instanceof STreePropertyAssocMany) {
|
||||
return new SqlTreeNodeManyRoot(prefix, (STreePropertyAssocMany) prop, props, myList, temporalMode, disableLazyLoad);
|
||||
@@ -497,9 +502,9 @@ public final class SqlTreeBuilder {
|
||||
for (STreePropertyAssocOne propertyAssocOne : desc.propsOne()) {
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (queryProps != null
|
||||
&& queryProps.isIncludedBeanJoin(propertyAssocOne.getName())
|
||||
&& propertyAssocOne.hasForeignKey()
|
||||
&& !propertyAssocOne.isFormula()) {
|
||||
&& queryProps.isIncludedBeanJoin(propertyAssocOne.getName())
|
||||
&& propertyAssocOne.hasForeignKey()
|
||||
&& !propertyAssocOne.isFormula()) {
|
||||
// if it is a joined bean with FK constraint... then don't add the property
|
||||
// as it will have its own entire Node in the SqlTree
|
||||
} else {
|
||||
|
||||
@@ -16,15 +16,18 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean {
|
||||
|
||||
private final boolean sqlDistinct;
|
||||
|
||||
private final String baseTable;
|
||||
|
||||
/**
|
||||
* Specify for SqlSelect to include an Id property or not.
|
||||
*/
|
||||
SqlTreeNodeRoot(STreeType desc, SqlTreeProperties props, List<SqlTreeNode> myList, boolean withId,
|
||||
TableJoin includeJoin, STreePropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad, boolean sqlDistinct) {
|
||||
SqlTreeNodeRoot(STreeType desc, SqlTreeProperties props, List<SqlTreeNode> myList, boolean withId, TableJoin includeJoin,
|
||||
STreePropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad, boolean sqlDistinct, String baseTable) {
|
||||
|
||||
super(desc, props, myList, withId, many, temporalMode, disableLazyLoad);
|
||||
this.includeJoin = includeJoin;
|
||||
this.sqlDistinct = sqlDistinct;
|
||||
this.baseTable = baseTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +76,7 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean {
|
||||
@Override
|
||||
public SqlJoinType appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
|
||||
ctx.append(desc.getBaseTable(temporalMode));
|
||||
ctx.append(baseTable);
|
||||
ctx.append(" ").append(baseTableAlias);
|
||||
ctx.appendFromForUpdate();
|
||||
|
||||
|
||||
Reference in new issue
Block a user