#2318 - Refactor internals - trim whitespace in deploy package

This commit is contained in:
rbygrave
2021-08-20 17:39:11 +12:00
parent 90e321ddbd
commit 6f7efe6922
35 changed files with 60 additions and 282 deletions
@@ -14,9 +14,7 @@ import java.sql.SQLException;
abstract class AssocOneHelp {
final BeanPropertyAssocOne<?> property;
private final BeanDescriptor<?> target;
private final String path;
AssocOneHelp(BeanPropertyAssocOne<?> property) {
@@ -58,19 +56,16 @@ abstract class AssocOneHelp {
* Read and return the bean.
*/
Object read(DbReadContext ctx) throws SQLException {
// Support for Inheritance hierarchy on exported OneToOne ?
Object id = property.targetIdBinder.read(ctx);
if (id == null) {
return null;
}
PersistenceContext pc = ctx.getPersistenceContext();
Object existing = target.contextGet(pc, id);
if (existing != null) {
return existing;
}
boolean disableLazyLoading = ctx.isDisableLazyLoading();
Object ref = target.contextRef(pc, ctx.isReadOnly(), disableLazyLoading, id);
if (!disableLazyLoading) {
@@ -79,7 +74,6 @@ abstract class AssocOneHelp {
return ref;
}
/**
* Read setting values into the bean.
*/
@@ -32,7 +32,6 @@ final class AssocOneHelpEmbedded extends AssocOneHelp {
@Override
Object read(DataReader reader) throws SQLException {
EntityBean embeddedBean = property.targetDescriptor.createEntityBean();
boolean notNull = false;
for (BeanProperty property : property.embeddedProps) {
@@ -63,9 +62,7 @@ final class AssocOneHelpEmbedded extends AssocOneHelp {
@Override
Object read(DbReadContext ctx) throws SQLException {
EntityBean embeddedBean = property.targetDescriptor.createEntityBean();
boolean notNull = false;
for (BeanProperty property : property.embeddedProps) {
Object value = property.readSet(ctx, embeddedBean);
@@ -8,7 +8,6 @@ import io.ebeaninternal.server.query.SqlJoinType;
final class AssocOneHelpRefExported extends AssocOneHelp {
private final boolean softDelete;
private final String softDeletePredicate;
AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
@@ -22,7 +21,6 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
*/
@Override
void appendSelect(DbSqlContext ctx, boolean subQuery) {
// set appropriate tableAlias for the exported id columns
String relativePrefix = ctx.getRelativePrefix(property.getName());
ctx.pushTableAlias(relativePrefix);
@@ -32,7 +30,6 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
@Override
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
String relativePrefix = ctx.getRelativePrefix(property.getName());
if (softDelete && !ctx.isIncludeSoftDelete()) {
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
@@ -29,7 +29,6 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
*/
@Override
Object read(DbReadContext ctx) throws SQLException {
// read discriminator to determine the type
InheritInfo rowInheritInfo = inherit.readType(ctx);
if (rowInheritInfo == null) {
@@ -37,12 +36,10 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
property.targetIdBinder.loadIgnore(ctx);
return null;
}
Object id = property.targetIdBinder.read(ctx);
if (id == null) {
return null;
}
// check transaction context to see if it already exists
PersistenceContext pc = ctx.getPersistenceContext();
BeanDescriptor<?> desc = rowInheritInfo.desc();
@@ -50,7 +47,6 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
if (existing != null) {
return existing;
}
// for inheritance hierarchy create the correct type for this row...
boolean disableLazyLoading = ctx.isDisableLazyLoading();
Object ref = desc.contextRef(pc, ctx.isReadOnly(), disableLazyLoading, id);
@@ -72,7 +68,6 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
*/
@Override
void appendSelect(DbSqlContext ctx, boolean subQuery) {
if (!subQuery) {
// add discriminator column
String relativePrefix = ctx.getRelativePrefix(property.getName());
@@ -13,7 +13,6 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
final BeanPropertyAssocMany<T> many;
private final BeanDescriptor<T> targetDescriptor;
final String propertyName;
BeanCollectionLoader loader;
BaseCollectionHelp(BeanPropertyAssocMany<T> many) {
@@ -11,9 +11,7 @@ import javax.persistence.CascadeType;
public final class BeanCascadeInfo {
private boolean delete;
private boolean save;
private boolean refresh;
public void setTypes(CascadeType[] types) {
@@ -25,7 +25,6 @@ final class BeanChangeJson implements BeanDiffVisitor {
this.newData = new StringWriter(200);
this.newJson = descriptor.createJsonWriter(newData);
newJson.writeStartObject();
if (statelessUpdate) {
this.oldJson = null;
this.oldData = null;
@@ -38,7 +37,6 @@ final class BeanChangeJson implements BeanDiffVisitor {
@Override
public void visit(int position, Object newVal, Object oldVal) {
try {
BeanProperty prop = descriptor.propertiesIndex[position];
if (prop.isDbUpdatable()) {
@@ -55,7 +53,6 @@ final class BeanChangeJson implements BeanDiffVisitor {
@Override
public void visitPush(int position) {
stack.push(descriptor);
BeanPropertyAssocOne<?> embedded = (BeanPropertyAssocOne<?>)descriptor.propertiesIndex[position];
descriptor = embedded.getTargetDescriptor();
newJson.writeStartObject(embedded.getName());
@@ -33,7 +33,6 @@ public final class BeanCollectionHelpFactory {
default:
throw new RuntimeException("Invalid type " + manyType);
}
}
@SuppressWarnings("unchecked")
@@ -115,37 +115,23 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private static final Logger logger = LoggerFactory.getLogger(BeanDescriptor.class);
private final ConcurrentHashMap<String, SpiUpdatePlan> updatePlanCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<CQueryPlanKey, CQueryPlan> queryPlanCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElPropertyValue> elCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElPropertyDeploy> elDeployCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElComparator<T>> comparatorCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, STreeProperty> dynamicProperty = new ConcurrentHashMap<>();
private final Map<String, SpiRawSql> namedRawSql;
private final Map<String, String> namedQuery;
private final boolean multiValueSupported;
private boolean batchEscalateOnCascadeInsert;
private boolean batchEscalateOnCascadeDelete;
private final BeanIudMetrics iudMetrics;
public enum EntityType {
ORM, EMBEDDED, VIEW, SQL, DOC
}
/**
* The nature/type of this bean.
*/
private final ConcurrentHashMap<String, SpiUpdatePlan> updatePlanCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<CQueryPlanKey, CQueryPlan> queryPlanCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElPropertyValue> elCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElPropertyDeploy> elDeployCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ElComparator<T>> comparatorCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, STreeProperty> dynamicProperty = new ConcurrentHashMap<>();
private final Map<String, SpiRawSql> namedRawSql;
private final Map<String, String> namedQuery;
private final boolean multiValueSupported;
private boolean batchEscalateOnCascadeInsert;
private boolean batchEscalateOnCascadeDelete;
private final BeanIudMetrics iudMetrics;
private final EntityType entityType;
/**
* Set when Id property is marked with GeneratedValue annotation.
*/
@@ -153,71 +139,39 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private final PlatformIdGenerator idGenerator;
private final IdentityMode identityMode;
private final IdType idType;
/**
* SQL used to return last inserted id. Used for Identity columns where
* getGeneratedKeys is not supported.
*/
private final String selectLastInsertedId;
private final String selectLastInsertedIdDraft;
private final boolean autoTunable;
/**
* The concurrency mode for beans of this type.
*/
private final ConcurrencyMode concurrencyMode;
private final IndexDefinition[] indexDefinitions;
private final String[] dependentTables;
/**
* The base database table.
*/
private final String baseTable;
private final String baseTableAsOf;
private final String baseTableVersionsBetween;
private final boolean historySupport;
private final TableJoin primaryKeyJoin;
private final BeanProperty softDeleteProperty;
private final boolean softDelete;
private final String draftTable;
private final PartitionMeta partitionMeta;
private final String storageEngine;
/**
* DB table comment.
*/
private final String dbComment;
/**
* Set to true if read auditing is on for this bean type.
*/
private final boolean readAuditing;
private final boolean draftable;
private final boolean draftableElement;
private final BeanProperty unmappedJson;
private final BeanProperty tenant;
private final BeanProperty draft;
private final BeanProperty draftDirty;
private final LinkedHashMap<String, BeanProperty> propMap;
/**
* Map of DB column to property path (for nativeSql mapping).
*/
private final Map<String, String> columnPath = new HashMap<>();
/**
* Map of related table to assoc property (for nativeSql mapping).
*/
@@ -235,46 +189,34 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private final BeanQueryAdapter queryAdapter;
private final BeanFindController beanFinder;
private final ChangeLogFilter changeLogFilter;
/**
* Inheritance information. Server side only.
*/
final InheritInfo inheritInfo;
private final boolean abstractType;
private final BeanProperty idProperty;
private final int idPropertyIndex;
private final BeanProperty versionProperty;
private final int versionPropertyIndex;
private final BeanProperty whenModifiedProperty;
private final BeanProperty whenCreatedProperty;
/**
* Properties that are initialised in the constructor need to be 'unloaded' to support partial object queries.
*/
private final int[] unloadProperties;
/**
* Properties local to this type (not from a super type).
*/
private final BeanProperty[] propertiesLocal;
/**
* Scalar mutable properties (need to dirty check on update).
*/
private final BeanProperty[] propertiesMutable;
private final BeanPropertyAssocOne<?> unidirectional;
private final BeanProperty orderColumn;
private final BeanProperty[] propertiesNonMany;
private final BeanProperty[] propertiesAggregate;
private final BeanPropertyAssocMany<?>[] propertiesMany;
private final BeanPropertyAssocMany<?>[] propertiesManySave;
private final BeanPropertyAssocMany<?>[] propertiesManyDelete;
private final BeanPropertyAssocMany<?>[] propertiesManyToMany;
/**
* list of properties that are associated beans and not embedded (Derived).
*/
@@ -285,10 +227,8 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private final BeanPropertyAssocOne<?>[] propertiesOneExportedSave;
private final BeanPropertyAssocOne<?>[] propertiesOneExportedDelete;
private final BeanPropertyAssocOne<?>[] propertiesEmbedded;
private final BeanProperty[] propertiesBaseScalar;
private final BeanProperty[] propertiesTransient;
/**
* All non transient properties excluding the id properties.
*/
@@ -300,21 +240,10 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
private final boolean idOnlyReference;
private BeanNaturalKey beanNaturalKey;
/**
* The bean class name or the table name for MapBeans.
*/
private final String fullName;
/**
* Flag used to determine if saves can be skipped.
*/
private boolean saveRecurseSkippable;
/**
* Flag used to determine if deletes can be skipped.
*/
private boolean deleteRecurseSkippable;
private final EntityBean prototypeEntityBean;
private final IdBinder idBinder;
@@ -629,11 +558,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
}
prop.registerColumn(this, null);
}
if (unidirectional != null) {
unidirectional.initialise(initContext);
}
idBinder.initialise();
idBinderInLHSSql = idBinder.getBindIdInSql(baseTableAlias);
idBinderIdSql = idBinder.getBindIdSql(baseTableAlias);
@@ -50,38 +50,27 @@ final class BeanDescriptorCacheHelp<T> {
private static final Logger natLog = LoggerFactory.getLogger("io.ebean.cache.NATKEY");
private final BeanDescriptor<T> desc;
private final SpiCacheManager cacheManager;
private final CacheOptions cacheOptions;
/**
* Flag indicating this bean has no relationships.
*/
private final boolean cacheSharableBeans;
private final boolean invalidateQueryCache;
private final Class<?> beanType;
private final String cacheName;
private final BeanPropertyAssocOne<?>[] propertiesOneImported;
private final String[] naturalKey;
private final ServerCache beanCache;
private final ServerCache naturalKeyCache;
private final ServerCache queryCache;
private final boolean noCaching;
private final SpiCacheControl cacheControl;
private final SpiCacheRegion cacheRegion;
/**
* Set to true if all persist changes need to notify the cache.
*/
private boolean cacheNotifyOnAll;
/**
* Set to true if delete changes need to notify cache.
*/
@@ -293,13 +282,11 @@ final class BeanDescriptorCacheHelp<T> {
// held as part of the bean cache so skip
return false;
}
CachedManyIds entry = manyPropGet(parentId, many.getName());
if (entry == null) {
// not in cache so return unsuccessful
return false;
}
EntityBean ownerBean = bc.getOwnerBean();
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
PersistenceContext persistenceContext = ebi.getPersistenceContext();
@@ -14,9 +14,7 @@ import java.util.List;
final class BeanDescriptorDraftHelp<T> {
private final BeanDescriptor<T> desc;
private final BeanProperty draftDirty;
private final BeanProperty[] resetProperties;
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
@@ -29,16 +27,12 @@ final class BeanDescriptorDraftHelp<T> {
* Return the properties that are reset on draft beans after publish.
*/
private BeanProperty[] resetProperties() {
List<BeanProperty> list = new ArrayList<>();
BeanProperty[] props = desc.propertiesNonMany();
for (BeanProperty prop : props) {
for (BeanProperty prop : desc.propertiesNonMany()) {
if (prop.isDraftReset()) {
list.add(prop);
}
}
return list.toArray(new BeanProperty[0]);
}
@@ -46,19 +40,15 @@ final class BeanDescriptorDraftHelp<T> {
* Set the value of all the 'reset properties' to null on the draft bean.
*/
boolean draftReset(T draftBean) {
EntityBean draftEntityBean = (EntityBean) draftBean;
if (draftDirty != null) {
// set @DraftDirty property to false
draftDirty.setValueIntercept(draftEntityBean, false);
}
// set to null on all @DraftReset properties
for (BeanProperty resetProperty : resetProperties) {
resetProperty.setValueIntercept(draftEntityBean, null);
}
// return true if the bean is dirty (and should be persisted)
return draftEntityBean._ebean_getIntercept().isDirty();
}
@@ -71,31 +61,23 @@ final class BeanDescriptorDraftHelp<T> {
*/
@SuppressWarnings("unchecked")
public T publish(T draftBean, T liveBean) {
if (liveBean == null) {
liveBean = (T) desc.createEntityBean();
}
EntityBean draft = (EntityBean) draftBean;
EntityBean live = (EntityBean) liveBean;
BeanProperty idProperty = desc.getIdProperty();
if (idProperty != null) {
idProperty.publish(draft, live);
}
BeanProperty[] props = desc.propertiesNonMany();
for (BeanProperty prop : props) {
for (BeanProperty prop : desc.propertiesNonMany()) {
prop.publish(draft, live);
}
BeanPropertyAssocMany<?>[] many = desc.propertiesMany();
for (BeanPropertyAssocMany<?> aMany : many) {
if (aMany.getTargetDescriptor().isDraftable()) {
aMany.publishMany(draft, live);
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
if (many.getTargetDescriptor().isDraftable()) {
many.publishMany(draft, live);
}
}
return liveBean;
}
@@ -103,20 +85,15 @@ final class BeanDescriptorDraftHelp<T> {
* Fetch draftable element relationships.
*/
void draftQueryOptimise(Query<T> query) {
BeanPropertyAssocOne<?>[] one = desc.propertiesOne();
for (BeanPropertyAssocOne<?> anOne : one) {
for (BeanPropertyAssocOne<?> anOne : desc.propertiesOne()) {
if (anOne.getTargetDescriptor().isDraftableElement()) {
query.fetch(anOne.getName());
}
}
BeanPropertyAssocMany<?>[] many = desc.propertiesMany();
for (BeanPropertyAssocMany<?> aMany : many) {
for (BeanPropertyAssocMany<?> aMany : desc.propertiesMany()) {
if (aMany.getTargetDescriptor().isDraftableElement()) {
query.fetch(aMany.getName());
}
}
}
}
@@ -15,7 +15,6 @@ import java.util.Arrays;
abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
private final String simpleName;
final ElementHelp elementHelp;
BeanDescriptorElement(BeanDescriptorMap owner, DeployBeanDescriptor<T> deploy, ElementHelp elementHelp) {
@@ -12,12 +12,11 @@ import java.io.IOException;
/**
* Bean descriptor used with element collection of list/set of embeddable.
*/
@SuppressWarnings("rawtypes")
class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
private final BeanPropertyAssocOne embeddedProperty;
private final EntityBean prototype;
private BeanDescriptor targetDescriptor;
BeanDescriptorElementEmbedded(BeanDescriptorMap owner, DeployBeanDescriptor<T> deploy, ElementHelp elementHelp) {
@@ -18,7 +18,6 @@ import java.util.Map;
class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<T> {
private final ScalarType scalarTypeKey;
private final boolean stringKey;
BeanDescriptorElementEmbeddedMap(BeanDescriptorMap owner, DeployBeanDescriptor<T> deploy, ElementHelp elementHelp) {
@@ -50,7 +49,6 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
@Override
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
JsonParser parser = readJson.getParser();
ElementCollector add = elementHelp.createCollector();
do {
@@ -70,7 +68,6 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
add.addKeyValue(key, val);
}
} while (true);
return add.collection();
}
@@ -40,7 +40,6 @@ class BeanDescriptorElementScalar<T> extends BeanDescriptorElement<T> {
@Override
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
JsonParser parser = readJson.getParser();
ElementCollector add = elementHelp.createCollector();
do {
@@ -50,7 +49,6 @@ class BeanDescriptorElementScalar<T> extends BeanDescriptorElement<T> {
}
add.addElement(scalarType.jsonRead(parser));
} while (true);
return add.collection();
}
@@ -49,7 +49,6 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
@Override
public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
JsonParser parser = readJson.getParser();
ElementCollector add = elementHelp.createCollector();
do {
@@ -69,7 +68,6 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
add.addKeyValue(key, val);
}
} while (true);
return add.collection();
}
@@ -7,7 +7,6 @@ class BeanDescriptorInitContext {
private final Map<String, String> withHistoryTables;
private final Map<String, String> draftTables;
private final String asOfViewSuffix;
private String embeddedPrefix;
BeanDescriptorInitContext(Map<String, String> withHistoryTables, Map<String, String> draftTables, String asOfViewSuffix) {
@@ -133,10 +133,8 @@ final class BeanDescriptorJsonHelp<T> {
}
unmappedProperties.put(key, EJson.parse(parser));
}
} else if (JsonToken.END_OBJECT == event) {
break;
} else {
throw new RuntimeException("Unexpected token " + event + " - expecting key or end_object at: " + parser.getCurrentLocation());
}
@@ -107,19 +107,16 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
private final int queryPlanTTLSeconds;
private int entityBeanCount;
private List<BeanDescriptor<?>> immutableDescriptorList;
/**
* Map of base tables to 'with history views' used to support 'as of' queries.
*/
private final Map<String, String> asOfTableMap = new HashMap<>();
/**
* Map of base tables to 'draft' tables.
*/
private final Map<String, String> draftTableMap = new HashMap<>();
// temporary collections used during startup and then cleared
private Map<Class<?>, DeployBeanInfo<?>> deployInfoMap = new HashMap<>();
private Set<Class<?>> embeddedIdTypes = new HashSet<>();
private List<DeployBeanInfo<?>> embeddedBeans = new ArrayList<>();
@@ -297,11 +294,9 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
readInheritedIdGenerators();
// creates the BeanDescriptors
readEntityRelationships();
List<BeanDescriptor<?>> list = new ArrayList<>(descMap.values());
list.sort(beanDescComparator);
immutableDescriptorList = Collections.unmodifiableList(list);
initialiseAll();
readForeignKeys();
readTableToDescriptor();
@@ -311,12 +306,9 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
embeddedIdTypes = null;
embeddedBeans = null;
deployInfoMap = null;
return asOfTableMap;
} catch (BeanNotEnhancedException e) {
throw e;
} catch (RuntimeException e) {
logger.error("Error in deployment", e);
throw e;
@@ -51,7 +51,7 @@ public final class ChainedBeanPersistController implements BeanPersistController
/**
* Return the size of the chain.
*/
protected int size() {
int size() {
return chain.length;
}
@@ -64,7 +64,6 @@ public final class ChainedBeanPersistController implements BeanPersistController
} else {
List<BeanPersistController> newList = new ArrayList<>(list);
newList.add(c);
return new ChainedBeanPersistController(newList);
}
}
@@ -78,7 +77,6 @@ public final class ChainedBeanPersistController implements BeanPersistController
} else {
List<BeanPersistController> newList = new ArrayList<>(list);
newList.remove(c);
return new ChainedBeanPersistController(newList);
}
}
@@ -101,36 +99,36 @@ public final class ChainedBeanPersistController implements BeanPersistController
@Override
public void postDelete(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
aChain.postDelete(request);
for (BeanPersistController controller : chain) {
controller.postDelete(request);
}
}
@Override
public void postInsert(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
aChain.postInsert(request);
for (BeanPersistController controller : chain) {
controller.postInsert(request);
}
}
@Override
public void postUpdate(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
aChain.postUpdate(request);
for (BeanPersistController controller : chain) {
controller.postUpdate(request);
}
}
@Override
public void postSoftDelete(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
aChain.postSoftDelete(request);
for (BeanPersistController controller : chain) {
controller.postSoftDelete(request);
}
}
@Override
public boolean preDelete(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
if (!aChain.preDelete(request)) {
for (BeanPersistController controller : chain) {
if (!controller.preDelete(request)) {
return false;
}
}
@@ -139,8 +137,8 @@ public final class ChainedBeanPersistController implements BeanPersistController
@Override
public boolean preSoftDelete(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
if (!aChain.preSoftDelete(request)) {
for (BeanPersistController controller : chain) {
if (!controller.preSoftDelete(request)) {
return false;
}
}
@@ -149,15 +147,15 @@ public final class ChainedBeanPersistController implements BeanPersistController
@Override
public void preDelete(BeanDeleteIdRequest request) {
for (BeanPersistController aChain : chain) {
aChain.preDelete(request);
for (BeanPersistController controller : chain) {
controller.preDelete(request);
}
}
@Override
public boolean preInsert(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
if (!aChain.preInsert(request)) {
for (BeanPersistController controller : chain) {
if (!controller.preInsert(request)) {
return false;
}
}
@@ -166,8 +164,8 @@ public final class ChainedBeanPersistController implements BeanPersistController
@Override
public boolean preUpdate(BeanPersistRequest<?> request) {
for (BeanPersistController aChain : chain) {
if (!aChain.preUpdate(request)) {
for (BeanPersistController controller : chain) {
if (!controller.preUpdate(request)) {
return false;
}
}
@@ -80,29 +80,29 @@ public final class ChainedBeanPersistListener implements BeanPersistListener {
@Override
public void deleted(Object bean) {
for (BeanPersistListener aChain : chain) {
aChain.deleted(bean);
for (BeanPersistListener listener : chain) {
listener.deleted(bean);
}
}
@Override
public void softDeleted(Object bean) {
for (BeanPersistListener aChain : chain) {
aChain.softDeleted(bean);
for (BeanPersistListener listener : chain) {
listener.softDeleted(bean);
}
}
@Override
public void inserted(Object bean) {
for (BeanPersistListener aChain : chain) {
aChain.inserted(bean);
for (BeanPersistListener listener : chain) {
listener.inserted(bean);
}
}
@Override
public void updated(Object bean, Set<String> updatedProperties) {
for (BeanPersistListener aChain : chain) {
aChain.updated(bean, updatedProperties);
for (BeanPersistListener listener : chain) {
listener.updated(bean, updatedProperties);
}
}
}
@@ -47,13 +47,6 @@ public final class ChainedBeanPostConstructListener implements BeanPostConstruct
}
}
// /**
// * Return the size of the chain.
// */
// int size() {
// return chain.length;
// }
@Override
public boolean isRegisterFor(Class<?> cls) {
// never called
@@ -65,22 +58,22 @@ public final class ChainedBeanPostConstructListener implements BeanPostConstruct
*/
@Override
public void postConstruct(Object bean) {
for (BeanPostConstructListener aChain : chain) {
aChain.postConstruct(bean);
for (BeanPostConstructListener listener : chain) {
listener.postConstruct(bean);
}
}
@Override
public void autowire(Object bean) {
for (BeanPostConstructListener aChain : chain) {
aChain.autowire(bean);
for (BeanPostConstructListener listener : chain) {
listener.autowire(bean);
}
}
@Override
public void postCreate(Object bean) {
for (BeanPostConstructListener aChain : chain) {
aChain.postCreate(bean);
for (BeanPostConstructListener listener : chain) {
listener.postCreate(bean);
}
}
}
@@ -47,13 +47,6 @@ public final class ChainedBeanPostLoad implements BeanPostLoad {
}
}
// /**
// * Return the size of the chain.
// */
// int size() {
// return chain.length;
// }
@Override
public boolean isRegisterFor(Class<?> cls) {
// never called
@@ -65,8 +58,8 @@ public final class ChainedBeanPostLoad implements BeanPostLoad {
*/
@Override
public void postLoad(Object bean) {
for (BeanPostLoad aChain : chain) {
aChain.postLoad(bean);
for (BeanPostLoad postLoad : chain) {
postLoad.postLoad(bean);
}
}
}
@@ -72,8 +72,8 @@ public final class ChainedBeanQueryAdapter implements BeanQueryAdapter {
@Override
public void preQuery(BeanQueryRequest<?> request) {
for (BeanQueryAdapter aChain : chain) {
aChain.preQuery(request);
for (BeanQueryAdapter adapter : chain) {
adapter.preQuery(request);
}
}
@@ -5,7 +5,6 @@ import io.ebeaninternal.api.SpiCacheRegion;
public final class DCacheRegion implements SpiCacheRegion {
private boolean enabled = true;
private final String name;
public DCacheRegion(String name) {
@@ -35,21 +35,13 @@ public abstract class DeployParser {
private static final char OPEN_BRACKET = '(';
boolean encrypted;
private String source;
private StringBuilder sb;
private int sourceLength;
private int pos;
String priorWord;
String word;
private char wordTerminator;
private StringBuilder wordBuffer;
protected abstract String convertWord();
@@ -66,16 +58,13 @@ public abstract class DeployParser {
}
public String parse(String source) {
if (source == null) {
return null;
}
pos = -1;
this.source = source;
this.sourceLength = source.length();
this.sb = new StringBuilder(source.length() + 20);
while (nextWord()) {
if (skipWordConvert()) {
sb.append(word);
@@ -94,7 +83,6 @@ public abstract class DeployParser {
}
}
}
return sb.toString();
}
@@ -103,11 +91,9 @@ public abstract class DeployParser {
}
private boolean nextWord() {
if (!findWordStart()) {
return false;
}
wordBuffer = new StringBuilder();
wordBuffer.append(source.charAt(pos));
while (++pos < sourceLength) {
@@ -119,9 +105,7 @@ public abstract class DeployParser {
break;
}
}
word = wordBuffer.toString();
return true;
}
@@ -15,15 +15,11 @@ import java.util.Set;
public final class DeployPropertyParser extends DeployParser {
private static final String JOIN = "join";
private static final String FROM = "from";
private final BeanDescriptor<?> beanDescriptor;
private final Set<String> includes = new HashSet<>();
private boolean catchFirst;
private ElPropertyDeploy firstProp;
DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
@@ -25,7 +25,6 @@ public final class DeployUpdateParser extends DeployParser {
@Override
public String convertWord() {
String dbWord = getDeployWord(word);
if (dbWord != null) {
return dbWord;
@@ -35,10 +34,8 @@ public final class DeployUpdateParser extends DeployParser {
}
private String convertSubword(String currentWord) {
int start = 0;
StringBuilder localBuffer = null;
while (true) {
int dotPos = currentWord.indexOf('.', start);
if (start == 0 && dotPos == -1) {
@@ -76,11 +73,9 @@ public final class DeployUpdateParser extends DeployParser {
@Override
public String getDeployWord(String expression) {
if (expression.equalsIgnoreCase(beanDescriptor.getName())) {
return beanDescriptor.getBaseTable();
}
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
return elProp != null ? elProp.getDbColumn() : null;
}
@@ -28,7 +28,6 @@ final class DetermineAggPath {
* Parse and return the full path for the aggregation.
*/
static String path(String aggregation) {
// aggregations always have a form of sum(), avg(), max(), count() etc
// so find the first open bracket
int start = aggregation.indexOf('(');
@@ -49,7 +48,6 @@ final class DetermineAggPath {
return ch == '.' || Character.isJavaIdentifierPart(ch);
}
/**
* Helper class holding aggregation path segments.
*/
@@ -12,11 +12,8 @@ import javax.persistence.PersistenceException;
class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
private final String parsedFormula;
private final boolean aggregate;
final BeanProperty asTarget;
private final String alias;
DynamicPropertyAggregationFormula(String name, ScalarType<?> scalarType, String parsedFormula, boolean aggregate, BeanProperty asTarget, String alias) {
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.deploy;
import io.ebeaninternal.server.query.SqlBeanLoad;
@SuppressWarnings("rawtypes")
public final class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyAggregationFormula {
private final BeanPropertyAssocOne prop;
@@ -7,7 +7,6 @@ import io.ebeaninternal.server.core.InternString;
* The Exported foreign key and property.
* <p>
* Used to for Assoc Manys to create references etc.
* </p>
*/
final class ExportedProperty {
@@ -42,7 +41,6 @@ final class ExportedProperty {
* in preference to a parentProperty.idProperty = value.
* Just using the foreign database column avoids triggering
* a join to the 'parent' table.
* </p>
*/
public String getForeignDbColumn() {
return foreignDbColumn;
@@ -13,19 +13,12 @@ final class FormulaPropertyPath {
private static final String DISTINCT_ = "distinct ";
private final BeanDescriptor<?> descriptor;
private final String formula;
private final String outerFunction;
private final String internalExpression;
private final ElPropertyDeploy firstProp;
private final String parsedAggregation;
private boolean countDistinct;
private String cast;
private String alias;
@@ -36,7 +29,6 @@ final class FormulaPropertyPath {
FormulaPropertyPath(BeanDescriptor<?> descriptor, String formula, String path) {
this.descriptor = descriptor;
this.formula = formula;
int openBracket = formula.indexOf('(');
int closeBracket = formula.lastIndexOf(')');
if (openBracket == -1 || closeBracket == -1) {
@@ -49,7 +41,6 @@ final class FormulaPropertyPath {
// ::CastType as foo
parseSuffix(formula.substring(closeBracket + 1).trim());
}
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
String parsed = parser.parse(internalExpression);
if (path != null) {
@@ -105,7 +96,6 @@ final class FormulaPropertyPath {
}
STreeProperty build() {
if (cast != null) {
ScalarType<?> scalarType = descriptor.getScalarType(cast);
if (scalarType == null) {
@@ -122,7 +112,6 @@ final class FormulaPropertyPath {
if (firstProp == null) {
throw new IllegalStateException("unable to determine scalarType of formula [" + formula + "] for type " + descriptor + " - maybe use a cast like ::String ?");
}
// determine scalarType based on first property found by parser
final BeanProperty property = firstProp.getBeanProperty();
if (!property.isAssocId()) {
@@ -133,13 +122,12 @@ final class FormulaPropertyPath {
}
private DynamicPropertyAggregationFormula create(ScalarType<?> scalarType) {
String logicalName = logicalName();
return new DynamicPropertyAggregationFormula(logicalName, scalarType, parsedAggregation, isAggregate(), target(logicalName), alias);
}
@SuppressWarnings("rawtypes")
private DynamicPropertyAggregationFormula createManyToOne(BeanProperty property) {
String logicalName = logicalName();
return new DynamicPropertyAggregationFormulaMTO((BeanPropertyAssocOne) property, logicalName, parsedAggregation, isAggregate(), target(logicalName), alias);
}
@@ -46,19 +46,16 @@ public final class InheritInfo {
this.discriminatorColumn = InternString.intern(deploy.getColumnName(parent));
this.discriminatorValue = deploy.getDiscriminatorObjectValue();
this.discriminatorStringValue = deploy.getDiscriminatorStringValue();
this.discriminatorType = deploy.getDiscriminatorType(parent);
this.discriminatorLength = deploy.getColumnLength(parent);
this.columnDefn = deploy.getColumnDefn();
this.where = InternString.intern(deploy.getWhere());
if (r == null) {
// this is a root node
root = this;
discMap = new HashMap<>();
typeMap = new HashMap<>();
registerWithRoot(this);
} else {
this.root = r;
// register with the root node...
@@ -12,20 +12,14 @@ public final class TableJoinColumn {
* The local database column name.
*/
private final String localDbColumn;
private final String localSqlFormula;
/**
* The foreign database column name.
*/
private final String foreignDbColumn;
private final String foreignSqlFormula;
private final boolean insertable;
private final boolean updateable;
/**
* Hash for including in a query plan
*/