mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Bugfix/create entity bean unload (#1729)
* #1726 Add a testcase to reveal wrong behaviour of createEntityBean * #1726 FIX: createEntityBean must not unload properties for "new" beans (cherry picked from commit 270721bdb54373a83ef00b19a3c35da50f2a2bf5)
This commit is contained in:
committed by
Rob Bygrave
parent
385cc76e34
commit
2923dd1d96
@@ -1915,18 +1915,19 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
beanPostConstructListener.autowire(bean); // calls all registered listeners
|
||||
beanPostConstructListener.postConstruct(bean); // calls first the @PostConstruct method and then the listeners
|
||||
}
|
||||
|
||||
if (unloadProperties.length > 0) {
|
||||
if (isNew) {
|
||||
if (beanPostConstructListener != null) {
|
||||
beanPostConstructListener.postCreate(bean);
|
||||
// if bean is not new, postLoad will be executed later in the bean's lifecycle
|
||||
}
|
||||
// do not unload properties for new beans!
|
||||
} else if (unloadProperties.length > 0) {
|
||||
// 'unload' any properties initialised in the default constructor
|
||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||
for (int unloadProperty : unloadProperties) {
|
||||
ebi.setPropertyUnloaded(unloadProperty);
|
||||
}
|
||||
}
|
||||
if (beanPostConstructListener != null && isNew) {
|
||||
beanPostConstructListener.postCreate(bean);
|
||||
// if bean is not new, postLoad will be executed later in the bean's lifecycle
|
||||
}
|
||||
return bean;
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
Reference in New Issue
Block a user