mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#296 - ENH: Add to transaction setUpdateAllLoadedProperties() - force update all properties api
This commit is contained in:
1 parent
3baa5bca46
commit
d396f09b3a
9 files changed
+221
-43
No files matched your search
@@ -641,10 +641,14 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the property value has changed and if so include it in the update.
|
||||
* Return true if the property should be included in the update.
|
||||
*/
|
||||
public boolean isAddToUpdate(BeanProperty prop) {
|
||||
return intercept.isDirtyProperty(prop.getPropertyIndex());
|
||||
if (transaction.isUpdateAllLoadedProperties()) {
|
||||
return intercept.isLoadedProperty(prop.getPropertyIndex());
|
||||
} else {
|
||||
return intercept.isDirtyProperty(prop.getPropertyIndex());
|
||||
}
|
||||
}
|
||||
|
||||
public List<DerivedRelationshipData> getDerivedRelationships() {
|
||||
|
||||
@@ -110,12 +110,17 @@ public final class UpdateMeta {
|
||||
|
||||
private SpiUpdatePlan getDynamicUpdatePlan(ConcurrencyMode mode, PersistRequestBean<?> persistRequest) {
|
||||
|
||||
|
||||
// we can use a cached UpdatePlan for the changed properties
|
||||
|
||||
|
||||
EntityBeanIntercept ebi = persistRequest.getEntityBeanIntercept();
|
||||
int hash = ebi.getDirtyPropertyHash();
|
||||
|
||||
|
||||
int hash;
|
||||
if (persistRequest.getTransaction().isUpdateAllLoadedProperties()) {
|
||||
hash = ebi.getLoadedPropertyHash();
|
||||
} else {
|
||||
hash = ebi.getDirtyPropertyHash();
|
||||
}
|
||||
|
||||
BeanDescriptor<?> beanDescriptor = persistRequest.getBeanDescriptor();
|
||||
|
||||
BeanProperty versionProperty = beanDescriptor.getVersionProperty();
|
||||
|
||||
@@ -91,6 +91,8 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
|
||||
protected boolean localReadOnly;
|
||||
|
||||
protected boolean updateAllLoadedProperties;
|
||||
|
||||
protected PersistBatch oldBatchMode;
|
||||
|
||||
protected PersistBatch batchMode;
|
||||
@@ -393,6 +395,15 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
this.updateAllLoadedProperties = updateAllLoadedProperties;
|
||||
}
|
||||
|
||||
public boolean isUpdateAllLoadedProperties() {
|
||||
return updateAllLoadedProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBatchMode(boolean batchMode) {
|
||||
if (!isActive()) {
|
||||
|
||||
Reference in new issue
Block a user