diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java
index 809992f9ab..5f84af1671 100644
--- a/ebean-api/src/main/java/io/ebean/Database.java
+++ b/ebean-api/src/main/java/io/ebean/Database.java
@@ -1326,104 +1326,6 @@ public interface Database {
*/
DocumentStore docStore();
- /**
- * Publish a single bean given its type and id returning the resulting live bean.
- *
- * The values are published from the draft to the live bean.
- *
- * @param the type of the entity bean
- * @param beanType the type of the entity bean
- * @param id the id of the entity bean
- * @param transaction the transaction the publish process should use (can be null)
- */
- @Nullable
- T publish(Class beanType, Object id, Transaction transaction);
-
- /**
- * Publish a single bean given its type and id returning the resulting live bean.
- * This will use the current transaction or create one if required.
- *
- * The values are published from the draft to the live bean.
- *
- * @param the type of the entity bean
- * @param beanType the type of the entity bean
- * @param id the id of the entity bean
- */
- @Nullable
- T publish(Class beanType, Object id);
-
- /**
- * Publish the beans that match the query returning the resulting published beans.
- *
- * The values are published from the draft beans to the live beans.
- *
- * @param the type of the entity bean
- * @param query the query used to select the draft beans to publish
- * @param transaction the transaction the publish process should use (can be null)
- */
- List publish(Query query, Transaction transaction);
-
- /**
- * Publish the beans that match the query returning the resulting published beans.
- * This will use the current transaction or create one if required.
- *
- * The values are published from the draft beans to the live beans.
- *
- * @param the type of the entity bean
- * @param query the query used to select the draft beans to publish
- */
- List publish(Query query);
-
- /**
- * Restore the draft bean back to the live state.
- *
- * The values from the live beans are set back to the draft bean and the
- * @DraftDirty and @DraftReset properties are reset.
- *
- * @param the type of the entity bean
- * @param beanType the type of the entity bean
- * @param id the id of the entity bean to restore
- * @param transaction the transaction the restore process should use (can be null)
- */
- @Nullable
- T draftRestore(Class beanType, Object id, Transaction transaction);
-
- /**
- * Restore the draft bean back to the live state.
- *
- * The values from the live beans are set back to the draft bean and the
- * @DraftDirty and @DraftReset properties are reset.
- *
- * @param the type of the entity bean
- * @param beanType the type of the entity bean
- * @param id the id of the entity bean to restore
- */
- @Nullable
- T draftRestore(Class beanType, Object id);
-
- /**
- * Restore the draft beans matching the query back to the live state.
- *
- * The values from the live beans are set back to the draft bean and the
- * @DraftDirty and @DraftReset properties are reset.
- *
- * @param the type of the entity bean
- * @param query the query used to select the draft beans to restore
- * @param transaction the transaction the restore process should use (can be null)
- */
- List draftRestore(Query query, Transaction transaction);
-
- /**
- * Restore the draft beans matching the query back to the live state.
- *
- * The values from the live beans are set back to the draft bean and the
- * @DraftDirty and @DraftReset properties are reset.
- *
- * @param the type of the entity bean
- * @param query the query used to select the draft beans to restore
- */
- List draftRestore(Query query);
-
/**
* Returns the set of properties/paths that are unknown (do not map to known properties or paths).
*
diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java
index 9660d3e3e8..d5d4003ccb 100644
--- a/ebean-api/src/main/java/io/ebean/ExpressionList.java
+++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java
@@ -106,11 +106,6 @@ default OrderBy order() {
*/
Query asOf(Timestamp asOf);
- /**
- * Execute the query against the draft set of tables.
- */
- Query asDraft();
-
/**
* Convert the query to a DTO bean query.
*
diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java
index 3cde03c15a..49f2b96003 100644
--- a/ebean-api/src/main/java/io/ebean/Query.java
+++ b/ebean-api/src/main/java/io/ebean/Query.java
@@ -250,11 +250,6 @@ enum LockWait {
*/
Query asOf(Timestamp asOf);
- /**
- * Execute the query against the draft set of tables.
- */
- Query asDraft();
-
/**
* Convert the query to a DTO bean query.
*
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
index 77fc16e43a..b8b0a37a2b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQuery.java
@@ -168,11 +168,6 @@ enum TemporalMode {
*/
SOFT_DELETED(false),
- /**
- * Query runs against draft tables.
- */
- DRAFT(false),
-
/**
* Query runs against current data (normal).
*/
@@ -375,11 +370,6 @@ public static TemporalMode of(SpiQuery> query) {
*/
boolean isAsOfQuery();
- /**
- * Return true if this is a 'As Draft' query.
- */
- boolean isAsDraft();
-
/**
* Return true if this query includes soft deleted rows.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java
index 563a68274f..e3f747682b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultBeanLoader.java
@@ -178,12 +178,11 @@ private void refreshBeanInternal(EntityBean bean, SpiQuery.Mode mode, int embedd
desc.contextPut(pc, id, bean);
ebi.setPersistenceContext(pc);
}
- boolean draft = desc.isDraftInstance(bean);
if (embeddedOwnerIndex == -1) {
if (desc.lazyLoadMany(ebi)) {
return;
}
- if (!draft && Mode.LAZYLOAD_BEAN == mode && desc.isBeanCaching()) {
+ if (Mode.LAZYLOAD_BEAN == mode && desc.isBeanCaching()) {
// lazy loading and the bean cache is active
if (desc.cacheBeanLoad(bean, ebi, id, pc)) {
return;
@@ -192,9 +191,7 @@ private void refreshBeanInternal(EntityBean bean, SpiQuery.Mode mode, int embedd
}
SpiQuery> query = server.createQuery(desc.type());
query.setLazyLoadProperty(ebi.lazyLoadProperty());
- if (draft) {
- query.asDraft();
- } else if (mode == SpiQuery.Mode.LAZYLOAD_BEAN && desc.isSoftDelete()) {
+ if (mode == SpiQuery.Mode.LAZYLOAD_BEAN && desc.isSoftDelete()) {
query.setIncludeSoftDeletes();
}
if (embeddedOwnerIndex > -1) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index 80e8cf9037..20a1006ed3 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -1636,54 +1636,6 @@ public void insertAll(@Nullable Collection> beans, @Nullable Transaction trans
}, transaction);
}
- @Override
- public List publish(Query query, @Nullable Transaction transaction) {
- return executeInTrans((txn) -> persister.publish(query, txn), transaction);
- }
-
- @Nullable
- @Override
- public T publish(Class beanType, Object id) {
- return publish(beanType, id, null);
- }
-
- @Override
- public List publish(Query query) {
- return publish(query, null);
- }
-
- @Nullable
- @Override
- public T publish(Class beanType, Object id, @Nullable Transaction transaction) {
- Query query = find(beanType).setId(id);
- List liveBeans = publish(query, transaction);
- return (liveBeans.size() == 1) ? liveBeans.get(0) : null;
- }
-
- @Override
- public List draftRestore(Query query, @Nullable Transaction transaction) {
- return executeInTrans((txn) -> persister.draftRestore(query, txn), transaction);
- }
-
- @Nullable
- @Override
- public T draftRestore(Class beanType, Object id, @Nullable Transaction transaction) {
- Query query = find(beanType).setId(id);
- List beans = draftRestore(query, transaction);
- return (beans.size() == 1) ? beans.get(0) : null;
- }
-
- @Nullable
- @Override
- public T draftRestore(Class beanType, Object id) {
- return draftRestore(beanType, id, null);
- }
-
- @Override
- public List draftRestore(Query query) {
- return draftRestore(query, null);
- }
-
private EntityBean checkEntityBean(Object bean) {
return (EntityBean) Objects.requireNonNull(bean);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
index 7c2d5d9bc9..578586b0c3 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
@@ -120,11 +120,10 @@ public final class InternalConfiguration {
this.dtoBeanManager = new DtoBeanManager(typeManager);
this.beanDescriptorManager = new BeanDescriptorManager(this);
Map asOfTableMapping = beanDescriptorManager.deploy();
- Map draftTableMap = beanDescriptorManager.draftTableMap();
beanDescriptorManager.scheduleBackgroundTrim();
this.dataTimeZone = initDataTimeZone();
this.binder = getBinder(typeManager, databasePlatform, dataTimeZone);
- this.cQueryEngine = new CQueryEngine(config, databasePlatform, binder, asOfTableMapping, draftTableMap);
+ this.cQueryEngine = new CQueryEngine(config, databasePlatform, binder, asOfTableMapping);
}
public boolean isJacksonCorePresent() {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
index 32da95dab1..b622b679ca 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
@@ -44,7 +44,6 @@ public final class PersistRequestBean extends PersistRequest implements BeanP
*/
private final Object parentBean;
private final boolean dirty;
- private final boolean publish;
private int flags;
private boolean saveRecurse;
private DocStoreMode docStoreMode;
@@ -153,10 +152,6 @@ public PersistRequestBean(SpiEbeanServer server, T bean, Object parentBean, Bean
}
}
this.concurrencyMode = beanDescriptor.concurrencyMode(intercept);
- this.publish = Flags.isPublish(flags);
- if (isMarkDraftDirty(publish)) {
- beanDescriptor.setDraftDirty(entityBean, true);
- }
this.dirty = intercept.isDirty();
}
@@ -201,13 +196,6 @@ public boolean isCascade() {
return Flags.isRecurse(flags);
}
- /**
- * Return true if the draftDirty property should be set to true for this request.
- */
- private boolean isMarkDraftDirty(boolean publish) {
- return !publish && type != Type.DELETE && beanDescriptor.isDraftable();
- }
-
/**
* Set the transaction from prior persist request.
* Only used when hard deleting draft & associated live beans.
@@ -417,7 +405,7 @@ public Map updatedValues() {
* Set the cache notify status.
*/
private void setNotifyCache() {
- this.notifyCache = beanDescriptor.isCacheNotify(type, publish);
+ this.notifyCache = beanDescriptor.isCacheNotify(type);
}
/**
@@ -642,28 +630,6 @@ public T createReference() {
return beanDescriptor.createRef(beanId(), null);
}
- /**
- * Return true if the bean type is a Draftable.
- */
- public boolean isDraftable() {
- return beanDescriptor.isDraftable();
- }
-
- /**
- * Return true if this request is a hard delete of a draftable bean.
- * If this is true Ebean is expected to auto-publish and delete the associated live bean.
- */
- public boolean isHardDeleteDraft() {
- if (type == Type.DELETE && beanDescriptor.isDraftable() && !beanDescriptor.isDraftableElement()) {
- // deleting a top level draftable bean
- if (beanDescriptor.isLiveInstance(entityBean)) {
- throw new PersistenceException("Explicit Delete is not allowed on a 'live' bean - only draft beans");
- }
- return true;
- }
- return false;
- }
-
/**
* Return true if this was a hard/permanent delete request (and should cascade as such).
*/
@@ -671,16 +637,6 @@ public boolean isHardDeleteCascade() {
return (type == Type.DELETE && beanDescriptor.isSoftDelete());
}
- /**
- * Checks for @Draftable entity beans with @Draft property that the bean is a 'draft'.
- * Save or Update is not allowed to execute using 'live' beans - must use publish().
- */
- public void checkDraft() {
- if (beanDescriptor.isDraftable() && beanDescriptor.isLiveInstance(entityBean)) {
- throw new PersistenceException("Save or update is not allowed on a 'live' bean - only draft beans");
- }
- }
-
/**
* Return the parent bean for cascading save with unidirectional relationship.
*/
@@ -928,20 +884,19 @@ private void controllerPost() {
}
private void logSummaryMessage() {
- String draft = (beanDescriptor.isDraftable() && !publish) ? " draft[true]" : "";
String name = beanDescriptor.name();
switch (type) {
case INSERT:
- transaction.logSummary("Inserted [{0}] [{1}]{2}", name, (idValue == null ? "" : idValue), draft);
+ transaction.logSummary("Inserted [{0}] [{1}]", name, (idValue == null ? "" : idValue));
break;
case UPDATE:
- transaction.logSummary("Updated [{0}] [{1}]{2}", name, idValue , draft);
+ transaction.logSummary("Updated [{0}] [{1}]", name, idValue);
break;
case DELETE:
- transaction.logSummary("Deleted [{0}] [{1}]{2}", name, idValue , draft);
+ transaction.logSummary("Deleted [{0}] [{1}]", name, idValue);
break;
case DELETE_SOFT:
- transaction.logSummary("SoftDelete [{0}] [{1}]{2}", name, idValue , draft);
+ transaction.logSummary("SoftDelete [{0}] [{1}]", name, idValue);
break;
default:
break;
@@ -979,9 +934,6 @@ public void deferredRelationship(EntityBean assocBean, ImportedId importedId, En
private void postInsert() {
// mark all properties as loaded after an insert to support immediate update
beanDescriptor.setAllLoaded(entityBean);
- if (!publish) {
- beanDescriptor.setDraft(entityBean);
- }
if (transaction.isAutoPersistUpdates() && idValue != null) {
// with getGeneratedKeys off we will not have a idValue
beanDescriptor.contextPut(transaction.persistenceContext(), idValue, entityBean);
@@ -1129,13 +1081,6 @@ public int flags() {
return flags;
}
- /**
- * Return true if this request is a 'publish' action.
- */
- public boolean isPublish() {
- return publish;
- }
-
/**
* Return the key for an update persist request.
*/
@@ -1152,17 +1097,14 @@ public String updatePlanHash() {
key.append('v');
}
}
- if (publish) {
- key.append('p');
- }
return key.toString();
}
/**
- * Return the table to update depending if the request is a 'publish' one or normal.
+ * Return the table to update.
*/
public String updateTable() {
- return publish ? beanDescriptor.baseTable() : beanDescriptor.draftTable();
+ return beanDescriptor.baseTable();
}
/**
@@ -1374,7 +1316,7 @@ public EntityBean importedOrphanForRemoval() {
* Return the SQL used to fetch the last inserted id value.
*/
public String selectLastInsertedId() {
- return beanDescriptor.selectLastInsertedId(publish);
+ return beanDescriptor.selectLastInsertedId();
}
/**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/Persister.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/Persister.java
index 46927f1122..24ffc24166 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/Persister.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/Persister.java
@@ -83,16 +83,6 @@ public interface Persister {
*/
int executeCallable(CallableSql callable, Transaction t);
- /**
- * Publish the draft beans matching the given query.
- */
- List publish(Query query, Transaction transaction);
-
- /**
- * Restore the draft beans back to the matching live beans.
- */
- List draftRestore(Query query, Transaction transaction);
-
/**
* Visit the metrics.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
index 5b56011d49..ade52548eb 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
@@ -42,7 +42,6 @@
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
-import io.ebeaninternal.server.rawsql.SpiRawSql;
import io.ebeaninternal.util.SortByClause;
import io.ebeaninternal.util.SortByClauseParser;
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
@@ -103,7 +102,6 @@ public enum EntityType {
* getGeneratedKeys is not supported.
*/
private final String selectLastInsertedId;
- private final String selectLastInsertedIdDraft;
private final boolean autoTunable;
private final ConcurrencyMode concurrencyMode;
private final IndexDefinition[] indexDefinitions;
@@ -115,17 +113,12 @@ public enum EntityType {
private final TableJoin primaryKeyJoin;
private final BeanProperty softDeleteProperty;
private final boolean softDelete;
- private final String draftTable;
private final PartitionMeta partitionMeta;
private final TablespaceMeta tablespaceMeta;
private final String storageEngine;
private final String dbComment;
- private final boolean draftable;
- private final boolean draftableElement;
private final BeanProperty unmappedJson;
private final BeanProperty tenant;
- private final BeanProperty draft;
- private final BeanProperty draftDirty;
private final LinkedHashMap propMap;
/**
* Map of DB column to property path (for nativeSql mapping).
@@ -218,7 +211,6 @@ public enum EntityType {
private final String baseTableAlias;
private final boolean cacheSharableBeans;
private final String docStoreQueueId;
- private final BeanDescriptorDraftHelp draftHelp;
private final BeanDescriptorCacheHelp cacheHelp;
private final BeanDescriptorJsonHelp jsonHelp;
private DocStoreBeanAdapter docStoreAdapter;
@@ -253,13 +245,9 @@ public BeanDescriptor(BeanDescriptorMap owner, DeployBeanDescriptor deploy) {
this.idGeneratedValue = deploy.isIdGeneratedValue();
this.idGenerator = deploy.getIdGenerator();
this.selectLastInsertedId = deploy.getSelectLastInsertedId();
- this.selectLastInsertedIdDraft = deploy.getSelectLastInsertedIdDraft();
this.concurrencyMode = deploy.getConcurrencyMode();
this.indexDefinitions = deploy.getIndexDefinitions();
- this.draftable = deploy.isDraftable();
- this.draftableElement = deploy.isDraftableElement();
this.historySupport = deploy.isHistorySupport();
- this.draftTable = deploy.getDraftTable();
this.baseTable = InternString.intern(deploy.getBaseTable());
this.baseTableAsOf = deploy.getBaseTableAsOf();
this.primaryKeyJoin = deploy.getPrimaryKeyJoin();
@@ -281,8 +269,6 @@ public BeanDescriptor(BeanDescriptorMap owner, DeployBeanDescriptor deploy) {
this.versionProperty = listHelper.getVersionProperty();
this.unmappedJson = listHelper.getUnmappedJson();
this.tenant = listHelper.getTenant();
- this.draft = listHelper.getDraft();
- this.draftDirty = listHelper.getDraftDirty();
this.propMap = listHelper.getPropertyMap();
this.propertiesTransient = listHelper.getTransients();
this.propertiesNonTransient = listHelper.getNonTransients();
@@ -311,7 +297,6 @@ public BeanDescriptor(BeanDescriptorMap owner, DeployBeanDescriptor deploy) {
this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly();
this.cacheHelp = new BeanDescriptorCacheHelp<>(this, owner.cacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported);
this.jsonHelp = initJsonHelp();
- this.draftHelp = new BeanDescriptorDraftHelp<>(this);
this.docStoreAdapter = owner.createDocStoreBeanAdapter(this, deploy);
this.docStoreQueueId = docStoreAdapter.queueId();
// Check if there are no cascade save associated beans ( subject to change
@@ -473,9 +458,6 @@ public BeanProperty propertyByIndex(int pos) {
* as they are used to get the imported and exported properties.
*/
void initialiseId(BeanDescriptorInitContext initContext) {
- if (draftable) {
- initContext.addDraft(baseTable, draftTable);
- }
if (historySupport) {
// add mapping (used to swap out baseTable for asOf queries)
initContext.addHistory(baseTable, baseTableAsOf);
@@ -494,10 +476,6 @@ void initialiseId(BeanDescriptorInitContext initContext) {
* Initialise the exported and imported parts for associated properties.
*/
public void initialiseOther(BeanDescriptorInitContext initContext) {
- for (BeanPropertyAssocMany> many : propertiesManyToMany) {
- // register associated draft table for M2M intersection
- many.registerDraftIntersectionTable(initContext);
- }
if (historySupport) {
// history support on this bean so check all associated intersection tables
// and if they are not excluded register the associated 'with history' table
@@ -1044,24 +1022,6 @@ public void docStoreDeleteById(Object idValue, DocStoreUpdateContext txn) throws
docStoreAdapter.deleteById(idValue, txn);
}
- public T publish(T draftBean, T liveBean) {
- return draftHelp.publish(draftBean, liveBean);
- }
-
- /**
- * Reset properties on the draft bean based on @DraftDirty and @DraftReset.
- */
- public boolean draftReset(T draftBean) {
- return draftHelp.draftReset(draftBean);
- }
-
- /**
- * Return the draft dirty boolean property or null if there is not one assigned to this bean type.
- */
- BeanProperty draftDirty() {
- return draftDirty;
- }
-
/**
* Prepare the query for multi-tenancy check for document store only use.
*/
@@ -1114,11 +1074,7 @@ public boolean isManyPropCaching() {
/**
* Return true if the persist request needs to notify the cache.
*/
- public boolean isCacheNotify(PersistRequest.Type type, boolean publish) {
- if (draftable && !publish) {
- // no caching when editing draft beans
- return false;
- }
+ public boolean isCacheNotify(PersistRequest.Type type) {
return cacheHelp.isCacheNotify(type);
}
@@ -2622,8 +2578,6 @@ public boolean isBaseTable() {
@Override
public String baseTable(SpiQuery.TemporalMode mode) {
switch (mode) {
- case DRAFT:
- return draftTable;
case VERSIONS:
return baseTableVersionsBetween;
case AS_OF:
@@ -2633,13 +2587,6 @@ public String baseTable(SpiQuery.TemporalMode mode) {
}
}
- /**
- * Return the associated draft table.
- */
- public String draftTable() {
- return draftTable;
- }
-
@Override
public boolean isSoftDelete() {
return softDelete;
@@ -2671,20 +2618,6 @@ public void markAsDeleted(EntityBean bean) {
}
}
- /**
- * Return true if this entity type is draftable.
- */
- public boolean isDraftable() {
- return draftable;
- }
-
- /**
- * Return true if this entity type is a draftable element (child).
- */
- public boolean isDraftableElement() {
- return draftableElement;
- }
-
@Override
public Map pathMap(String prefix) {
return pathMaps.computeIfAbsent(prefix, s -> {
@@ -2750,28 +2683,6 @@ public void setTenantId(EntityBean entityBean, Object tenantId) {
}
}
- /**
- * Set the draft to true for this entity bean instance.
- * This bean is being loaded via asDraft() query.
- */
- @Override
- public void setDraft(EntityBean entityBean) {
- if (draft != null) {
- draft.setValue(entityBean, true);
- }
- }
-
- /**
- * Return true if the bean is considered a 'draft' instance (not 'live').
- */
- public boolean isDraftInstance(EntityBean entityBean) {
- if (draft != null) {
- return Boolean.TRUE == draft.getValue(entityBean);
- }
- // no draft property - so return false
- return false;
- }
-
@Override
public boolean isToManyDirty(EntityBean bean) {
final EntityBeanIntercept ebi = bean._ebean_getIntercept();
@@ -2786,39 +2697,6 @@ public boolean isToManyDirty(EntityBean bean) {
return false;
}
- /**
- * Return true if the bean is draftable and considered a 'live' instance.
- */
- public boolean isLiveInstance(EntityBean entityBean) {
- if (draft != null) {
- return Boolean.FALSE == draft.getValue(entityBean);
- }
- // no draft property - so return false
- return false;
- }
-
- /**
- * If there is a @DraftDirty property set it's value on the bean.
- */
- public void setDraftDirty(EntityBean entityBean, boolean value) {
- if (draftDirty != null) {
- // check to see if the dirty property has already
- // been set and if so do not set the value
- if (!entityBean._ebean_getIntercept().isChangedProperty(draftDirty.propertyIndex())) {
- draftDirty.setValueIntercept(entityBean, value);
- }
- }
- }
-
- /**
- * Optimise the draft query fetching any draftable element relationships.
- */
- public void draftQueryOptimise(Query query) {
- // use per query PersistenceContext to ensure fresh beans loaded
- query.setPersistenceContextScope(PersistenceContextScope.QUERY);
- draftHelp.draftQueryOptimise(query);
- }
-
/**
* Return true if this entity bean has history support.
*/
@@ -2864,8 +2742,8 @@ public IdentityMode identityMode() {
* This is only used with Identity columns and getGeneratedKeys is not
* supported.
*/
- public String selectLastInsertedId(boolean publish) {
- return publish ? selectLastInsertedId : selectLastInsertedIdDraft;
+ public String selectLastInsertedId() {
+ return selectLastInsertedId;
}
/**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java
deleted file mode 100644
index f11a921c73..0000000000
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package io.ebeaninternal.server.deploy;
-
-import io.ebean.Query;
-import io.ebean.bean.EntityBean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Helper for BeanDescriptor that manages draft entity beans.
- *
- * @param The entity bean type
- */
-final class BeanDescriptorDraftHelp {
-
- private final BeanDescriptor desc;
- private final BeanProperty draftDirty;
- private final BeanProperty[] resetProperties;
-
- BeanDescriptorDraftHelp(BeanDescriptor desc) {
- this.desc = desc;
- this.draftDirty = desc.draftDirty();
- this.resetProperties = resetProperties();
- }
-
- /**
- * Return the properties that are reset on draft beans after publish.
- */
- private BeanProperty[] resetProperties() {
- List list = new ArrayList<>();
- for (BeanProperty prop : desc.propertiesNonMany()) {
- if (prop.isDraftReset()) {
- list.add(prop);
- }
- }
- return list.toArray(new BeanProperty[0]);
- }
-
- /**
- * Set the value of all the 'reset properties' to null on the draft bean.
- */
- boolean draftReset(T draftBean) {
- EntityBean draftEntityBean = (EntityBean) draftBean;
- if (draftDirty != null) {
- // set @DraftDirty property to false
- draftDirty.setValueIntercept(draftEntityBean, false);
- }
- // set to null on all @DraftReset properties
- for (BeanProperty resetProperty : resetProperties) {
- resetProperty.setValueIntercept(draftEntityBean, null);
- }
- // return true if the bean is dirty (and should be persisted)
- return draftEntityBean._ebean_getIntercept().isDirty();
- }
-
- /**
- * Transfer the values from the draftBean to the liveBean.
- *
- * This will recursive transfer values to all @DraftableElement properties.
- *
- */
- @SuppressWarnings("unchecked")
- public T publish(T draftBean, T liveBean) {
- if (liveBean == null) {
- liveBean = (T) desc.createEntityBean();
- }
- EntityBean draft = (EntityBean) draftBean;
- EntityBean live = (EntityBean) liveBean;
- BeanProperty idProperty = desc.idProperty();
- if (idProperty != null) {
- idProperty.publish(draft, live);
- }
- for (BeanProperty prop : desc.propertiesNonMany()) {
- prop.publish(draft, live);
- }
- for (BeanPropertyAssocMany> many : desc.propertiesMany()) {
- if (many.targetDescriptor().isDraftable()) {
- many.publishMany(draft, live);
- }
- }
- return liveBean;
- }
-
- /**
- * Fetch draftable element relationships.
- */
- void draftQueryOptimise(Query query) {
- for (BeanPropertyAssocOne> anOne : desc.propertiesOne()) {
- if (anOne.targetDescriptor().isDraftableElement()) {
- query.fetch(anOne.name());
- }
- }
- for (BeanPropertyAssocMany> aMany : desc.propertiesMany()) {
- if (aMany.targetDescriptor().isDraftableElement()) {
- query.fetch(aMany.name());
- }
- }
- }
-}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorInitContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorInitContext.java
index 9ce8615696..c8484470b6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorInitContext.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorInitContext.java
@@ -5,20 +5,14 @@
class BeanDescriptorInitContext {
private final Map withHistoryTables;
- private final Map draftTables;
private final String asOfViewSuffix;
private String embeddedPrefix;
- BeanDescriptorInitContext(Map withHistoryTables, Map draftTables, String asOfViewSuffix) {
+ BeanDescriptorInitContext(Map withHistoryTables, String asOfViewSuffix) {
this.withHistoryTables = withHistoryTables;
- this.draftTables = draftTables;
this.asOfViewSuffix = asOfViewSuffix;
}
- void addDraft(String baseTable, String draftTable) {
- draftTables.put(baseTable, draftTable);
- }
-
void addHistory(String baseTable, String baseTableAsOf) {
withHistoryTables.put(baseTable, baseTableAsOf);
}
@@ -27,10 +21,6 @@ void addHistoryIntersection(String intersectionTableName) {
withHistoryTables.put(intersectionTableName, intersectionTableName + asOfViewSuffix);
}
- void addDraftIntersection(String intersectionPublishTable, String intersectionDraftTable) {
- draftTables.put(intersectionPublishTable, intersectionDraftTable);
- }
-
public void setEmbeddedPrefix(String embeddedPrefix) {
this.embeddedPrefix = embeddedPrefix;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java
index 2173a8d26b..e647aee934 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java
@@ -106,10 +106,6 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Map of base tables to 'with history views' used to support 'as of' queries.
*/
private final Map asOfTableMap = new HashMap<>();
- /**
- * Map of base tables to 'draft' tables.
- */
- private final Map draftTableMap = new HashMap<>();
// temporary collections used during startup and then cleared
private Map, DeployBeanInfo>> deployInfoMap = new HashMap<>();
@@ -269,13 +265,6 @@ public IdBinder createIdBinder(BeanProperty idProperty) {
return idBinderFactory.createIdBinder(idProperty);
}
- /**
- * Return the map of base tables to draft tables.
- */
- public Map draftTableMap() {
- return draftTableMap;
- }
-
/**
* Deploy returning the asOfTableMap (which is required by the SQL builders).
*/
@@ -417,7 +406,7 @@ private void initialiseAll() {
// now that all the BeanDescriptors are in their map
// we can initialise them which sorts out circular
// dependencies for OneToMany and ManyToOne etc
- BeanDescriptorInitContext initContext = new BeanDescriptorInitContext(asOfTableMap, draftTableMap, asOfViewSuffix);
+ BeanDescriptorInitContext initContext = new BeanDescriptorInitContext(asOfTableMap, asOfViewSuffix);
// PASS 1:
// initialise the ID properties of all the beans
@@ -959,13 +948,6 @@ private void checkMappedByOneToMany(DeployBeanInfo> info, DeployBeanPropertyAs
// skip mapping check
return;
}
- DeployBeanDescriptor> targetDesc = targetDescriptor(prop);
- if (targetDesc.isDraftableElement()) {
- // automatically turning on orphan removal and CascadeType.ALL
- prop.setModifyListenMode(BeanCollection.ModifyListenMode.REMOVALS);
- prop.getCascadeInfo().setSaveDelete(true, true);
- }
-
if (prop.hasOrderColumn()) {
makeOrderColumn(prop);
}
@@ -991,6 +973,7 @@ private void checkMappedByOneToMany(DeployBeanInfo> info, DeployBeanPropertyAs
String mappedBy = prop.getMappedBy();
// get the mappedBy property
+ DeployBeanDescriptor> targetDesc = targetDescriptor(prop);
DeployBeanPropertyAssocOne> mappedAssocOne = mappedManyToOne(prop, targetDesc, mappedBy);
DeployTableJoin tableJoin = prop.getTableJoin();
if (!tableJoin.hasJoinColumns()) {
@@ -1032,9 +1015,6 @@ private void checkMappedByManyToMany(DeployBeanPropertyAssocMany> prop) {
// get the bean descriptor that holds the mappedBy property
String mappedBy = prop.getMappedBy();
if (mappedBy == null) {
- if (targetDescriptor(prop).isDraftable()) {
- prop.setIntersectionDraftTable();
- }
return;
}
@@ -1059,10 +1039,6 @@ private void checkMappedByManyToMany(DeployBeanPropertyAssocMany> prop) {
DeployTableJoin inverseJoin = new DeployTableJoin();
mappedIntJoin.copyTo(inverseJoin, false, intTableName);
prop.setInverseJoin(inverseJoin);
-
- if (targetDesc.isDraftable()) {
- prop.setIntersectionDraftTable();
- }
}
private DeployBeanPropertyAssocMany> mappedManyToMany(DeployBeanPropertyAssocMany> prop, String mappedBy, DeployBeanDescriptor> targetDesc) {
@@ -1179,8 +1155,7 @@ private void setIdGeneration(DeployBeanDescriptor desc) {
if (identityMode.isIdentity()) {
// used when getGeneratedKeys is not supported (SQL Server 2000, SAP Hana)
String selectLastInsertedId = dbIdentity.getSelectLastInsertedId(desc.getBaseTable());
- String selectLastInsertedIdDraft = (!desc.isDraftable()) ? selectLastInsertedId : dbIdentity.getSelectLastInsertedId(desc.getDraftTable());
- desc.setSelectLastInsertedId(selectLastInsertedId, selectLastInsertedIdDraft);
+ desc.setSelectLastInsertedId(selectLastInsertedId);
return;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
index a439e73794..2d1e74edff 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
@@ -171,10 +171,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
final boolean jsonDeserialize;
private final boolean unmappedJson;
private final boolean tenantId;
- private final boolean draft;
- private final boolean draftOnly;
- private final boolean draftDirty;
- private final boolean draftReset;
private final boolean softDelete;
private final String softDeleteDbSet;
private final String softDeleteDbPredicate;
@@ -201,10 +197,6 @@ public BeanProperty(BeanDescriptor> descriptor, DeployBeanProperty deploy) {
this.excludedFromHistory = deploy.isExcludedFromHistory();
this.unmappedJson = deploy.isUnmappedJson();
this.tenantId = deploy.isTenantId();
- this.draft = deploy.isDraft();
- this.draftDirty = deploy.isDraftDirty();
- this.draftOnly = deploy.isDraftOnly();
- this.draftReset = deploy.isDraftReset();
this.secondaryTable = deploy.isSecondaryTable();
if (secondaryTable) {
this.secondaryTableJoin = new TableJoin(deploy.getSecondaryTableJoin());
@@ -296,10 +288,6 @@ protected BeanProperty(BeanProperty source, BeanPropertyOverride override) {
this.aggregation = null;
this.excludedFromHistory = source.excludedFromHistory;
this.tenantId = source.tenantId;
- this.draft = source.draft;
- this.draftDirty = source.draftDirty;
- this.draftOnly = source.draftOnly;
- this.draftReset = source.draftReset;
this.softDelete = source.softDelete;
this.softDeleteDbSet = source.softDeleteDbSet;
this.softDeleteDbPredicate = source.softDeleteDbPredicate;
@@ -483,7 +471,7 @@ public void appendSelect(DbSqlContext ctx, boolean subQuery) {
ctx.appendFormulaSelect(aggregation);
} else if (formula) {
ctx.appendFormulaSelect(sqlFormulaSelect);
- } else if (!isTransient && !ignoreDraftOnlyProperty(ctx.isDraftQuery())) {
+ } else if (!isTransient) {
if (secondaryTableJoin != null) {
ctx.pushTableAlias(ctx.relativePrefix(secondaryTableJoinPrefix));
}
@@ -590,17 +578,6 @@ public boolean isLocal() {
return local;
}
- /**
- * Copy/set the property value from the draft bean to the live bean.
- */
- public void publish(EntityBean draftBean, EntityBean liveBean) {
- if (!version && !draftOnly) {
- // set property value from draft to live
- Object value = getValueIntercept(draftBean);
- setValueIntercept(liveBean, value);
- }
- }
-
/**
* Return the DB literal expression to set the deleted state to true.
*/
@@ -1090,16 +1067,8 @@ public boolean isTransient() {
/**
* Return true if this property is loadable from a resultSet.
*/
- public boolean isLoadProperty(boolean draftQuery) {
- return !ignoreDraftOnlyProperty(draftQuery) && (!isTransient || formula);
- }
-
- /**
- * Return true if this is a draftOnly property on a non-asDraft query and as such this
- * property should not be included in a sql query.
- */
- private boolean ignoreDraftOnlyProperty(boolean draftQuery) {
- return draftOnly && !draftQuery;
+ public boolean isLoadProperty() {
+ return !isTransient || formula;
}
/**
@@ -1248,36 +1217,6 @@ public boolean isTenantId() {
return tenantId;
}
- /**
- * Return true if this property only exists on the draft table.
- */
- public boolean isDraftOnly() {
- return draftOnly;
- }
-
- /**
- * Return true if this property is a boolean flag on a draftable bean
- * indicating if the instance is a draft or live bean.
- */
- public boolean isDraft() {
- return draft;
- }
-
- /**
- * Return true if this property is a boolean flag only on the draft table
- * indicating that when the draft is different from the published row.
- */
- public boolean isDraftDirty() {
- return draftDirty;
- }
-
- /**
- * Return true if this property is reset/cleared on publish (on the draft bean).
- */
- boolean isDraftReset() {
- return draftReset;
- }
-
/**
* Return true if this property is the soft delete property.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java
index c9899888c5..f349ea253f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java
@@ -41,8 +41,6 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc implements ST
* Join for manyToMany intersection table.
*/
private final TableJoin intersectionJoin;
- private final String intersectionPublishTable;
- private final String intersectionDraftTable;
private final boolean orphanRemoval;
private IntersectionTable intersectionTable;
/**
@@ -102,13 +100,6 @@ public BeanPropertyAssocMany(BeanDescriptor> descriptor, DeployBeanPropertyAss
this.mapKey = deploy.getMapKey();
this.fetchOrderBy = deploy.getFetchOrderBy();
this.intersectionJoin = deploy.createIntersectionTableJoin();
- if (intersectionJoin != null) {
- this.intersectionPublishTable = intersectionJoin.getTable();
- this.intersectionDraftTable = deploy.getIntersectionDraftTable();
- } else {
- this.intersectionPublishTable = null;
- this.intersectionDraftTable = null;
- }
this.inverseJoin = deploy.createInverseTableJoin();
this.modifyListenMode = deploy.getModifyListenMode();
this.jsonHelp = descriptor.isJacksonCorePresent() ? new BeanPropertyAssocManyJsonHelp(this) : null;
@@ -375,7 +366,7 @@ public void setEbeanServer(SpiEbeanServer server) {
}
private IntersectionTable initIntersectionTable() {
- IntersectionBuilder row = new IntersectionBuilder(intersectionPublishTable, intersectionDraftTable);
+ IntersectionBuilder row = new IntersectionBuilder(intersectionJoin.getTable());
for (ExportedProperty exportedProperty : exportedProperties) {
row.addColumn(exportedProperty.getForeignDbColumn());
}
@@ -434,7 +425,7 @@ public String assocIsEmpty(SpiExpressionRequest request, String path) {
StringBuilder sb = new StringBuilder(50).append("from "); // use from to stop parsing on table name
SpiQuery> query = request.queryRequest().query();
if (hasJoinTable()) {
- sb.append(query.isAsDraft() ? intersectionDraftTable : intersectionPublishTable);
+ sb.append(intersectionJoin.getTable());
} else {
sb.append(targetDescriptor.baseTable(query.temporalMode()));
}
@@ -764,37 +755,21 @@ public IntersectionRow buildManyDeleteChildren(EntityBean parentBean, Set