mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#462 - When fetching, collections can get populated with too many entities - Fix
This commit is contained in:
@@ -232,6 +232,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
PersistenceContext persistenceContext = (!readId || temporalVersions) ? null : ctx.getPersistenceContext();
|
||||
|
||||
boolean newBean = false;
|
||||
if (readId) {
|
||||
Object id = localIdBinder.readSet(ctx, localBean);
|
||||
if (id == null) {
|
||||
@@ -242,6 +243,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
|
||||
contextBean = (EntityBean) persistenceContext.putIfAbsent(id, localBean);
|
||||
if (contextBean == null) {
|
||||
// bean just added to the persistenceContext
|
||||
newBean = true;
|
||||
contextBean = localBean;
|
||||
} else {
|
||||
// bean already exists in persistenceContext
|
||||
@@ -345,7 +347,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
|
||||
return localBean;
|
||||
|
||||
} else {
|
||||
if (lazyLoadParentId != null) {
|
||||
if (lazyLoadParentId != null && newBean) {
|
||||
ctx.setLazyLoadedChildBean(contextBean, lazyLoadParentId);
|
||||
}
|
||||
return contextBean;
|
||||
|
||||
Reference in New Issue
Block a user