mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor rename getters to accessors for BeanCollection, EntityBeanIntercept etc
This commit is contained in:
@@ -23,7 +23,7 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
* Construct for lazy load request.
|
||||
*/
|
||||
public LoadBeanRequest(LoadBeanBuffer loadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
|
||||
this(loadBuffer, null, true, ebi.getLazyLoadProperty(), ebi.isLoaded(), loadCache || ebi.isLoadedFromCache());
|
||||
this(loadBuffer, null, true, ebi.lazyLoadProperty(), ebi.isLoaded(), loadCache || ebi.isLoadedFromCache());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
final List<Object> idList = new ArrayList<>(batch.size());
|
||||
final BeanDescriptor<?> desc = loadBuffer.descriptor();
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
idList.add(desc.getId(ebi.getOwner()));
|
||||
idList.add(desc.getId(ebi.owner()));
|
||||
}
|
||||
return idList;
|
||||
}
|
||||
@@ -116,10 +116,10 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
// check if the underlying row in DB was deleted. Mark the bean as 'failed' if
|
||||
// necessary but allow processing to continue until it is accessed by client code
|
||||
Object id = desc.getId(ebi.getOwner());
|
||||
Object id = desc.getId(ebi.owner());
|
||||
if (!loadedIds.contains(id)) {
|
||||
// assume this is logically deleted (hence not found)
|
||||
desc.markAsDeleted(ebi.getOwner());
|
||||
desc.markAsDeleted(ebi.owner());
|
||||
missedIds.add(id);
|
||||
missed.add(ebi);
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
if (lazy && !originIncluded && bc == originCollection) {
|
||||
originIncluded = true;
|
||||
}
|
||||
idList.add(many.parentId(bc.getOwnerBean()));
|
||||
idList.add(many.parentId(bc.owner()));
|
||||
bc.setLoader(server); // don't use the load buffer again
|
||||
}
|
||||
}
|
||||
if (originCollection != null && !originIncluded) {
|
||||
CoreLog.log.log(INFO, "Batch lazy loading including origin collection - size:{0}", idList.size());
|
||||
idList.add(many.parentId(originCollection.getOwnerBean()));
|
||||
idList.add(many.parentId(originCollection.owner()));
|
||||
originCollection.setLoader(server); // don't use the load buffer again
|
||||
}
|
||||
if (many.targetDescriptor().isPadInExpression()) {
|
||||
@@ -129,12 +129,12 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
if (bc != null) {
|
||||
if (bc.checkEmptyLazyLoad()) {
|
||||
if (log.isLoggable(DEBUG)) {
|
||||
EntityBean ownerBean = bc.getOwnerBean();
|
||||
EntityBean ownerBean = bc.owner();
|
||||
Object parentId = desc.getId(ownerBean);
|
||||
log.log(DEBUG, "BeanCollection after lazy load was empty. type:{0} id:{1} owner:{2}", ownerBean.getClass().getName(), parentId, ownerBean);
|
||||
}
|
||||
} else if (loadCache && many.isUseCache()) {
|
||||
desc.cacheManyPropPut(many, bc, desc.cacheKeyForBean(bc.getOwnerBean()));
|
||||
desc.cacheManyPropPut(many, bc, desc.cacheKeyForBean(bc.owner()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ final class DefaultBeanLoader {
|
||||
}
|
||||
|
||||
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
|
||||
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), false, onlyIds);
|
||||
loadManyInternal(bc.owner(), bc.propertyName(), false, onlyIds);
|
||||
}
|
||||
|
||||
void refreshMany(EntityBean parentBean, String propertyName) {
|
||||
@@ -51,7 +51,7 @@ final class DefaultBeanLoader {
|
||||
|
||||
private void loadManyInternal(EntityBean parentBean, String propertyName, boolean refresh, boolean onlyIds) {
|
||||
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
|
||||
PersistenceContext pc = ebi.getPersistenceContext();
|
||||
PersistenceContext pc = ebi.persistenceContext();
|
||||
BeanDescriptor<?> parentDesc = server.descriptor(parentBean.getClass());
|
||||
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.beanProperty(propertyName);
|
||||
BeanCollection<?> beanCollection = null;
|
||||
@@ -60,7 +60,7 @@ final class DefaultBeanLoader {
|
||||
Object currentValue = many.getValue(parentBean);
|
||||
if (currentValue instanceof BeanCollection<?>) {
|
||||
beanCollection = (BeanCollection<?>) currentValue;
|
||||
filterMany = beanCollection.getFilterMany();
|
||||
filterMany = beanCollection.filterMany();
|
||||
}
|
||||
|
||||
Object parentId = parentDesc.getId(parentBean);
|
||||
@@ -113,7 +113,7 @@ final class DefaultBeanLoader {
|
||||
if (beanCollection != null) {
|
||||
if (beanCollection.checkEmptyLazyLoad()) {
|
||||
if (log.isLoggable(DEBUG)) {
|
||||
log.log(DEBUG, "BeanCollection after load was empty. Owner:{0}", beanCollection.getOwnerBean());
|
||||
log.log(DEBUG, "BeanCollection after load was empty. Owner:{0}", beanCollection.owner());
|
||||
}
|
||||
} else if (useManyIdCache) {
|
||||
final String parentKey = parentDesc.cacheKey(parentId);
|
||||
@@ -172,12 +172,12 @@ final class DefaultBeanLoader {
|
||||
}
|
||||
|
||||
void loadBean(EntityBeanIntercept ebi) {
|
||||
refreshBeanInternal(ebi.getOwner(), SpiQuery.Mode.LAZYLOAD_BEAN, -1);
|
||||
refreshBeanInternal(ebi.owner(), SpiQuery.Mode.LAZYLOAD_BEAN, -1);
|
||||
}
|
||||
|
||||
private void refreshBeanInternal(EntityBean bean, SpiQuery.Mode mode, int embeddedOwnerIndex) {
|
||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||
PersistenceContext pc = ebi.getPersistenceContext();
|
||||
PersistenceContext pc = ebi.persistenceContext();
|
||||
if (Mode.REFRESH_BEAN == mode) {
|
||||
// need a new PersistenceContext for REFRESH
|
||||
pc = null;
|
||||
@@ -185,8 +185,8 @@ final class DefaultBeanLoader {
|
||||
BeanDescriptor<?> desc = server.descriptor(bean.getClass());
|
||||
if (EntityType.EMBEDDED == desc.entityType()) {
|
||||
// lazy loading on an embedded bean property
|
||||
EntityBean embeddedOwner = (EntityBean) ebi.getEmbeddedOwner();
|
||||
refreshBeanInternal(embeddedOwner, mode, ebi.getEmbeddedOwnerIndex());
|
||||
EntityBean embeddedOwner = (EntityBean) ebi.embeddedOwner();
|
||||
refreshBeanInternal(embeddedOwner, mode, ebi.embeddedOwnerIndex());
|
||||
}
|
||||
Object id = desc.getId(bean);
|
||||
if (pc == null) {
|
||||
@@ -208,14 +208,14 @@ final class DefaultBeanLoader {
|
||||
}
|
||||
}
|
||||
SpiQuery<?> query = server.createQuery(desc.type());
|
||||
query.setLazyLoadProperty(ebi.getLazyLoadProperty());
|
||||
query.setLazyLoadProperty(ebi.lazyLoadProperty());
|
||||
if (draft) {
|
||||
query.asDraft();
|
||||
} else if (mode == SpiQuery.Mode.LAZYLOAD_BEAN && desc.isSoftDelete()) {
|
||||
query.setIncludeSoftDeletes();
|
||||
}
|
||||
if (embeddedOwnerIndex > -1) {
|
||||
query.select(ebi.getProperty(embeddedOwnerIndex));
|
||||
query.select(ebi.property(embeddedOwnerIndex));
|
||||
}
|
||||
// don't collect AutoTune usage profiling information
|
||||
// as we just copy the data out of these fetched beans
|
||||
|
||||
@@ -46,17 +46,17 @@ public final class DefaultBeanState implements BeanState {
|
||||
|
||||
@Override
|
||||
public Set<String> loadedProps() {
|
||||
return intercept.getLoadedPropertyNames();
|
||||
return intercept.loadedPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> changedProps() {
|
||||
return intercept.getDirtyPropertyNames();
|
||||
return intercept.dirtyPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ValuePair> dirtyValues() {
|
||||
return intercept.getDirtyValues();
|
||||
return intercept.dirtyValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,11 +91,11 @@ public final class DefaultBeanState implements BeanState {
|
||||
|
||||
@Override
|
||||
public Map<String, Exception> loadErrors() {
|
||||
return intercept.getLoadErrors();
|
||||
return intercept.loadErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sortOrder() {
|
||||
return intercept.getSortOrder();
|
||||
return intercept.sortOrder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class DiffHelp {
|
||||
}
|
||||
}
|
||||
if (oldBean == null) {
|
||||
return ((EntityBean) newBean)._ebean_getIntercept().getDirtyValues();
|
||||
return ((EntityBean) newBean)._ebean_getIntercept().dirtyValues();
|
||||
}
|
||||
return desc.diff((EntityBean) newBean, (EntityBean) oldBean);
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
OrderBy<T> orderBy = query.getOrderBy();
|
||||
if (orderBy != null && !orderBy.isEmpty()) {
|
||||
// in memory sort after merging the cache hits with the DB hits
|
||||
beanDescriptor.sort(((BeanList<T>) result).getActualList(), orderBy.toStringFormat());
|
||||
beanDescriptor.sort(((BeanList<T>) result).actualList(), orderBy.toStringFormat());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -646,7 +646,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
if (cached != null && isAuditReads() && readAuditQueryType()) {
|
||||
if (cached instanceof BeanCollection) {
|
||||
// raw sql can't use L2 cache so normal queries only in here
|
||||
Collection<T> actualDetails = ((BeanCollection<T>) cached).getActualDetails();
|
||||
Collection<T> actualDetails = ((BeanCollection<T>) cached).actualDetails();
|
||||
List<Object> ids = new ArrayList<>(actualDetails.size());
|
||||
for (T bean : actualDetails) {
|
||||
ids.add(beanDescriptor.idForJson(bean));
|
||||
@@ -657,7 +657,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||
// return shallow copies if readonly is explicitly set to false
|
||||
if (cached instanceof BeanCollection) {
|
||||
cached = ((BeanCollection<?>) cached).getShallowCopy();
|
||||
cached = ((BeanCollection<?>) cached).shallowCopy();
|
||||
} else if (cached instanceof List) {
|
||||
cached = new CopyOnFirstWriteList<>((List<?>) cached);
|
||||
} else if (cached instanceof Set) {
|
||||
|
||||
@@ -281,7 +281,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
private void onFailedUpdateUndoGeneratedProperties() {
|
||||
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
|
||||
Object oldVal = intercept.getOrigValue(prop.propertyIndex());
|
||||
Object oldVal = intercept.origValue(prop.propertyIndex());
|
||||
prop.setValue(entityBean, oldVal);
|
||||
}
|
||||
}
|
||||
@@ -372,12 +372,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
@Override
|
||||
public Set<String> loadedProperties() {
|
||||
return intercept.getLoadedPropertyNames();
|
||||
return intercept.loadedPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> updatedProperties() {
|
||||
return intercept.getDirtyPropertyNames();
|
||||
return intercept.dirtyPropertyNames();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,7 +410,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
@Override
|
||||
public Map<String, ValuePair> updatedValues() {
|
||||
return intercept.getDirtyValues();
|
||||
return intercept.dirtyValues();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,7 +713,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Return the original / old value for the given property.
|
||||
*/
|
||||
public Object getOrigValue(BeanProperty prop) {
|
||||
return intercept.getOrigValue(prop.propertyIndex());
|
||||
return intercept.origValue(prop.propertyIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -867,7 +867,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
boolean isChangeLog = beanDescriptor.isChangeLog();
|
||||
if (type == Type.UPDATE && (isChangeLog || notifyCache || docStoreMode == DocStoreMode.UPDATE)) {
|
||||
// get the dirty properties for update notification to the doc store
|
||||
dirtyProperties = intercept.getDirtyProperties();
|
||||
dirtyProperties = intercept.dirtyProperties();
|
||||
}
|
||||
if (isChangeLog) {
|
||||
changeLog();
|
||||
@@ -1142,9 +1142,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
public String updatePlanHash() {
|
||||
StringBuilder key;
|
||||
if (determineUpdateAllLoadedProperties()) {
|
||||
key = intercept.getLoadedPropertyKey();
|
||||
key = intercept.loadedPropertyKey();
|
||||
} else {
|
||||
key = intercept.getDirtyPropertyKey();
|
||||
key = intercept.dirtyPropertyKey();
|
||||
}
|
||||
BeanProperty versionProperty = beanDescriptor.versionProperty();
|
||||
if (versionProperty != null) {
|
||||
@@ -1237,7 +1237,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
public void docStorePersist() {
|
||||
idValue = beanDescriptor.getId(entityBean);
|
||||
if (type == Type.UPDATE) {
|
||||
dirtyProperties = intercept.getDirtyProperties();
|
||||
dirtyProperties = intercept.dirtyProperties();
|
||||
}
|
||||
// processing now so set IGNORE (unlike DB + DocStore processing with post-commit)
|
||||
docStoreMode = DocStoreMode.IGNORE;
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
|
||||
@Override
|
||||
public final Collection underlying(Object value) {
|
||||
if (value instanceof BeanCollection) {
|
||||
return ((BeanCollection)value).getActualDetails();
|
||||
return ((BeanCollection)value).actualDetails();
|
||||
} else {
|
||||
return (Collection)value;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public final class BeanCollectionUtil {
|
||||
}
|
||||
// For maps this is a collection of Map.Entry, otherwise it
|
||||
// returns a collection of beans
|
||||
return bc.getActualEntries();
|
||||
return bc.actualEntries();
|
||||
}
|
||||
if (o instanceof Collection<?>) {
|
||||
return ((Collection<?>) o);
|
||||
@@ -61,7 +61,7 @@ public final class BeanCollectionUtil {
|
||||
}
|
||||
// For maps this is a collection of Map.Entry, otherwise it
|
||||
// returns a collection of beans
|
||||
return bc.getActualDetails();
|
||||
return bc.actualDetails();
|
||||
}
|
||||
if (o instanceof Map<?, ?>) {
|
||||
// yes, we want the entrySet (to set the keys)
|
||||
|
||||
@@ -29,6 +29,7 @@ import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.TransactionEventTable.TableIUD;
|
||||
import io.ebeaninternal.api.json.SpiJsonReader;
|
||||
import io.ebeaninternal.api.json.SpiJsonWriter;
|
||||
import io.ebeaninternal.server.bind.DataBind;
|
||||
import io.ebeaninternal.server.cache.CacheChangeSet;
|
||||
import io.ebeaninternal.server.cache.CachedBeanData;
|
||||
import io.ebeaninternal.server.cache.CachedManyIds;
|
||||
@@ -45,7 +46,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.server.bind.DataBind;
|
||||
import io.ebeaninternal.util.SortByClause;
|
||||
import io.ebeaninternal.util.SortByClauseParser;
|
||||
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||
@@ -350,9 +350,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
this.idPropertyIndex = (idProperty == null) ? -1 : ebi.findProperty(idProperty.name());
|
||||
this.versionPropertyIndex = (versionProperty == null) ? -1 : ebi.findProperty(versionProperty.name());
|
||||
this.unloadProperties = derivePropertiesToUnload(prototypeEntityBean);
|
||||
this.propertiesIndex = new BeanProperty[ebi.getPropertyLength()];
|
||||
this.propertiesIndex = new BeanProperty[ebi.propertyLength()];
|
||||
for (int i = 0; i < propertiesIndex.length; i++) {
|
||||
propertiesIndex[i] = propMap.get(ebi.getProperty(i));
|
||||
propertiesIndex[i] = propMap.get(ebi.property(i));
|
||||
}
|
||||
}
|
||||
idSelect = initIdSelect();
|
||||
@@ -400,7 +400,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* These properties need to be unloaded when populating beans for queries.
|
||||
*/
|
||||
private int[] derivePropertiesToUnload(EntityBean prototypeEntityBean) {
|
||||
boolean[] loaded = prototypeEntityBean._ebean_getIntercept().getLoaded();
|
||||
boolean[] loaded = prototypeEntityBean._ebean_getIntercept().loaded();
|
||||
int[] props = new int[loaded.length];
|
||||
int pos = 0;
|
||||
// collect the positions of the properties initialised in the default constructor.
|
||||
@@ -711,7 +711,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
EntityBeanIntercept fromEbi = bean._ebean_getIntercept();
|
||||
EntityBeanIntercept toEbi = existing._ebean_getIntercept();
|
||||
int propertyLength = toEbi.getPropertyLength();
|
||||
int propertyLength = toEbi.propertyLength();
|
||||
String[] names = properties();
|
||||
for (int i = 0; i < propertyLength; i++) {
|
||||
if (fromEbi.isLoadedProperty(i)) {
|
||||
@@ -2217,12 +2217,12 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
}
|
||||
|
||||
public boolean lazyLoadMany(EntityBeanIntercept ebi, LoadBeanContext parent) {
|
||||
int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
|
||||
int lazyLoadProperty = ebi.lazyLoadPropertyIndex();
|
||||
if (lazyLoadProperty == -1) {
|
||||
return false;
|
||||
}
|
||||
if (inheritInfo != null) {
|
||||
return descOf(ebi.getOwner().getClass()).lazyLoadMany(ebi, lazyLoadProperty, parent);
|
||||
return descOf(ebi.owner().getClass()).lazyLoadMany(ebi, lazyLoadProperty, parent);
|
||||
}
|
||||
return lazyLoadMany(ebi, lazyLoadProperty, parent);
|
||||
}
|
||||
@@ -2241,7 +2241,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
BeanProperty lazyLoadBeanProp = propertiesIndex[lazyLoadProperty];
|
||||
if (lazyLoadBeanProp instanceof BeanPropertyAssocMany<?>) {
|
||||
BeanPropertyAssocMany<?> manyProp = (BeanPropertyAssocMany<?>) lazyLoadBeanProp;
|
||||
final BeanCollection<?> collection = manyProp.createReference(ebi.getOwner());
|
||||
final BeanCollection<?> collection = manyProp.createReference(ebi.owner());
|
||||
ebi.setLoadedLazy();
|
||||
if (loadBeanContext != null) {
|
||||
loadBeanContext.register(manyProp, collection);
|
||||
@@ -3076,7 +3076,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
// not using Id generator so just base on isLoaded()
|
||||
return !ebi.isLoaded();
|
||||
}
|
||||
if (!hasIdValue(ebi.getOwner())) {
|
||||
if (!hasIdValue(ebi.owner())) {
|
||||
// No Id property means it must be an insert
|
||||
return true;
|
||||
}
|
||||
@@ -3139,7 +3139,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
for (BeanProperty beanProperty : propertiesMutable) {
|
||||
int propertyIndex = beanProperty.propertyIndex();
|
||||
if (ebi.isLoadedProperty(propertyIndex)) {
|
||||
Object value = beanProperty.getValue(ebi.getOwner());
|
||||
Object value = beanProperty.getValue(ebi.owner());
|
||||
if (beanProperty.checkMutable(value, ebi.isDirtyProperty(propertyIndex), ebi)) {
|
||||
// mutable scalar value which is considered dirty so mark
|
||||
// it as such so that it is included in an update
|
||||
@@ -3156,7 +3156,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
for (BeanProperty beanProperty : propertiesMutable) {
|
||||
int propertyIndex = beanProperty.propertyIndex();
|
||||
if (ebi.isLoadedProperty(propertyIndex)) {
|
||||
Object value = beanProperty.getValue(ebi.getOwner());
|
||||
Object value = beanProperty.getValue(ebi.owner());
|
||||
if (beanProperty.checkMutable(value, ebi.isDirtyProperty(propertyIndex), ebi)) {
|
||||
ebi.markPropertyAsChanged(propertyIndex);
|
||||
return;
|
||||
|
||||
+7
-7
@@ -271,9 +271,9 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
// not in cache so return unsuccessful
|
||||
return false;
|
||||
}
|
||||
EntityBean ownerBean = bc.getOwnerBean();
|
||||
EntityBean ownerBean = bc.owner();
|
||||
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
|
||||
PersistenceContext persistenceContext = ebi.getPersistenceContext();
|
||||
PersistenceContext persistenceContext = ebi.persistenceContext();
|
||||
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
|
||||
|
||||
List<Object> idList = entry.getIdList();
|
||||
@@ -696,7 +696,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
Set<EntityBeanIntercept> beanCacheLoadAll(Set<EntityBeanIntercept> batch, PersistenceContext context, int lazyLoadProperty, String propertyName) {
|
||||
Map<Object, EntityBeanIntercept> ebis = new HashMap<>();
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
ebis.put(desc.cacheKeyForBean(ebi.getOwner()), ebi);
|
||||
ebis.put(desc.cacheKeyForBean(ebi.owner()), ebi);
|
||||
}
|
||||
|
||||
Map<Object, Object> hits = getBeanCache().getAll(ebis.keySet());
|
||||
@@ -715,7 +715,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
beanLog.log(TRACE, " load {0}({1}) - cache miss on property({2})", cacheName, key, propertyName);
|
||||
}
|
||||
} else {
|
||||
CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context);
|
||||
CachedBeanDataToBean.load(desc, ebi.owner(), cacheData, context);
|
||||
loaded.add(ebi);
|
||||
if (beanLog.isLoggable(DEBUG)) {
|
||||
beanLog.log(DEBUG, " load {0}({1}) - hit", cacheName, key);
|
||||
@@ -739,10 +739,10 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
|
||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.getLazyLoadProperty())) {
|
||||
int lazyLoadProperty = ebi.lazyLoadPropertyIndex();
|
||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.lazyLoadProperty())) {
|
||||
if (beanLog.isLoggable(TRACE)) {
|
||||
beanLog.log(TRACE, " LOAD {0}({1}) - cache miss on property({2})", cacheName, key, ebi.getLazyLoadProperty());
|
||||
beanLog.log(TRACE, " LOAD {0}({1}) - cache miss on property({2})", cacheName, key, ebi.lazyLoadProperty());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
public final BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
||||
if (bc instanceof BeanList<?>) {
|
||||
BeanList<?> bl = (BeanList<?>) bc;
|
||||
if (bl.getActualList() == null) {
|
||||
if (bl.actualList() == null) {
|
||||
bl.setActualList(new ArrayList<>());
|
||||
}
|
||||
return bl;
|
||||
@@ -85,7 +85,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
} else if (currentList instanceof BeanList<?>) {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanList<?> currentBeanList = (BeanList<?>) currentList;
|
||||
currentBeanList.setActualList(newBeanList.getActualList());
|
||||
currentBeanList.setActualList(newBeanList.actualList());
|
||||
currentBeanList.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
list = beanList.getActualList();
|
||||
list = beanList.actualList();
|
||||
} else {
|
||||
list = (List<?>) collection;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
BeanProperty beanProp = targetDescriptor.beanProperty(mapKey);
|
||||
if (bc instanceof BeanMap<?, ?>) {
|
||||
BeanMap<Object, Object> bm = (BeanMap<Object, Object>) bc;
|
||||
Map<Object, Object> actualMap = bm.getActualMap();
|
||||
Map<Object, Object> actualMap = bm.actualMap();
|
||||
if (actualMap == null) {
|
||||
actualMap = new LinkedHashMap<>();
|
||||
bm.setActualMap(actualMap);
|
||||
@@ -132,7 +132,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
} else if (current instanceof BeanMap<?, ?>) {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanMap<?, ?> currentBeanMap = (BeanMap<?, ?>) current;
|
||||
currentBeanMap.setActualMap(newBeanMap.getActualMap());
|
||||
currentBeanMap.setActualMap(newBeanMap.actualMap());
|
||||
currentBeanMap.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
@@ -155,7 +155,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
map = bc.getActualMap();
|
||||
map = bc.actualMap();
|
||||
} else {
|
||||
map = (Map<?, ?>) collection;
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return the bean cache value for this property using original values.
|
||||
*/
|
||||
public Object getCacheDataValueOrig(EntityBeanIntercept ebi) {
|
||||
return cacheDataConvert(ebi.getOrigValue(propertyIndex));
|
||||
return cacheDataConvert(ebi.origValue(propertyIndex));
|
||||
}
|
||||
|
||||
private Object cacheDataConvert(Object value) {
|
||||
|
||||
@@ -875,7 +875,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
|
||||
// publish from each draft to live bean creating new live beans as required
|
||||
draftVal.size();
|
||||
Collection<T> actualDetails = draftVal.getActualDetails();
|
||||
Collection<T> actualDetails = draftVal.actualDetails();
|
||||
for (T bean : actualDetails) {
|
||||
Object id = targetDescriptor.id(bean);
|
||||
T liveBean = liveBeansAsMap.remove(id);
|
||||
@@ -904,7 +904,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Object, T> liveBeansAsMap(BeanCollection<?> liveVal) {
|
||||
liveVal.size();
|
||||
Collection<?> liveBeans = liveVal.getActualDetails();
|
||||
Collection<?> liveBeans = liveVal.actualDetails();
|
||||
Map<Object, T> liveMap = new LinkedHashMap<>();
|
||||
for (Object liveBean : liveBeans) {
|
||||
Object id = targetDescriptor.id(liveBean);
|
||||
|
||||
@@ -408,7 +408,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
*/
|
||||
@Override
|
||||
public Object getCacheDataValueOrig(EntityBeanIntercept ebi) {
|
||||
return cacheDataConvert(ebi.getOrigValue(propertyIndex));
|
||||
return cacheDataConvert(ebi.origValue(propertyIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,12 +25,12 @@ public final class BeanPropertyIdClass extends BeanPropertyAssocOne {
|
||||
|
||||
@Override
|
||||
public Object getValue(EntityBean bean) {
|
||||
return bean._ebean_getIntercept().getOwnerId();
|
||||
return bean._ebean_getIntercept().ownerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueIntercept(EntityBean bean) {
|
||||
return bean._ebean_getIntercept().getOwnerId();
|
||||
return bean._ebean_getIntercept().ownerId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,12 +16,12 @@ public final class BeanPropertyOrderColumn extends BeanProperty {
|
||||
|
||||
@Override
|
||||
public Object getValue(EntityBean bean) {
|
||||
return bean._ebean_getIntercept().getSortOrder();
|
||||
return bean._ebean_getIntercept().sortOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueIntercept(EntityBean bean) {
|
||||
return bean._ebean_getIntercept().getSortOrder();
|
||||
return bean._ebean_getIntercept().sortOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
public final BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
||||
if (bc instanceof BeanSet<?>) {
|
||||
BeanSet<?> beanSet = (BeanSet<?>) bc;
|
||||
if (beanSet.getActualSet() == null) {
|
||||
if (beanSet.actualSet() == null) {
|
||||
beanSet.setActualSet(new LinkedHashSet<>());
|
||||
}
|
||||
return beanSet;
|
||||
@@ -90,7 +90,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
} else if (current instanceof BeanSet<?>) {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanSet<?> currentBeanSet = (BeanSet<?>) current;
|
||||
currentBeanSet.setActualSet(newBeanSet.getActualSet());
|
||||
currentBeanSet.setActualSet(newBeanSet.actualSet());
|
||||
currentBeanSet.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
@@ -113,7 +113,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
set = bc.getActualSet();
|
||||
set = bc.actualSet();
|
||||
} else {
|
||||
set = (Set<?>) collection;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
public void add(EntityBeanIntercept ebi) {
|
||||
if (persistenceContext == null) {
|
||||
// get persistenceContext from first loaded bean into the buffer
|
||||
persistenceContext = ebi.getPersistenceContext();
|
||||
persistenceContext = ebi.persistenceContext();
|
||||
}
|
||||
batch.add(ebi);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
// re-add to the batch and lazy load from DB skipping l2 cache
|
||||
batch.add(ebi);
|
||||
} else if (context.hitCache) {
|
||||
Set<EntityBeanIntercept> hits = context.desc.cacheBeanLoadAll(batch, persistenceContext, ebi.getLazyLoadPropertyIndex(), ebi.getLazyLoadProperty());
|
||||
Set<EntityBeanIntercept> hits = context.desc.cacheBeanLoadAll(batch, persistenceContext, ebi.lazyLoadPropertyIndex(), ebi.lazyLoadProperty());
|
||||
batch.removeAll(hits);
|
||||
if (batch.isEmpty() || hits.contains(ebi)) {
|
||||
// successfully hit the L2 cache so don't invoke DB lazy loading
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package io.ebeaninternal.server.loadcontext;
|
||||
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.BeanCollectionLoader;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.ObjectGraphNode;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebean.bean.*;
|
||||
import io.ebeaninternal.api.LoadManyBuffer;
|
||||
import io.ebeaninternal.api.LoadManyContext;
|
||||
import io.ebeaninternal.api.LoadManyRequest;
|
||||
@@ -198,7 +194,7 @@ final class DLoadManyContext extends DLoadBaseContext implements LoadManyContext
|
||||
try {
|
||||
boolean useCache = !onlyIds && context.hitCache && context.property.isUseCache();
|
||||
if (useCache) {
|
||||
EntityBean ownerBean = bc.getOwnerBean();
|
||||
EntityBean ownerBean = bc.owner();
|
||||
BeanDescriptor<?> parentDesc = context.desc.descriptor(ownerBean.getClass());
|
||||
Object parentId = parentDesc.getId(ownerBean);
|
||||
final String parentKey = parentDesc.cacheKey(parentId);
|
||||
|
||||
@@ -972,7 +972,7 @@ public final class DefaultPersister implements Persister {
|
||||
if (deleteMode.isHard() || many.isTargetSoftDelete()) {
|
||||
Object details = many.getValue(parentBean);
|
||||
if (details instanceof BeanCollection<?>) {
|
||||
Set<?> modifyRemovals = ((BeanCollection<?>) details).getModifyRemovals();
|
||||
Set<?> modifyRemovals = ((BeanCollection<?>) details).modifyRemovals();
|
||||
if (modifyRemovals != null && !modifyRemovals.isEmpty()) {
|
||||
// delete the orphans that have been removed from the collection
|
||||
for (Object detail : modifyRemovals) {
|
||||
|
||||
@@ -6,18 +6,10 @@ import io.ebean.bean.EntityBeanIntercept;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.api.SpiSqlUpdate;
|
||||
import io.ebeaninternal.server.core.PersistRequestBean;
|
||||
import io.ebeaninternal.server.deploy.BeanCollectionUtil;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import io.ebeaninternal.server.deploy.IntersectionRow;
|
||||
import io.ebeaninternal.server.deploy.*;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
@@ -165,7 +157,7 @@ final class SaveManyBeans extends SaveManyBase {
|
||||
} else {
|
||||
int originalOrder = 0;
|
||||
if (orderColumn != null) {
|
||||
originalOrder = detail._ebean_getIntercept().getSortOrder();
|
||||
originalOrder = detail._ebean_getIntercept().sortOrder();
|
||||
if (sortOrder != originalOrder) {
|
||||
detail._ebean_intercept().setSortOrder(sortOrder);
|
||||
ebi.setDirty(true);
|
||||
@@ -285,10 +277,10 @@ final class SaveManyBeans extends SaveManyBase {
|
||||
// BeanCollection so get the additions/deletions
|
||||
BeanCollection<?> manyValue = (BeanCollection<?>) value;
|
||||
if (setListenMode(manyValue, many)) {
|
||||
additions = manyValue.getActualDetails();
|
||||
additions = manyValue.actualDetails();
|
||||
} else {
|
||||
additions = manyValue.getModifyAdditions();
|
||||
deletions = manyValue.getModifyRemovals();
|
||||
additions = manyValue.modifyAdditions();
|
||||
deletions = manyValue.modifyRemovals();
|
||||
}
|
||||
// reset so the changes are only processed once
|
||||
manyValue.modifyReset();
|
||||
@@ -343,7 +335,7 @@ final class SaveManyBeans extends SaveManyBase {
|
||||
forceOrphanRemoval = !insertedParent && isChangedProperty();
|
||||
} else {
|
||||
BeanCollection<?> c = (BeanCollection<?>) value;
|
||||
Set<?> modifyRemovals = c.getModifyRemovals();
|
||||
Set<?> modifyRemovals = c.modifyRemovals();
|
||||
if (insertedParent) {
|
||||
// after insert set the modify listening mode for private owned etc
|
||||
c.setModifyListening(many.modifyListenMode());
|
||||
@@ -372,7 +364,7 @@ final class SaveManyBeans extends SaveManyBase {
|
||||
* Check if we need to set the listen mode (on new collections persisted for the first time).
|
||||
*/
|
||||
private boolean setListenMode(BeanCollection<?> manyValue, BeanPropertyAssocMany<?> prop) {
|
||||
BeanCollection.ModifyListenMode mode = manyValue.getModifyListening();
|
||||
BeanCollection.ModifyListenMode mode = manyValue.modifyListening();
|
||||
if (mode == null) {
|
||||
// new collection persisted for the first time
|
||||
manyValue.setModifyListening(prop.modifyListenMode());
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ public final class BindableOrderColumn extends BindableProperty {
|
||||
|
||||
@Override
|
||||
public void addToUpdate(PersistRequestBean<?> request, List<Bindable> list) {
|
||||
int sortOrder = request.intercept().getSortOrder();
|
||||
int sortOrder = request.intercept().sortOrder();
|
||||
if (sortOrder > 0) {
|
||||
list.add(this);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public final class BindableOrderColumn extends BindableProperty {
|
||||
*/
|
||||
@Override
|
||||
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
int sortOrder = bean._ebean_getIntercept().getSortOrder();
|
||||
int sortOrder = bean._ebean_getIntercept().sortOrder();
|
||||
request.bind(sortOrder, prop);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ final class BindablePropertyVersion implements Bindable {
|
||||
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
|
||||
// get prior version value from 'old values'
|
||||
Object value = bean._ebean_getIntercept().getOrigValue(prop.propertyIndex());
|
||||
Object value = bean._ebean_getIntercept().origValue(prop.propertyIndex());
|
||||
request.bind(value, prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.core.OrmQueryEngine;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import io.ebeaninternal.server.core.SpiResultSet;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.persist.Binder;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
@@ -129,9 +128,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
SpiQuery<T> query = request.query();
|
||||
if (result != null && request.isBeanCachePutMany()) {
|
||||
// load the individual beans into the bean cache
|
||||
BeanDescriptor<T> descriptor = request.descriptor();
|
||||
Collection<T> c = result.getActualDetails();
|
||||
descriptor.cacheBeanPutAll(c);
|
||||
request.descriptor().cacheBeanPutAll(result.actualDetails());
|
||||
}
|
||||
|
||||
request.mergeCacheHits(result);
|
||||
@@ -140,7 +137,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
result.setReadOnly(true);
|
||||
request.putToQueryCache(result);
|
||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||
result = result.getShallowCopy();
|
||||
result = result.shallowCopy();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user