#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
@@ -22,24 +22,56 @@ public interface BeanType<T> {
* Return the short name of the bean type.
*/
@Nonnull
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the full name of the bean type.
*/
@Nonnull
String getFullName();
String fullName();
/**
* Deprecated migrate to fullName().
*/
@Deprecated
default String getFullName() {
return fullName();
}
/**
* Return the class type this BeanDescriptor describes.
*/
@Nonnull
Class<T> getBeanType();
Class<T> type();
/**
* Deprecated migrate to type().
*/
@Deprecated
default Class<T> getBeanType() {
return type();
}
/**
* Return the type bean for an OneToMany or ManyToOne or ManyToMany property.
*/
BeanType<?> getBeanTypeAtPath(String propertyName);
BeanType<?> beanTypeAtPath(String propertyName);
/**
* Deprecated migrate to beanTypeAtPath().
*/
@Deprecated
default BeanType<?> getBeanTypeAtPath(String propertyName) {
return beanTypeAtPath(propertyName);
}
/**
* Return all the properties for this bean type.
@@ -50,22 +82,54 @@ public interface BeanType<T> {
/**
* Return the Id property.
*/
Property getIdProperty();
Property idProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getIdProperty() {
return idProperty();
}
/**
* Return the when modified property if there is one defined.
*/
Property getWhenModifiedProperty();
Property whenModifiedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenModifiedProperty() {
return whenModifiedProperty();
}
/**
* Return the when created property if there is one defined.
*/
Property getWhenCreatedProperty();
Property whenCreatedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenCreatedProperty() {
return whenCreatedProperty();
}
/**
* Return the Property to read values from a bean.
*/
Property getProperty(String propertyName);
Property property(String propertyName);
/**
* Deprecated migrate to property().
*/
@Deprecated
default Property getProperty(String propertyName) {
return property(propertyName);
}
/**
* Return the ExpressionPath for a given property path.
@@ -73,7 +137,15 @@ public interface BeanType<T> {
* This can return a property or nested property path.
* </p>
*/
ExpressionPath getExpressionPath(String path);
ExpressionPath expressionPath(String path);
/**
* Deprecated migrate to expressionPath().
*/
@Deprecated
default ExpressionPath getExpressionPath(String path) {
return expressionPath(path);
}
/**
* Return true if the property is a valid known property or path for the given bean type.
@@ -108,7 +180,15 @@ public interface BeanType<T> {
/**
* Return the base table this bean type maps to.
*/
String getBaseTable();
String baseTable();
/**
* Deprecated migrate to baseTable().
*/
@Deprecated
default String getBaseTable() {
return baseTable();
}
/**
* Create a new instance of the bean.
@@ -118,10 +198,18 @@ public interface BeanType<T> {
/**
* Return the bean id. This is the same as getBeanId() but without the generic type.
*/
Object beanId(Object bean);
Object id(Object bean);
/**
* Deprecated migrate to beanId()
* Deprecated migrate to id()
*/
@Deprecated
default Object beanId(Object bean) {
return id(bean);
}
/**
* Deprecated migrate to id()
*/
@Deprecated
Object getBeanId(T bean);
@@ -129,32 +217,80 @@ public interface BeanType<T> {
/**
* Set the id value to the bean.
*/
void setBeanId(T bean, Object idValue);
void setId(T bean, Object idValue);
/**
* Deprecated migrate to setId()
*/
@Deprecated
default void setBeanId(T bean, Object idValue) {
setId(bean, idValue);
}
/**
* Return the bean persist controller.
*/
BeanPersistController getPersistController();
BeanPersistController persistController();
/**
* Deprecated migrate to persistController()
*/
@Deprecated
default BeanPersistController getPersistController() {
return persistController();
}
/**
* Return the bean persist listener.
*/
BeanPersistListener getPersistListener();
BeanPersistListener persistListener();
/**
* Deprecated migrate to persistListener()
*/
@Deprecated
default BeanPersistListener getPersistListener() {
return persistListener();
}
/**
* Return the beanFinder. Usually null unless overriding the finder.
*/
BeanFindController getFindController();
BeanFindController findController();
/**
* Deprecated migrate to findController()
*/
@Deprecated
default BeanFindController getFindController() {
return findController();
}
/**
* Return the BeanQueryAdapter or null if none is defined.
*/
BeanQueryAdapter getQueryAdapter();
BeanQueryAdapter queryAdapter();
/**
* Deprecated migrate to queryAdapter()
*/
@Deprecated
default BeanQueryAdapter getQueryAdapter() {
return queryAdapter();
}
/**
* Return the identity generation type.
*/
IdType getIdType();
IdType idType();
/**
* Deprecated migrate to idType()
*/
@Deprecated
default IdType getIdType() {
return idType();
}
/**
* Return true if this bean type has doc store backing.
@@ -168,12 +304,28 @@ public interface BeanType<T> {
* for the document store.
* </p>
*/
DocMapping getDocMapping();
DocMapping docMapping();
/**
* Deprecated migrate to docMapping()
*/
@Deprecated
default DocMapping getDocMapping() {
return docMapping();
}
/**
* Return the doc store queueId for this bean type.
*/
String getDocStoreQueueId();
String docStoreQueueId();
/**
* Deprecated migrate to docStoreQueueId()
*/
@Deprecated
default String getDocStoreQueueId() {
return docStoreQueueId();
}
/**
* Return the doc store support for this bean type.\
@@ -204,12 +356,28 @@ public interface BeanType<T> {
/**
* Returns all direct children of this beantype
*/
List<BeanType<?>> getInheritanceChildren();
List<BeanType<?>> inheritanceChildren();
/**
* Returns the parent in inheritance hiearchy
* Deprecated migrate to inheritanceChildren()
*/
BeanType<?> getInheritanceParent();
@Deprecated
default List<BeanType<?>> getInheritanceChildren() {
return inheritanceChildren();
}
/**
* Returns the parent in inheritance hierarchy
*/
BeanType<?> inheritanceParent();
/**
* Deprecated migrate to inheritanceParent()
*/
@Deprecated
default BeanType<?> getInheritanceParent() {
return inheritanceParent();
}
/**
* Visit all children recursively
@@ -219,7 +387,15 @@ public interface BeanType<T> {
/**
* Return the discriminator column.
*/
String getDiscColumn();
String discColumn();
/**
* Deprecated migrate to discColumn()
*/
@Deprecated
default String getDiscColumn() {
return discColumn();
}
/**
* Create a bean given the discriminator value.
@@ -45,7 +45,7 @@ public class ProfileOriginNodeUsage {
if (path != null) {
ElPropertyValue elGetValue = rootDesc.getElGetValue(path);
if (elGetValue == null) {
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.getName());
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
return;
} else {
BeanProperty beanProperty = elGetValue.getBeanProperty();
@@ -61,7 +61,7 @@ public class ProfileOriginNodeUsage {
for (String propName : aggregateUsed) {
BeanProperty beanProp = desc.findPropertyFromPath(propName);
if (beanProp == null) {
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.getName());
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.name());
} else {
if (beanProp.isId()) {
+2 -1
View File
@@ -63,7 +63,8 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.11.3</version>
<!-- <version>12.11.3</version>-->
<version>12.11.4A</version>
<scope>test</scope>
</dependency>
@@ -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);
@@ -31,33 +31,33 @@ public class BeanTypeTest {
@Test
public void getBeanType() {
assertThat(beanType(Order.class).getBeanType()).isEqualTo(Order.class);
assertThat(beanType(Order.class).type()).isEqualTo(Order.class);
}
@Test
public void getTypeAtPath_when_ManyToOne() {
BeanType<Order> orderType = beanType(Order.class);
BeanType<?> customerType = orderType.getBeanTypeAtPath("customer");
assertThat(customerType.getBeanType()).isEqualTo(Customer.class);
BeanType<?> customerType = orderType.beanTypeAtPath("customer");
assertThat(customerType.type()).isEqualTo(Customer.class);
}
@Test
public void getTypeAtPath_when_OneToMany() {
BeanType<Order> orderType = beanType(Order.class);
BeanType<?> detailsType = orderType.getBeanTypeAtPath("details");
assertThat(detailsType.getBeanType()).isEqualTo(OrderDetail.class);
BeanType<?> detailsType = orderType.beanTypeAtPath("details");
assertThat(detailsType.type()).isEqualTo(OrderDetail.class);
}
@Test
public void getTypeAtPath_when_nested() {
BeanType<Order> orderType = beanType(Order.class);
BeanType<?> productType = orderType.getBeanTypeAtPath("details.product");
assertThat(productType.getBeanType()).isEqualTo(Product.class);
BeanType<?> productType = orderType.beanTypeAtPath("details.product");
assertThat(productType.type()).isEqualTo(Product.class);
}
@Test
public void getTypeAtPath_when_simpleType() {
assertThrows(RuntimeException.class, () -> beanType(Order.class).getBeanTypeAtPath("status"));
assertThrows(RuntimeException.class, () -> beanType(Order.class).beanTypeAtPath("status"));
}
@Test
@@ -70,7 +70,7 @@ public class BeanTypeTest {
Order order = new Order();
order.setStatus(Order.Status.APPROVED);
Property statusProperty = beanType(Order.class).getProperty("status");
Property statusProperty = beanType(Order.class).property("status");
assertThat(statusProperty.getVal(order)).isEqualTo(order.getStatus());
}
@@ -78,7 +78,7 @@ public class BeanTypeTest {
@Test
public void getBaseTable() {
assertThat(beanType(Order.class).getBaseTable()).isEqualTo("o_order");
assertThat(beanType(Order.class).baseTable()).isEqualTo("o_order");
}
@Test
@@ -87,7 +87,7 @@ public class BeanTypeTest {
Order order = new Order();
order.setId(42);
Object id1 = beanType(Order.class).beanId(order);
Object id1 = beanType(Order.class).id(order);
assertThat(id1).isEqualTo(order.getId());
}
@@ -95,7 +95,7 @@ public class BeanTypeTest {
public void setBeanId() {
Order order = new Order();
beanType(Order.class).setBeanId(order, 42);
beanType(Order.class).setId(order, 42);
assertThat(42).isEqualTo(order.getId());
}
@@ -106,8 +106,8 @@ public class BeanTypeTest {
assertThat(beanType(Order.class).isDocStoreMapped()).isFalse();
assertThat(beanType(Person.class).isDocStoreMapped()).isFalse();
assertThat(beanType(Order.class).getDocMapping()).isNotNull();
assertThat(beanType(Person.class).getDocMapping()).isNull();
assertThat(beanType(Order.class).docMapping()).isNotNull();
assertThat(beanType(Person.class).docMapping()).isNull();
}
@Test
@@ -136,8 +136,8 @@ public class BeanTypeTest {
@Test
public void getDocStoreQueueId() {
assertThat(beanType(Order.class).getDocStoreQueueId()).isEqualTo("order");
assertThat(beanType(Customer.class).getDocStoreQueueId()).isEqualTo("customer");
assertThat(beanType(Order.class).docStoreQueueId()).isEqualTo("order");
assertThat(beanType(Customer.class).docStoreQueueId()).isEqualTo("customer");
}
@Test
@@ -205,12 +205,12 @@ public class BeanTypeTest {
@Test
public void getDiscColumn_when_default() {
assertEquals(beanType(Car.class).getDiscColumn(), "dtype");
assertEquals(beanType(Car.class).discColumn(), "dtype");
}
@Test
public void getDiscColumn_when_set() {
assertEquals(beanType(Stockforecast.class).getDiscColumn(), "type");
assertEquals(beanType(Stockforecast.class).discColumn(), "type");
}
@Test
@@ -22,42 +22,42 @@ public class ExpressionPathTest {
public void containsMany_when_many() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("details").containsMany()).isTrue();
assertThat(beanType.expressionPath("details").containsMany()).isTrue();
}
@Test
public void containsMany_when_manyChild() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("details.id").containsMany()).isTrue();
assertThat(beanType.expressionPath("details.id").containsMany()).isTrue();
}
@Test
public void containsMany_when_manyGrandChild() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("details.product.sku").containsMany()).isTrue();
assertThat(beanType.expressionPath("details.product.sku").containsMany()).isTrue();
}
@Test
public void containsMany_when_one() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("customer.name").containsMany()).isFalse();
assertThat(beanType.expressionPath("customer.name").containsMany()).isFalse();
}
@Test
public void containsMany_when_oneWithMany() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("customer.contacts").containsMany()).isTrue();
assertThat(beanType.expressionPath("customer.contacts").containsMany()).isTrue();
}
@Test
public void containsMany_when_oneWithManyChild() throws Exception {
BeanType<Order> beanType = beanType(Order.class);
assertThat(beanType.getExpressionPath("customer.contacts.firstName").containsMany()).isTrue();
assertThat(beanType.expressionPath("customer.contacts.firstName").containsMany()).isTrue();
}
@Test
@@ -65,7 +65,7 @@ public class ExpressionPathTest {
BeanType<Order> beanType = beanType(Order.class);
Order order = new Order();
beanType.getExpressionPath("id").pathSet(order, 42);
beanType.expressionPath("id").pathSet(order, 42);
assertThat(order.getId()).isEqualTo(42);
}
@@ -74,7 +74,7 @@ public class ExpressionPathTest {
BeanType<Order> beanType = beanType(Order.class);
Order order = new Order();
beanType.getExpressionPath("customer.name").pathSet(order, "Rob");
beanType.expressionPath("customer.name").pathSet(order, "Rob");
assertThat(order.getCustomer().getName()).isEqualTo("Rob");
}
@@ -94,7 +94,7 @@ public class ExpressionPathTest {
customer = server.find(Customer.class, customer.getId());
assertThat(customer.getName()).isEqualTo("foo");
customerBeanType.getExpressionPath("name").pathSet(customer, "bar");
customerBeanType.expressionPath("name").pathSet(customer, "bar");
server.save(customer);
customer = server.find(Customer.class, customer.getId());
@@ -108,7 +108,7 @@ public class ExpressionPathTest {
order = server.find(Order.class, order.getId());
ExpressionPath customerNamePath = orderBeanType.getExpressionPath("customer.name");
ExpressionPath customerNamePath = orderBeanType.expressionPath("customer.name");
assertThat(customerNamePath.pathGet(order)).isEqualTo("bar");
customerNamePath.pathSet(order, "baz");
@@ -27,30 +27,30 @@ public class PropertyTest {
order.setCustomer(customer);
order.setStatus(Order.Status.APPROVED);
Property statusProperty = beanType(Order.class).getProperty("status");
Property statusProperty = beanType(Order.class).property("status");
assertThat(statusProperty.getVal(order)).isEqualTo(order.getStatus());
Property customerProperty = beanType(Order.class).getProperty("customer");
Property customerProperty = beanType(Order.class).property("customer");
assertThat(customerProperty.getVal(order)).isEqualTo(customer);
}
@Test
public void isMany_when_not() {
assertThat(beanType(Order.class).getProperty("status").isMany()).isFalse();
assertThat(beanType(Order.class).getProperty("customer").isMany()).isFalse();
assertThat(beanType(Order.class).property("status").isMany()).isFalse();
assertThat(beanType(Order.class).property("customer").isMany()).isFalse();
}
@Test
public void isMany_when_true() {
assertThat(beanType(Order.class).getProperty("details").isMany()).isTrue();
assertThat(beanType(Order.class).property("details").isMany()).isTrue();
}
@Test
public void name() {
assertThat(beanType(Order.class).getProperty("status").getName()).isEqualTo("status");
assertThat(beanType(Order.class).getProperty("customer").getName()).isEqualTo("customer");
assertThat(beanType(Order.class).getProperty("details").getName()).isEqualTo("details");
assertThat(beanType(Order.class).property("status").getName()).isEqualTo("status");
assertThat(beanType(Order.class).property("customer").getName()).isEqualTo("customer");
assertThat(beanType(Order.class).property("details").getName()).isEqualTo("details");
}
}
@@ -26,12 +26,12 @@ public class SpiServerTest extends BaseTestCase {
SpiServer pluginApi = defaultServer.pluginApi();
BeanType<Customer> beanType = pluginApi.beanType(Customer.class);
assertEquals("o_customer", beanType.getBaseTable());
assertEquals("o_customer", beanType.baseTable());
assertNotNull(pluginApi.databasePlatform());
assertNull(beanType.getFindController());
assertNotNull(beanType.getPersistController());
assertNull(beanType.getPersistListener());
assertNull(beanType.getQueryAdapter());
assertNull(beanType.findController());
assertNotNull(beanType.persistController());
assertNull(beanType.persistListener());
assertNull(beanType.queryAdapter());
assertTrue(beanType.isValidExpression("name"));
assertTrue(beanType.isValidExpression("contacts.firstName"));
@@ -43,7 +43,7 @@ public class SpiServerTest extends BaseTestCase {
Customer customer = new Customer();
customer.setId(42);
assertEquals(42, beanType.beanId(customer));
assertEquals(42, beanType.id(customer));
List<? extends BeanType<?>> beanTypes = pluginApi.beanTypes("o_customer");
assertEquals(2, beanTypes.size());
@@ -17,7 +17,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
DocumentMapping documentMapping = desc.getDocMapping();
DocumentMapping documentMapping = desc.docMapping();
DocPropertyMapping properties = documentMapping.getProperties();
@@ -29,7 +29,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
DocumentMapping documentMapping = desc.getDocMapping();
DocumentMapping documentMapping = desc.docMapping();
DocPropertyMapping properties = documentMapping.getProperties();
@@ -39,42 +39,42 @@ public class BeanDescriptor_registerTest {
Controller1 controller1 = new Controller1();
assertNull(desc.getPersistController());
assertNull(desc.persistController());
desc.register(controller1);
assertSame(controller1, desc.getPersistController());
assertSame(controller1, desc.persistController());
Controller2 controller2 = new Controller2();
desc.register(controller2);
assertEquals(2, ((ChainedBeanPersistController) desc.getPersistController()).size());
assertEquals(2, ((ChainedBeanPersistController) desc.persistController()).size());
desc.deregister(controller1);
assertEquals(1, ((ChainedBeanPersistController) desc.getPersistController()).size());
assertEquals(1, ((ChainedBeanPersistController) desc.persistController()).size());
desc.deregister(controller2);
assertEquals(0, ((ChainedBeanPersistController) desc.getPersistController()).size());
assertEquals(0, ((ChainedBeanPersistController) desc.persistController()).size());
}
private void persistListenerRegistrationTests(BeanDescriptor<EBasic> desc) {
Listener1 listener1 = new Listener1();
assertNull(desc.getPersistListener());
assertNull(desc.persistListener());
desc.register(listener1);
assertSame(listener1, desc.getPersistListener());
assertSame(listener1, desc.persistListener());
Listener2 listener2 = new Listener2();
desc.register(listener2);
BeanPersistListener persistListener = desc.getPersistListener();
BeanPersistListener persistListener = desc.persistListener();
assertTrue(persistListener instanceof ChainedBeanPersistListener);
assertEquals(2, ((ChainedBeanPersistListener) persistListener).size());
desc.deregister(listener1);
assertEquals(1, ((ChainedBeanPersistListener) desc.getPersistListener()).size());
assertEquals(1, ((ChainedBeanPersistListener) desc.persistListener()).size());
desc.deregister(listener2);
assertEquals(0, ((ChainedBeanPersistListener) desc.getPersistListener()).size());
assertEquals(0, ((ChainedBeanPersistListener) desc.persistListener()).size());
}
public static class Listener1 extends AbstractBeanPersistListener {
@@ -21,15 +21,15 @@ public class BeanDescriptor_whenCreatedPropertyTest extends BaseTestCase {
BeanDescriptor<Customer> desc = server.getBeanDescriptor(Customer.class);
BeanProperty whenCreatedProperty = desc.getWhenCreatedProperty();
BeanProperty whenCreatedProperty = desc.whenCreatedProperty();
assertEquals("cretime", whenCreatedProperty.getDbColumn());
BeanProperty whenModifiedProperty = desc.getWhenModifiedProperty();
BeanProperty whenModifiedProperty = desc.whenModifiedProperty();
assertEquals("updtime", whenModifiedProperty.getDbColumn());
BeanDescriptor<EBasic> eBasicDesc = server.getBeanDescriptor(EBasic.class);
assertNull(eBasicDesc.getWhenCreatedProperty());
assertNull(eBasicDesc.getWhenModifiedProperty());
assertNull(eBasicDesc.whenCreatedProperty());
assertNull(eBasicDesc.whenModifiedProperty());
}
}
@@ -32,8 +32,8 @@ public class TestBeanDescriptorHasIdProperty extends BaseTestCase {
public void testHasId() {
BeanDescriptor<Order> beanDescriptor = spiServer.getBeanDescriptor(Order.class);
assertNotNull(beanDescriptor.getIdProperty());
assertEquals("id", beanDescriptor.getIdProperty().getName());
assertNotNull(beanDescriptor.idProperty());
assertEquals("id", beanDescriptor.idProperty().getName());
assertNotNull(beanDescriptor.getVersionProperty());
assertEquals("updtime", beanDescriptor.getVersionProperty().getName());
@@ -46,7 +46,7 @@ public class TestDPersonEl {
EntityBean entityBean = (EntityBean) p;
ExpressionPath elSalary = descriptor.getExpressionPath("salary");
ExpressionPath elSalary = descriptor.expressionPath("salary");
Object money = elSalary.pathGet(entityBean);
@@ -22,9 +22,9 @@ public class TestPathExpression {
public TestPathExpression() {
SpiServer server = DB.getDefault().pluginApi();
beanType = server.beanType(Customer.class);
billingId = beanType.getExpressionPath("billingAddress.id");
line1 = beanType.getExpressionPath("billingAddress.line1");
city = beanType.getExpressionPath("billingAddress.city");
billingId = beanType.expressionPath("billingAddress.id");
line1 = beanType.expressionPath("billingAddress.line1");
city = beanType.expressionPath("billingAddress.city");
}
@Test
@@ -35,11 +35,11 @@ public class TestPathExpression {
city.pathSet(c1, "Auckland");
billingId.pathSet(c1, 4);
beanType.getExpressionPath("id").pathSet(c1, 42L);
beanType.getExpressionPath("name").pathSet(c1, "jimmy");
beanType.getExpressionPath("status").pathSet(c1, "ACTIVE");
beanType.getExpressionPath("billingAddress.country.code").pathSet(c1, "NZ");
beanType.getExpressionPath("billingAddress.country.name").pathSet(c1, "New Zealand");
beanType.expressionPath("id").pathSet(c1, 42L);
beanType.expressionPath("name").pathSet(c1, "jimmy");
beanType.expressionPath("status").pathSet(c1, "ACTIVE");
beanType.expressionPath("billingAddress.country.code").pathSet(c1, "NZ");
beanType.expressionPath("billingAddress.country.name").pathSet(c1, "New Zealand");
assertEquals(c1.getId(), Integer.valueOf(42));
@@ -75,7 +75,7 @@ public class TestPathExpression {
assertEquals(billingId.pathGet(e0), Integer.valueOf("12"));
assertEquals(beanType.getExpressionPath("billingAddress.country.code").pathGet(e0), "NZ");
assertEquals(beanType.getExpressionPath("billingAddress.country.name").pathGet(e0), "New Zealand");
assertEquals(beanType.expressionPath("billingAddress.country.code").pathGet(e0), "NZ");
assertEquals(beanType.expressionPath("billingAddress.country.name").pathGet(e0), "New Zealand");
}
}
@@ -29,7 +29,7 @@ public class TestEmbeddedManyToOne extends BaseTestCase {
EAddr addr = new EAddr("Foo", "Bar", nz);
EPerAddr perAddr = new EPerAddr("Embed", addr);
Property country = embType.getProperty("country");
Property country = embType.property("country");
Object val = country.getVal(addr);
assertThat(val).isSameAs(nz);
@@ -217,22 +217,22 @@ public class TestNewTypes extends BaseTestCase {
private void testSetGetPath(SomeNewTypesBean refBean) {
SomeNewTypesBean testBean = new SomeNewTypesBean();
BeanType<SomeNewTypesBean> beanType = DB.getDefault().pluginApi().beanType(SomeNewTypesBean.class);
ExpressionPath localDate = beanType.getExpressionPath("localDate");
ExpressionPath localDateTime = beanType.getExpressionPath("localDateTime");
ExpressionPath offsetDateTime = beanType.getExpressionPath("offsetDateTime");
ExpressionPath zonedDateTime = beanType.getExpressionPath("zonedDateTime");
ExpressionPath localTime = beanType.getExpressionPath("localTime");
ExpressionPath instant = beanType.getExpressionPath("instant");
ExpressionPath year = beanType.getExpressionPath("year");
ExpressionPath month = beanType.getExpressionPath("month");
ExpressionPath dayOfWeek = beanType.getExpressionPath("dayOfWeek");
ExpressionPath zoneId = beanType.getExpressionPath("zoneId");
ExpressionPath zoneOffset = beanType.getExpressionPath("zoneOffset");
ExpressionPath yearMonth = beanType.getExpressionPath("yearMonth");
ExpressionPath monthDay = beanType.getExpressionPath("monthDay");
ExpressionPath path = beanType.getExpressionPath("path");
ExpressionPath period = beanType.getExpressionPath("period");
ExpressionPath duration = beanType.getExpressionPath("duration");
ExpressionPath localDate = beanType.expressionPath("localDate");
ExpressionPath localDateTime = beanType.expressionPath("localDateTime");
ExpressionPath offsetDateTime = beanType.expressionPath("offsetDateTime");
ExpressionPath zonedDateTime = beanType.expressionPath("zonedDateTime");
ExpressionPath localTime = beanType.expressionPath("localTime");
ExpressionPath instant = beanType.expressionPath("instant");
ExpressionPath year = beanType.expressionPath("year");
ExpressionPath month = beanType.expressionPath("month");
ExpressionPath dayOfWeek = beanType.expressionPath("dayOfWeek");
ExpressionPath zoneId = beanType.expressionPath("zoneId");
ExpressionPath zoneOffset = beanType.expressionPath("zoneOffset");
ExpressionPath yearMonth = beanType.expressionPath("yearMonth");
ExpressionPath monthDay = beanType.expressionPath("monthDay");
ExpressionPath path = beanType.expressionPath("path");
ExpressionPath period = beanType.expressionPath("period");
ExpressionPath duration = beanType.expressionPath("duration");
localDate.pathSet(testBean, refBean.getLocalDate());
assertThat(localDate.pathGet(testBean)).isEqualTo(refBean.getLocalDate());
+1 -1
View File
@@ -10,7 +10,7 @@
<name>ebean ddl generation</name>
<description>DDL and DB Migration generation</description>
<artifactId>ebean-ddl-generator</artifactId>
<!-- <version>12.11.3A</version>-->
<!-- <version>12.11.4A</version>-->
<dependencies>
@@ -89,14 +89,14 @@ public class MTable {
private final List<String> droppedColumns = new ArrayList<>();
public MTable(BeanDescriptor<?> descriptor) {
this.name = descriptor.getBaseTable();
this.name = descriptor.baseTable();
this.identityMode = descriptor.getIdentityMode();
this.storageEngine = descriptor.getStorageEngine();
this.partitionMeta = descriptor.getPartitionMeta();
this.comment = descriptor.getDbComment();
if (descriptor.isHistorySupport()) {
withHistory = true;
BeanProperty whenCreated = descriptor.getWhenCreatedProperty();
BeanProperty whenCreated = descriptor.whenCreatedProperty();
if (whenCreated != null) {
whenCreatedColumn = whenCreated.getDbColumn();
}