mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 22:59:25 +00:00
Fix for #167 - Ebean try to do update child nodes instead of inserting them on cascading save resulting in OptimisticLockException
This commit is contained in:
1 parent
aee46955a7
commit
6d1a41f979
6 files changed
+228
-46
No files matched your search
@@ -1886,21 +1886,31 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
return idProperty;
|
||||
}
|
||||
|
||||
public boolean isInsertMode(EntityBeanIntercept ebi) {
|
||||
/**
|
||||
* Return true if this bean should be inserted rather than updated.
|
||||
*
|
||||
* @param ebi
|
||||
* The entity bean intercept
|
||||
* @param insertMode
|
||||
* true if the 'root request' was an insert rather than an update
|
||||
*/
|
||||
public boolean isInsertMode(EntityBeanIntercept ebi, boolean insertMode) {
|
||||
|
||||
if (ebi.isLoaded()) {
|
||||
// must be an update as the bean is loaded
|
||||
return false;
|
||||
}
|
||||
|
||||
// determine based on Id property
|
||||
if (idProperty.isEmbedded()) {
|
||||
// not using Id generator so just base on isLoaded()
|
||||
return !ebi.isLoaded();
|
||||
}
|
||||
//if (idGenerator == null) {
|
||||
// return !ebi.isLoaded();
|
||||
//} else {
|
||||
return !hasIdProperty(ebi);
|
||||
//}
|
||||
if (!hasIdProperty(ebi)) {
|
||||
// No Id property means it must be an insert
|
||||
return true;
|
||||
}
|
||||
// same as the 'root request'
|
||||
return insertMode;
|
||||
}
|
||||
|
||||
public boolean isReference(EntityBeanIntercept ebi) {
|
||||
|
||||
Reference in new issue
Block a user