#2359 - Rename plugin api methods with deprecation - BeanType

This commit is contained in:
rbygrave
2021-09-08 13:13:29 +12:00
parent d6dc147497
commit bc02eeac57
69 changed files with 467 additions and 292 deletions
@@ -48,7 +48,7 @@ public final class LoadBeanRequest extends LoadRequest {
@Override
public Class<?> beanType() {
return loadBuffer.descriptor().getBeanType();
return loadBuffer.descriptor().type();
}
public String description() {
@@ -108,7 +108,7 @@ public final class LoadBeanRequest extends LoadRequest {
BeanDescriptor<?> desc = loadBuffer.descriptor();
// collect Ids and maybe load bean cache
for (Object bean : list) {
loadedIds.add(desc.beanId(bean));
loadedIds.add(desc.id(bean));
}
if (loadCache) {
desc.cacheBeanPutAll(list);
@@ -49,7 +49,7 @@ public final class LoadManyRequest extends LoadRequest {
@Override
public Class<?> beanType() {
return loadContext.getBeanDescriptor().getBeanType();
return loadContext.getBeanDescriptor().type();
}
public String description() {
@@ -63,7 +63,7 @@ public final class CacheChangeSet {
* Add an entry to clear a query cache.
*/
public void addInvalidate(BeanDescriptor<?> descriptor) {
touchedTables.add(descriptor.getBaseTable());
touchedTables.add(descriptor.baseTable());
}
/**
@@ -78,7 +78,7 @@ public final class CacheChangeSet {
*/
public void addClearQuery(BeanDescriptor<?> descriptor) {
queryCaches.add(descriptor);
touchedTables.add(descriptor.getBaseTable());
touchedTables.add(descriptor.baseTable());
}
/**
@@ -125,7 +125,7 @@ public final class CacheChangeSet {
entry.addId(id);
} else {
beanRemoveMap.put(desc, new CacheChangeBeanRemove(id, desc));
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
}
}
@@ -138,7 +138,7 @@ public final class CacheChangeSet {
entry.addIds(ids);
} else {
beanRemoveMap.put(desc, new CacheChangeBeanRemove(desc, ids));
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
}
}
@@ -146,7 +146,7 @@ public final class CacheChangeSet {
* Update a bean entry.
*/
public <T> void addBeanUpdate(BeanDescriptor<T> desc, String key, Map<String, Object> changes, boolean updateNaturalKey, long version) {
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
entries.add(new CacheChangeBeanUpdate(desc, key, changes, updateNaturalKey, version));
}
@@ -15,7 +15,7 @@ public final class CachedBeanDataFromBean {
EntityBeanIntercept ebi = bean._ebean_getIntercept();
Map<String, Object> data = new LinkedHashMap<>();
BeanProperty idProperty = desc.getIdProperty();
BeanProperty idProperty = desc.idProperty();
if (idProperty != null) {
int propertyIndex = idProperty.getPropertyIndex();
if (ebi.isLoadedProperty(propertyIndex)) {
@@ -54,7 +54,7 @@ public final class CachedBeanDataFromBean {
// create a readOnly sharable instance by copying the data
EntityBean sharableBean = desc.createEntityBean();
BeanProperty idProp = desc.getIdProperty();
BeanProperty idProp = desc.idProperty();
if (idProp != null) {
Object v = idProp.getValue(bean);
idProp.setValue(sharableBean, v);
@@ -13,7 +13,7 @@ public final class CachedBeanDataToBean {
EntityBeanIntercept ebi = bean._ebean_getIntercept();
// any future lazy loading skips L2 bean cache
ebi.setLoadedFromCache(true);
BeanProperty idProperty = desc.getIdProperty();
BeanProperty idProperty = desc.idProperty();
if (desc.getInheritInfo() != null) {
desc = desc.getInheritInfo().readType(bean.getClass()).desc();
}
@@ -81,7 +81,7 @@ final class DefaultBeanLoader {
}
}
SpiQuery<?> query = server.createQuery(parentDesc.getBeanType());
SpiQuery<?> query = server.createQuery(parentDesc.type());
if (refresh) {
// populate a new collection
BeanCollection<?> emptyCollection = many.createEmpty(parentBean);
@@ -203,7 +203,7 @@ final class DefaultBeanLoader {
}
}
SpiQuery<?> query = server.createQuery(desc.getBeanType());
SpiQuery<?> query = server.createQuery(desc.type());
query.setLazyLoadProperty(ebi.getLazyLoadProperty());
if (draft) {
query.asDraft();
@@ -236,7 +236,7 @@ final class DefaultBeanLoader {
Object dbBean = query.findOne();
if (dbBean == null) {
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.getBeanType() + "]");
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
}
desc.resetManyProperties(dbBean);
}
@@ -628,7 +628,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
public void truncate(Class<?>... types) {
List<String> tableNames = new ArrayList<>();
for (Class<?> type : types) {
tableNames.add(getBeanDescriptor(type).getBaseTable());
tableNames.add(getBeanDescriptor(type).baseTable());
}
truncate(tableNames.toArray(new String[0]));
}
@@ -707,7 +707,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (inheritInfo == null || inheritInfo.isConcrete()) {
return (T) desc.contextRef(pc, null, false, id);
}
BeanProperty idProp = desc.getIdProperty();
BeanProperty idProp = desc.idProperty();
if (idProp == null) {
throw new PersistenceException("No ID properties for this type? " + desc);
}
@@ -988,7 +988,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
throw new PersistenceException(m);
}
return new DefaultOrmUpdate<>(beanType, this, desc.getBaseTable(), ormUpdate);
return new DefaultOrmUpdate<>(beanType, this, desc.baseTable(), ormUpdate);
}
@Override
@@ -2279,7 +2279,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
EntityBean entityBean = checkEntityBean(bean);
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
BeanProperty idProperty = beanDesc.getIdProperty();
BeanProperty idProperty = beanDesc.idProperty();
// if the ID of the Property is null we are unable to check uniqueness
if (idProperty == null) {
return Collections.emptySet();
@@ -2306,7 +2306,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Returns a set of properties if saving the bean will violate the unique constraints (defined by given properties).
*/
private Set<Property> checkUniqueness(EntityBean entityBean, BeanDescriptor<?> beanDesc, BeanProperty[] props, Transaction transaction) {
BeanProperty idProperty = beanDesc.getIdProperty();
BeanProperty idProperty = beanDesc.idProperty();
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
ExpressionList<?> exprList = query.where();
if (!entityBean._ebean_getIntercept().isNew()) {
@@ -190,7 +190,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Run BeanQueryAdapter preQuery() if needed.
*/
private void adapterPreQuery() {
BeanQueryAdapter queryAdapter = beanDescriptor.getQueryAdapter();
BeanQueryAdapter queryAdapter = beanDescriptor.queryAdapter();
if (queryAdapter != null) {
queryAdapter.preQuery(this);
}
@@ -468,7 +468,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
public <K> Map<K, T> findMap() {
String mapKey = query.getMapKey();
if (mapKey == null) {
BeanProperty idProp = beanDescriptor.getIdProperty();
BeanProperty idProp = beanDescriptor.idProperty();
if (idProp != null) {
query.setMapKey(idProp.getName());
} else {
@@ -150,10 +150,10 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
this.intercept = entityBean._ebean_getIntercept();
this.beanManager = mgr;
this.beanDescriptor = mgr.getBeanDescriptor();
this.beanPersistListener = beanDescriptor.getPersistListener();
this.beanPersistListener = beanDescriptor.persistListener();
this.bean = bean;
this.parentBean = parentBean;
this.controller = beanDescriptor.getPersistController();
this.controller = beanDescriptor.persistController();
this.type = type;
this.docStoreMode = calcDocStoreMode(transaction, type);
this.flags = flags;
@@ -199,7 +199,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
@Override
public void profile(long offset, int flushCount) {
profileBase(type.profileEventId, offset, beanDescriptor.getName(), flushCount);
profileBase(type.profileEventId, offset, beanDescriptor.name(), flushCount);
}
/**
@@ -495,10 +495,10 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
case INSERT:
case UPDATE:
case DELETE_SOFT:
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
break;
case DELETE:
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
break;
default:
throw new IllegalStateException("Invalid type " + type);
@@ -618,7 +618,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* </p>
*/
public String fullName() {
return beanDescriptor.getFullName();
return beanDescriptor.fullName();
}
/**
@@ -937,7 +937,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
private void logSummaryMessage() {
String draft = (beanDescriptor.isDraftable() && !publish) ? " draft[true]" : "";
String name = beanDescriptor.getName();
String name = beanDescriptor.name();
switch (type) {
case INSERT:
transaction.logSummary("Inserted [" + name + "] [" + idValue + "]" + draft);
@@ -1101,9 +1101,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
case QUEUE: {
if (type == Type.DELETE) {
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
} else {
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
}
}
break;
@@ -1170,7 +1170,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Return the table to update depending if the request is a 'publish' one or normal.
*/
public String updateTable() {
return publish ? beanDescriptor.getBaseTable() : beanDescriptor.getDraftTable();
return publish ? beanDescriptor.baseTable() : beanDescriptor.getDraftTable();
}
/**
@@ -1280,7 +1280,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
@Override
public void profile() {
profileBase(type.profileEventId, profileOffset, beanDescriptor.getName(), 1);
profileBase(type.profileEventId, profileOffset, beanDescriptor.name(), 1);
}
/**
@@ -26,7 +26,7 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
@Override
public void profile(long offset, int flushCount) {
profileBase(EVT_ORMUPDATE, offset, beanDescriptor.getName(), flushCount);
profileBase(EVT_ORMUPDATE, offset, beanDescriptor.name(), flushCount);
}
public BeanDescriptor<?> descriptor() {
@@ -999,12 +999,12 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the queueId used to uniquely identify this type when queuing an index updateAdd.
*/
@Override
public String getDocStoreQueueId() {
public String docStoreQueueId() {
return docStoreQueueId;
}
@Override
public DocumentMapping getDocMapping() {
public DocumentMapping docMapping() {
return docMapping;
}
@@ -1067,7 +1067,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
*/
public String rootName() {
if (inheritInfo != null && !inheritInfo.isRoot()) {
return inheritInfo.getRoot().desc().getName();
return inheritInfo.getRoot().desc().name();
}
return name;
}
@@ -1597,7 +1597,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the 'when modified' property if there is one defined.
*/
@Override
public BeanProperty getWhenModifiedProperty() {
public BeanProperty whenModifiedProperty() {
return whenModifiedProperty;
}
@@ -1605,7 +1605,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the 'when created' property if there is one defined.
*/
@Override
public BeanProperty getWhenCreatedProperty() {
public BeanProperty whenCreatedProperty() {
return whenCreatedProperty;
}
@@ -1747,7 +1747,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
*/
private EntityBean createEntityBean(boolean isNew) {
if (prototypeEntityBean == null) {
throw new UnsupportedOperationException("cannot create entity bean for abstract entity " + getName());
throw new UnsupportedOperationException("cannot create entity bean for abstract entity " + name());
}
try {
EntityBean bean = (EntityBean) prototypeEntityBean._ebean_newInstance();
@@ -1911,7 +1911,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public BeanType<?> getBeanTypeAtPath(String path) {
public BeanType<?> beanTypeAtPath(String path) {
return getBeanDescriptor(path);
}
@@ -1931,7 +1931,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
path = splitBegin[1];
result = assocProp.getTargetDescriptor();
} else {
throw new PersistenceException("Invalid path " + path + " from " + result.getFullName());
throw new PersistenceException("Invalid path " + path + " from " + result.fullName());
}
}
}
@@ -2000,7 +2000,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
*/
@Override
@Nonnull
public Class<T> getBeanType() {
public Class<T> type() {
return beanType;
}
@@ -2012,7 +2012,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
*/
@Override
@Nonnull
public String getFullName() {
public String fullName() {
return fullName;
}
@@ -2021,7 +2021,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
*/
@Override
@Nonnull
public String getName() {
public String name() {
return name;
}
@@ -2122,7 +2122,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public Object beanId(Object bean) {
public Object id(Object bean) {
return getId((EntityBean) bean);
}
@@ -2168,7 +2168,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Set the bean id value converting if necessary.
*/
@Override
public void setBeanId(T bean, Object idValue) {
public void setId(T bean, Object idValue) {
idBinder.convertSetId(idValue, (EntityBean) bean);
}
@@ -2190,7 +2190,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public Property getProperty(String propName) {
public Property property(String propName) {
return findProperty(propName);
}
@@ -2342,7 +2342,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public ExpressionPath getExpressionPath(String path) {
public ExpressionPath expressionPath(String path) {
return getElGetValue(path);
}
@@ -2520,7 +2520,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public String getDiscColumn() {
public String discColumn() {
return inheritInfo.getDiscriminatorColumn();
}
@@ -2562,7 +2562,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the beanListener.
*/
@Override
public BeanPersistListener getPersistListener() {
public BeanPersistListener persistListener() {
return persistListener;
}
@@ -2577,7 +2577,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the find controller (SPI interface).
*/
@Override
public BeanFindController getFindController() {
public BeanFindController findController() {
return beanFinder;
}
@@ -2585,7 +2585,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the BeanQueryAdapter or null if none is defined.
*/
@Override
public BeanQueryAdapter getQueryAdapter() {
public BeanQueryAdapter queryAdapter() {
return queryAdapter;
}
@@ -2661,7 +2661,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the Controller.
*/
@Override
public BeanPersistController getPersistController() {
public BeanPersistController persistController() {
return persistController;
}
@@ -2712,7 +2712,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the base table. Only properties mapped to the base table are by default persisted.
*/
@Override
public String getBaseTable() {
public String baseTable() {
return baseTable;
}
@@ -2776,7 +2776,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
public void markAsDeleted(EntityBean bean) {
if (softDeleteProperty == null) {
Object id = getId(bean);
logger.info("(Lazy) loading unsuccessful for type:{} id:{} - expecting when bean has been deleted", getName(), id);
logger.info("(Lazy) loading unsuccessful for type:{} id:{} - expecting when bean has been deleted", name(), id);
bean._ebean_getIntercept().setLazyLoadFailure(id);
} else {
setSoftDeleteValue(bean);
@@ -2803,7 +2803,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
public boolean isEmbeddedPath(String propertyPath) {
ElPropertyDeploy elProp = getElPropertyDeploy(propertyPath);
if (elProp == null) {
throw new PersistenceException("Invalid path " + propertyPath + " from " + getFullName());
throw new PersistenceException("Invalid path " + propertyPath + " from " + fullName());
}
return elProp.getBeanProperty().isEmbedded();
}
@@ -2929,7 +2929,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
* Return the identity generation type.
*/
@Override
public IdType getIdType() {
public IdType idType() {
return idType;
}
@@ -3050,7 +3050,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public BeanProperty getIdProperty() {
public BeanProperty idProperty() {
return idProperty;
}
@@ -3382,7 +3382,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public List<BeanType<?>> getInheritanceChildren() {
public List<BeanType<?>> inheritanceChildren() {
if (hasInheritance()) {
return getInheritInfo().getChildren()
.stream()
@@ -3394,7 +3394,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
@Override
public BeanType<?> getInheritanceParent() {
public BeanType<?> inheritanceParent() {
return getInheritInfo() == null ? null : getInheritInfo().getParent().desc();
}
@@ -124,7 +124,7 @@ final class BeanDescriptorCacheHelp<T> {
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
logger.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ",
desc.getFullName(), isBeanCaching(), isQueryCaching(), notifyMode);
desc.fullName(), isBeanCaching(), isQueryCaching(), notifyMode);
}
}
}
@@ -352,7 +352,7 @@ final class BeanDescriptorCacheHelp<T> {
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
List<Object> idList = new ArrayList<>(actualDetails.size());
for (Object bean : actualDetails) {
idList.add(targetDescriptor.beanId(bean));
idList.add(targetDescriptor.id(bean));
}
return new CachedManyIds(idList);
}
@@ -375,7 +375,7 @@ final class BeanDescriptorCacheHelp<T> {
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
CachedBeanData cachedBeanData = (CachedBeanData) entry.getValue();
T bean = convertToBean(entry.getKey(), false, context, cachedBeanData);
result.add(bean, desc.beanId(bean));
result.add(bean, desc.id(bean));
}
return result;
}
@@ -773,7 +773,7 @@ final class BeanDescriptorCacheHelp<T> {
void cacheUpdateQuery(boolean update, SpiTransaction transaction) {
if (invalidateQueryCache || cacheNotifyOnAll || (!update && cacheNotifyOnDelete)) {
transaction.getEvent().add(desc.getBaseTable(), false, update, !update);
transaction.getEvent().add(desc.baseTable(), false, update, !update);
}
}
@@ -816,7 +816,7 @@ final class BeanDescriptorCacheHelp<T> {
} else {
queryCacheClear(changeSet);
cacheDeleteImported(false, insertRequest.entityBean(), changeSet);
changeSet.addBeanInsert(desc.getBaseTable());
changeSet.addBeanInsert(desc.baseTable());
}
}
@@ -66,7 +66,7 @@ final class BeanDescriptorDraftHelp<T> {
}
EntityBean draft = (EntityBean) draftBean;
EntityBean live = (EntityBean) liveBean;
BeanProperty idProperty = desc.getIdProperty();
BeanProperty idProperty = desc.idProperty();
if (idProperty != null) {
idProperty.publish(draft, live);
}
@@ -145,7 +145,7 @@ final class BeanDescriptorJsonHelp<T> {
desc.setUnmappedJson(bean, unmappedProperties);
}
Object contextBean = null;
Object id = desc.beanId(bean);
Object id = desc.id(bean);
if (!isNullOrZero(id)) {
// check if the bean has already been loaded
contextBean = readJson.persistenceContextPutIfAbsent(id, bean, desc);
@@ -433,7 +433,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
*/
private void readTableToDescriptor() {
for (BeanDescriptor<?> desc : descMap.values()) {
String baseTable = desc.getBaseTable();
String baseTable = desc.baseTable();
if (baseTable != null) {
baseTable = baseTable.toLowerCase();
List<BeanDescriptor<?>> list = tableToDescMap.computeIfAbsent(baseTable, k -> new ArrayList<>(1));
@@ -508,7 +508,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
for (BeanDescriptor<?> d : descMap.values()) {
d.initLast();
if (!d.isEmbedded()) {
beanManagerMap.put(d.getFullName(), beanManagerFactory.create(d));
beanManagerMap.put(d.fullName(), beanManagerFactory.create(d));
checkForValidEmbeddedId(d);
}
}
@@ -519,12 +519,12 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
if (idBinder instanceof IdBinderEmbedded) {
IdBinderEmbedded embId = (IdBinderEmbedded) idBinder;
BeanDescriptor<?> idBeanDescriptor = embId.getIdBeanDescriptor();
Class<?> idType = idBeanDescriptor.getBeanType();
Class<?> idType = idBeanDescriptor.type();
try {
idType.getDeclaredMethod("hashCode");
idType.getDeclaredMethod("equals", Object.class);
} catch (NoSuchMethodException e) {
checkMissingHashCodeOrEquals(e, idType, d.getBeanType());
checkMissingHashCodeOrEquals(e, idType, d.type());
}
}
}
@@ -597,9 +597,9 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
private void registerBeanDescriptor(DeployBeanInfo<?> info) {
BeanDescriptor<?> desc = new BeanDescriptor<>(this, info.getDescriptor());
descMap.put(desc.getBeanType().getName(), desc);
descMap.put(desc.type().getName(), desc);
if (desc.isDocStoreMapped()) {
descQueueMap.put(desc.getDocStoreQueueId(), desc);
descQueueMap.put(desc.docStoreQueueId(), desc);
}
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
if (many.isElementCollection()) {
@@ -1517,7 +1517,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
@Override
public int compare(BeanDescriptor<?> o1, BeanDescriptor<?> o2) {
return o1.getName().compareTo(o2.getName());
return o1.name().compareTo(o2.name());
}
}
}
@@ -14,7 +14,6 @@ import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
import io.ebean.plugin.Property;
import io.ebean.text.StringParser;
import io.ebean.text.TextException;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.api.SpiQuery;
@@ -50,7 +49,6 @@ import java.io.IOException;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -269,7 +267,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
s = s.replace("${ta}", "${}");
if (dbEncrypted) {
s = dbEncryptFunction.getDecryptSql(s);
String namedParam = ":encryptkey_" + descriptor.getBaseTable() + "___" + dbColumn;
String namedParam = ":encryptkey_" + descriptor.baseTable() + "___" + dbColumn;
s = s.replace("?", namedParam);
}
}
@@ -329,7 +327,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
this.dbMigrationInfos = source.dbMigrationInfos;
this.inherited = source.isInherited();
this.owningType = source.owningType;
this.local = owningType.equals(descriptor.getBeanType());
this.local = owningType.equals(descriptor.type());
this.version = source.isVersion();
this.embedded = source.isEmbedded();
this.id = source.isId();
@@ -358,7 +356,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
public void initialise(BeanDescriptorInitContext initContext) {
// do nothing for normal BeanProperty
if (!isTransient && scalarType == null) {
throw new RuntimeException("No ScalarType assigned to " + descriptor.getFullName() + "." + getName());
throw new RuntimeException("No ScalarType assigned to " + descriptor.fullName() + "." + getName());
}
}
@@ -920,7 +918,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
*/
@Override
public String getFullBeanName() {
return descriptor.getFullName() + "." + name;
return descriptor.fullName() + "." + name;
}
/**
@@ -284,7 +284,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
*/
public boolean hasId(EntityBean bean) {
BeanDescriptor<?> targetDesc = getTargetDescriptor();
BeanProperty idProp = targetDesc.getIdProperty();
BeanProperty idProp = targetDesc.idProperty();
// all the unique properties are non-null
return idProp == null || idProp.getValue(bean) != null;
}
@@ -422,7 +422,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
* descriptor back to local database columns in the TableJoin.
*/
ImportedId createImportedId(BeanPropertyAssoc<?> owner, BeanDescriptor<?> target, TableJoin join) {
BeanProperty idProp = target.getIdProperty();
BeanProperty idProp = target.idProperty();
BeanProperty[] others = target.propertiesBaseScalar();
if (descriptor.isRawSqlBased()) {
String dbColumn = owner.getDbColumn();
@@ -175,7 +175,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
*/
void initialisePostTarget() {
if (childMasterProperty != null) {
BeanProperty masterId = childMasterProperty.getTargetDescriptor().getIdProperty();
BeanProperty masterId = childMasterProperty.getTargetDescriptor().idProperty();
if (masterId != null) { // in docstore only, the master-id may be not available
childMasterIdProperty = childMasterProperty.getName() + "." + masterId.getName();
}
@@ -200,7 +200,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
@Override
public void registerColumn(BeanDescriptor<?> desc, String prefix) {
if (targetDescriptor != null) {
desc.registerTable(targetDescriptor.getBaseTable(), this);
desc.registerTable(targetDescriptor.baseTable(), this);
}
}
@@ -654,7 +654,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
* Create the array of ExportedProperty used to build reference objects.
*/
private ExportedProperty[] createExported() {
BeanProperty idProp = descriptor.getIdProperty();
BeanProperty idProp = descriptor.idProperty();
ArrayList<ExportedProperty> list = new ArrayList<>();
if (idProp != null && idProp.isEmbedded()) {
BeanPropertyAssocOne<?> one = (BeanPropertyAssocOne<?>) idProp;
@@ -697,7 +697,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return null;
}
// search for the property, to see if it exists
Class<?> beanType = descriptor.getBeanType();
Class<?> beanType = descriptor.type();
BeanDescriptor<?> targetDesc = getTargetDescriptor();
for (BeanPropertyAssocOne<?> prop : targetDesc.propertiesOne()) {
if (mappedBy != null) {
@@ -727,8 +727,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return prop;
}
}
String from = descriptor.getFullName();
String to = targetDesc.getFullName();
String from = descriptor.fullName();
String to = targetDesc.fullName();
throw new PersistenceException(from + ": Could not find mapKey property [" + mapKey + "] on [" + to + "]");
}
@@ -777,7 +777,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
*/
public void intersectionBind(SqlUpdate sql, EntityBean parentBean, EntityBean other) {
if (embeddedExportedProperties) {
BeanProperty idProp = descriptor.getIdProperty();
BeanProperty idProp = descriptor.idProperty();
parentBean = (EntityBean) idProp.getValue(parentBean);
}
for (ExportedProperty exportedProperty : exportedProperties) {
@@ -788,7 +788,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
private void buildExport(IntersectionRow row, EntityBean parentBean) {
if (embeddedExportedProperties) {
BeanProperty idProp = descriptor.getIdProperty();
BeanProperty idProp = descriptor.idProperty();
parentBean = (EntityBean) idProp.getValue(parentBean);
}
for (ExportedProperty exportedProperty : exportedProperties) {
@@ -869,7 +869,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
draftVal.size();
Collection<T> actualDetails = draftVal.getActualDetails();
for (T bean : actualDetails) {
Object id = targetDescriptor.beanId(bean);
Object id = targetDescriptor.id(bean);
T liveBean = liveBeansAsMap.remove(id);
if (isManyToMany()) {
@@ -899,7 +899,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
Collection<?> liveBeans = liveVal.getActualDetails();
Map<Object, T> liveMap = new LinkedHashMap<>();
for (Object liveBean : liveBeans) {
Object id = targetDescriptor.beanId(liveBean);
Object id = targetDescriptor.id(liveBean);
liveMap.put(id, (T) liveBean);
}
return liveMap;
@@ -129,7 +129,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
// limit JoinColumn mapping to the @Id / primary key
TableJoinColumn[] columns = tableJoin.columns();
String foreignJoinColumn = columns[0].getForeignDbColumn();
String foreignIdColumn = targetDescriptor.getIdProperty().getDbColumn();
String foreignIdColumn = targetDescriptor.idProperty().getDbColumn();
if (!foreignJoinColumn.equalsIgnoreCase(foreignIdColumn)) {
throw new PersistenceException("Mapping limitation - @JoinColumn on " + getFullBeanName() + " needs to map to a primary key as per Issue #529 "
+ " - joining to " + foreignJoinColumn + " and not " + foreignIdColumn);
@@ -137,7 +137,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
} else {
exportedProperties = createExported();
String delStmt = "delete from " + targetDescriptor.getBaseTable() + " where ";
String delStmt = "delete from " + targetDescriptor.baseTable() + " where ";
deleteByParentIdSql = delStmt + deriveWhereParentIdSql(false);
deleteByParentIdInSql = delStmt + deriveWhereParentIdSql(true);
}
@@ -195,7 +195,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
} else {
Object assocBean = getValue(bean);
if (assocBean != null) {
Object parentId = targetDescriptor.beanId(assocBean);
Object parentId = targetDescriptor.id(assocBean);
if (parentId != null) {
changeSet.addManyRemove(targetDescriptor, relationshipProperty.getName(), parentId);
}
@@ -300,10 +300,10 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
BeanDescriptor<T> target = getTargetDescriptor();
String basePath = SplitName.add(prefix, name);
if (dbColumn != null) {
BeanProperty idProperty = target.getIdProperty();
BeanProperty idProperty = target.idProperty();
desc.registerColumn(dbColumn, SplitName.add(basePath, idProperty.getName()));
}
desc.registerTable(target.getBaseTable(), this);
desc.registerTable(target.baseTable(), this);
}
}
}
@@ -383,7 +383,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
oldBean = (EntityBean) oldEmb;
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
BeanProperty idProperty = targetDescriptor.getIdProperty();
BeanProperty idProperty = targetDescriptor.idProperty();
Object newId = (newBean == null) ? null : idProperty.getValue(newBean);
Object oldId = (oldBean == null) ? null : idProperty.getValue(oldBean);
@@ -424,13 +424,13 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
} else if (targetInheritInfo != null) {
return createCacheBeanId(ap);
} else {
return targetDescriptor.getIdProperty().getCacheDataValue((EntityBean) ap);
return targetDescriptor.idProperty().getCacheDataValue((EntityBean) ap);
}
}
private Object createCacheBeanId(Object bean) {
final BeanDescriptor<?> desc = targetDescriptor.descOf(bean.getClass());
final Object id = desc.getIdProperty().getCacheDataValue((EntityBean) bean);
final Object id = desc.idProperty().getCacheDataValue((EntityBean) bean);
return new CachedBeanId(desc.getDiscValue(), id);
}
@@ -463,7 +463,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
private Object refBean(BeanDescriptor<?> desc, Object id, PersistenceContext context) {
if (id instanceof String) {
id = desc.getIdProperty().scalarType.parse((String) id);
id = desc.idProperty().scalarType.parse((String) id);
}
Object bean = desc.contextGet(context, id);
if (bean == null) {
@@ -474,11 +474,11 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
@Override
public ScalarDataReader<?> getIdReader() {
return targetDescriptor.getIdProperty();
return targetDescriptor.idProperty();
}
ScalarType<?> getIdScalarType() {
return targetDescriptor.getIdProperty().scalarType;
return targetDescriptor.idProperty().scalarType;
}
/**
@@ -565,7 +565,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
* Create the array of ExportedProperty used to build reference objects.
*/
private ExportedProperty[] createExported() {
BeanProperty idProp = descriptor.getIdProperty();
BeanProperty idProp = descriptor.idProperty();
ArrayList<ExportedProperty> list = new ArrayList<>();
if (idProp != null && idProp.isEmbedded()) {
BeanPropertyAssocOne<?> one = (BeanPropertyAssocOne<?>) idProp;
@@ -598,7 +598,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
public void appendSelect(DbSqlContext ctx, boolean subQuery) {
if (!isTransient) {
if (primaryKeyExport) {
descriptor.getIdProperty().appendSelect(ctx, subQuery);
descriptor.idProperty().appendSelect(ctx, subQuery);
} else {
localHelp.appendSelect(ctx, subQuery);
}
@@ -744,7 +744,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
* Just write the Id property of the ToOne property.
*/
private void jsonWriteTargetId(SpiJsonWriter writeJson, EntityBean childBean) throws IOException {
BeanProperty idProperty = targetDescriptor.getIdProperty();
BeanProperty idProperty = targetDescriptor.idProperty();
if (idProperty != null) {
writeJson.writeStartObject(name);
idProperty.jsonWriteForInsert(writeJson, childBean);
@@ -73,8 +73,8 @@ public final class DeployUpdateParser extends DeployParser {
@Override
public String getDeployWord(String expression) {
if (expression.equalsIgnoreCase(beanDescriptor.getName())) {
return beanDescriptor.getBaseTable();
if (expression.equalsIgnoreCase(beanDescriptor.name())) {
return beanDescriptor.baseTable();
}
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
return elProp != null ? elProp.getDbColumn() : null;
@@ -184,7 +184,7 @@ public final class DeployBeanPropertyLists {
}
if (prop.isId()) {
if (id != null) {
throw new IllegalStateException("More that one @Id property on " + desc.getFullName() + " ?");
throw new IllegalStateException("More that one @Id property on " + desc.fullName() + " ?");
}
id = prop;
return;
@@ -21,7 +21,7 @@ public class VisitProperties {
}
protected void visitProperties(BeanDescriptor<?> desc, BeanPropertyVisitor propertyVisitor) {
BeanProperty idProp = desc.getIdProperty();
BeanProperty idProp = desc.idProperty();
if (idProp != null) {
visit(propertyVisitor, idProp);
}
@@ -87,7 +87,7 @@ public final class DLoadContext implements LoadContext {
private ObjectGraphOrigin initOrigin() {
CallOrigin callOrigin = ebeanServer.createCallOrigin();
return new ObjectGraphOrigin(0, callOrigin, rootDescriptor.getFullName());
return new ObjectGraphOrigin(0, callOrigin, rootDescriptor.fullName());
}
public DLoadContext(OrmQueryRequest<?> request, SpiQuerySecondary secondaryQueries) {
@@ -295,7 +295,7 @@ public final class DLoadContext implements LoadContext {
}
DLoadBeanContext getBeanContextWithInherit(String path, BeanPropertyAssocOne<?> property) {
String key = path + ":" + property.getTargetDescriptor().getName();
String key = path + ":" + property.getTargetDescriptor().name();
return beanMap.computeIfAbsent(key, p -> createBeanContext(property, path, null));
}
@@ -57,7 +57,7 @@ final class BatchedBeanHolder {
*/
BatchedBeanHolder(BatchControl control, BeanDescriptor<?> beanDescriptor, int order) {
this.control = control;
this.shortDesc = beanDescriptor.getName() + ":" + order;
this.shortDesc = beanDescriptor.name() + ":" + order;
this.order = order;
}
@@ -180,7 +180,7 @@ public final class DefaultPersister implements Persister {
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
List<T> liveBeans = draftHandler.fetchSourceBeans(query, false);
PUB.debug("draftRestore [{}] count[{}]", desc.getName(), liveBeans.size());
PUB.debug("draftRestore [{}] count[{}]", desc.name(), liveBeans.size());
if (liveBeans.isEmpty()) {
return Collections.emptyList();
}
@@ -194,11 +194,11 @@ public final class DefaultPersister implements Persister {
// reset @DraftDirty and @DraftReset properties
draftHandler.resetDraft(draftBean);
PUB.trace("draftRestore bean [{}] id[{}]", desc.getName(), draftHandler.getId());
PUB.trace("draftRestore bean [{}] id[{}]", desc.name(), draftHandler.getId());
update(createRequest(draftBean, transaction, null, mgr, Type.UPDATE, Flags.RECURSE));
}
PUB.debug("draftRestore - complete for [{}]", desc.getName());
PUB.debug("draftRestore - complete for [{}]", desc.name());
return draftHandler.getDrafts();
}
@@ -208,7 +208,7 @@ public final class DefaultPersister implements Persister {
private <T> List<Object> getBeanIds(BeanDescriptor<T> desc, List<T> beans) {
List<Object> idList = new ArrayList<>(beans.size());
for (T liveBean : beans) {
idList.add(desc.beanId(liveBean));
idList.add(desc.id(liveBean));
}
return idList;
}
@@ -225,7 +225,7 @@ public final class DefaultPersister implements Persister {
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
List<T> draftBeans = draftHandler.fetchSourceBeans(query, true);
PUB.debug("publish [{}] count[{}]", desc.getName(), draftBeans.size());
PUB.debug("publish [{}] count[{}]", desc.name(), draftBeans.size());
if (draftBeans.isEmpty()) {
return Collections.emptyList();
}
@@ -243,7 +243,7 @@ public final class DefaultPersister implements Persister {
draftHandler.resetDraft(draftBean);
Type persistType = draftHandler.isInsert() ? Type.INSERT : Type.UPDATE;
PUB.trace("publish bean [{}] id[{}] type[{}]", desc.getName(), draftHandler.getId(), persistType);
PUB.trace("publish bean [{}] id[{}] type[{}]", desc.name(), draftHandler.getId(), persistType);
PersistRequestBean<T> request = createRequest(liveBean, transaction, null, mgr, persistType, Flags.PUBLISH_RECURSE);
if (persistType == Type.INSERT) {
@@ -255,7 +255,7 @@ public final class DefaultPersister implements Persister {
draftHandler.updateDrafts(transaction, mgr);
PUB.debug("publish - complete for [{}]", desc.getName());
PUB.debug("publish - complete for [{}]", desc.name());
return livePublish;
}
@@ -336,7 +336,7 @@ public final class DefaultPersister implements Persister {
List<Object> ids = getBeanIds(desc, sourceBeans);
Query<T> destQuery = server.find(desc.getBeanType()).where().idIn(ids).query();
Query<T> destQuery = server.find(desc.type()).where().idIn(ids).query();
if (asDraft) {
destQuery.asDraft();
}
@@ -348,7 +348,7 @@ public final class DefaultPersister implements Persister {
* Publish/restore the values from the sourceBean to the matching destination bean.
*/
T publishToDestinationBean(T sourceBean) {
id = desc.beanId(sourceBean);
id = desc.id(sourceBean);
T destBean = destBeans.get(id);
insert = (destBean == null);
// apply changes from liveBean to draftBean
@@ -714,7 +714,7 @@ public final class DefaultPersister implements Persister {
if (idList != null) {
q.where().idIn(idList);
if (t.isLogSummary()) {
t.logSummary("-- DeleteById of " + descriptor.getName() + " ids[" + idList + "] requires fetch of foreign key values");
t.logSummary("-- DeleteById of " + descriptor.name() + " ids[" + idList + "] requires fetch of foreign key values");
}
List<?> beanList = server.findList(q, t);
deleteList(beanList, t, deleteMode, false);
@@ -723,7 +723,7 @@ public final class DefaultPersister implements Persister {
} else {
q.where().idEq(id);
if (t.isLogSummary()) {
t.logSummary("-- DeleteById of " + descriptor.getName() + " id[" + id + "] requires fetch of foreign key values");
t.logSummary("-- DeleteById of " + descriptor.name() + " id[" + id + "] requires fetch of foreign key values");
}
EntityBean bean = (EntityBean) server.findOne(q, t);
if (bean == null) {
@@ -793,9 +793,9 @@ public final class DefaultPersister implements Persister {
SqlUpdate deleteById = descriptor.deleteById(id, idList, deleteMode);
if (t.isLogSummary()) {
if (idList != null) {
t.logSummary("-- Deleting " + descriptor.getName() + " Ids: " + idList);
t.logSummary("-- Deleting " + descriptor.name() + " Ids: " + idList);
} else {
t.logSummary("-- Deleting " + descriptor.getName() + " Id: " + id);
t.logSummary("-- Deleting " + descriptor.name() + " Id: " + id);
}
}
@@ -823,9 +823,9 @@ public final class DefaultPersister implements Persister {
private void notifyDeleteById(BeanDescriptor<?> descriptor, Object id, List<Object> idList, Transaction transaction) {
BeanPersistController controller = descriptor.getPersistController();
BeanPersistController controller = descriptor.persistController();
if (controller != null) {
DeleteIdRequest request = new DeleteIdRequest(server, transaction, descriptor.getBeanType(), id);
DeleteIdRequest request = new DeleteIdRequest(server, transaction, descriptor.type(), id);
if (idList == null) {
controller.preDelete(request);
} else {
@@ -843,7 +843,7 @@ public final class DefaultPersister implements Persister {
*/
private Query<?> deleteRequiresQuery(BeanDescriptor<?> desc, BeanPropertyAssocOne<?>[] propImportDelete, DeleteMode deleteMode) {
Query<?> q = server.createQuery(desc.getBeanType());
Query<?> q = server.createQuery(desc.type());
StringBuilder sb = new StringBuilder(30);
for (BeanPropertyAssocOne<?> aPropImportDelete : propImportDelete) {
sb.append(aPropImportDelete.getName()).append(",");
@@ -50,7 +50,7 @@ final class DeleteUnloadedForeignKeys {
void queryForeignKeys() {
BeanDescriptor<?> descriptor = request.descriptor();
SpiQuery<?> q = (SpiQuery<?>) server.createQuery(descriptor.getBeanType());
SpiQuery<?> q = (SpiQuery<?>) server.createQuery(descriptor.type());
Object id = request.beanId();
@@ -69,7 +69,7 @@ final class DeleteUnloadedForeignKeys {
SpiTransaction t = request.transaction();
if (t.isLogSummary()) {
t.logSummary("-- Ebean fetching foreign key values for delete of " + descriptor.getName() + " id:" + id);
t.logSummary("-- Ebean fetching foreign key values for delete of " + descriptor.name() + " id:" + id);
}
beanWithForeignKeys = (EntityBean) server.findOne(q, t);
}
@@ -82,11 +82,11 @@ final class MergeHandler {
* We use the Id values to determine what are inserts, updates and deletes as part of the merge.
*/
private EntityBean fetchOutline(Set<String> paths) {
Query<?> query = server.find(desc.getBeanType());
Query<?> query = server.find(desc.type());
query.setBeanCacheMode(CacheMode.OFF);
query.setPersistenceContextScope(PersistenceContextScope.QUERY);
query.setId(desc.getId(bean));
query.select(desc.getIdProperty().getName());
query.select(desc.idProperty().getName());
for (String path : paths) {
MergeNode node = buildNode(path);
@@ -128,7 +128,7 @@ final class MergeHandler {
static MergeNode createMergeNode(String fullPath, BeanDescriptor<?> targetDesc, String path) {
BeanProperty prop = targetDesc.getBeanProperty(path);
if (!(prop instanceof BeanPropertyAssoc)) {
throw new PersistenceException("merge path [" + path + "] is not a ToMany or ToOne property of " + targetDesc.getFullName());
throw new PersistenceException("merge path [" + path + "] is not a ToMany or ToOne property of " + targetDesc.fullName());
}
if (prop instanceof BeanPropertyAssocMany<?>) {
BeanPropertyAssocMany<?> assocMany = (BeanPropertyAssocMany<?>) prop;
@@ -71,7 +71,7 @@ abstract class MergeNode {
* Add to the query to fetch the Ids values for the foreign keys basically.
*/
final void addSelectId(Query<?> query) {
BeanProperty idProperty = targetDescriptor.getIdProperty();
BeanProperty idProperty = targetDescriptor.idProperty();
query.fetch(fullPath, idProperty.getName());
}
@@ -51,7 +51,7 @@ final class MergeNodeAssocOne extends MergeNode {
private boolean isUpdate(Object beanId, Object outlineId, MergeRequest request) {
return Objects.equals(beanId, outlineId)
|| !request.isClientGeneratedIds()
|| request.idExists(targetDescriptor.getBeanType(), beanId);
|| request.idExists(targetDescriptor.type(), beanId);
}
private EntityBean getEntityBean(Object bean) {
@@ -225,7 +225,7 @@ public final class SaveManyBeans extends SaveManyBase {
detailBean = ((Map.Entry<?, ?>) detailBean).getValue();
}
if (detailBean instanceof EntityBean) {
Object id = targetDescriptor.beanId(detailBean);
Object id = targetDescriptor.id(detailBean);
if (!isNullOrZero(id)) {
// remember the Id (other details not in the collection) will be removed
detailIds.add(id);
@@ -23,7 +23,7 @@ final class DeleteMeta extends BaseMeta {
DeleteMeta(BeanDescriptor<?> desc, BindableId id, Bindable version, Bindable tenantId) {
super(id, version, tenantId);
String tableName = desc.getBaseTable();
String tableName = desc.baseTable();
this.sqlNone = genSql(ConcurrencyMode.NONE, tableName);
this.sqlVersion = genSql(ConcurrencyMode.VERSION, tableName);
if (desc.isDraftable()) {
@@ -48,7 +48,7 @@ final class InsertMeta {
this.allExcludeDraftOnly = all.excludeDraftOnly();
this.shadowFKey = shadowFKey;
String tableName = desc.getBaseTable();
String tableName = desc.baseTable();
String draftTableName = desc.getDraftTable();
this.sqlWithId = genSql(false, tableName, false);
this.sqlDraftWithId = desc.isDraftable() ? genSql(false, draftTableName, true) : sqlWithId;
@@ -56,7 +56,7 @@ public final class BindableUnidirectional implements Bindable {
PersistRequestBean<?> persistRequest = request.getPersistRequest();
Object parentBean = persistRequest.parentBean();
if (parentBean == null) {
Class<?> localType = desc.getBeanType();
Class<?> localType = desc.type();
Class<?> targetType = unidirectional.getTargetType();
String msg = "Error inserting bean [" + localType + "] with unidirectional relationship. ";
@@ -13,7 +13,7 @@ public final class FactoryId {
* Add uniqueId properties.
*/
public BindableId createId(BeanDescriptor<?> desc) {
BeanProperty id = desc.getIdProperty();
BeanProperty id = desc.idProperty();
if (id == null) {
return new BindableIdEmpty();
}
@@ -564,7 +564,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
public void profile() {
getTransaction()
.profileStream()
.addQueryEvent(query.profileEventId(), profileOffset, desc.getName(), loadedBeanCount, query.getProfileId());
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), loadedBeanCount, query.getProfileId());
}
QueryIterator<T> readIterate(int bufferSize, OrmQueryRequest<T> request) {
@@ -637,7 +637,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
* Return the short bean name.
*/
String getBeanName() {
return desc.getName();
return desc.name();
}
/**
@@ -145,7 +145,7 @@ final class CQueryBuilder {
private <T> String buildUpdateSql(OrmQueryRequest<T> request, String rootTableAlias, CQueryPredicates predicates, SqlTree sqlTree) {
StringBuilder sb = new StringBuilder(200);
sb.append("update ").append(request.descriptor().getBaseTable());
sb.append("update ").append(request.descriptor().baseTable());
if (rootTableAlias != null) {
sb.append(" ").append(rootTableAlias);
}
@@ -361,7 +361,7 @@ final class CQueryBuilder {
BeanDescriptor<T> desc = request.descriptor();
if (desc.isReadAuditing()) {
// log the query plan based bean type (i.e. ignoring query disabling for logging the sql/plan)
desc.getReadAuditLogger().queryPlan(new ReadAuditQueryPlan(desc.getFullName(), queryPlan.getAuditQueryKey(), queryPlan.getSql()));
desc.getReadAuditLogger().queryPlan(new ReadAuditQueryPlan(desc.fullName(), queryPlan.getAuditQueryKey(), queryPlan.getSql()));
}
// cache the query plan because we can reuse it and also
// gather query performance statistics based on it.
@@ -465,7 +465,7 @@ final class CQueryBuilder {
}
}
if (el == null) {
throw new PersistenceException("Property [" + propertyName + "] not found on " + descriptor.getFullName());
throw new PersistenceException("Property [" + propertyName + "] not found on " + descriptor.fullName());
}
addRawColumnMapping(pathProps, column, propertyName, el);
}
@@ -478,7 +478,7 @@ final class CQueryBuilder {
}
// check if @Id property included in RawSql
boolean rawNoId = true;
BeanProperty idProperty = descriptor.getIdProperty();
BeanProperty idProperty = descriptor.idProperty();
if (idProperty != null && columnMapping.contains(idProperty.getName())) {
// contains the @Id property for the root level bean
rawNoId = false;
@@ -583,7 +583,7 @@ final class CQueryBuilder {
sb.append("r1.attribute_, count(*) from (select ");
if (distinct) {
sb.append("distinct t0.");
sb.append(request.descriptor().getIdProperty().getDbColumn()).append(", ");
sb.append(request.descriptor().idProperty().getDbColumn()).append(", ");
}
sb.append(select.getSelectSql()).append(" as attribute_");
} else {
@@ -663,7 +663,7 @@ final class CQueryBuilder {
BeanDescriptor<?> desc = request.descriptor();
String idSql = desc.getIdBinderIdSql(query.getAlias());
if (idSql.isEmpty()) {
throw new IllegalStateException("Executing FindById query on entity bean " + desc.getName()
throw new IllegalStateException("Executing FindById query on entity bean " + desc.name()
+ " that doesn't have an @Id property??");
}
if (updateStatement) {
@@ -66,7 +66,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
StringBuilder sb = new StringBuilder(80);
sb.append("FindAttr exeMicros[").append(executionTimeMicros)
.append("] rows[").append(rowCount)
.append("] type[").append(desc.getName())
.append("] type[").append(desc.name())
.append("] predicates[").append(predicates.getLogWhereSql())
.append("] bind[").append(bindLog).append("]");
return sb.toString();
@@ -168,7 +168,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
public void profile() {
getTransaction()
.profileStream()
.addQueryEvent(query.profileEventId(), profileOffset, desc.getName(), rowCount, query.getProfileId());
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
}
Set<String> getDependentTables() {
@@ -87,7 +87,7 @@ public class CQueryPlan implements SpiQueryPlan {
CQueryPlan(OrmQueryRequest<?> request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) {
this.server = request.server();
this.dataTimeZone = server.getDataTimeZone();
this.beanType = request.descriptor().getBeanType();
this.beanType = request.descriptor().type();
this.planKey = request.queryPlanKey();
SpiQuery<?> query = request.query();
this.profileLocation = query.getProfileLocation();
@@ -112,7 +112,7 @@ public class CQueryPlan implements SpiQueryPlan {
CQueryPlan(OrmQueryRequest<?> request, String sql, SqlTree sqlTree, String logWhereSql) {
this.server = request.server();
this.dataTimeZone = server.getDataTimeZone();
this.beanType = request.descriptor().getBeanType();
this.beanType = request.descriptor().type();
SpiQuery<?> query = request.query();
this.profileLocation = query.getProfileLocation();
this.location = (profileLocation == null) ? null : profileLocation.location();
@@ -56,7 +56,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
StringBuilder sb = new StringBuilder(80);
sb.append("FindCount exeMicros[").append(executionTimeMicros)
.append("] rows[").append(rowCount)
.append("] type[").append(desc.getFullName())
.append("] type[").append(desc.fullName())
.append("] predicates[").append(predicates.getLogWhereSql())
.append("] bind[").append(bindLog).append("]");
@@ -137,7 +137,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
public void profile() {
getTransaction()
.profileStream()
.addQueryEvent(query.profileEventId(), profileOffset, desc.getName(), rowCount, query.getProfileId());
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
}
Set<String> getDependentTables() {
@@ -113,7 +113,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
public void profile() {
getTransaction()
.profileStream()
.addQueryEvent(query.profileEventId(), profileOffset, desc.getName(), rowCount, query.getProfileId());
.addQueryEvent(query.profileEventId(), profileOffset, desc.name(), rowCount, query.getProfileId());
}
@Override
@@ -15,7 +15,7 @@ public interface STreeType {
/**
* Return the bean short name.
*/
String getName();
String name();
/**
* Return true if the underlying type has an Id property.
@@ -165,7 +165,7 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
public DefaultOrmQuery(BeanDescriptor<T> desc, SpiEbeanServer server, ExpressionFactory expressionFactory) {
this.beanDescriptor = desc;
this.rootBeanDescriptor = desc;
this.beanType = desc.getBeanType();
this.beanType = desc.type();
this.server = server;
this.orderById = server.config().isDefaultOrderById();
this.disableLazyLoading = server.config().isDisableLazyLoading();
@@ -1688,7 +1688,7 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
@Override
public Class<? extends T> getInheritType() {
return beanDescriptor.getBeanType();
return beanDescriptor.type();
}
@SuppressWarnings("unchecked")
@@ -309,7 +309,7 @@ public final class OrmQueryDetail implements Serializable {
if (parentProp == null) {
ElPropertyValue el = d.getElGetValue(parentPath);
if (el == null) {
throw new PersistenceException("Path [" + parentPath + "] not valid from " + d.getFullName());
throw new PersistenceException("Path [" + parentPath + "] not valid from " + d.fullName());
}
// add a missing parent path just fetching the Id property
BeanPropertyAssoc<?> assocOne = (BeanPropertyAssoc<?>) el.getBeanProperty();
@@ -372,7 +372,7 @@ public final class OrmQueryDetail implements Serializable {
String fetchPath = entry.getKey();
ElPropertyDeploy elProp = desc.getElPropertyDeploy(fetchPath);
if (elProp == null) {
throw new PersistenceException("Invalid fetch path " + fetchPath + " from " + desc.getFullName());
throw new PersistenceException("Invalid fetch path " + fetchPath + " from " + desc.fullName());
}
entries.add(new FetchEntry(idx++, fetchPath, elProp, entry.getValue()));
}
@@ -124,7 +124,7 @@ public class TCsvReader<T> implements CsvReader<T> {
@Override
public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) {
ExpressionPath elProp = descriptor.getExpressionPath(propertyName);
ExpressionPath elProp = descriptor.expressionPath(propertyName);
if (!elProp.isDateTimeCapable()) {
throw new TextException("Property " + propertyName + " is not DateTime capable");
}
@@ -160,7 +160,7 @@ public class TCsvReader<T> implements CsvReader<T> {
@Override
public void addProperty(String propertyName, StringParser parser) {
ExpressionPath elProp = descriptor.getExpressionPath(propertyName);
ExpressionPath elProp = descriptor.expressionPath(propertyName);
if (parser == null) {
parser = elProp.getStringParser();
}
@@ -529,7 +529,7 @@ public final class WriteJson implements SpiJsonWriter {
public void write(WriteJson writeJson) {
try {
BeanProperty beanProp = desc.getIdProperty();
BeanProperty beanProp = desc.idProperty();
if (beanProp != null) {
if (isIncludeProperty(beanProp)) {
beanProp.jsonWrite(writeJson, currentBean);
@@ -37,7 +37,7 @@ public final class BeanPersistIdMap {
}
private BeanPersistIds getPersistIds(BeanDescriptor<?> desc) {
String beanType = desc.getFullName();
String beanType = desc.fullName();
return beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc));
}
@@ -94,7 +94,7 @@ public final class BeanPersistIds implements BinaryWritable {
StringBuilder sb = new StringBuilder();
sb.append("BeanIds[");
if (beanDescriptor != null) {
sb.append(beanDescriptor.getFullName());
sb.append(beanDescriptor.fullName());
} else {
sb.append("descId:").append(descriptorId);
}
@@ -63,7 +63,7 @@ public final class DeleteByIdMap {
}
private BeanPersistIds getPersistIds(BeanDescriptor<?> desc) {
String beanType = desc.getFullName();
String beanType = desc.fullName();
return beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc));
}
@@ -77,7 +77,7 @@ public final class DeleteByIdMap {
if (DocStoreMode.IGNORE != mode) {
// Add to queue or bulk update entries
boolean queue = (DocStoreMode.QUEUE == mode);
String queueId = desc.getDocStoreQueueId();
String queueId = desc.docStoreQueueId();
List<Object> idValues = deleteIds.getIds();
if (idValues != null) {
for (Object idValue : idValues) {
@@ -175,11 +175,11 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
String path = pathProp.getPath();
if (path != null) {
BeanDescriptor<?> targetDesc = desc.getBeanDescriptor(path);
BeanProperty idProperty = targetDesc.getIdProperty();
BeanProperty idProperty = targetDesc.idProperty();
if (idProperty != null) {
// embedded beans don't have id property
String fullPath = path + "." + idProperty.getName();
targetDesc.docStoreAdapter().registerInvalidationPath(desc.getDocStoreQueueId(), fullPath, pathProp.getProperties());
targetDesc.docStoreAdapter().registerInvalidationPath(desc.docStoreQueueId(), fullPath, pathProp.getProperties());
}
}
}
@@ -323,7 +323,7 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
* Return the supplied value or default to the bean name lower case.
*/
protected String derive(BeanType<?> desc, String suppliedValue) {
return (suppliedValue != null && !suppliedValue.isEmpty()) ? suppliedValue : desc.getName().toLowerCase();
return (suppliedValue != null && !suppliedValue.isEmpty()) ? suppliedValue : desc.name().toLowerCase();
}
@Override
@@ -34,6 +34,6 @@ public class DocStoreDeleteEvent implements DocStoreUpdate {
*/
@Override
public void addToQueue(DocStoreUpdates docStoreUpdates) {
docStoreUpdates.queueDelete(beanType.getDocStoreQueueId(), idValue);
docStoreUpdates.queueDelete(beanType.docStoreQueueId(), idValue);
}
}
@@ -37,6 +37,6 @@ public class DocStoreIndexEvent<T> implements DocStoreUpdate {
*/
@Override
public void addToQueue(DocStoreUpdates docStoreUpdates) {
docStoreUpdates.queueIndex(beanType.getDocStoreQueueId(), idValue);
docStoreUpdates.queueIndex(beanType.docStoreQueueId(), idValue);
}
}
@@ -87,7 +87,7 @@ public class DocStructure {
BeanDescriptor<?> targetDesc = embProp.getTargetDescriptor();
PathProperties manyRootPath = new PathProperties();
manyRootPath.addToPath(null, targetDesc.getIdProperty().getName());
manyRootPath.addToPath(null, targetDesc.idProperty().getName());
manyRootPath.addNested(prop, embedded.get(prop));
manyRoot.put(prop, manyRootPath);