mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge remote-tracking branch 'ebean/master' into pr/enh/formula_in_where_and_order_by
# Conflicts: # ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinOnFormula.java
This commit is contained in:
@@ -11,15 +11,15 @@ import java.util.List;
|
||||
*/
|
||||
public interface LoadBeanBuffer {
|
||||
|
||||
int getBatchSize();
|
||||
int batchSize();
|
||||
|
||||
List<EntityBeanIntercept> getBatch();
|
||||
List<EntityBeanIntercept> batch();
|
||||
|
||||
BeanDescriptor<?> getBeanDescriptor();
|
||||
BeanDescriptor<?> descriptor();
|
||||
|
||||
PersistenceContext getPersistenceContext();
|
||||
PersistenceContext persistenceContext();
|
||||
|
||||
String getFullPath();
|
||||
String fullPath();
|
||||
|
||||
void configureQuery(SpiQuery<?> query, String lazyLoadProperty);
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.CacheMode;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
import io.ebeaninternal.api.SpiQuery.Mode;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
@@ -19,77 +20,54 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
private final LoadBeanBuffer loadBuffer;
|
||||
private final String lazyLoadProperty;
|
||||
private final boolean loadCache;
|
||||
private boolean loadedFromCache;
|
||||
private final boolean alreadyLoaded;
|
||||
|
||||
/**
|
||||
* Construct for lazy load request.
|
||||
*/
|
||||
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
|
||||
this(LoadBuffer, null, true, ebi.getLazyLoadProperty(), loadCache);
|
||||
this.loadedFromCache = ebi.isLoadedFromCache();
|
||||
public LoadBeanRequest(LoadBeanBuffer loadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
|
||||
this(loadBuffer, null, true, ebi.getLazyLoadProperty(), ebi.isLoaded(), loadCache || ebi.isLoadedFromCache());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct for secondary query.
|
||||
*/
|
||||
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, OrmQueryRequest<?> parentRequest) {
|
||||
this(LoadBuffer, parentRequest, false, null, false);
|
||||
public LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest) {
|
||||
this(loadBuffer, parentRequest, false, null, false, false);
|
||||
}
|
||||
|
||||
private LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest, boolean lazy,
|
||||
String lazyLoadProperty, boolean loadCache) {
|
||||
|
||||
String lazyLoadProperty, boolean alreadyLoaded, boolean loadCache) {
|
||||
super(parentRequest, lazy);
|
||||
this.loadBuffer = loadBuffer;
|
||||
this.batch = loadBuffer.getBatch();
|
||||
this.batch = loadBuffer.batch();
|
||||
this.lazyLoadProperty = lazyLoadProperty;
|
||||
this.alreadyLoaded = alreadyLoaded;
|
||||
this.loadCache = loadCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getBeanType() {
|
||||
return loadBuffer.getBeanDescriptor().getBeanType();
|
||||
public Class<?> beanType() {
|
||||
return loadBuffer.descriptor().type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the beans invoking lazy loading were previously loaded from cache.
|
||||
*/
|
||||
public boolean isLoadedFromCache() {
|
||||
return loadedFromCache;
|
||||
}
|
||||
|
||||
private boolean isLoadCache() {
|
||||
return loadCache;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "path:" + loadBuffer.getFullPath() + " batch:" + batch.size();
|
||||
public String description() {
|
||||
return loadBuffer.fullPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the batch of beans to actually load.
|
||||
*/
|
||||
public List<EntityBeanIntercept> getBatch() {
|
||||
public List<EntityBeanIntercept> batch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the load context.
|
||||
*/
|
||||
private LoadBeanBuffer getLoadContext() {
|
||||
return loadBuffer;
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return getLoadContext().getBatchSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of Id values for the beans in the lazy load buffer.
|
||||
*/
|
||||
public List<Object> getIdList() {
|
||||
List<Object> idList = new ArrayList<>();
|
||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = loadBuffer.descriptor();
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
idList.add(desc.getId(ebi.getOwner()));
|
||||
}
|
||||
@@ -100,16 +78,21 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
* Configure the query for lazy loading execution.
|
||||
*/
|
||||
public void configureQuery(SpiQuery<?> query, List<Object> idList) {
|
||||
query.setMode(SpiQuery.Mode.LAZYLOAD_BEAN);
|
||||
query.setPersistenceContext(loadBuffer.getPersistenceContext());
|
||||
String mode = isLazy() ? "+lazy" : "+query";
|
||||
query.setLoadDescription(mode, getDescription());
|
||||
|
||||
if (isLazy()) {
|
||||
// cascade the batch size (if set) for further lazy loading
|
||||
query.setLazyLoadBatchSize(getBatchSize());
|
||||
query.setMode(Mode.LAZYLOAD_BEAN);
|
||||
query.setPersistenceContext(loadBuffer.persistenceContext());
|
||||
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
|
||||
if (lazy) {
|
||||
query.setLazyLoadBatchSize(loadBuffer.batchSize());
|
||||
if (alreadyLoaded) {
|
||||
query.setBeanCacheMode(CacheMode.OFF);
|
||||
}
|
||||
} else {
|
||||
query.setBeanCacheMode(CacheMode.OFF);
|
||||
}
|
||||
loadBuffer.configureQuery(query, lazyLoadProperty);
|
||||
if (loadCache) {
|
||||
query.setBeanCacheMode(CacheMode.PUT);
|
||||
}
|
||||
if (idList.size() == 1) {
|
||||
query.where().idEq(idList.get(0));
|
||||
} else {
|
||||
@@ -122,13 +105,12 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
*/
|
||||
public void postLoad(List<?> list) {
|
||||
Set<Object> loadedIds = new HashSet<>();
|
||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = loadBuffer.descriptor();
|
||||
// collect Ids and maybe load bean cache
|
||||
for (Object bean : list) {
|
||||
EntityBean loadedBean = (EntityBean) bean;
|
||||
loadedIds.add(desc.getId(loadedBean));
|
||||
loadedIds.add(desc.id(bean));
|
||||
}
|
||||
if (isLoadCache()) {
|
||||
if (loadCache) {
|
||||
desc.cacheBeanPutAll(list);
|
||||
}
|
||||
if (lazyLoadProperty != null) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.CacheMode;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebeaninternal.server.core.BindPadding;
|
||||
@@ -47,96 +48,58 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getBeanType() {
|
||||
return loadContext.getBeanDescriptor().getBeanType();
|
||||
public Class<?> beanType() {
|
||||
return loadContext.getBeanDescriptor().type();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return "path:" + loadContext.getFullPath() + " size:" + batch.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the batch of collections to actually load.
|
||||
*/
|
||||
public List<BeanCollection<?>> getBatch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if lazy loading should only load the id values.
|
||||
* <p>
|
||||
* This for use when lazy loading is invoked on methods such as clear() and removeAll() where it
|
||||
* generally makes sense to only fetch the Id values as the other property information is not
|
||||
* used.
|
||||
*/
|
||||
private boolean isOnlyIds() {
|
||||
return onlyIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if we should load the Collection ids into the cache.
|
||||
*/
|
||||
private boolean isLoadCache() {
|
||||
return loadCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the batch size used for this load context.
|
||||
*/
|
||||
public int getBatchSize() {
|
||||
return loadContext.getBatchSize();
|
||||
public String description() {
|
||||
return loadContext.getFullPath();
|
||||
}
|
||||
|
||||
private List<Object> parentIdList(SpiEbeanServer server) {
|
||||
List<Object> idList = new ArrayList<>();
|
||||
BeanPropertyAssocMany<?> many = getMany();
|
||||
BeanPropertyAssocMany<?> many = many();
|
||||
for (BeanCollection<?> bc : batch) {
|
||||
idList.add(many.getParentId(bc.getOwnerBean()));
|
||||
idList.add(many.parentId(bc.getOwnerBean()));
|
||||
bc.setLoader(server); // don't use the load buffer again
|
||||
}
|
||||
if (many.getTargetDescriptor().isPadInExpression()) {
|
||||
if (many.targetDescriptor().isPadInExpression()) {
|
||||
BindPadding.padIds(idList);
|
||||
}
|
||||
return idList;
|
||||
}
|
||||
|
||||
private BeanPropertyAssocMany<?> getMany() {
|
||||
private BeanPropertyAssocMany<?> many() {
|
||||
return loadContext.getBeanProperty();
|
||||
}
|
||||
|
||||
public SpiQuery<?> createQuery(SpiEbeanServer server) {
|
||||
BeanPropertyAssocMany<?> many = getMany();
|
||||
BeanPropertyAssocMany<?> many = many();
|
||||
SpiQuery<?> query = many.newQuery(server);
|
||||
String orderBy = many.getLazyFetchOrderBy();
|
||||
String orderBy = many.lazyFetchOrderBy();
|
||||
if (orderBy != null) {
|
||||
query.order(orderBy);
|
||||
}
|
||||
|
||||
String extraWhere = many.getExtraWhere();
|
||||
String extraWhere = many.extraWhere();
|
||||
if (extraWhere != null) {
|
||||
// replace special ${ta} placeholder with the base table alias
|
||||
// which is always t0 and add the extra where clause
|
||||
query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_"));
|
||||
}
|
||||
|
||||
query.setLazyLoadForParents(many);
|
||||
many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
|
||||
query.setPersistenceContext(loadContext.getPersistenceContext());
|
||||
|
||||
String mode = isLazy() ? "+lazy" : "+query";
|
||||
query.setLoadDescription(mode, getDescription());
|
||||
|
||||
if (isLazy()) {
|
||||
// cascade the batch size (if set) for further lazy loading
|
||||
query.setLazyLoadBatchSize(getBatchSize());
|
||||
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
|
||||
if (lazy) {
|
||||
query.setLazyLoadBatchSize(loadContext.getBatchSize());
|
||||
} else {
|
||||
query.setBeanCacheMode(CacheMode.OFF);
|
||||
}
|
||||
|
||||
// potentially changes the joins and selected properties
|
||||
// potentially changes the joins, selected properties, cache mode
|
||||
loadContext.configureQuery(query);
|
||||
|
||||
if (isOnlyIds()) {
|
||||
// override to just select the Id values
|
||||
query.select(many.getTargetIdProperty());
|
||||
if (onlyIds) {
|
||||
// lazy loading invoked via clear() and removeAll()
|
||||
query.select(many.targetIdProperty());
|
||||
}
|
||||
return query;
|
||||
}
|
||||
@@ -146,7 +109,7 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
*/
|
||||
public void postLoad() {
|
||||
BeanDescriptor<?> desc = loadContext.getBeanDescriptor();
|
||||
BeanPropertyAssocMany<?> many = getMany();
|
||||
BeanPropertyAssocMany<?> many = many();
|
||||
// check for BeanCollection's that where never processed
|
||||
// in the +query or +lazy load due to no rows (predicates)
|
||||
for (BeanCollection<?> bc : batch) {
|
||||
@@ -156,9 +119,8 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
Object parentId = desc.getId(ownerBean);
|
||||
logger.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
||||
}
|
||||
} else if (isLoadCache() && many.isUseCache()) {
|
||||
Object parentId = desc.getId(bc.getOwnerBean());
|
||||
desc.cacheManyPropPut(many, bc, parentId);
|
||||
} else if (loadCache && many.isUseCache()) {
|
||||
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,22 +9,19 @@ import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
public abstract class LoadRequest {
|
||||
|
||||
protected final OrmQueryRequest<?> parentRequest;
|
||||
|
||||
protected final Transaction transaction;
|
||||
|
||||
protected final boolean lazy;
|
||||
|
||||
public LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
|
||||
|
||||
LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
|
||||
this.parentRequest = parentRequest;
|
||||
this.transaction = parentRequest == null ? null : parentRequest.getTransaction();
|
||||
this.transaction = parentRequest == null ? null : parentRequest.transaction();
|
||||
this.lazy = lazy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the associated bean type for this load request.
|
||||
*/
|
||||
public abstract Class<?> getBeanType();
|
||||
public abstract Class<?> beanType();
|
||||
|
||||
/**
|
||||
* Return true if this is a lazy load and false if it is a secondary query.
|
||||
@@ -39,7 +36,7 @@ public abstract class LoadRequest {
|
||||
* Lazy loading queries run in their own transaction.
|
||||
* </p>
|
||||
*/
|
||||
public Transaction getTransaction() {
|
||||
public Transaction transaction() {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
@@ -48,6 +45,6 @@ public abstract class LoadRequest {
|
||||
* So one of - findIterate(), findEach(), findEachWhile() or findVisit().
|
||||
*/
|
||||
public boolean isParentFindIterate() {
|
||||
return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE;
|
||||
return parentRequest != null && parentRequest.query().getType() == SpiQuery.Type.ITERATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,15 +51,15 @@ public final class ManyWhereJoins implements Serializable {
|
||||
*/
|
||||
public void add(ElPropertyDeploy elProp) {
|
||||
|
||||
String join = elProp.getElPrefix();
|
||||
BeanProperty p = elProp.getBeanProperty();
|
||||
String join = elProp.elPrefix();
|
||||
BeanProperty p = elProp.beanProperty();
|
||||
if (p instanceof BeanPropertyAssocMany<?>) {
|
||||
join = addManyToJoin(join, p.getName());
|
||||
join = addManyToJoin(join, p.name());
|
||||
}
|
||||
if (join != null) {
|
||||
addJoin(join);
|
||||
if (p != null) {
|
||||
String secondaryTableJoinPrefix = p.getSecondaryTableJoinPrefix();
|
||||
String secondaryTableJoinPrefix = p.secondaryTableJoinPrefix();
|
||||
if (secondaryTableJoinPrefix != null) {
|
||||
addJoin(join + "." + secondaryTableJoinPrefix);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ public interface SpiBeanTypeManager {
|
||||
/**
|
||||
* Return the bean type for the given entity class.
|
||||
*/
|
||||
SpiBeanType getBeanType(Class<?> entityType);
|
||||
SpiBeanType beanType(Class<?> entityType);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,6 @@ public interface SpiDtoQuery<T> extends DtoQuery<T>, SpiSqlBinding {
|
||||
*/
|
||||
boolean isRelaxedMode();
|
||||
|
||||
/**
|
||||
* Return the label for the query.
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* Return the label with fallback to profile location label.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.event.readaudit.ReadAuditLogger;
|
||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.plugin.SpiServer;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
import io.ebeaninternal.server.core.SpiResultSet;
|
||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||
@@ -23,7 +24,7 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* Service Provider extension to EbeanServer.
|
||||
*/
|
||||
public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollectionLoader {
|
||||
public interface SpiEbeanServer extends SpiServer, ExtendedServer, EbeanServer, BeanCollectionLoader {
|
||||
|
||||
/**
|
||||
* Return true if the L2 cache has been disabled.
|
||||
@@ -50,16 +51,6 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
||||
*/
|
||||
Object currentTenantId();
|
||||
|
||||
/**
|
||||
* Return the server configuration.
|
||||
*/
|
||||
DatabaseConfig getServerConfig();
|
||||
|
||||
/**
|
||||
* Return the DatabasePlatform for this server.
|
||||
*/
|
||||
DatabasePlatform getDatabasePlatform();
|
||||
|
||||
/**
|
||||
* Create an object to represent the current CallStack.
|
||||
* <p>
|
||||
@@ -72,7 +63,7 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
||||
/**
|
||||
* Return the PersistenceContextScope to use defined at query or server level.
|
||||
*/
|
||||
PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query);
|
||||
PersistenceContextScope persistenceContextScope(SpiQuery<?> query);
|
||||
|
||||
/**
|
||||
* Clear the query execution statistics.
|
||||
@@ -82,32 +73,32 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
||||
/**
|
||||
* Return the transaction manager.
|
||||
*/
|
||||
SpiTransactionManager getTransactionManager();
|
||||
SpiTransactionManager transactionManager();
|
||||
|
||||
/**
|
||||
* Return all the descriptors.
|
||||
*/
|
||||
List<BeanDescriptor<?>> getBeanDescriptors();
|
||||
List<BeanDescriptor<?>> descriptors();
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptor for a given type of bean.
|
||||
*/
|
||||
<T> BeanDescriptor<T> getBeanDescriptor(Class<T> type);
|
||||
<T> BeanDescriptor<T> descriptor(Class<T> type);
|
||||
|
||||
/**
|
||||
* Return BeanDescriptor using it's unique id.
|
||||
*/
|
||||
BeanDescriptor<?> getBeanDescriptorById(String className);
|
||||
BeanDescriptor<?> descriptorById(String className);
|
||||
|
||||
/**
|
||||
* Return BeanDescriptor using it's unique doc store queueId.
|
||||
*/
|
||||
BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId);
|
||||
BeanDescriptor<?> descriptorByQueueId(String queueId);
|
||||
|
||||
/**
|
||||
* Return BeanDescriptors mapped to this table.
|
||||
*/
|
||||
List<BeanDescriptor<?>> getBeanDescriptors(String tableName);
|
||||
List<BeanDescriptor<?>> descriptors(String tableName);
|
||||
|
||||
/**
|
||||
* Process committed changes from another framework.
|
||||
@@ -179,7 +170,7 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
||||
/**
|
||||
* Return the default batch size for lazy loading.
|
||||
*/
|
||||
int getLazyLoadBatchSize();
|
||||
int lazyLoadBatchSize();
|
||||
|
||||
/**
|
||||
* Return true if the type is known as an Entity or Xml type or a List Set or
|
||||
@@ -190,18 +181,18 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
||||
/**
|
||||
* Return the ReadAuditLogger to use for logging all read audit events.
|
||||
*/
|
||||
ReadAuditLogger getReadAuditLogger();
|
||||
ReadAuditLogger readAuditLogger();
|
||||
|
||||
/**
|
||||
* Return the ReadAuditPrepare used to populate the read audit events with
|
||||
* user context information (user id, user ip address etc).
|
||||
*/
|
||||
ReadAuditPrepare getReadAuditPrepare();
|
||||
ReadAuditPrepare readAuditPrepare();
|
||||
|
||||
/**
|
||||
* Return the DataTimeZone to use when reading/writing timestamps via JDBC.
|
||||
*/
|
||||
DataTimeZone getDataTimeZone();
|
||||
DataTimeZone dataTimeZone();
|
||||
|
||||
/**
|
||||
* Check for slow query event.
|
||||
|
||||
@@ -44,8 +44,4 @@ public interface SpiExpressionList<T> extends ExpressionList<T>, SpiExpression {
|
||||
// do nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply property prefix when filterMany expressions included in main query.
|
||||
*/
|
||||
void prefixProperty(String path);
|
||||
}
|
||||
|
||||
@@ -318,8 +318,8 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return transaction.getConnection();
|
||||
public Connection connection() {
|
||||
return transaction.connection();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
|
||||
}
|
||||
|
||||
public void add(TableIUD newTableIUD) {
|
||||
TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD);
|
||||
TableIUD existingTableIUD = map.put(newTableIUD.tableName(), newTableIUD);
|
||||
if (existingTableIUD != null) {
|
||||
newTableIUD.add(existingTableIUD);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
public String tableName() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -15,33 +15,33 @@ 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();
|
||||
int propertyIndex = idProperty.propertyIndex();
|
||||
if (ebi.isLoadedProperty(propertyIndex)) {
|
||||
data.put(idProperty.getName(), idProperty.getCacheDataValue(bean));
|
||||
data.put(idProperty.name(), idProperty.getCacheDataValue(bean));
|
||||
}
|
||||
}
|
||||
|
||||
// extract all the non-many properties
|
||||
final boolean dirty = ebi.isDirty();
|
||||
for (BeanProperty prop : desc.propertiesNonMany()) {
|
||||
if (dirty && ebi.isDirtyProperty(prop.getPropertyIndex())) {
|
||||
data.put(prop.getName(), prop.getCacheDataValueOrig(ebi));
|
||||
} else if (ebi.isLoadedProperty(prop.getPropertyIndex())) {
|
||||
data.put(prop.getName(), prop.getCacheDataValue(bean));
|
||||
if (dirty && ebi.isDirtyProperty(prop.propertyIndex())) {
|
||||
data.put(prop.name(), prop.getCacheDataValueOrig(ebi));
|
||||
} else if (ebi.isLoadedProperty(prop.propertyIndex())) {
|
||||
data.put(prop.name(), prop.getCacheDataValue(bean));
|
||||
}
|
||||
}
|
||||
|
||||
for (BeanPropertyAssocMany<?> prop : desc.propertiesMany()) {
|
||||
if (prop.isElementCollection()) {
|
||||
data.put(prop.getName(), prop.getCacheDataValue(bean));
|
||||
data.put(prop.name(), prop.getCacheDataValue(bean));
|
||||
}
|
||||
}
|
||||
|
||||
long version = desc.getVersion(bean);
|
||||
EntityBean sharableBean = createSharableBean(desc, bean, ebi);
|
||||
return new CachedBeanData(sharableBean, desc.getDiscValue(), data, version);
|
||||
return new CachedBeanData(sharableBean, desc.discValue(), data, version);
|
||||
}
|
||||
|
||||
private static EntityBean createSharableBean(BeanDescriptor<?> desc, EntityBean bean, EntityBeanIntercept beanEbi) {
|
||||
@@ -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);
|
||||
|
||||
+6
-6
@@ -13,9 +13,9 @@ public final class CachedBeanDataToBean {
|
||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||
// any future lazy loading skips L2 bean cache
|
||||
ebi.setLoadedFromCache(true);
|
||||
BeanProperty idProperty = desc.getIdProperty();
|
||||
if (desc.getInheritInfo() != null) {
|
||||
desc = desc.getInheritInfo().readType(bean.getClass()).desc();
|
||||
BeanProperty idProperty = desc.idProperty();
|
||||
if (desc.inheritInfo() != null) {
|
||||
desc = desc.inheritInfo().readType(bean.getClass()).desc();
|
||||
}
|
||||
if (idProperty != null) {
|
||||
// load the id property
|
||||
@@ -36,9 +36,9 @@ public final class CachedBeanDataToBean {
|
||||
}
|
||||
|
||||
private static void loadProperty(EntityBean bean, CachedBeanData cacheBeanData, EntityBeanIntercept ebi, BeanProperty prop, PersistenceContext context) {
|
||||
if (cacheBeanData.isLoaded(prop.getName())) {
|
||||
if (!ebi.isLoadedProperty(prop.getPropertyIndex())) {
|
||||
Object value = cacheBeanData.getData(prop.getName());
|
||||
if (cacheBeanData.isLoaded(prop.name())) {
|
||||
if (!ebi.isLoadedProperty(prop.propertyIndex())) {
|
||||
Object value = cacheBeanData.getData(prop.name());
|
||||
prop.setCacheDataValue(bean, value, context);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -27,7 +27,7 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalL2Caching() {
|
||||
public boolean localL2Caching() {
|
||||
return cacheManager.isLocalL2Caching();
|
||||
}
|
||||
|
||||
@@ -37,37 +37,37 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabledRegions(String regions) {
|
||||
public void enabledRegions(String regions) {
|
||||
cacheManager.setEnabledRegions(regions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheRegion getRegion(String region) {
|
||||
public ServerCacheRegion region(String region) {
|
||||
return cacheManager.getRegion(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllRegionsEnabled(boolean enabled) {
|
||||
public void allRegionsEnabled(boolean enabled) {
|
||||
cacheManager.setAllRegionsEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCache getNaturalKeyCache(Class<?> beanType) {
|
||||
public ServerCache naturalKeyCache(Class<?> beanType) {
|
||||
return cacheManager.getNaturalKeyCache(beanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCache getBeanCache(Class<?> beanType) {
|
||||
public ServerCache beanCache(Class<?> beanType) {
|
||||
return cacheManager.getBeanCache(beanType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
|
||||
public ServerCache collectionIdsCache(Class<?> beanType, String propertyName) {
|
||||
return cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCache getQueryCache(Class<?> beanType) {
|
||||
public ServerCache queryCache(Class<?> beanType) {
|
||||
return cacheManager.getQueryCache(beanType);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -65,17 +65,17 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
|
||||
List<String> enabled = new ArrayList<>();
|
||||
|
||||
for (SpiCacheRegion region : regionMap.values()) {
|
||||
if (enabledRegionNames.contains(region.getName())) {
|
||||
enabled.add(region.getName());
|
||||
if (enabledRegionNames.contains(region.name())) {
|
||||
enabled.add(region.name());
|
||||
if (!region.isEnabled()) {
|
||||
region.setEnabled(true);
|
||||
log.debug("Cache region[{}] enabled", region.getName());
|
||||
log.debug("Cache region[{}] enabled", region.name());
|
||||
}
|
||||
} else {
|
||||
disabled.add(region.getName());
|
||||
disabled.add(region.name());
|
||||
if (region.isEnabled()) {
|
||||
region.setEnabled(false);
|
||||
log.debug("Cache region[{}] disabled", region.getName());
|
||||
log.debug("Cache region[{}] disabled", region.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
||||
@Override
|
||||
public void configure(SpiServer server) {
|
||||
jsonBuilder = new ChangeJsonBuilder();
|
||||
Properties properties = server.getServerConfig().getProperties();
|
||||
Properties properties = server.config().getProperties();
|
||||
if (properties != null) {
|
||||
String bufferSize = properties.getProperty("ebean.changeLog.bufferSize");
|
||||
if (bufferSize != null) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ClusterManager implements ServerLookup {
|
||||
public void registerServer(EbeanServer server) {
|
||||
lock.lock();
|
||||
try {
|
||||
serverMap.put(server.getName(), server);
|
||||
serverMap.put(server.name(), server);
|
||||
if (!started) {
|
||||
startup();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
|
||||
int firstRow = query.getFirstRow();
|
||||
int maxRows = query.getMaxRows();
|
||||
if (firstRow > 0 || maxRows > 0) {
|
||||
return server.getDatabasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
|
||||
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -14,21 +14,13 @@ public abstract class BeanRequest {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(BeanRequest.class);
|
||||
|
||||
/**
|
||||
* The server processing the request.
|
||||
*/
|
||||
protected final SpiEbeanServer ebeanServer;
|
||||
|
||||
/**
|
||||
* The transaction this is part of.
|
||||
*/
|
||||
protected final SpiEbeanServer server;
|
||||
protected SpiTransaction transaction;
|
||||
|
||||
protected boolean createdTransaction;
|
||||
|
||||
public BeanRequest(SpiEbeanServer ebeanServer, SpiTransaction t) {
|
||||
this.ebeanServer = ebeanServer;
|
||||
this.transaction = t;
|
||||
public BeanRequest(SpiEbeanServer server, SpiTransaction transaction) {
|
||||
this.server = server;
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +28,6 @@ public abstract class BeanRequest {
|
||||
* <p>
|
||||
* A transaction may have been passed in or active in the thread local. If
|
||||
* not then create one implicitly to handle the request.
|
||||
* </p>
|
||||
*
|
||||
* @return True if a transaction was set (from current or created).
|
||||
*/
|
||||
@@ -44,10 +35,10 @@ public abstract class BeanRequest {
|
||||
if (transaction != null) {
|
||||
return false;
|
||||
}
|
||||
transaction = ebeanServer.currentServerTransaction();
|
||||
transaction = server.currentServerTransaction();
|
||||
if (transaction == null || !transaction.isActive()) {
|
||||
// create an implicit transaction to execute this query
|
||||
transaction = ebeanServer.beginServerTransaction();
|
||||
transaction = server.beginServerTransaction();
|
||||
createdTransaction = true;
|
||||
}
|
||||
return true;
|
||||
@@ -58,7 +49,7 @@ public abstract class BeanRequest {
|
||||
*/
|
||||
public void commitTransIfRequired() {
|
||||
if (createdTransaction) {
|
||||
ebeanServer.commitTransaction();
|
||||
server.commitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +59,7 @@ public abstract class BeanRequest {
|
||||
public void rollbackTransIfRequired() {
|
||||
if (createdTransaction) {
|
||||
try {
|
||||
ebeanServer.endTransaction();
|
||||
server.endTransaction();
|
||||
} catch (Exception e) {
|
||||
// Just log this and carry on. A previous exception has been
|
||||
// thrown and if this rollback throws exception it likely means
|
||||
@@ -83,7 +74,7 @@ public abstract class BeanRequest {
|
||||
*/
|
||||
public void clearTransIfRequired() {
|
||||
if (createdTransaction) {
|
||||
ebeanServer.clearServerTransaction();
|
||||
server.clearServerTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,45 +83,45 @@ public abstract class BeanRequest {
|
||||
* BeanController and BeanFinder.
|
||||
*/
|
||||
public EbeanServer getEbeanServer() {
|
||||
return ebeanServer;
|
||||
return server;
|
||||
}
|
||||
|
||||
public SpiEbeanServer getServer() {
|
||||
return ebeanServer;
|
||||
public SpiEbeanServer server() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Transaction associated with this request.
|
||||
*/
|
||||
public SpiTransaction getTransaction() {
|
||||
public SpiTransaction transaction() {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transaction to use for this request.
|
||||
*/
|
||||
public void setTransaction(SpiTransaction transaction) {
|
||||
public void transaction(SpiTransaction transaction) {
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if SQL should be logged for this transaction.
|
||||
*/
|
||||
public boolean isLogSql() {
|
||||
public boolean logSql() {
|
||||
return transaction.isLogSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if SUMMARY information should be logged for this transaction.
|
||||
*/
|
||||
public boolean isLogSummary() {
|
||||
public boolean logSummary() {
|
||||
return transaction.isLogSummary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DataTimeZone to use.
|
||||
*/
|
||||
public DataTimeZone getDataTimeZone() {
|
||||
return ebeanServer.getDataTimeZone();
|
||||
public DataTimeZone dataTimeZone() {
|
||||
return server.dataTimeZone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ final class DScriptRunner implements ScriptRunner {
|
||||
|
||||
DScriptRunner(SpiEbeanServer server) {
|
||||
this.server = server;
|
||||
this.platformName = this.server.getDatabasePlatform().getPlatform().base().name();
|
||||
this.platformName = this.server.platform().base().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,7 +102,7 @@ final class DScriptRunner implements ScriptRunner {
|
||||
|
||||
private Connection obtainConnection() {
|
||||
try {
|
||||
return server.getDataSource().getConnection();
|
||||
return server.dataSource().getConnection();
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException("Failed to obtain connection to run script", e);
|
||||
}
|
||||
|
||||
@@ -35,19 +35,16 @@ final class DefaultBeanLoader {
|
||||
|
||||
DefaultBeanLoader(DefaultServer server) {
|
||||
this.server = server;
|
||||
this.onIterateUseExtraTxn = server.getDatabasePlatform().useExtraTransactionOnIterateSecondaryQueries();
|
||||
this.onIterateUseExtraTxn = server.databasePlatform().useExtraTransactionOnIterateSecondaryQueries();
|
||||
}
|
||||
|
||||
void loadMany(LoadManyRequest loadRequest) {
|
||||
SpiQuery<?> query = loadRequest.createQuery(server);
|
||||
executeQuery(loadRequest, query);
|
||||
executeQuery(loadRequest, loadRequest.createQuery(server));
|
||||
loadRequest.postLoad();
|
||||
}
|
||||
|
||||
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
|
||||
EntityBean parentBean = bc.getOwnerBean();
|
||||
String propertyName = bc.getPropertyName();
|
||||
loadManyInternal(parentBean, propertyName, null, false, onlyIds);
|
||||
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), null, false, onlyIds);
|
||||
}
|
||||
|
||||
void refreshMany(EntityBean parentBean, String propertyName) {
|
||||
@@ -57,8 +54,8 @@ final class DefaultBeanLoader {
|
||||
private void loadManyInternal(EntityBean parentBean, String propertyName, Transaction t, boolean refresh, boolean onlyIds) {
|
||||
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
|
||||
PersistenceContext pc = ebi.getPersistenceContext();
|
||||
BeanDescriptor<?> parentDesc = server.getBeanDescriptor(parentBean.getClass());
|
||||
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.getBeanProperty(propertyName);
|
||||
BeanDescriptor<?> parentDesc = server.descriptor(parentBean.getClass());
|
||||
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.beanProperty(propertyName);
|
||||
BeanCollection<?> beanCollection = null;
|
||||
ExpressionList<?> filterMany = null;
|
||||
|
||||
@@ -69,12 +66,10 @@ final class DefaultBeanLoader {
|
||||
}
|
||||
|
||||
Object parentId = parentDesc.getId(parentBean);
|
||||
|
||||
if (pc == null) {
|
||||
pc = new DefaultPersistenceContext();
|
||||
parentDesc.contextPut(pc, parentId, parentBean);
|
||||
}
|
||||
|
||||
boolean useManyIdCache = beanCollection != null && parentDesc.isManyPropCaching() && many.isUseCache();
|
||||
if (useManyIdCache) {
|
||||
Boolean readOnly = null;
|
||||
@@ -86,8 +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);
|
||||
@@ -97,23 +91,21 @@ final class DefaultBeanLoader {
|
||||
query.setLoadDescription("+lazy", null);
|
||||
}
|
||||
|
||||
query.select(parentDesc.getIdBinder().getIdProperty());
|
||||
|
||||
query.select(parentDesc.idBinder().getIdProperty());
|
||||
if (onlyIds) {
|
||||
query.fetch(many.getName(), many.getTargetIdProperty());
|
||||
query.fetch(many.name(), many.targetIdProperty());
|
||||
} else {
|
||||
query.fetch(many.getName());
|
||||
query.fetch(many.name());
|
||||
}
|
||||
if (filterMany != null) {
|
||||
query.setFilterMany(many.getName(), filterMany);
|
||||
query.setFilterMany(many.name(), filterMany);
|
||||
}
|
||||
|
||||
query.where().idEq(parentId);
|
||||
query.setUseCache(false);
|
||||
query.setBeanCacheMode(CacheMode.OFF);
|
||||
query.setMode(Mode.LAZYLOAD_MANY);
|
||||
query.setLazyLoadManyPath(many.getName());
|
||||
query.setLazyLoadManyPath(many.name());
|
||||
query.setPersistenceContext(pc);
|
||||
|
||||
if (ebi.isReadOnly()) {
|
||||
query.setReadOnly(true);
|
||||
}
|
||||
@@ -134,7 +126,7 @@ final class DefaultBeanLoader {
|
||||
* Load a batch of beans for +query or +lazy loading.
|
||||
*/
|
||||
void loadBean(LoadBeanRequest loadRequest) {
|
||||
List<EntityBeanIntercept> batch = loadRequest.getBatch();
|
||||
List<EntityBeanIntercept> batch = loadRequest.batch();
|
||||
if (batch.isEmpty()) {
|
||||
throw new RuntimeException("Nothing in batch?");
|
||||
}
|
||||
@@ -145,12 +137,8 @@ final class DefaultBeanLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
SpiQuery<?> query = server.createQuery(loadRequest.getBeanType());
|
||||
SpiQuery<?> query = server.createQuery(loadRequest.beanType());
|
||||
loadRequest.configureQuery(query, idList);
|
||||
if (loadRequest.isLoadedFromCache()) {
|
||||
query.setBeanCacheMode(CacheMode.PUT);
|
||||
}
|
||||
|
||||
List<?> list = executeQuery(loadRequest, query);
|
||||
loadRequest.postLoad(list);
|
||||
}
|
||||
@@ -168,7 +156,7 @@ final class DefaultBeanLoader {
|
||||
extraTxn.end();
|
||||
}
|
||||
} else {
|
||||
return server.findList(query, loadRequest.getTransaction());
|
||||
return server.findList(query, loadRequest.transaction());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,12 +176,11 @@ final class DefaultBeanLoader {
|
||||
pc = null;
|
||||
}
|
||||
|
||||
BeanDescriptor<?> desc = server.getBeanDescriptor(bean.getClass());
|
||||
if (EntityType.EMBEDDED == desc.getEntityType()) {
|
||||
BeanDescriptor<?> desc = server.descriptor(bean.getClass());
|
||||
if (EntityType.EMBEDDED == desc.entityType()) {
|
||||
// lazy loading on an embedded bean property
|
||||
EntityBean embeddedOwner = (EntityBean) ebi.getEmbeddedOwner();
|
||||
int ownerIndex = ebi.getEmbeddedOwnerIndex();
|
||||
refreshBeanInternal(embeddedOwner, mode, ownerIndex);
|
||||
refreshBeanInternal(embeddedOwner, mode, ebi.getEmbeddedOwnerIndex());
|
||||
}
|
||||
|
||||
Object id = desc.getId(bean);
|
||||
@@ -216,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();
|
||||
@@ -235,7 +222,7 @@ final class DefaultBeanLoader {
|
||||
query.setId(id);
|
||||
if (embeddedOwnerIndex > -1 || mode == Mode.REFRESH_BEAN) {
|
||||
// make sure the query doesn't use the cache
|
||||
query.setUseCache(false);
|
||||
query.setBeanCacheMode(CacheMode.OFF);
|
||||
}
|
||||
if (ebi.isReadOnly()) {
|
||||
query.setReadOnly(true);
|
||||
@@ -249,8 +236,7 @@ final class DefaultBeanLoader {
|
||||
|
||||
Object dbBean = query.findOne();
|
||||
if (dbBean == null) {
|
||||
String msg = "Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.getBeanType() + "]";
|
||||
throw new EntityNotFoundException(msg);
|
||||
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
|
||||
}
|
||||
desc.resetManyProperties(dbBean);
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ public final class DefaultBeanState implements BeanState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getLoadedProps() {
|
||||
public Set<String> loadedProps() {
|
||||
return intercept.getLoadedPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getChangedProps() {
|
||||
public Set<String> changedProps() {
|
||||
return intercept.getDirtyPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ValuePair> getDirtyValues() {
|
||||
public Map<String, ValuePair> dirtyValues() {
|
||||
return intercept.getDirtyValues();
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ public final class DefaultBeanState implements BeanState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Exception> getLoadErrors() {
|
||||
public Map<String, Exception> loadErrors() {
|
||||
return intercept.getLoadErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortOrder() {
|
||||
public int sortOrder() {
|
||||
return intercept.getSortOrder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.CallableSql;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Database;
|
||||
import io.ebeaninternal.api.BindParams;
|
||||
import io.ebeaninternal.api.BindParams.Param;
|
||||
import io.ebeaninternal.api.SpiCallableSql;
|
||||
@@ -9,39 +9,23 @@ import io.ebeaninternal.api.TransactionEventTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
||||
final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
||||
|
||||
private static final long serialVersionUID = 8984272253185424701L;
|
||||
|
||||
private transient final EbeanServer server;
|
||||
|
||||
/**
|
||||
* The callable sql.
|
||||
*/
|
||||
private String sql;
|
||||
|
||||
/**
|
||||
* To display in the transaction log to help identify the procedure.
|
||||
*/
|
||||
private String label;
|
||||
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* Holds the table modification information. On commit this information is
|
||||
* used to manage the cache etc.
|
||||
*/
|
||||
private final TransactionEventTable transactionEvent = new TransactionEventTable();
|
||||
|
||||
private final BindParams bindParameters = new BindParams();
|
||||
private transient final Database server;
|
||||
private String sql;
|
||||
private String label;
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* Create with callable sql.
|
||||
*/
|
||||
public DefaultCallableSql(EbeanServer server, String sql) {
|
||||
DefaultCallableSql(Database server, String sql) {
|
||||
this.server = server;
|
||||
this.sql = sql;
|
||||
}
|
||||
@@ -108,13 +92,12 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeOverride(CallableStatement cstmt) throws SQLException {
|
||||
public boolean executeOverride(CallableStatement statement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
|
||||
transactionEvent.add(tableName, inserts, updates, deletes);
|
||||
return this;
|
||||
}
|
||||
@@ -122,7 +105,7 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
||||
/**
|
||||
* Return the TransactionEvent which holds the table modification
|
||||
* information for this CallableSql. This information is merged into the
|
||||
* transaction after the transaction is commited.
|
||||
* transaction after the transaction is committed.
|
||||
*/
|
||||
@Override
|
||||
public TransactionEventTable getTransactionEventTable() {
|
||||
|
||||
@@ -15,7 +15,7 @@ final class DefaultQueryPlanListener implements QueryPlanListener {
|
||||
@Override
|
||||
public void process(QueryPlanCapture capture) {
|
||||
// better to log this in JSON form?
|
||||
String dbName = capture.getDatabase().getName();
|
||||
String dbName = capture.getDatabase().name();
|
||||
for (MetaQueryPlan plan : capture.getPlans()) {
|
||||
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
||||
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||
|
||||
@@ -129,16 +129,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -295,7 +286,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLazyLoadBatchSize() {
|
||||
public int lazyLoadBatchSize() {
|
||||
return lazyLoadBatchSize;
|
||||
}
|
||||
|
||||
@@ -305,12 +296,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseConfig getServerConfig() {
|
||||
public DatabaseConfig config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabasePlatform getDatabasePlatform() {
|
||||
public DatabasePlatform databasePlatform() {
|
||||
return databasePlatform;
|
||||
}
|
||||
|
||||
@@ -320,57 +311,57 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTimeZone getDataTimeZone() {
|
||||
public DataTimeZone dataTimeZone() {
|
||||
return dataTimeZone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaInfoManager getMetaInfoManager() {
|
||||
public MetaInfoManager metaInfo() {
|
||||
return metaInfoManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getPlatform() {
|
||||
public Platform platform() {
|
||||
return databasePlatform.getPlatform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiServer getPluginApi() {
|
||||
public SpiServer pluginApi() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackgroundExecutor getBackgroundExecutor() {
|
||||
public BackgroundExecutor backgroundExecutor() {
|
||||
return backgroundExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionFactory getExpressionFactory() {
|
||||
public ExpressionFactory expressionFactory() {
|
||||
return expressionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoTune getAutoTune() {
|
||||
public AutoTune autoTune() {
|
||||
return autoTuneService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource() {
|
||||
public DataSource dataSource() {
|
||||
return transactionManager.getDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getReadOnlyDataSource() {
|
||||
public DataSource readOnlyDataSource() {
|
||||
return transactionManager.getReadOnlyDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadAuditPrepare getReadAuditPrepare() {
|
||||
public ReadAuditPrepare readAuditPrepare() {
|
||||
return readAuditPrepare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadAuditLogger getReadAuditLogger() {
|
||||
public ReadAuditLogger readAuditLogger() {
|
||||
return readAuditLogger;
|
||||
}
|
||||
|
||||
@@ -381,7 +372,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (encryptKeyManager != null) {
|
||||
encryptKeyManager.initialise();
|
||||
}
|
||||
serverCacheManager.setEnabledRegions(config.getEnabledL2Regions());
|
||||
serverCacheManager.enabledRegions(config.getEnabledL2Regions());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,7 +490,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Return the server name.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@@ -519,7 +510,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanState getBeanState(Object bean) {
|
||||
public BeanState beanState(Object bean) {
|
||||
if (bean instanceof EntityBean) {
|
||||
return new DefaultBeanState((EntityBean) bean);
|
||||
}
|
||||
@@ -538,7 +529,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheManager getServerCacheManager() {
|
||||
public ServerCacheManager cacheManager() {
|
||||
return serverCacheManager;
|
||||
}
|
||||
|
||||
@@ -595,7 +586,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(a.getClass());
|
||||
BeanDescriptor<?> desc = descriptor(a.getClass());
|
||||
return DiffHelp.diff(a, b, desc);
|
||||
}
|
||||
|
||||
@@ -628,14 +619,14 @@ 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(descriptor(type).baseTable());
|
||||
}
|
||||
truncate(tableNames.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void truncate(String... tables) {
|
||||
try (Connection connection = getDataSource().getConnection()) {
|
||||
try (Connection connection = dataSource().getConnection()) {
|
||||
for (String table : tables) {
|
||||
executeSql(connection, databasePlatform.truncateStatement(table));
|
||||
}
|
||||
@@ -659,7 +650,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
*/
|
||||
@Override
|
||||
public void clearQueryStatistics() {
|
||||
for (BeanDescriptor<?> desc : getBeanDescriptors()) {
|
||||
for (BeanDescriptor<?> desc : descriptors()) {
|
||||
desc.clearQueryStatistics();
|
||||
}
|
||||
}
|
||||
@@ -674,7 +665,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
*/
|
||||
@Override
|
||||
public <T> T createEntityBean(Class<T> type) {
|
||||
return getBeanDescriptor(type).createBean();
|
||||
return descriptor(type).createBean();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -687,11 +678,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public <T> T getReference(Class<T> type, Object id) {
|
||||
public <T> T reference(Class<T> type, Object id) {
|
||||
if (id == null) {
|
||||
throw new NullPointerException("The id is null");
|
||||
}
|
||||
BeanDescriptor desc = getBeanDescriptor(type);
|
||||
BeanDescriptor desc = descriptor(type);
|
||||
id = desc.convertId(id);
|
||||
PersistenceContext pc = null;
|
||||
SpiTransaction t = transactionManager.getActive();
|
||||
@@ -703,17 +694,17 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
}
|
||||
|
||||
InheritInfo inheritInfo = desc.getInheritInfo();
|
||||
InheritInfo inheritInfo = desc.inheritInfo();
|
||||
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);
|
||||
}
|
||||
// we actually need to do a query because we don't know the type without the discriminator
|
||||
// value, just select the id property and discriminator column (auto added)
|
||||
return find(type).select(idProp.getName()).setId(id).findOne();
|
||||
return find(type).select(idProp.name()).setId(id).findOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -852,7 +843,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public Object nextId(Class<?> beanType) {
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<?> desc = descriptor(beanType);
|
||||
return desc.nextId(null);
|
||||
}
|
||||
|
||||
@@ -871,7 +862,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
// use first bean in the list as the correct type
|
||||
Class<T> beanType = (Class<T>) list.get(0).getClass();
|
||||
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> beanDescriptor = descriptor(beanType);
|
||||
if (beanDescriptor == null) {
|
||||
throw new PersistenceException("BeanDescriptor not found, is [" + beanType + "] an entity bean?");
|
||||
}
|
||||
@@ -880,7 +871,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> Set<String> validateQuery(Query<T> query) {
|
||||
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(query.getBeanType());
|
||||
BeanDescriptor<T> beanDescriptor = descriptor(query.getBeanType());
|
||||
if (beanDescriptor == null) {
|
||||
throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?");
|
||||
}
|
||||
@@ -889,7 +880,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> Filter<T> filter(Class<T> beanType) {
|
||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> desc = descriptor(beanType);
|
||||
if (desc == null) {
|
||||
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
|
||||
throw new PersistenceException(m);
|
||||
@@ -899,7 +890,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
|
||||
BeanDescriptor<T> descriptor = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> descriptor = descriptor(beanType);
|
||||
if (descriptor == null) {
|
||||
throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found");
|
||||
}
|
||||
@@ -923,13 +914,27 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public void merge(Object bean, MergeOptions options, Transaction transaction) {
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
||||
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
executeInTrans((txn) -> persister.merge(desc, checkEntityBean(bean), options, txn), transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock(Object bean) {
|
||||
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(bean.getClass() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
Object id = desc.id(bean);
|
||||
Objects.requireNonNull(id, "Bean missing an @Id value which is required to lock");
|
||||
new DefaultOrmQuery<>(desc, this, expressionFactory)
|
||||
.setId(id)
|
||||
.withLock(Query.LockType.DEFAULT, Query.LockWait.NOWAIT)
|
||||
.findOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Query<T> find(Class<T> beanType) {
|
||||
return createQuery(beanType);
|
||||
@@ -937,7 +942,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
|
||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> desc = descriptor(beanType);
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
@@ -948,15 +953,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
|
||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> desc = descriptor(beanType);
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
String named = desc.getNamedQuery(namedQuery);
|
||||
String named = desc.namedQuery(namedQuery);
|
||||
if (named != null) {
|
||||
return createQuery(beanType, named);
|
||||
}
|
||||
SpiRawSql rawSql = desc.getNamedRawSql(namedQuery);
|
||||
SpiRawSql rawSql = desc.namedRawSql(namedQuery);
|
||||
if (rawSql != null) {
|
||||
DefaultOrmQuery<T> query = createQuery(beanType);
|
||||
query.setRawSql(rawSql);
|
||||
@@ -974,7 +979,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
|
||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<T> desc = descriptor(beanType);
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
@@ -983,12 +988,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
@Override
|
||||
public <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
|
||||
BeanDescriptor<?> desc = descriptor(beanType);
|
||||
if (desc == null) {
|
||||
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
|
||||
@@ -1134,14 +1139,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Return true if transactions PersistenceContext should be used.
|
||||
*/
|
||||
private <T> boolean useTransactionPersistenceContext(SpiQuery<T> query) {
|
||||
return PersistenceContextScope.TRANSACTION == getPersistenceContextScope(query);
|
||||
return PersistenceContextScope.TRANSACTION == persistenceContextScope(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the PersistenceContextScope to use defined at query or server level.
|
||||
*/
|
||||
@Override
|
||||
public PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query) {
|
||||
public PersistenceContextScope persistenceContextScope(SpiQuery<?> query) {
|
||||
PersistenceContextScope scope = query.getPersistenceContextScope();
|
||||
return (scope != null) ? scope : defaultPersistenceContextScope;
|
||||
}
|
||||
@@ -1227,7 +1232,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
request.resetBeanCacheAutoMode(false);
|
||||
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
||||
// hit bean cache and got all results from cache
|
||||
return request.getBeanCacheHitsAsMap();
|
||||
return request.beanCacheHitsAsMap();
|
||||
}
|
||||
Object result = request.getFromQueryCache();
|
||||
if (result != null) {
|
||||
@@ -1312,7 +1317,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
SpiOrmQueryRequest<?> request = createQueryRequest(Type.ID_LIST, query, t);
|
||||
Object result = request.getFromQueryCache();
|
||||
if (result != null) {
|
||||
if (Boolean.FALSE.equals(request.getQuery().isReadOnly())) {
|
||||
if (Boolean.FALSE.equals(request.query().isReadOnly())) {
|
||||
return new CopyOnFirstWriteList<>((List<A>) result);
|
||||
} else {
|
||||
return (List<A>) result;
|
||||
@@ -1341,7 +1346,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (ids.isEmpty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return persister.deleteByIds(request.getBeanDescriptor(), ids, request.getTransaction(), false);
|
||||
return persister.deleteByIds(request.descriptor(), ids, request.transaction(), false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -1391,7 +1396,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
// FutureList query always run in it's own persistence content
|
||||
spiQuery.setPersistenceContext(new DefaultPersistenceContext());
|
||||
if (!spiQuery.isDisableReadAudit()) {
|
||||
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(spiQuery.getBeanType());
|
||||
BeanDescriptor<T> desc = beanDescriptorManager.descriptor(spiQuery.getBeanType());
|
||||
desc.readAuditFutureList(spiQuery);
|
||||
}
|
||||
// Create a new transaction solely to execute the findList() at some future time
|
||||
@@ -1504,7 +1509,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
request.resetBeanCacheAutoMode(findOne);
|
||||
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
||||
// hit bean cache and got all results from cache
|
||||
return request.getBeanCacheHits();
|
||||
return request.beanCacheHits();
|
||||
}
|
||||
request.prepareQuery();
|
||||
Object result = request.getFromQueryCache();
|
||||
@@ -2048,26 +2053,26 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Return all the BeanDescriptors.
|
||||
*/
|
||||
@Override
|
||||
public List<BeanDescriptor<?>> getBeanDescriptors() {
|
||||
return beanDescriptorManager.getBeanDescriptorList();
|
||||
public List<BeanDescriptor<?>> descriptors() {
|
||||
return beanDescriptorManager.descriptorList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the transaction manager.
|
||||
*/
|
||||
@Override
|
||||
public SpiTransactionManager getTransactionManager() {
|
||||
public SpiTransactionManager transactionManager() {
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
public void register(BeanPersistController controller) {
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
|
||||
desc.register(controller);
|
||||
}
|
||||
}
|
||||
|
||||
public void deregister(BeanPersistController c) {
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
|
||||
desc.deregister(c);
|
||||
}
|
||||
}
|
||||
@@ -2075,13 +2080,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
@Override
|
||||
public boolean isSupportedType(java.lang.reflect.Type genericType) {
|
||||
TypeInfo typeInfo = ParamTypeHelper.getTypeInfo(genericType);
|
||||
return typeInfo != null && getBeanDescriptor(typeInfo.getBeanType()) != null;
|
||||
return typeInfo != null && descriptor(typeInfo.getBeanType()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setBeanId(Object bean, Object id) {
|
||||
public Object beanId(Object bean, Object id) {
|
||||
EntityBean eb = checkEntityBean(bean);
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
||||
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
@@ -2089,9 +2094,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBeanId(Object bean) {
|
||||
public Object beanId(Object bean) {
|
||||
EntityBean eb = checkEntityBean(bean);
|
||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
||||
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
@@ -2102,58 +2107,58 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Return the BeanDescriptor for a given type of bean.
|
||||
*/
|
||||
@Override
|
||||
public <T> BeanDescriptor<T> getBeanDescriptor(Class<T> beanClass) {
|
||||
return beanDescriptorManager.getBeanDescriptor(beanClass);
|
||||
public <T> BeanDescriptor<T> descriptor(Class<T> beanClass) {
|
||||
return beanDescriptorManager.descriptor(beanClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptor's for a given table name.
|
||||
*/
|
||||
@Override
|
||||
public List<BeanDescriptor<?>> getBeanDescriptors(String tableName) {
|
||||
return beanDescriptorManager.getBeanDescriptors(tableName);
|
||||
public List<BeanDescriptor<?>> descriptors(String tableName) {
|
||||
return beanDescriptorManager.descriptors(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the SPI BeanTypes.
|
||||
*/
|
||||
@Override
|
||||
public List<? extends BeanType<?>> getBeanTypes() {
|
||||
return getBeanDescriptors();
|
||||
public List<? extends BeanType<?>> beanTypes() {
|
||||
return descriptors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SPI bean types mapped to the given table.
|
||||
*/
|
||||
@Override
|
||||
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
|
||||
return beanDescriptorManager.getBeanTypes(tableName);
|
||||
public List<? extends BeanType<?>> beanTypes(String tableName) {
|
||||
return beanDescriptorManager.beanTypes(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanType<?> getBeanTypeForQueueId(String queueId) {
|
||||
return getBeanDescriptorByQueueId(queueId);
|
||||
public BeanType<?> beanTypeForQueueId(String queueId) {
|
||||
return descriptorByQueueId(queueId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
|
||||
return beanDescriptorManager.getBeanDescriptorByQueueId(queueId);
|
||||
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
|
||||
return beanDescriptorManager.descriptorByQueueId(queueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SPI bean types for the given bean class.
|
||||
*/
|
||||
@Override
|
||||
public <T> BeanType<T> getBeanType(Class<T> beanType) {
|
||||
return getBeanDescriptor(beanType);
|
||||
public <T> BeanType<T> beanType(Class<T> beanType) {
|
||||
return descriptor(beanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptor using its class name.
|
||||
*/
|
||||
@Override
|
||||
public BeanDescriptor<?> getBeanDescriptorById(String beanClassName) {
|
||||
return beanDescriptorManager.getBeanDescriptorByClassName(beanClassName);
|
||||
public BeanDescriptor<?> descriptorById(String beanClassName) {
|
||||
return beanDescriptorManager.descriptorByClassName(beanClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2278,13 +2283,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
@Override
|
||||
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
|
||||
EntityBean entityBean = checkEntityBean(bean);
|
||||
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
|
||||
BeanProperty idProperty = beanDesc.getIdProperty();
|
||||
BeanDescriptor<?> beanDesc = descriptor(entityBean.getClass());
|
||||
BeanProperty idProperty = beanDesc.idProperty();
|
||||
// if the ID of the Property is null we are unable to check uniqueness
|
||||
if (idProperty == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Object id = idProperty.getVal(entityBean);
|
||||
Object id = idProperty.value(entityBean);
|
||||
if (entityBean._ebean_getIntercept().isNew() && id != null) {
|
||||
// Primary Key is changeable only on new models - so skip check if we are not new
|
||||
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
|
||||
@@ -2293,7 +2298,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return Collections.singleton(idProperty);
|
||||
}
|
||||
}
|
||||
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
|
||||
for (BeanProperty[] props : beanDesc.uniqueProps()) {
|
||||
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
@@ -2306,19 +2311,19 @@ 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()) {
|
||||
// if model is not new, exclude ourself.
|
||||
exprList.ne(idProperty.getName(), idProperty.getVal(entityBean));
|
||||
exprList.ne(idProperty.name(), idProperty.value(entityBean));
|
||||
}
|
||||
for (Property prop : props) {
|
||||
Object value = prop.getVal(entityBean);
|
||||
Object value = prop.value(entityBean);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
exprList.eq(prop.getName(), value);
|
||||
exprList.eq(prop.name(), value);
|
||||
}
|
||||
if (findCount(query, transaction) > 0) {
|
||||
Set<Property> ret = new LinkedHashSet<>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.SqlUpdate;
|
||||
import io.ebean.Update;
|
||||
import io.ebeaninternal.api.BindParams;
|
||||
@@ -143,7 +143,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
return server.execute(this);
|
||||
} else {
|
||||
// Hopefully this doesn't catch anyone out...
|
||||
return Ebean.execute(this);
|
||||
return DB.getDefault().execute(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,6 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
return server.executeBatch(this, transaction);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addBatch() {
|
||||
if (server == null) {
|
||||
@@ -179,7 +178,6 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
throw new IllegalStateException("No current transaction? Must have a transaction to use addBatch()");
|
||||
}
|
||||
}
|
||||
|
||||
batched = true;
|
||||
server.addBatch(this, transaction);
|
||||
}
|
||||
@@ -287,8 +285,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
return this;
|
||||
}
|
||||
|
||||
private SqlUpdate setParamWithBindExpansion(int position, Collection values, String bindLiteral) {
|
||||
|
||||
private SqlUpdate setParamWithBindExpansion(int position, Collection<?> values, String bindLiteral) {
|
||||
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
|
||||
position = position + bindExpansion;
|
||||
int offset = 0;
|
||||
@@ -310,10 +307,9 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
String bindLiteral = "?" + position;
|
||||
int pos = baseSql.indexOf(bindLiteral);
|
||||
if (pos > -1) {
|
||||
return setParamWithBindExpansion(position, (Collection) value, bindLiteral);
|
||||
return setParamWithBindExpansion(position, (Collection<?>) value, bindLiteral);
|
||||
}
|
||||
}
|
||||
|
||||
bindParams.setParameter(bindExpansion + position, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
|
||||
@Override
|
||||
protected void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException {
|
||||
this.resultSet = resultSet;
|
||||
this.dataReader = new RsetDataReader(server.getDataTimeZone(), resultSet);
|
||||
this.dataReader = new RsetDataReader(server.dataTimeZone(), resultSet);
|
||||
obtainPlan(queryPlanKey);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
|
||||
return queryEngine.findList(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() throws SQLException {
|
||||
query.checkCancelled();
|
||||
return dataReader.next();
|
||||
|
||||
@@ -73,8 +73,8 @@ final class DumpMetrics {
|
||||
|
||||
void dump() {
|
||||
|
||||
out("-- Dumping metrics for " + server.getName() + " -- ");
|
||||
ServerMetrics serverMetrics = server.getMetaInfoManager().collectMetrics();
|
||||
out("-- Dumping metrics for " + server.name() + " -- ");
|
||||
ServerMetrics serverMetrics = server.metaInfo().collectMetrics();
|
||||
|
||||
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
||||
log(metric);
|
||||
|
||||
@@ -24,7 +24,7 @@ final class DumpMetricsData {
|
||||
}
|
||||
|
||||
List<MetricData> data() {
|
||||
collect(database.getMetaInfoManager().collectMetrics());
|
||||
collect(database.metaInfo().collectMetrics());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
@Override
|
||||
public String json() {
|
||||
writer = new StringWriter();
|
||||
collect(database.getMetaInfoManager().collectMetrics());
|
||||
collect(database.metaInfo().collectMetrics());
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Appendable buffer) {
|
||||
writer = buffer;
|
||||
collect(database.getMetaInfoManager().collectMetrics());
|
||||
collect(database.metaInfo().collectMetrics());
|
||||
}
|
||||
|
||||
private void collect(ServerMetrics serverMetrics) {
|
||||
@@ -112,7 +112,7 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
if (withHeader) {
|
||||
objStart();
|
||||
key("db");
|
||||
val(database.getName());
|
||||
val(database.name());
|
||||
key("metrics");
|
||||
listStart();
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public final class InternalConfiguration {
|
||||
this.dtoBeanManager = new DtoBeanManager(typeManager, xmlMap.readDtoMapping());
|
||||
this.beanDescriptorManager = new BeanDescriptorManager(this);
|
||||
Map<String, String> asOfTableMapping = beanDescriptorManager.deploy(xmlMap.xmlDeployment());
|
||||
Map<String, String> draftTableMap = beanDescriptorManager.getDraftTableMap();
|
||||
Map<String, String> draftTableMap = beanDescriptorManager.draftTableMap();
|
||||
beanDescriptorManager.scheduleBackgroundTrim();
|
||||
this.dataTimeZone = initDataTimeZone();
|
||||
this.binder = getBinder(typeManager, databasePlatform, dataTimeZone);
|
||||
|
||||
@@ -60,42 +60,25 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
private static final Logger log = LoggerFactory.getLogger(OrmQueryRequest.class);
|
||||
|
||||
private final BeanDescriptor<T> beanDescriptor;
|
||||
|
||||
private final OrmQueryEngine queryEngine;
|
||||
|
||||
private final SpiQuery<T> query;
|
||||
|
||||
private final BeanFindController finder;
|
||||
|
||||
private final Boolean readOnly;
|
||||
|
||||
private LoadContext loadContext;
|
||||
|
||||
private PersistenceContext persistenceContext;
|
||||
|
||||
private JsonReadOptions jsonRead;
|
||||
|
||||
private HashQuery cacheKey;
|
||||
|
||||
private CQueryPlanKey queryPlanKey;
|
||||
|
||||
private SpiQuerySecondary secondaryQueries;
|
||||
|
||||
private List<T> cacheBeans;
|
||||
|
||||
private BeanPropertyAssocMany<?> manyProperty;
|
||||
|
||||
private boolean inlineCountDistinct;
|
||||
|
||||
private Set<String> dependentTables;
|
||||
|
||||
/**
|
||||
* Create the InternalQueryRequest.
|
||||
*/
|
||||
public OrmQueryRequest(SpiEbeanServer server, OrmQueryEngine queryEngine, SpiQuery<T> query, SpiTransaction t) {
|
||||
super(server, t);
|
||||
this.beanDescriptor = query.getBeanDescriptor();
|
||||
this.finder = beanDescriptor.getBeanFinder();
|
||||
this.finder = beanDescriptor.beanFinder();
|
||||
this.queryEngine = queryEngine;
|
||||
this.query = query;
|
||||
this.readOnly = query.isReadOnly();
|
||||
@@ -145,8 +128,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return the database platform like clause.
|
||||
*/
|
||||
@Override
|
||||
public String getDBLikeClause(boolean rawLikeExpression) {
|
||||
return ebeanServer.getDatabasePlatform().getLikeClause(rawLikeExpression);
|
||||
public String dbLikeClause(boolean rawLikeExpression) {
|
||||
return server.databasePlatform().getLikeClause(rawLikeExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +137,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
*/
|
||||
@Override
|
||||
public String escapeLikeString(String value) {
|
||||
return ebeanServer.getDatabasePlatform().escapeLikeString(value);
|
||||
return server.databasePlatform().escapeLikeString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,9 +154,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* <p>
|
||||
* If -1 is returned then NO secondary queries are registered and simple
|
||||
* iteration is fine.
|
||||
* </p>
|
||||
*/
|
||||
public int getSecondaryQueriesMinBatchSize() {
|
||||
public int secondaryQueriesMinBatchSize() {
|
||||
return loadContext.getSecondaryQueriesMinBatchSize();
|
||||
}
|
||||
|
||||
@@ -188,14 +170,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return the BeanDescriptor for the associated bean.
|
||||
*/
|
||||
@Override
|
||||
public BeanDescriptor<T> getBeanDescriptor() {
|
||||
public BeanDescriptor<T> descriptor() {
|
||||
return beanDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the graph context for this query.
|
||||
*/
|
||||
public LoadContext getGraphContext() {
|
||||
public LoadContext loadContext() {
|
||||
return loadContext;
|
||||
}
|
||||
|
||||
@@ -208,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);
|
||||
}
|
||||
@@ -244,7 +226,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return the PersistenceContext used for this request.
|
||||
*/
|
||||
public PersistenceContext getPersistenceContext() {
|
||||
public PersistenceContext persistenceContext() {
|
||||
return persistenceContext;
|
||||
}
|
||||
|
||||
@@ -271,15 +253,15 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
if (transaction == null) {
|
||||
if (query.getType().isUpdate()) {
|
||||
// bulk update or delete query
|
||||
transaction = ebeanServer.beginServerTransaction();
|
||||
transaction = server.beginServerTransaction();
|
||||
} else {
|
||||
// create an implicit transaction to execute this query
|
||||
// potentially using read-only DataSource with autoCommit
|
||||
transaction = ebeanServer.createReadOnlyTransaction(query.getTenantId());
|
||||
transaction = server.createReadOnlyTransaction(query.getTenantId());
|
||||
}
|
||||
createdTransaction = true;
|
||||
}
|
||||
persistenceContext = getPersistenceContext(query, transaction);
|
||||
persistenceContext = persistenceContext(query, transaction);
|
||||
loadContext = new DLoadContext(this, secondaryQueries);
|
||||
}
|
||||
|
||||
@@ -305,7 +287,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
*/
|
||||
@Override
|
||||
public JsonReadOptions createJsonReadOptions() {
|
||||
persistenceContext = getPersistenceContext(query, transaction);
|
||||
persistenceContext = persistenceContext(query, transaction);
|
||||
if (query.getPersistenceContext() == null) {
|
||||
query.setPersistenceContext(persistenceContext);
|
||||
}
|
||||
@@ -336,14 +318,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Get the TransactionContext either explicitly set on the query or
|
||||
* transaction scoped.
|
||||
*/
|
||||
private PersistenceContext getPersistenceContext(SpiQuery<?> query, SpiTransaction t) {
|
||||
private PersistenceContext persistenceContext(SpiQuery<?> query, SpiTransaction t) {
|
||||
// check if there is already a persistence context set which is the case
|
||||
// when lazy loading or query joins are executed
|
||||
PersistenceContext ctx = query.getPersistenceContext();
|
||||
if (ctx != null) return ctx;
|
||||
|
||||
// determine the scope (from the query and then server)
|
||||
PersistenceContextScope scope = ebeanServer.getPersistenceContextScope(query);
|
||||
PersistenceContextScope scope = server.persistenceContextScope(query);
|
||||
if (scope == PersistenceContextScope.QUERY || t == null) {
|
||||
return new DefaultPersistenceContext();
|
||||
}
|
||||
@@ -365,7 +347,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
transaction.commit();
|
||||
if (query.getType().isUpdate()) {
|
||||
// for implicit update/delete queries clear the thread local
|
||||
ebeanServer.clearServerTransaction();
|
||||
server.clearServerTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,9 +468,9 @@ 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());
|
||||
query.setMapKey(idProp.name());
|
||||
} else {
|
||||
throw new PersistenceException("No mapKey specified for query");
|
||||
}
|
||||
@@ -504,12 +486,12 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return a bean specific finder if one has been set.
|
||||
*/
|
||||
public BeanFindController getBeanFinder() {
|
||||
public BeanFindController finder() {
|
||||
return finder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiQuery<T> getQuery() {
|
||||
public SpiQuery<T> query() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@@ -517,14 +499,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Determine and return the ToMany property that is included in the query.
|
||||
*/
|
||||
public BeanPropertyAssocMany<?> determineMany() {
|
||||
manyProperty = beanDescriptor.getManyProperty(query);
|
||||
manyProperty = beanDescriptor.manyProperty(query);
|
||||
return manyProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the many property that is fetched in the query or null if there is not one.
|
||||
*/
|
||||
public BeanPropertyAssocMany<?> getManyProperty() {
|
||||
public BeanPropertyAssocMany<?> manyProperty() {
|
||||
return manyProperty;
|
||||
}
|
||||
|
||||
@@ -532,8 +514,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return a queryPlan for the current query if one exists. Returns null if no
|
||||
* query plan for this query exists.
|
||||
*/
|
||||
public CQueryPlan getQueryPlan() {
|
||||
return beanDescriptor.getQueryPlan(queryPlanKey);
|
||||
public CQueryPlan queryPlan() {
|
||||
return beanDescriptor.queryPlan(queryPlanKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,9 +524,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* This identifies the query plan for a given bean type. It effectively
|
||||
* matches a SQL statement with ? bind variables. A query plan can be reused
|
||||
* with just the bind variables changing.
|
||||
* </p>
|
||||
*/
|
||||
public CQueryPlanKey getQueryPlanKey() {
|
||||
public CQueryPlanKey queryPlanKey() {
|
||||
return queryPlanKey;
|
||||
}
|
||||
|
||||
@@ -552,7 +533,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Put the QueryPlan into the cache.
|
||||
*/
|
||||
public void putQueryPlan(CQueryPlan queryPlan) {
|
||||
beanDescriptor.putQueryPlan(queryPlanKey, queryPlan);
|
||||
beanDescriptor.queryPlan(queryPlanKey, queryPlan);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -608,7 +589,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getBeanCacheHits() {
|
||||
public List<T> beanCacheHits() {
|
||||
OrderBy<T> orderBy = query.getOrderBy();
|
||||
if (orderBy != null) {
|
||||
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
||||
@@ -617,7 +598,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> Map<K, T> getBeanCacheHitsAsMap() {
|
||||
public <K> Map<K, T> beanCacheHitsAsMap() {
|
||||
OrderBy<T> orderBy = query.getOrderBy();
|
||||
if (orderBy != null) {
|
||||
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
||||
@@ -636,7 +617,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
}
|
||||
|
||||
private ElPropertyValue mapProperty() {
|
||||
ElPropertyValue property = beanDescriptor.getElGetValue(query.getMapKey());
|
||||
ElPropertyValue property = beanDescriptor.elGetValue(query.getMapKey());
|
||||
if (property == null) {
|
||||
throw new IllegalStateException("Unknown map key property "+query.getMapKey());
|
||||
}
|
||||
@@ -665,7 +646,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
if (!beanDescriptor.isNaturalKeyCaching()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NaturalKeyQueryData<T> data = query.naturalKey();
|
||||
if (data != null) {
|
||||
NaturalKeySet naturalKeySet = data.buildKeys();
|
||||
@@ -688,30 +668,27 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
public Object getFromQueryCache() {
|
||||
if (query.getUseQueryCache() == CacheMode.OFF
|
||||
|| (transaction != null && transaction.isSkipCache())
|
||||
|| ebeanServer.isDisableL2Cache()) {
|
||||
|| server.isDisableL2Cache()) {
|
||||
return null;
|
||||
} else {
|
||||
cacheKey = query.queryHash();
|
||||
}
|
||||
|
||||
if (!query.getUseQueryCache().isGet()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object cached = beanDescriptor.queryCacheGet(cacheKey);
|
||||
|
||||
if (cached != null && isAuditReads() && readAuditQueryType()) {
|
||||
if (cached instanceof BeanCollection) {
|
||||
// raw sql can't use L2 cache so normal queries only in here
|
||||
Collection<T> actualDetails = ((BeanCollection<T>)cached).getActualDetails();
|
||||
List<Object> ids = new ArrayList<>(actualDetails.size());
|
||||
for (T bean : actualDetails) {
|
||||
ids.add(beanDescriptor.getIdForJson(bean));
|
||||
ids.add(beanDescriptor.idForJson(bean));
|
||||
}
|
||||
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||
// return shallow copies if readonly is explicitly set to false
|
||||
if (cached instanceof BeanCollection) {
|
||||
@@ -750,7 +727,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an Query object that owns the PreparedStatement that can be cancelled.
|
||||
* Set a Query object that owns the PreparedStatement that can be cancelled.
|
||||
*/
|
||||
public void setCancelableQuery(CancelableQuery cancelableQuery) {
|
||||
query.setCancelableQuery(cancelableQuery);
|
||||
@@ -766,16 +743,15 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return the batch size for lazy loading on this bean query request.
|
||||
*/
|
||||
public int getLazyLoadBatchSize() {
|
||||
public int lazyLoadBatchSize() {
|
||||
int batchSize = query.getLazyLoadBatchSize();
|
||||
return (batchSize > 0) ? batchSize : ebeanServer.getLazyLoadBatchSize();
|
||||
return (batchSize > 0) ? batchSize : server.lazyLoadBatchSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if read auditing is on for this query request.
|
||||
* <p>
|
||||
* This means that read audit is on for this bean type and that query has not explicitly disabled it.
|
||||
* </p>
|
||||
*/
|
||||
public boolean isAuditReads() {
|
||||
return beanDescriptor.isReadAuditing() && !query.isDisableReadAudit();
|
||||
@@ -784,8 +760,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return the base table alias for this query.
|
||||
*/
|
||||
public String getBaseTableAlias() {
|
||||
return query.getAlias(beanDescriptor.getBaseTableAlias());
|
||||
public String baseTableAlias() {
|
||||
return query.getAlias(beanDescriptor.baseTableAlias());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -798,7 +774,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return the tenantId associated with this request.
|
||||
*/
|
||||
public Object getTenantId() {
|
||||
public Object tenantId() {
|
||||
return (transaction == null) ? null : transaction.getTenantId();
|
||||
}
|
||||
|
||||
@@ -806,7 +782,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Check for slow query event.
|
||||
*/
|
||||
public void slowQueryCheck(long executionTimeMicros, int rowCount) {
|
||||
ebeanServer.slowQueryCheck(executionTimeMicros, rowCount, query);
|
||||
server.slowQueryCheck(executionTimeMicros, rowCount, query);
|
||||
}
|
||||
|
||||
public void setInlineCountDistinct() {
|
||||
@@ -830,6 +806,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return true if no MaxRows or use LIMIT in SQL update.
|
||||
*/
|
||||
public boolean isInlineSqlUpdateLimit() {
|
||||
return query.getMaxRows() < 1 || ebeanServer.getDatabasePlatform().isInlineSqlUpdateLimit();
|
||||
return query.getMaxRows() < 1 || server.databasePlatform().isInlineSqlUpdateLimit();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,13 +35,13 @@ public final class PersistDeferredRelationship {
|
||||
*/
|
||||
public void execute(SpiTransaction transaction) {
|
||||
|
||||
String sql = beanDescriptor.getUpdateImportedIdSql(importedId);
|
||||
String sql = beanDescriptor.updateImportedIdSql(importedId);
|
||||
SqlUpdate sqlUpdate = ebeanServer.sqlUpdate(sql);
|
||||
|
||||
// bind the set clause for the importedId
|
||||
int pos = importedId.bind(1, sqlUpdate, assocBean);
|
||||
// bind the where clause for the bean
|
||||
Object[] idValues = beanDescriptor.getIdBinder().getIdValues(bean);
|
||||
Object[] idValues = beanDescriptor.idBinder().getIdValues(bean);
|
||||
for (int j = 0; j < idValues.length; j++) {
|
||||
sqlUpdate.setParameter(pos + j, idValues[j]);
|
||||
}
|
||||
|
||||
@@ -31,17 +31,10 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
||||
}
|
||||
}
|
||||
|
||||
boolean persistCascade;
|
||||
|
||||
/**
|
||||
* One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL.
|
||||
*/
|
||||
protected Type type;
|
||||
|
||||
boolean persistCascade;
|
||||
final PersistExecute persistExecute;
|
||||
|
||||
protected String label;
|
||||
|
||||
protected long startNanos;
|
||||
|
||||
PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) {
|
||||
@@ -95,12 +88,12 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogSql() {
|
||||
public boolean logSql() {
|
||||
return transaction.isLogSql();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogSummary() {
|
||||
public boolean logSummary() {
|
||||
return transaction.isLogSummary();
|
||||
}
|
||||
|
||||
@@ -149,10 +142,9 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL
|
||||
* or CALLABLESQL.
|
||||
* Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL.
|
||||
*/
|
||||
public Type getType() {
|
||||
public Type type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,142 +50,94 @@ import java.util.Set;
|
||||
public final class PersistRequestBean<T> extends PersistRequest implements BeanPersistRequest<T>, DocStoreUpdate, PreGetterCallback, SpiProfileTransactionEvent {
|
||||
|
||||
private final BeanManager<T> beanManager;
|
||||
|
||||
private final BeanDescriptor<T> beanDescriptor;
|
||||
|
||||
private final BeanPersistListener beanPersistListener;
|
||||
|
||||
/**
|
||||
* For per post insert update delete control.
|
||||
*/
|
||||
private final BeanPersistController controller;
|
||||
|
||||
/**
|
||||
* The bean being persisted.
|
||||
*/
|
||||
private final T bean;
|
||||
|
||||
private final EntityBean entityBean;
|
||||
|
||||
/**
|
||||
* The associated intercept.
|
||||
*/
|
||||
private final EntityBeanIntercept intercept;
|
||||
|
||||
/**
|
||||
* The parent bean for unidirectional save.
|
||||
*/
|
||||
private final Object parentBean;
|
||||
|
||||
private final boolean dirty;
|
||||
|
||||
private final boolean publish;
|
||||
|
||||
private int flags;
|
||||
|
||||
private boolean saveRecurse;
|
||||
|
||||
private DocStoreMode docStoreMode;
|
||||
|
||||
private final ConcurrencyMode concurrencyMode;
|
||||
|
||||
/**
|
||||
* The unique id used for logging summary.
|
||||
*/
|
||||
private Object idValue;
|
||||
|
||||
/**
|
||||
* Hash value used to handle cascade delete both ways in a relationship.
|
||||
*/
|
||||
private Integer beanHash;
|
||||
|
||||
/**
|
||||
* Flag set if this is a stateless update.
|
||||
*/
|
||||
private boolean statelessUpdate;
|
||||
|
||||
private boolean notifyCache;
|
||||
|
||||
/**
|
||||
* Flag used to detect when only many properties where updated via a cascade. Used to ensure
|
||||
* appropriate caches are updated in that case.
|
||||
*/
|
||||
private boolean updatedManysOnly;
|
||||
|
||||
/**
|
||||
* Element collection change as part of bean cache.
|
||||
*/
|
||||
private Map<String, Object> collectionChanges;
|
||||
|
||||
/**
|
||||
* Set true when the request includes cascade save to a many.
|
||||
*/
|
||||
private boolean updatedMany;
|
||||
|
||||
/**
|
||||
* Many properties that were cascade saved (and hence might need caches updated later).
|
||||
*/
|
||||
private List<BeanPropertyAssocMany<?>> updatedManys;
|
||||
|
||||
/**
|
||||
* Need to get and store the updated properties because the persist listener is notified
|
||||
* later on a different thread and the bean has been reset at that point.
|
||||
*/
|
||||
private Set<String> updatedProperties;
|
||||
|
||||
/**
|
||||
* Flags indicating the dirty properties on the bean.
|
||||
*/
|
||||
private boolean[] dirtyProperties;
|
||||
|
||||
/**
|
||||
* Imported OneToOne orphan that needs to be deleted.
|
||||
*/
|
||||
private EntityBean orphanBean;
|
||||
|
||||
/**
|
||||
* Flag set when request is added to JDBC batch.
|
||||
*/
|
||||
private boolean batched;
|
||||
|
||||
/**
|
||||
* Flag set when batchOnCascade to avoid using batch on the top bean.
|
||||
*/
|
||||
private boolean skipBatchForTopLevel;
|
||||
|
||||
/**
|
||||
* Flag set when batch mode is turned on for a persist cascade.
|
||||
*/
|
||||
private boolean batchOnCascadeSet;
|
||||
|
||||
/**
|
||||
* Set for updates to determine if all loaded properties are included in the update.
|
||||
*/
|
||||
private boolean requestUpdateAllLoadedProps;
|
||||
|
||||
private long version;
|
||||
|
||||
private long now;
|
||||
|
||||
private long profileOffset;
|
||||
|
||||
/**
|
||||
* Flag set when request is added to JDBC batch registered as a "getter callback" to automatically flush batch.
|
||||
*/
|
||||
private boolean getterCallback;
|
||||
|
||||
private boolean pendingPostUpdateNotify;
|
||||
|
||||
/**
|
||||
* Set to true when post execute has occurred (so includes batch flush).
|
||||
*/
|
||||
private boolean postExecute;
|
||||
|
||||
/**
|
||||
* Set to true after many properties have been persisted (so includes element collections).
|
||||
*/
|
||||
private boolean complete;
|
||||
|
||||
/**
|
||||
* Many to many intersection table changes that are held for later batch processing.
|
||||
*/
|
||||
@@ -198,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;
|
||||
@@ -217,7 +169,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
// Mark Mutable scalar properties (like Hstore) as dirty where necessary
|
||||
beanDescriptor.checkMutableProperties(intercept);
|
||||
}
|
||||
this.concurrencyMode = beanDescriptor.getConcurrencyMode(intercept);
|
||||
this.concurrencyMode = beanDescriptor.concurrencyMode(intercept);
|
||||
this.publish = Flags.isPublish(flags);
|
||||
if (isMarkDraftDirty(publish)) {
|
||||
beanDescriptor.setDraftDirty(entityBean, true);
|
||||
@@ -247,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +210,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
*/
|
||||
private DocStoreMode calcDocStoreMode(SpiTransaction txn, Type type) {
|
||||
DocStoreMode txnMode = (txn == null) ? null : txn.getDocStoreMode();
|
||||
return beanDescriptor.getDocStoreMode(type, txnMode);
|
||||
return beanDescriptor.docStoreMode(type, txnMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,28 +272,28 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
private void onUpdateGeneratedProperties() {
|
||||
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
|
||||
GeneratedProperty generatedProperty = prop.getGeneratedProperty();
|
||||
GeneratedProperty generatedProperty = prop.generatedProperty();
|
||||
if (prop.isVersion()) {
|
||||
if (isLoadedProperty(prop)) {
|
||||
// @Version property must be loaded to be involved
|
||||
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
||||
Object oldVal = prop.getValue(entityBean);
|
||||
setVersionValue(value);
|
||||
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
|
||||
intercept.setOldValue(prop.propertyIndex(), oldVal);
|
||||
}
|
||||
} else {
|
||||
// @WhenModified set without invoking interception
|
||||
Object oldVal = prop.getValue(entityBean);
|
||||
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
||||
prop.setValueChanged(entityBean, value);
|
||||
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
|
||||
intercept.setOldValue(prop.propertyIndex(), oldVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onInsertGeneratedProperties() {
|
||||
for (BeanProperty prop : beanDescriptor.propertiesGenInsert()) {
|
||||
Object value = prop.getGeneratedProperty().getInsertValue(prop, entityBean, now());
|
||||
Object value = prop.generatedProperty().getInsertValue(prop, entityBean, now());
|
||||
prop.setValueChanged(entityBean, value);
|
||||
}
|
||||
}
|
||||
@@ -424,12 +376,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getLoadedProperties() {
|
||||
public Set<String> loadedProperties() {
|
||||
return intercept.getLoadedPropertyNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUpdatedProperties() {
|
||||
public Set<String> updatedProperties() {
|
||||
return intercept.getDirtyPropertyNames();
|
||||
}
|
||||
|
||||
@@ -437,7 +389,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Return the dirty properties on this request.
|
||||
*/
|
||||
@Override
|
||||
public boolean[] getDirtyProperties() {
|
||||
public boolean[] dirtyProperties() {
|
||||
return dirtyProperties;
|
||||
}
|
||||
|
||||
@@ -462,7 +414,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ValuePair> getUpdatedValues() {
|
||||
public Map<String, ValuePair> updatedValues() {
|
||||
return intercept.getDirtyValues();
|
||||
}
|
||||
|
||||
@@ -543,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);
|
||||
@@ -582,8 +534,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this bean has been already been persisted (inserted or updated) in this
|
||||
* transaction.
|
||||
* Return true if this bean has been already been persisted (inserted or updated) in this transaction.
|
||||
*/
|
||||
public boolean isRegisteredBean() {
|
||||
return transaction.isRegisteredBean(bean);
|
||||
@@ -600,7 +551,6 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* The hash used to register the bean with the transaction.
|
||||
* <p>
|
||||
* Takes into account the class type and id value.
|
||||
* </p>
|
||||
*/
|
||||
private Integer getBeanHash() {
|
||||
if (beanHash == null) {
|
||||
@@ -631,7 +581,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the BeanDescriptor for the associated bean.
|
||||
*/
|
||||
public BeanDescriptor<T> getBeanDescriptor() {
|
||||
public BeanDescriptor<T> descriptor() {
|
||||
return beanDescriptor;
|
||||
}
|
||||
|
||||
@@ -656,7 +606,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the concurrency mode used for this persist.
|
||||
*/
|
||||
public ConcurrencyMode getConcurrencyMode() {
|
||||
public ConcurrencyMode concurrencyMode() {
|
||||
return concurrencyMode;
|
||||
}
|
||||
|
||||
@@ -667,26 +617,26 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Used to determine common persist requests for queueing and statement batching.
|
||||
* </p>
|
||||
*/
|
||||
public String getFullName() {
|
||||
return beanDescriptor.getFullName();
|
||||
public String fullName() {
|
||||
return beanDescriptor.fullName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bean associated with this request.
|
||||
*/
|
||||
@Override
|
||||
public T getBean() {
|
||||
public T bean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public EntityBean getEntityBean() {
|
||||
public EntityBean entityBean() {
|
||||
return entityBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Id value for the bean.
|
||||
*/
|
||||
public Object getBeanId() {
|
||||
public Object beanId() {
|
||||
return beanDescriptor.getId(entityBean);
|
||||
}
|
||||
|
||||
@@ -694,7 +644,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Create and return a new reference bean matching this beans Id value.
|
||||
*/
|
||||
public T createReference() {
|
||||
return beanDescriptor.createRef(getBeanId(), null);
|
||||
return beanDescriptor.createRef(beanId(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -739,14 +689,14 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the parent bean for cascading save with unidirectional relationship.
|
||||
*/
|
||||
public Object getParentBean() {
|
||||
public Object parentBean() {
|
||||
return parentBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the intercept if there is one.
|
||||
*/
|
||||
public EntityBeanIntercept getEntityBeanIntercept() {
|
||||
public EntityBeanIntercept intercept() {
|
||||
return intercept;
|
||||
}
|
||||
|
||||
@@ -754,21 +704,21 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Return true if this property is loaded (full bean or included in partial bean).
|
||||
*/
|
||||
public boolean isLoadedProperty(BeanProperty prop) {
|
||||
return intercept.isLoadedProperty(prop.getPropertyIndex());
|
||||
return intercept.isLoadedProperty(prop.propertyIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the property is dirty.
|
||||
*/
|
||||
public boolean isDirtyProperty(BeanProperty prop) {
|
||||
return intercept.isDirtyProperty(prop.getPropertyIndex());
|
||||
return intercept.isDirtyProperty(prop.propertyIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original / old value for the given property.
|
||||
*/
|
||||
public Object getOrigValue(BeanProperty prop) {
|
||||
return intercept.getOrigValue(prop.getPropertyIndex());
|
||||
return intercept.getOrigValue(prop.propertyIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -783,7 +733,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
case UPDATE:
|
||||
if (beanPersistListener != null) {
|
||||
// store the updated properties for sending later
|
||||
updatedProperties = getUpdatedProperties();
|
||||
updatedProperties = updatedProperties();
|
||||
}
|
||||
executeUpdate();
|
||||
return -1;
|
||||
@@ -802,7 +752,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Soft delete is executed as update so we want to set deleted=true property.
|
||||
*/
|
||||
private void prepareForSoftDelete() {
|
||||
beanDescriptor.setSoftDeleteValue(entityBean);
|
||||
beanDescriptor.softDeleteValue(entityBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -854,7 +804,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Check for optimistic concurrency exception.
|
||||
*/
|
||||
@Override
|
||||
public final void checkRowCount(int rowCount) {
|
||||
public void checkRowCount(int rowCount) {
|
||||
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
|
||||
if (ConcurrencyMode.VERSION == concurrencyMode) {
|
||||
throw new OptimisticLockException("Data has changed. updated row count " + rowCount, null, bean);
|
||||
@@ -905,7 +855,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
|
||||
private void changeLog() {
|
||||
BeanChange changeLogBean = beanDescriptor.getChangeLogBean(this);
|
||||
BeanChange changeLogBean = beanDescriptor.changeLogBean(this);
|
||||
if (changeLogBean != null) {
|
||||
transaction.addBeanChange(changeLogBean);
|
||||
}
|
||||
@@ -937,8 +887,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
addPostCommitListeners();
|
||||
notifyCacheOnPostExecute();
|
||||
if (isLogSummary()) {
|
||||
logSummary();
|
||||
if (logSummary()) {
|
||||
logSummaryMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,9 +935,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
}
|
||||
|
||||
private void logSummary() {
|
||||
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);
|
||||
@@ -1021,9 +971,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
*/
|
||||
public boolean isAddToUpdate(BeanProperty prop) {
|
||||
if (requestUpdateAllLoadedProps) {
|
||||
return intercept.isLoadedProperty(prop.getPropertyIndex());
|
||||
return intercept.isLoadedProperty(prop.propertyIndex());
|
||||
} else {
|
||||
return intercept.isDirtyProperty(prop.getPropertyIndex());
|
||||
return intercept.isDirtyProperty(prop.propertyIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1031,7 +981,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Register the derived relationships to get executed later (on JDBC batch flush or commit).
|
||||
*/
|
||||
public void deferredRelationship(EntityBean assocBean, ImportedId importedId, EntityBean bean) {
|
||||
transaction.registerDeferred(new PersistDeferredRelationship(ebeanServer, beanDescriptor, assocBean, importedId, bean));
|
||||
transaction.registerDeferred(new PersistDeferredRelationship(server, beanDescriptor, assocBean, importedId, bean));
|
||||
}
|
||||
|
||||
private void postInsert() {
|
||||
@@ -1074,7 +1024,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the list of updated many properties for L2 cache update (can be null).
|
||||
*/
|
||||
public List<BeanPropertyAssocMany<?>> getUpdatedManyForL2Cache() {
|
||||
public List<BeanPropertyAssocMany<?>> updatedManyForL2Cache() {
|
||||
return updatedManys;
|
||||
}
|
||||
|
||||
@@ -1151,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;
|
||||
@@ -1175,7 +1125,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
requestUpdateAllLoadedProps = txnUpdateAll;
|
||||
} else {
|
||||
// if using batch use the server default setting
|
||||
requestUpdateAllLoadedProps = isBatchThisRequest() && ebeanServer.isUpdateAllPropertiesInBatch();
|
||||
requestUpdateAllLoadedProps = isBatchThisRequest() && server.isUpdateAllPropertiesInBatch();
|
||||
}
|
||||
return requestUpdateAllLoadedProps;
|
||||
}
|
||||
@@ -1183,7 +1133,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the flags set on this persist request.
|
||||
*/
|
||||
public int getFlags() {
|
||||
public int flags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -1197,16 +1147,16 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the key for an update persist request.
|
||||
*/
|
||||
public String getUpdatePlanHash() {
|
||||
public String updatePlanHash() {
|
||||
StringBuilder key;
|
||||
if (determineUpdateAllLoadedProperties()) {
|
||||
key = intercept.getLoadedPropertyKey();
|
||||
} else {
|
||||
key = intercept.getDirtyPropertyKey();
|
||||
}
|
||||
BeanProperty versionProperty = beanDescriptor.getVersionProperty();
|
||||
BeanProperty versionProperty = beanDescriptor.versionProperty();
|
||||
if (versionProperty != null) {
|
||||
if (intercept.isLoadedProperty(versionProperty.getPropertyIndex())) {
|
||||
if (intercept.isLoadedProperty(versionProperty.propertyIndex())) {
|
||||
key.append('v');
|
||||
}
|
||||
}
|
||||
@@ -1219,8 +1169,8 @@ 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 getUpdateTable() {
|
||||
return publish ? beanDescriptor.getBaseTable() : beanDescriptor.getDraftTable();
|
||||
public String updateTable() {
|
||||
return publish ? beanDescriptor.baseTable() : beanDescriptor.draftTable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1240,7 +1190,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the version in long form (if set).
|
||||
*/
|
||||
public long getVersion() {
|
||||
public long version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -1313,7 +1263,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
*/
|
||||
public long now() {
|
||||
if (now == 0) {
|
||||
now = ebeanServer.clockNow();
|
||||
now = server.clockNow();
|
||||
}
|
||||
return now;
|
||||
}
|
||||
@@ -1330,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1383,15 +1333,15 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
String key = beanDescriptor.cacheKey(idValue);
|
||||
Map<String, Object> changes = new LinkedHashMap<>();
|
||||
EntityBean bean = getEntityBean();
|
||||
boolean[] dirtyProperties = getDirtyProperties();
|
||||
EntityBean bean = entityBean();
|
||||
boolean[] dirtyProperties = dirtyProperties();
|
||||
if (dirtyProperties != null) {
|
||||
for (int i = 0; i < dirtyProperties.length; i++) {
|
||||
if (dirtyProperties[i]) {
|
||||
BeanProperty property = beanDescriptor.propertyByIndex(i);
|
||||
if (property.isCacheDataInclude()) {
|
||||
Object val = property.getCacheDataValue(bean);
|
||||
changes.put(property.getName(), val);
|
||||
changes.put(property.name(), val);
|
||||
if (property.isNaturalKey()) {
|
||||
updateNaturalKey = true;
|
||||
String valStr = (val == null) ? null : val.toString();
|
||||
@@ -1405,7 +1355,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
// add element collection update
|
||||
changes.putAll(collectionChanges);
|
||||
}
|
||||
changeSet.addBeanUpdate(beanDescriptor, key, changes, updateNaturalKey, getVersion());
|
||||
changeSet.addBeanUpdate(beanDescriptor, key, changes, updateNaturalKey, version());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1419,7 +1369,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
}
|
||||
}
|
||||
|
||||
public EntityBean getImportedOrphanForRemoval() {
|
||||
public EntityBean importedOrphanForRemoval() {
|
||||
return orphanBean;
|
||||
}
|
||||
|
||||
@@ -1427,7 +1377,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Return the SQL used to fetch the last inserted id value.
|
||||
*/
|
||||
public String getSelectLastInsertedId() {
|
||||
return beanDescriptor.getSelectLastInsertedId(publish);
|
||||
return beanDescriptor.selectLastInsertedId(publish);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-15
@@ -19,20 +19,15 @@ import java.util.List;
|
||||
public final class PersistRequestCallableSql extends PersistRequest {
|
||||
|
||||
private final SpiCallableSql callableSql;
|
||||
|
||||
private int rowCount;
|
||||
|
||||
private String bindLog;
|
||||
|
||||
private CallableStatement cstmt;
|
||||
|
||||
private BindParams bindParam;
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*/
|
||||
public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) {
|
||||
|
||||
super(server, t, persistExecute, cs.getLabel());
|
||||
this.type = PersistRequest.Type.CALLABLESQL;
|
||||
this.callableSql = (SpiCallableSql) cs;
|
||||
@@ -56,7 +51,7 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
/**
|
||||
* Return the CallableSql.
|
||||
*/
|
||||
public SpiCallableSql getCallableSql() {
|
||||
public SpiCallableSql callableSql() {
|
||||
return callableSql;
|
||||
}
|
||||
|
||||
@@ -97,13 +92,11 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
|
||||
// register table modifications with the transaction event
|
||||
TransactionEventTable tableEvents = callableSql.getTransactionEventTable();
|
||||
|
||||
if (tableEvents != null && !tableEvents.isEmpty()) {
|
||||
transaction.getEvent().add(tableEvents);
|
||||
} else {
|
||||
transaction.markNotQueryOnly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +113,6 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
* Execute the statement in normal non batch mode.
|
||||
*/
|
||||
public int executeUpdate() throws SQLException {
|
||||
|
||||
// check to see if the execution has been overridden
|
||||
// only works in non-batch mode
|
||||
if (callableSql.executeOverride(cstmt)) {
|
||||
@@ -129,20 +121,15 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
// rowCount = callableSql.getRowCount();
|
||||
// return rowCount;
|
||||
}
|
||||
|
||||
rowCount = cstmt.executeUpdate();
|
||||
|
||||
// only read in non-batch mode
|
||||
readOutParams();
|
||||
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
private void readOutParams() throws SQLException {
|
||||
|
||||
List<Param> list = bindParam.positionedParameters();
|
||||
int pos = 0;
|
||||
|
||||
for (Param param : list) {
|
||||
pos++;
|
||||
if (param.isOutParam()) {
|
||||
@@ -151,5 +138,4 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,19 +14,11 @@ import io.ebeaninternal.server.persist.PersistExecute;
|
||||
public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
|
||||
private final BeanDescriptor<?> beanDescriptor;
|
||||
|
||||
private final SpiUpdate<?> ormUpdate;
|
||||
|
||||
private int rowCount;
|
||||
|
||||
private String bindLog;
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*/
|
||||
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate,
|
||||
SpiTransaction t, PersistExecute persistExecute) {
|
||||
|
||||
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate, SpiTransaction t, PersistExecute persistExecute) {
|
||||
super(server, t, persistExecute, ormUpdate.getLabel());
|
||||
this.beanDescriptor = mgr.getBeanDescriptor();
|
||||
this.ormUpdate = ormUpdate;
|
||||
@@ -34,10 +26,10 @@ 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<?> getBeanDescriptor() {
|
||||
public BeanDescriptor<?> descriptor() {
|
||||
return beanDescriptor;
|
||||
}
|
||||
|
||||
@@ -51,11 +43,10 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
return executeStatement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the UpdateSql.
|
||||
*/
|
||||
public SpiUpdate<?> getOrmUpdate() {
|
||||
public SpiUpdate<?> ormUpdate() {
|
||||
return ormUpdate;
|
||||
}
|
||||
|
||||
@@ -91,14 +82,11 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
}
|
||||
OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType();
|
||||
String tableName = ormUpdate.getBaseTable();
|
||||
|
||||
if (transaction.isLogSummary()) {
|
||||
String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
|
||||
transaction.logSummary(m);
|
||||
}
|
||||
|
||||
if (ormUpdate.isNotifyCache()) {
|
||||
|
||||
// add the modification info to the TransactionEvent
|
||||
// this is used to invalidate cached objects etc
|
||||
switch (ormUpdateType) {
|
||||
@@ -116,5 +104,4 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,17 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
}
|
||||
|
||||
private final SpiSqlUpdate updateSql;
|
||||
|
||||
private int rowCount;
|
||||
|
||||
private String bindLog;
|
||||
|
||||
private SqlType sqlType;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private boolean addBatch;
|
||||
|
||||
private final boolean forceNoBatch;
|
||||
|
||||
private boolean batchThisRequest;
|
||||
private boolean flushQueue;
|
||||
|
||||
public PersistRequestUpdateSql(SpiEbeanServer server, SpiSqlUpdate sqlUpdate,
|
||||
SpiTransaction t, PersistExecute persistExecute, boolean forceNoBatch) {
|
||||
|
||||
super(server, t, persistExecute, sqlUpdate.getLabel());
|
||||
this.type = Type.UPDATESQL;
|
||||
this.updateSql = sqlUpdate;
|
||||
@@ -105,7 +97,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
/**
|
||||
* Return the UpdateSql.
|
||||
*/
|
||||
public SpiSqlUpdate getUpdateSql() {
|
||||
public SpiSqlUpdate updateSql() {
|
||||
return updateSql;
|
||||
}
|
||||
|
||||
@@ -145,6 +137,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
this.bindLog = bindLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startBind(boolean batchThisRequest) {
|
||||
this.batchThisRequest = batchThisRequest;
|
||||
super.startBind(batchThisRequest);
|
||||
@@ -170,7 +163,6 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
||||
if (transaction.isLogSql() && !batchThisRequest) {
|
||||
transaction.logSql(Str.add(TrimLogSql.trim(updateSql.getGeneratedSql()), "; -- bind(", bindLog, ") rows(", String.valueOf(rowCount), ")"));
|
||||
}
|
||||
|
||||
if (updateSql.isAutoTableMod()) {
|
||||
// add the modification info to the TransactionEvent
|
||||
// this is used to invalidate cached objects etc
|
||||
|
||||
@@ -22,12 +22,12 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
||||
* Return the query.
|
||||
*/
|
||||
@Override
|
||||
SpiQuery<T> getQuery();
|
||||
SpiQuery<T> query();
|
||||
|
||||
/**
|
||||
* Return the associated BeanDescriptor.
|
||||
*/
|
||||
BeanDescriptor<T> getBeanDescriptor();
|
||||
BeanDescriptor<T> descriptor();
|
||||
|
||||
/**
|
||||
* Prepare the query for execution.
|
||||
@@ -145,12 +145,12 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
||||
/**
|
||||
* Return the bean cache hits (when all hits / no misses).
|
||||
*/
|
||||
List<T> getBeanCacheHits();
|
||||
List<T> beanCacheHits();
|
||||
|
||||
/**
|
||||
* Return the bean cache hits for findMap (when all hits / no misses).
|
||||
*/
|
||||
<K> Map<K,T> getBeanCacheHitsAsMap();
|
||||
<K> Map<K,T> beanCacheHitsAsMap();
|
||||
|
||||
/**
|
||||
* Reset Bean cache mode AUTO - require explicit setting for bean cache use with findList().
|
||||
@@ -160,7 +160,7 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
||||
/**
|
||||
* Return the Database platform like clause.
|
||||
*/
|
||||
String getDBLikeClause(boolean rawLikeExpression);
|
||||
String dbLikeClause(boolean rawLikeExpression);
|
||||
|
||||
/**
|
||||
* Escapes a string to use it as exact match in Like clause.
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
|
||||
super(property);
|
||||
this.softDelete = property.targetDescriptor.isSoftDelete();
|
||||
this.softDeletePredicate = (softDelete) ? property.targetDescriptor.getSoftDeletePredicate("") : null;
|
||||
this.softDeletePredicate = (softDelete) ? property.targetDescriptor.softDeletePredicate("") : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +22,7 @@ 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());
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
ctx.pushTableAlias(relativePrefix);
|
||||
property.targetIdBinder.appendSelect(ctx, subQuery);
|
||||
ctx.popTableAlias();
|
||||
@@ -30,7 +30,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
||||
|
||||
@Override
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
if (softDelete && !ctx.isIncludeSoftDelete()) {
|
||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
|
||||
} else {
|
||||
|
||||
@@ -70,7 +70,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||
if (!subQuery) {
|
||||
// add discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||
String tableAlias = ctx.getTableAlias(relativePrefix);
|
||||
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
|
||||
|
||||
BaseCollectionHelp(BeanPropertyAssocMany<T> many) {
|
||||
this.many = many;
|
||||
this.targetDescriptor = many.getTargetDescriptor();
|
||||
this.propertyName = many.getName();
|
||||
this.targetDescriptor = many.targetDescriptor();
|
||||
this.propertyName = many.name();
|
||||
}
|
||||
|
||||
BaseCollectionHelp() {
|
||||
|
||||
@@ -54,10 +54,10 @@ final class BeanChangeJson implements BeanDiffVisitor {
|
||||
public void visitPush(int position) {
|
||||
stack.push(descriptor);
|
||||
BeanPropertyAssocOne<?> embedded = (BeanPropertyAssocOne<?>)descriptor.propertiesIndex[position];
|
||||
descriptor = embedded.getTargetDescriptor();
|
||||
newJson.writeStartObject(embedded.getName());
|
||||
descriptor = embedded.targetDescriptor();
|
||||
newJson.writeStartObject(embedded.name());
|
||||
if (oldJson != null) {
|
||||
oldJson.writeStartObject(embedded.getName());
|
||||
oldJson.writeStartObject(embedded.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ public final class BeanCollectionHelpFactory {
|
||||
*/
|
||||
public static <T> BeanCollectionHelp<T> create(BeanPropertyAssocMany<T> many) {
|
||||
boolean elementCollection = many.isElementCollection();
|
||||
ManyType manyType = many.getManyType();
|
||||
ManyType manyType = many.manyType();
|
||||
switch (manyType) {
|
||||
case LIST:
|
||||
return elementCollection ? new BeanListHelpElement<>(many) : new BeanListHelp<>(many);
|
||||
@@ -44,8 +44,8 @@ public final class BeanCollectionHelpFactory {
|
||||
return SET_HELP;
|
||||
|
||||
} else if (manyType == SpiQuery.Type.MAP) {
|
||||
BeanDescriptor<T> target = request.getBeanDescriptor();
|
||||
ElPropertyValue elProperty = target.getElGetValue(request.getQuery().getMapKey());
|
||||
BeanDescriptor<T> target = request.descriptor();
|
||||
ElPropertyValue elProperty = target.elGetValue(request.query().getMapKey());
|
||||
return new BeanMapQueryHelp<>(elProperty);
|
||||
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+15
-15
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
// held as part of the bean cache so skip
|
||||
return false;
|
||||
}
|
||||
CachedManyIds entry = manyPropGet(parentId, many.getName());
|
||||
CachedManyIds entry = manyPropGet(parentId, many.name());
|
||||
if (entry == null) {
|
||||
// not in cache so return unsuccessful
|
||||
return false;
|
||||
@@ -290,7 +290,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
EntityBean ownerBean = bc.getOwnerBean();
|
||||
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
|
||||
PersistenceContext persistenceContext = ebi.getPersistenceContext();
|
||||
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
|
||||
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
|
||||
|
||||
List<Object> idList = entry.getIdList();
|
||||
bc.checkEmptyLazyLoad();
|
||||
@@ -316,7 +316,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
// add as JSON to bean cache
|
||||
String asJson = many.jsonWriteCollection(details);
|
||||
Map<String, Object> changes = new HashMap<>();
|
||||
changes.put(many.getName(), asJson);
|
||||
changes.put(many.name(), asJson);
|
||||
|
||||
CachedBeanData newData = data.update(changes, data.getVersion());
|
||||
if (beanLog.isDebugEnabled()) {
|
||||
@@ -330,7 +330,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
} else {
|
||||
CachedManyIds entry = createManyIds(many, details);
|
||||
if (entry != null) {
|
||||
cachePutManyIds(parentId, many.getName(), entry);
|
||||
cachePutManyIds(parentId, many.name(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,10 +349,10 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
|
||||
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
|
||||
List<Object> idList = new ArrayList<>(actualDetails.size());
|
||||
for (Object bean : actualDetails) {
|
||||
idList.add(targetDescriptor.getId((EntityBean) 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.getBeanId(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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
if (beanCache != null) {
|
||||
changeSet.addBeanRemove(desc, id);
|
||||
}
|
||||
cacheDeleteImported(true, deleteRequest.getEntityBean(), changeSet);
|
||||
cacheDeleteImported(true, deleteRequest.entityBean(), changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,8 +815,8 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
changeSet.addInvalidate(desc);
|
||||
} else {
|
||||
queryCacheClear(changeSet);
|
||||
cacheDeleteImported(false, insertRequest.getEntityBean(), changeSet);
|
||||
changeSet.addBeanInsert(desc.getBaseTable());
|
||||
cacheDeleteImported(false, insertRequest.entityBean(), changeSet);
|
||||
changeSet.addBeanInsert(desc.baseTable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,13 +839,13 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
// query caching only
|
||||
return;
|
||||
}
|
||||
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.getUpdatedManyForL2Cache();
|
||||
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.updatedManyForL2Cache();
|
||||
if (manyCollections != null) {
|
||||
for (BeanPropertyAssocMany<?> many : manyCollections) {
|
||||
Object details = many.getValue(updateRequest.getEntityBean());
|
||||
Object details = many.getValue(updateRequest.entityBean());
|
||||
CachedManyIds entry = createManyIds(many, details);
|
||||
if (entry != null) {
|
||||
changeSet.addManyPut(desc, many.getName(), id, entry);
|
||||
changeSet.addManyPut(desc, many.name(), id, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -19,7 +19,7 @@ final class BeanDescriptorDraftHelp<T> {
|
||||
|
||||
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
|
||||
this.desc = desc;
|
||||
this.draftDirty = desc.getDraftDirty();
|
||||
this.draftDirty = desc.draftDirty();
|
||||
this.resetProperties = resetProperties();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ final class BeanDescriptorDraftHelp<T> {
|
||||
prop.publish(draft, live);
|
||||
}
|
||||
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
|
||||
if (many.getTargetDescriptor().isDraftable()) {
|
||||
if (many.targetDescriptor().isDraftable()) {
|
||||
many.publishMany(draft, live);
|
||||
}
|
||||
}
|
||||
@@ -86,13 +86,13 @@ final class BeanDescriptorDraftHelp<T> {
|
||||
*/
|
||||
void draftQueryOptimise(Query<T> query) {
|
||||
for (BeanPropertyAssocOne<?> anOne : desc.propertiesOne()) {
|
||||
if (anOne.getTargetDescriptor().isDraftableElement()) {
|
||||
query.fetch(anOne.getName());
|
||||
if (anOne.targetDescriptor().isDraftableElement()) {
|
||||
query.fetch(anOne.name());
|
||||
}
|
||||
}
|
||||
for (BeanPropertyAssocMany<?> aMany : desc.propertiesMany()) {
|
||||
if (aMany.getTargetDescriptor().isDraftableElement()) {
|
||||
query.fetch(aMany.getName());
|
||||
if (aMany.targetDescriptor().isDraftableElement()) {
|
||||
query.fetch(aMany.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSimpleName() {
|
||||
public String simpleName() {
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
|
||||
if (props.length != 1) {
|
||||
throw new IllegalStateException("Expecting 1 property for element scalar but got " + Arrays.toString(props));
|
||||
}
|
||||
return props[0].getScalarType();
|
||||
return props[0].scalarType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
|
||||
@Override
|
||||
public void initialiseOther(BeanDescriptorInitContext initContext) {
|
||||
super.initialiseOther(initContext);
|
||||
this.targetDescriptor = embeddedProperty.getTargetDescriptor();
|
||||
this.targetDescriptor = embeddedProperty.targetDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
|
||||
if (props.length != 2) {
|
||||
throw new IllegalStateException("Expecting 2 properties for key and value but got " + Arrays.toString(props));
|
||||
}
|
||||
this.scalarTypeKey = props[0].getScalarType();
|
||||
this.scalarTypeVal = props[1].getScalarType();
|
||||
this.scalarTypeKey = props[0].scalarType();
|
||||
this.scalarTypeVal = props[1].scalarType();
|
||||
this.stringKey = String.class.equals(scalarTypeKey.getType());
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
// render the dirty properties
|
||||
BeanProperty[] props = desc.propertiesNonTransient();
|
||||
for (BeanProperty prop : props) {
|
||||
if (dirtyProps[prop.getPropertyIndex()]) {
|
||||
if (dirtyProps[prop.propertyIndex()]) {
|
||||
prop.jsonWrite(writeJson, bean);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
JsonToken event = parser.nextToken();
|
||||
if (JsonToken.FIELD_NAME == event) {
|
||||
String key = parser.getCurrentName();
|
||||
BeanProperty p = desc.getBeanProperty(key);
|
||||
BeanProperty p = desc.beanProperty(key);
|
||||
if (p != null) {
|
||||
p.jsonRead(readJson, bean);
|
||||
} else {
|
||||
@@ -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);
|
||||
|
||||
+51
-51
@@ -136,8 +136,8 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
this.multiValueBind = config.getMultiValueBind();
|
||||
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
|
||||
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
|
||||
this.asOfViewSuffix = getAsOfViewSuffix(databasePlatform, this.config);
|
||||
String versionsBetweenSuffix = getVersionsBetweenSuffix(databasePlatform, this.config);
|
||||
this.asOfViewSuffix = asOfViewSuffix(databasePlatform, this.config);
|
||||
String versionsBetweenSuffix = versionsBetweenSuffix(databasePlatform, this.config);
|
||||
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix, this.config);
|
||||
this.bootupClasses = config.getBootupClasses();
|
||||
this.createProperties = config.getDeployCreateProperties();
|
||||
@@ -183,19 +183,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarType<?> getScalarType(String cast) {
|
||||
public ScalarType<?> scalarType(String cast) {
|
||||
return typeManager.getScalarType(cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarType<?> getScalarType(int jdbcType) {
|
||||
public ScalarType<?> scalarType(int jdbcType) {
|
||||
return typeManager.getScalarType(jdbcType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the AsOfViewSuffix based on the DbHistorySupport.
|
||||
*/
|
||||
private String getAsOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
|
||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
|
||||
@@ -204,7 +204,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
/**
|
||||
* Return the versions between timestamp suffix based on the DbHistorySupport.
|
||||
*/
|
||||
private String getVersionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
|
||||
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
|
||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
|
||||
@@ -216,7 +216,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseConfig getConfig() {
|
||||
public DatabaseConfig config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -225,38 +225,38 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
return docStoreFactory.createAdapter(descriptor, deploy);
|
||||
}
|
||||
|
||||
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
|
||||
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
|
||||
return descQueueMap.get(queueId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiBeanType getBeanType(Class<?> entityType) {
|
||||
return getBeanDescriptor(entityType);
|
||||
public SpiBeanType beanType(Class<?> entityType) {
|
||||
return descriptor(entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> BeanDescriptor<T> getBeanDescriptor(Class<T> entityType) {
|
||||
public <T> BeanDescriptor<T> descriptor(Class<T> entityType) {
|
||||
return (BeanDescriptor<T>) descMap.get(entityType.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> BeanDescriptor<T> getBeanDescriptorByClassName(String entityClassName) {
|
||||
public <T> BeanDescriptor<T> descriptorByClassName(String entityClassName) {
|
||||
return (BeanDescriptor<T>) descMap.get(entityClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
public String name() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiCacheManager getCacheManager() {
|
||||
public SpiCacheManager cacheManager() {
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingConvention getNamingConvention() {
|
||||
public NamingConvention namingConvention() {
|
||||
return namingConvention;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
/**
|
||||
* Return the map of base tables to draft tables.
|
||||
*/
|
||||
public Map<String, String> getDraftTableMap() {
|
||||
public Map<String, String> draftTableMap() {
|
||||
return draftTableMap;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* Return the Encrypt key given the table and column name.
|
||||
*/
|
||||
@Override
|
||||
public EncryptKey getEncryptKey(String tableName, String columnName) {
|
||||
public EncryptKey encryptKey(String tableName, String columnName) {
|
||||
return encryptKeyManager.getEncryptKey(tableName, columnName);
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* For SQL based modifications we need to invalidate appropriate parts of the cache.
|
||||
*/
|
||||
public void cacheNotify(TransactionEventTable.TableIUD tableIUD, CacheChangeSet changeSet) {
|
||||
String tableName = tableIUD.getTableName().toLowerCase();
|
||||
String tableName = tableIUD.tableName().toLowerCase();
|
||||
List<BeanDescriptor<?>> normalBeanTypes = tableToDescMap.get(tableName);
|
||||
if (normalBeanTypes != null) {
|
||||
// 'normal' entity beans based on a "base table"
|
||||
@@ -397,14 +397,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
/**
|
||||
* Return the BeanDescriptors mapped to the table.
|
||||
*/
|
||||
public List<BeanDescriptor<?>> getBeanDescriptors(String tableName) {
|
||||
public List<BeanDescriptor<?>> descriptors(String tableName) {
|
||||
return tableToDescMap.get(tableName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptors mapped to the table.
|
||||
*/
|
||||
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
|
||||
public List<? extends BeanType<?>> beanTypes(String tableName) {
|
||||
return tableToDescMap.get(tableName.toLowerCase());
|
||||
}
|
||||
|
||||
@@ -433,16 +433,16 @@ 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));
|
||||
list.add(desc);
|
||||
}
|
||||
if (desc.getEntityType() == EntityType.VIEW && desc.isQueryCaching()) {
|
||||
if (desc.entityType() == EntityType.VIEW && desc.isQueryCaching()) {
|
||||
// build map of tables to view entities dependent on those tables
|
||||
// for the purpose of invalidating appropriate query caches
|
||||
String[] dependentTables = desc.getDependentTables();
|
||||
String[] dependentTables = desc.dependentTables();
|
||||
if (dependentTables != null && dependentTables.length > 0) {
|
||||
for (String depTable : dependentTables) {
|
||||
depTable = depTable.toLowerCase();
|
||||
@@ -508,23 +508,23 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForValidEmbeddedId(BeanDescriptor<?> d) {
|
||||
IdBinder idBinder = d.getIdBinder();
|
||||
IdBinder idBinder = d.idBinder();
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -546,11 +546,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
/**
|
||||
* Return an immutable list of all the BeanDescriptors.
|
||||
*/
|
||||
public List<BeanDescriptor<?>> getBeanDescriptorList() {
|
||||
public List<BeanDescriptor<?>> descriptorList() {
|
||||
return immutableDescriptorList;
|
||||
}
|
||||
|
||||
public BeanTable getBeanTable(Class<?> type) {
|
||||
public BeanTable beanTable(Class<?> type) {
|
||||
return beanTableMap.get(type);
|
||||
}
|
||||
|
||||
@@ -562,11 +562,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> BeanManager<T> getBeanManager(Class<T> entityType) {
|
||||
return (BeanManager<T>) getBeanManager(entityType.getName());
|
||||
public <T> BeanManager<T> beanManager(Class<T> entityType) {
|
||||
return (BeanManager<T>) beanManager(entityType.getName());
|
||||
}
|
||||
|
||||
private BeanManager<?> getBeanManager(String beanClassName) {
|
||||
private BeanManager<?> beanManager(String beanClassName) {
|
||||
return beanManagerMap.get(beanClassName);
|
||||
}
|
||||
|
||||
@@ -591,19 +591,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* Return the bean deploy info for the given class.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> DeployBeanInfo<T> getDeploy(Class<T> cls) {
|
||||
public <T> DeployBeanInfo<T> deploy(Class<T> cls) {
|
||||
return (DeployBeanInfo<T>) deployInfoMap.get(cls);
|
||||
}
|
||||
|
||||
private void registerBeanDescriptor(DeployBeanInfo<?> info) {
|
||||
private void registerDescriptor(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()) {
|
||||
elementDescriptors.add(many.getElementDescriptor());
|
||||
elementDescriptors.add(many.elementDescriptor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,7 +640,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
|
||||
private void registerEmbeddedBean(DeployBeanInfo<?> info) {
|
||||
readDeployAssociations(info);
|
||||
registerBeanDescriptor(info);
|
||||
registerDescriptor(info);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -711,7 +711,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
for (DeployBeanInfo<?> info : deployInfoMap.values()) {
|
||||
if (!info.isEmbedded()) {
|
||||
registerBeanDescriptor(info);
|
||||
registerDescriptor(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -785,7 +785,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
}
|
||||
|
||||
private DeployBeanDescriptor<?> getTargetDescriptor(DeployBeanPropertyAssoc<?> prop) {
|
||||
private DeployBeanDescriptor<?> targetDescriptor(DeployBeanPropertyAssoc<?> prop) {
|
||||
Class<?> targetType = prop.getTargetType();
|
||||
DeployBeanInfo<?> info = deployInfoMap.get(targetType);
|
||||
if (info == null) {
|
||||
@@ -805,7 +805,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
Set<String> matchSet = new HashSet<>();
|
||||
|
||||
// get the bean descriptor that holds the mappedBy property
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||
List<DeployBeanPropertyAssocOne<?>> ones = targetDesc.propertiesAssocOne();
|
||||
for (DeployBeanPropertyAssocOne<?> possibleMappedBy : ones) {
|
||||
Class<?> possibleMappedByType = possibleMappedBy.getTargetType();
|
||||
@@ -866,7 +866,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
}
|
||||
|
||||
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
|
||||
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
|
||||
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
|
||||
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, scalarType, null);
|
||||
@@ -898,7 +898,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* into the order_id column on the order_lines table).
|
||||
*/
|
||||
private void makeUnidirectional(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
|
||||
Class<?> owningType = oneToMany.getOwningType();
|
||||
if (!oneToMany.getCascadeInfo().isSave()) {
|
||||
// The property MUST have persist cascading so that inserts work.
|
||||
@@ -915,7 +915,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
oneToMany.setUnidirectional();
|
||||
|
||||
// specify table and table alias...
|
||||
BeanTable beanTable = getBeanTable(owningType);
|
||||
BeanTable beanTable = beanTable(owningType);
|
||||
|
||||
// define the TableJoin
|
||||
DeployTableJoin oneToManyJoin = oneToMany.getTableJoin();
|
||||
@@ -951,7 +951,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
// its associated join information if it is available
|
||||
String mappedBy = prop.getMappedBy();
|
||||
// get the mappedBy property
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||
if (mappedProp == null) {
|
||||
String m = "Error on " + prop.getFullBeanName();
|
||||
@@ -1008,7 +1008,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
// skip mapping check
|
||||
return;
|
||||
}
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||
|
||||
if (targetDesc.isDraftableElement()) {
|
||||
// automatically turning on orphan removal and CascadeType.ALL
|
||||
@@ -1087,14 +1087,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
// get the bean descriptor that holds the mappedBy property
|
||||
String mappedBy = prop.getMappedBy();
|
||||
if (mappedBy == null) {
|
||||
if (getTargetDescriptor(prop).isDraftable()) {
|
||||
if (targetDescriptor(prop).isDraftable()) {
|
||||
prop.setIntersectionDraftTable();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// get the mappedBy property
|
||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
||||
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||
|
||||
if (mappedProp == null) {
|
||||
@@ -1433,14 +1433,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
* Return the changeLogPrepare (for setting user context into the ChangeSet
|
||||
* in the foreground thread).
|
||||
*/
|
||||
public ChangeLogPrepare getChangeLogPrepare() {
|
||||
public ChangeLogPrepare changeLogPrepare() {
|
||||
return changeLogPrepare;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the changeLogListener (that actually does the logging).
|
||||
*/
|
||||
public ChangeLogListener getChangeLogListener() {
|
||||
public ChangeLogListener changeLogListener() {
|
||||
return changeLogListener;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@ public interface BeanDescriptorMap {
|
||||
/**
|
||||
* Return the name of the server/database.
|
||||
*/
|
||||
String getServerName();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Return the DatabaseConfig.
|
||||
*/
|
||||
DatabaseConfig getConfig();
|
||||
DatabaseConfig config();
|
||||
|
||||
/**
|
||||
* Return the Cache Manager.
|
||||
*/
|
||||
SpiCacheManager getCacheManager();
|
||||
SpiCacheManager cacheManager();
|
||||
|
||||
/**
|
||||
* Return the naming convention.
|
||||
*/
|
||||
NamingConvention getNamingConvention();
|
||||
NamingConvention namingConvention();
|
||||
|
||||
/**
|
||||
* Return true if multiple values can be bound as Array or Table Value and hence share the same query plan.
|
||||
@@ -45,12 +45,12 @@ public interface BeanDescriptorMap {
|
||||
/**
|
||||
* Return the BeanDescriptor for a given class.
|
||||
*/
|
||||
<T> BeanDescriptor<T> getBeanDescriptor(Class<T> entityType);
|
||||
<T> BeanDescriptor<T> descriptor(Class<T> entityType);
|
||||
|
||||
/**
|
||||
* Return the Encrypt key given the table and column name.
|
||||
*/
|
||||
EncryptKey getEncryptKey(String tableName, String columnName);
|
||||
EncryptKey encryptKey(String tableName, String columnName);
|
||||
|
||||
/**
|
||||
* Create a IdBinder for this bean property.
|
||||
@@ -65,18 +65,18 @@ public interface BeanDescriptorMap {
|
||||
/**
|
||||
* Return the scalarType for the given JDBC type.
|
||||
*/
|
||||
ScalarType<?> getScalarType(int jdbcType);
|
||||
ScalarType<?> scalarType(int jdbcType);
|
||||
|
||||
/**
|
||||
* Return the scalarType for the given logical type.
|
||||
*/
|
||||
ScalarType<?> getScalarType(String cast);
|
||||
ScalarType<?> scalarType(String cast);
|
||||
|
||||
/**
|
||||
* Return true if Jackson core is present on the classpath.
|
||||
*/
|
||||
boolean isJacksonCorePresent();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true, if the given table (or view) is managed by ebean
|
||||
* (= an entity exists)
|
||||
|
||||
+6
-6
@@ -19,7 +19,7 @@ final class BeanEmbeddedMetaFactory {
|
||||
// we can get a BeanDescriptor for an Embedded bean
|
||||
// and know that it is NOT recursive, as Embedded beans are
|
||||
// only allow to hold simple scalar types...
|
||||
BeanDescriptor<?> targetDesc = owner.getBeanDescriptor(prop.getTargetType());
|
||||
BeanDescriptor<?> targetDesc = owner.descriptor(prop.getTargetType());
|
||||
if (targetDesc == null) {
|
||||
String msg = "Could not find BeanDescriptor for " + prop.getTargetType()
|
||||
+ ". Perhaps the EmbeddedId class is not registered? See https://ebean.io/docs/trouble-shooting#not-registered";
|
||||
@@ -34,7 +34,7 @@ final class BeanEmbeddedMetaFactory {
|
||||
BeanProperty[] embeddedProperties = new BeanProperty[sourceProperties.length];
|
||||
|
||||
for (int i = 0; i < sourceProperties.length; i++) {
|
||||
String propertyName = sourceProperties[i].getName();
|
||||
String propertyName = sourceProperties[i].name();
|
||||
Column column = propColMap.get(propertyName);
|
||||
String dbColumn = dbColumn(columnPrefix, column, sourceProperties[i]);
|
||||
boolean dbNullable = dbNullable(column, sourceProperties[i]);
|
||||
@@ -49,7 +49,7 @@ final class BeanEmbeddedMetaFactory {
|
||||
}
|
||||
|
||||
private static String dbColumn(String prefix, Column override, BeanProperty source) {
|
||||
String dbCol = (override != null && !override.name().isEmpty()) ? override.name() : source.getDbColumn();
|
||||
String dbCol = (override != null && !override.name().isEmpty()) ? override.name() : source.dbColumn();
|
||||
return prefix == null ? dbCol : prefix + dbCol;
|
||||
}
|
||||
|
||||
@@ -58,15 +58,15 @@ final class BeanEmbeddedMetaFactory {
|
||||
}
|
||||
|
||||
private static int dbLength(Column override, BeanProperty source) {
|
||||
return (override != null && (override.length() != 255)) ? override.length() : source.getDbLength();
|
||||
return (override != null && (override.length() != 255)) ? override.length() : source.dbLength();
|
||||
}
|
||||
|
||||
private static int dbScale(Column override, BeanProperty source) {
|
||||
return (override != null && (override.scale() != 0)) ? override.scale() : source.getDbScale();
|
||||
return (override != null && (override.scale() != 0)) ? override.scale() : source.dbScale();
|
||||
}
|
||||
|
||||
private static String getDbColumnDefn(Column override, BeanProperty source) {
|
||||
return (override != null && !override.columnDefinition().isEmpty()) ? override.columnDefinition() : source.getDbColumnDefn();
|
||||
return (override != null && !override.columnDefinition().isEmpty()) ? override.columnDefinition() : source.dbColumnDefn();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchPreference() {
|
||||
public int fetchPreference() {
|
||||
// return some decently high value
|
||||
return 1000;
|
||||
}
|
||||
@@ -101,17 +101,17 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDbColumn() {
|
||||
public String dbColumn() {
|
||||
return dbColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElName() {
|
||||
public String elName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
* Returns null as not an AssocOne.
|
||||
*/
|
||||
@Override
|
||||
public Object[] getAssocIdValues(EntityBean value) {
|
||||
public Object[] assocIdValues(EntityBean value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
* Returns null as not an AssocOne.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdExpression(String prefix, String operator) {
|
||||
public String assocIdExpression(String prefix, String operator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
* Returns null as not an AssocOne.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
public String assocIdInExpr(String prefix) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
* Returns null as not an AssocOne.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
||||
public String assocIdInValueExpr(boolean not, int size) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
public String assocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
throw new RuntimeException("Not Supported or Expected");
|
||||
}
|
||||
|
||||
@@ -171,12 +171,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPlaceholder(boolean encrypted) {
|
||||
public String elPlaceholder(boolean encrypted) {
|
||||
return placeHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPrefix() {
|
||||
public String elPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@@ -186,12 +186,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcType() {
|
||||
public int jdbcType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanProperty getBeanProperty() {
|
||||
public BeanProperty beanProperty() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParser getStringParser() {
|
||||
public StringParser stringParser() {
|
||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property property() {
|
||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ final class BeanLifecycleAdapterFactory {
|
||||
|
||||
private void invoke(Method[] methods, BeanPersistRequest<?> request) {
|
||||
for (Method method : methods) {
|
||||
invoke(method, request.getBean());
|
||||
invoke(method, request.bean());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
public BeanCollection<T> createEmpty(EntityBean parentBean) {
|
||||
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
||||
if (many != null) {
|
||||
beanList.setModifyListening(many.getModifyListenMode());
|
||||
beanList.setModifyListening(many.modifyListenMode());
|
||||
}
|
||||
return beanList;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
public BeanCollection<T> createReference(EntityBean parentBean) {
|
||||
|
||||
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
||||
beanList.setModifyListening(many.getModifyListenMode());
|
||||
beanList.setModifyListening(many.modifyListenMode());
|
||||
return beanList;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
|
||||
List<?> currentList = (List<?>) many.getValue(parentBean);
|
||||
|
||||
newBeanList.setModifyListening(many.getModifyListenMode());
|
||||
newBeanList.setModifyListening(many.modifyListenMode());
|
||||
|
||||
if (currentList == null) {
|
||||
// the currentList is null? Not really expecting this...
|
||||
@@ -87,7 +87,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanList<?> currentBeanList = (BeanList<?>) currentList;
|
||||
currentBeanList.setActualList(newBeanList.getActualList());
|
||||
currentBeanList.setModifyListening(many.getModifyListenMode());
|
||||
currentBeanList.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
// replace the entire list with the BeanList
|
||||
|
||||
@@ -29,9 +29,9 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
*/
|
||||
BeanMapHelp(BeanPropertyAssocMany<T> many) {
|
||||
this.many = many;
|
||||
this.targetDescriptor = many.getTargetDescriptor();
|
||||
this.propertyName = many.getName();
|
||||
this.beanProperty = targetDescriptor.getBeanProperty(many.getMapKey());
|
||||
this.targetDescriptor = many.targetDescriptor();
|
||||
this.propertyName = many.name();
|
||||
this.beanProperty = targetDescriptor.beanProperty(many.mapKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,9 +39,9 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
public BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
||||
|
||||
if (mapKey == null) {
|
||||
mapKey = many.getMapKey();
|
||||
mapKey = many.mapKey();
|
||||
}
|
||||
BeanProperty beanProp = targetDescriptor.getBeanProperty(mapKey);
|
||||
BeanProperty beanProp = targetDescriptor.beanProperty(mapKey);
|
||||
|
||||
if (bc instanceof BeanMap<?, ?>) {
|
||||
BeanMap<Object, Object> bm = (BeanMap<Object, Object>) bc;
|
||||
@@ -85,7 +85,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
|
||||
BeanMap<?, T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
|
||||
if (many != null) {
|
||||
beanMap.setModifyListening(many.getModifyListenMode());
|
||||
beanMap.setModifyListening(many.modifyListenMode());
|
||||
}
|
||||
return beanMap;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
|
||||
BeanMap beanMap = new BeanMap(loader, parentBean, propertyName);
|
||||
if (many != null) {
|
||||
beanMap.setModifyListening(many.getModifyListenMode());
|
||||
beanMap.setModifyListening(many.modifyListenMode());
|
||||
}
|
||||
return beanMap;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
BeanMap<?, ?> newBeanMap = (BeanMap<?, ?>) bc;
|
||||
Map<?, ?> current = (Map<?, ?>) many.getValue(parentBean);
|
||||
|
||||
newBeanMap.setModifyListening(many.getModifyListenMode());
|
||||
newBeanMap.setModifyListening(many.modifyListenMode());
|
||||
if (current == null) {
|
||||
// the currentMap is null? Not really expecting this...
|
||||
many.setValue(parentBean, newBeanMap);
|
||||
@@ -134,7 +134,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanMap<?, ?> currentBeanMap = (BeanMap<?, ?>) current;
|
||||
currentBeanMap.setActualMap(newBeanMap.getActualMap());
|
||||
currentBeanMap.setModifyListening(many.getModifyListenMode());
|
||||
currentBeanMap.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
// replace the entire set
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -286,7 +284,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
protected BeanProperty(BeanProperty source, BeanPropertyOverride override) {
|
||||
this.descriptor = source.descriptor;
|
||||
this.propertyIndex = source.propertyIndex;
|
||||
this.name = source.getName();
|
||||
this.name = source.name();
|
||||
this.dbColumn = override.getDbColumn();
|
||||
this.nullable = override.isDbNullable();
|
||||
this.dbLength = override.getDbLength();
|
||||
@@ -316,9 +314,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
this.secondaryTableJoin = source.secondaryTableJoin;
|
||||
this.secondaryTableJoinPrefix = source.secondaryTableJoinPrefix;
|
||||
this.dbComment = source.dbComment;
|
||||
this.dbBind = source.getDbBind();
|
||||
this.dbBind = source.dbBind();
|
||||
this.dbEncrypted = source.isDbEncrypted();
|
||||
this.dbEncryptedType = source.getDbEncryptedType();
|
||||
this.dbEncryptedType = source.dbEncryptedType();
|
||||
this.dbEncryptFunction = source.dbEncryptFunction;
|
||||
this.dbRead = source.isDbRead();
|
||||
this.dbInsertable = source.isDbInsertable();
|
||||
@@ -329,18 +327,18 @@ 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();
|
||||
this.generatedProperty = source.getGeneratedProperty();
|
||||
this.generatedProperty = source.generatedProperty();
|
||||
this.getter = source.getter;
|
||||
this.setter = source.setter;
|
||||
this.dbType = source.getDbType(true);
|
||||
this.dbType = source.dbType(true);
|
||||
this.scalarType = source.scalarType;
|
||||
this.lob = isLobType(dbType);
|
||||
this.propertyType = source.getPropertyType();
|
||||
this.field = source.getField();
|
||||
this.propertyType = source.type();
|
||||
this.field = source.field();
|
||||
this.docOptions = source.docOptions;
|
||||
this.unmappedJson = source.unmappedJson;
|
||||
this.elPrefix = override.replace(source.elPrefix, source.dbColumn);
|
||||
@@ -358,14 +356,14 @@ 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() + "." + name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the order this property appears in the bean.
|
||||
*/
|
||||
public int getDeployOrder() {
|
||||
public int deployOrder() {
|
||||
return deployOrder;
|
||||
}
|
||||
|
||||
@@ -383,7 +381,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the BeanDescriptor that owns this property.
|
||||
*/
|
||||
public BeanDescriptor<?> getBeanDescriptor() {
|
||||
public BeanDescriptor<?> descriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@@ -426,28 +424,28 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the encrypt key for the column matching this property.
|
||||
*/
|
||||
public EncryptKey getEncryptKey() {
|
||||
return descriptor.getEncryptKey(this);
|
||||
public EncryptKey encryptKey() {
|
||||
return descriptor.encryptKey(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptKeyAsString() {
|
||||
return getEncryptKey().getStringValue();
|
||||
public String encryptKeyAsString() {
|
||||
return encryptKey().getStringValue();
|
||||
}
|
||||
|
||||
public String getDecryptProperty(String propertyName) {
|
||||
public String decryptProperty(String propertyName) {
|
||||
return dbEncryptFunction.getDecryptSql(propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SQL for the column including decryption function and column alias.
|
||||
*/
|
||||
private String getDecryptSqlWithColumnAlias(String tableAlias) {
|
||||
return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.getDbColumn()) + ENC_PREFIX + tableAlias + "_" + this.getDbColumn();
|
||||
private String decryptSqlWithColumnAlias(String tableAlias) {
|
||||
return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.dbColumn()) + ENC_PREFIX + tableAlias + "_" + this.dbColumn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchPreference() {
|
||||
public int fetchPreference() {
|
||||
// return some decently high value - override on ToMany property
|
||||
return 1000;
|
||||
}
|
||||
@@ -470,7 +468,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Returns null unless this property is using a secondary table. In that
|
||||
* case this returns the logical property prefix.
|
||||
*/
|
||||
public String getSecondaryTableJoinPrefix() {
|
||||
public String secondaryTableJoinPrefix() {
|
||||
return secondaryTableJoinPrefix;
|
||||
}
|
||||
|
||||
@@ -490,7 +488,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
ctx.pushTableAlias(ctx.getRelativePrefix(secondaryTableJoinPrefix));
|
||||
}
|
||||
if (dbEncrypted) {
|
||||
ctx.appendRawColumn(getDecryptSqlWithColumnAlias(ctx.peekTableAlias()));
|
||||
ctx.appendRawColumn(decryptSqlWithColumnAlias(ctx.peekTableAlias()));
|
||||
ctx.addEncryptedProp(this);
|
||||
} else {
|
||||
ctx.appendColumn(dbColumn);
|
||||
@@ -569,12 +567,12 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanProperty getBeanProperty() {
|
||||
public BeanProperty beanProperty() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property property() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -606,14 +604,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the DB literal expression to set the deleted state to true.
|
||||
*/
|
||||
String getSoftDeleteDbSet() {
|
||||
String softDeleteDbSet() {
|
||||
return softDeleteDbSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB literal predicate used to filter out soft deleted rows from a query.
|
||||
*/
|
||||
String getSoftDeleteDbPredicate(String tableAlias) {
|
||||
String softDeleteDbPredicate(String tableAlias) {
|
||||
return tableAlias + softDeleteDbPredicate;
|
||||
}
|
||||
|
||||
@@ -758,7 +756,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getVal(Object bean) {
|
||||
public Object value(Object bean) {
|
||||
return getValue((EntityBean) bean);
|
||||
}
|
||||
|
||||
@@ -819,19 +817,19 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the position of this property in the enhanced bean.
|
||||
*/
|
||||
public int getPropertyIndex() {
|
||||
public int propertyIndex() {
|
||||
return propertyIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElName() {
|
||||
public String elName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -851,31 +849,31 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
public String assocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
// overridden in BanePropertyAssocMany
|
||||
throw new RuntimeException("Not Supported or Expected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAssocIdValues(EntityBean bean) {
|
||||
public Object[] assocIdValues(EntityBean bean) {
|
||||
// Returns null as not an AssocOne.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdExpression(String prefix, String operator) {
|
||||
public String assocIdExpression(String prefix, String operator) {
|
||||
// Returns null as not an AssocOne.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
public String assocIdInExpr(String prefix) {
|
||||
// Returns null as not an AssocOne.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
||||
public String assocIdInValueExpr(boolean not, int size) {
|
||||
// Returns null as not an AssocOne.
|
||||
return null;
|
||||
}
|
||||
@@ -906,12 +904,12 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPlaceholder(boolean encrypted) {
|
||||
public String elPlaceholder(boolean encrypted) {
|
||||
return encrypted ? elPlaceHolderEncrypted : elPlaceHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPrefix() {
|
||||
public String elPrefix() {
|
||||
return elPrefix;
|
||||
}
|
||||
|
||||
@@ -919,8 +917,8 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return the full name of this property.
|
||||
*/
|
||||
@Override
|
||||
public String getFullBeanName() {
|
||||
return descriptor.getFullName() + "." + name;
|
||||
public String fullName() {
|
||||
return descriptor.fullName() + "." + name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -936,12 +934,12 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings(value = "unchecked")
|
||||
public ScalarType<Object> getScalarType() {
|
||||
public ScalarType<Object> scalarType() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParser getStringParser() {
|
||||
public StringParser stringParser() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
@@ -951,7 +949,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcType() {
|
||||
public int jdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
}
|
||||
|
||||
@@ -963,21 +961,21 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the DB max length (varchar) or precision (decimal).
|
||||
*/
|
||||
public int getDbLength() {
|
||||
public int dbLength() {
|
||||
return dbLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB scale for numeric columns.
|
||||
*/
|
||||
public int getDbScale() {
|
||||
public int dbScale() {
|
||||
return dbScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a specific column DDL definition if specified (otherwise null).
|
||||
*/
|
||||
public String getDbColumnDefn() {
|
||||
public String dbColumnDefn() {
|
||||
return dbColumnDefn;
|
||||
}
|
||||
|
||||
@@ -987,7 +985,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* For an Enum returns IN expression for the set of Enum values.
|
||||
* </p>
|
||||
*/
|
||||
public Set<String> getDbCheckConstraintValues() {
|
||||
public Set<String> dbCheckConstraintValues() {
|
||||
if (scalarType instanceof ScalarTypeEnum) {
|
||||
return ((ScalarTypeEnum<?>) scalarType).getDbCheckConstraintValues();
|
||||
}
|
||||
@@ -1007,28 +1005,28 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
/**
|
||||
* Return the DB column default to use for DDL.
|
||||
*/
|
||||
public String getDbColumnDefault() {
|
||||
public String dbColumnDefault() {
|
||||
return dbColumnDefn != null ? null : dbColumnDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DDL-Migration Infos
|
||||
*/
|
||||
public List<DbMigrationInfo> getDbMigrationInfos() {
|
||||
public List<DbMigrationInfo> dbMigrationInfos() {
|
||||
return dbMigrationInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bean Field associated with this property.
|
||||
*/
|
||||
private Field getField() {
|
||||
private Field field() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the GeneratedValue. Used to generate update timestamp etc.
|
||||
*/
|
||||
public GeneratedProperty getGeneratedProperty() {
|
||||
public GeneratedProperty generatedProperty() {
|
||||
return generatedProperty;
|
||||
}
|
||||
|
||||
@@ -1119,14 +1117,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* The database column name this is mapped to.
|
||||
*/
|
||||
@Override
|
||||
public String getDbColumn() {
|
||||
public String dbColumn() {
|
||||
return dbColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the comment for the associated DB column.
|
||||
*/
|
||||
public String getDbComment() {
|
||||
public String dbComment() {
|
||||
return dbComment;
|
||||
}
|
||||
|
||||
@@ -1135,7 +1133,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*
|
||||
* @param platformTypes Set as false when we want logical platform agnostic types.
|
||||
*/
|
||||
public int getDbType(boolean platformTypes) {
|
||||
public int dbType(boolean platformTypes) {
|
||||
if (platformTypes || !(scalarType instanceof ScalarTypeLogicalType)) {
|
||||
return dbType;
|
||||
}
|
||||
@@ -1184,7 +1182,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return the DB bind parameter. Typically is "?" but different for
|
||||
* encrypted bind.
|
||||
*/
|
||||
public String getDbBind() {
|
||||
public String dbBind() {
|
||||
return dbBind;
|
||||
}
|
||||
|
||||
@@ -1209,7 +1207,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return dbEncrypted;
|
||||
}
|
||||
|
||||
public int getDbEncryptedType() {
|
||||
public int dbEncryptedType() {
|
||||
return dbEncryptedType;
|
||||
}
|
||||
|
||||
@@ -1305,7 +1303,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public Class<?> getPropertyType() {
|
||||
public Class<?> type() {
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
@@ -1413,7 +1411,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
// change in behavior for #318
|
||||
objValue = null;
|
||||
String msg = "Error trying to use Jackson ObjectMapper to read transient property "
|
||||
+ getFullBeanName() + " - consider marking this property with @JsonIgnore";
|
||||
+ fullName() + " - consider marking this property with @JsonIgnore";
|
||||
logger.error(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +117,10 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
}
|
||||
|
||||
void initialiseTargetDescriptor(BeanDescriptorInitContext initContext) {
|
||||
targetDescriptor = descriptor.getBeanDescriptor(targetType);
|
||||
targetDescriptor = descriptor.descriptor(targetType);
|
||||
if (!isTransient) {
|
||||
targetIdBinder = targetDescriptor.getIdBinder();
|
||||
targetInheritInfo = targetDescriptor.getInheritInfo();
|
||||
targetIdBinder = targetDescriptor.idBinder();
|
||||
targetInheritInfo = targetDescriptor.inheritInfo();
|
||||
saveRecurseSkippable = targetDescriptor.isSaveRecurseSkippable();
|
||||
if (!targetIdBinder.isComplexId()) {
|
||||
targetIdProperty = targetIdBinder.getIdProperty();
|
||||
@@ -129,14 +129,14 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchPreference() {
|
||||
public int fetchPreference() {
|
||||
return fetchPreference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the extra configuration for the foreign key.
|
||||
*/
|
||||
public PropertyForeignKey getForeignKey() {
|
||||
public PropertyForeignKey foreignKey() {
|
||||
return foreignKey;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
*/
|
||||
ElPropertyValue createElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) {
|
||||
// associated or embedded bean
|
||||
BeanDescriptor<?> embDesc = getTargetDescriptor();
|
||||
BeanDescriptor<?> embDesc = targetDescriptor();
|
||||
if (chain == null) {
|
||||
chain = new ElPropertyChainBuilder(isEmbedded(), propName);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* Return the mappedBy property.
|
||||
* This will be null on the owning side.
|
||||
*/
|
||||
public String getMappedBy() {
|
||||
public String mappedBy() {
|
||||
return mappedBy;
|
||||
}
|
||||
|
||||
@@ -208,19 +208,19 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* This will return null for multiple Id properties.
|
||||
* </p>
|
||||
*/
|
||||
public String getTargetIdProperty() {
|
||||
public String targetIdProperty() {
|
||||
return targetIdProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptor of the target.
|
||||
*/
|
||||
public BeanDescriptor<T> getTargetDescriptor() {
|
||||
public BeanDescriptor<T> targetDescriptor() {
|
||||
return targetDescriptor;
|
||||
}
|
||||
|
||||
SpiEbeanServer server() {
|
||||
return descriptor.getEbeanServer();
|
||||
return descriptor.ebeanServer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,12 +229,12 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* We use target descriptor rather than target property type to support ElementCollection.
|
||||
*/
|
||||
public SpiQuery<T> newQuery(SpiEbeanServer server) {
|
||||
return new DefaultOrmQuery<>(targetDescriptor, server, server.getExpressionFactory());
|
||||
return new DefaultOrmQuery<>(targetDescriptor, server, server.expressionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdBinder getIdBinder() {
|
||||
return descriptor.getIdBinder();
|
||||
public IdBinder idBinder() {
|
||||
return descriptor.idBinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -251,8 +251,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSoftDeletePredicate(String tableAlias) {
|
||||
return targetDescriptor.getSoftDeletePredicate(tableAlias);
|
||||
public String softDeletePredicate(String tableAlias) {
|
||||
return targetDescriptor.softDeletePredicate(tableAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,8 +283,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* Return true if the unique id properties are all not null for this bean.
|
||||
*/
|
||||
public boolean hasId(EntityBean bean) {
|
||||
BeanDescriptor<?> targetDesc = getTargetDescriptor();
|
||||
BeanProperty idProp = targetDesc.getIdProperty();
|
||||
BeanDescriptor<?> targetDesc = targetDescriptor();
|
||||
BeanProperty idProp = targetDesc.idProperty();
|
||||
// all the unique properties are non-null
|
||||
return idProp == null || idProp.getValue(bean) != null;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* set or map.
|
||||
* </p>
|
||||
*/
|
||||
public Class<?> getTargetType() {
|
||||
public Class<?> targetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
@@ -305,14 +305,14 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
* to this bean type.
|
||||
*/
|
||||
@Override
|
||||
public String getExtraWhere() {
|
||||
public String extraWhere() {
|
||||
return extraWhere;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the elastic search doc for this embedded property.
|
||||
*/
|
||||
private String getDocStoreDoc() {
|
||||
private String docStoreDoc() {
|
||||
return docStoreDoc;
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
*/
|
||||
@Override
|
||||
public void docStoreInclude(boolean includeByDefault, DocStructure docStructure) {
|
||||
String embeddedDoc = getDocStoreDoc();
|
||||
String embeddedDoc = docStoreDoc();
|
||||
if (embeddedDoc == null) {
|
||||
// not annotated so use include by default
|
||||
// which is *ToOne included and *ToMany excluded
|
||||
@@ -399,21 +399,21 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
/**
|
||||
* Return the underlying BeanTable for this property.
|
||||
*/
|
||||
public BeanTable getBeanTable() {
|
||||
public BeanTable beanTable() {
|
||||
return beanTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the join to use for the bean.
|
||||
*/
|
||||
public TableJoin getTableJoin() {
|
||||
public TableJoin tableJoin() {
|
||||
return tableJoin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the persist info.
|
||||
*/
|
||||
public BeanCascadeInfo getCascadeInfo() {
|
||||
public BeanCascadeInfo cascadeInfo() {
|
||||
return cascadeInfo;
|
||||
}
|
||||
|
||||
@@ -422,10 +422,10 @@ 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();
|
||||
String dbColumn = owner.dbColumn();
|
||||
return new ImportedIdSimple(owner, dbColumn, null, idProp, 0);
|
||||
}
|
||||
if (idProp == null) {
|
||||
@@ -445,7 +445,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
} else {
|
||||
// embedded id
|
||||
BeanPropertyAssocOne<?> embProp = (BeanPropertyAssocOne<?>) idProp;
|
||||
BeanProperty[] embBaseProps = embProp.getTargetDescriptor().propertiesBaseScalar();
|
||||
BeanProperty[] embBaseProps = embProp.targetDescriptor().propertiesBaseScalar();
|
||||
ImportedIdSimple[] scalars = createImportedList(owner, cols, embBaseProps, others);
|
||||
return new ImportedIdEmbedded(owner, embProp, scalars);
|
||||
}
|
||||
@@ -466,16 +466,16 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
boolean insertable = col.isInsertable();
|
||||
boolean updateable = col.isUpdateable();
|
||||
for (int j = 0; j < props.length; j++) {
|
||||
if (props[j].getDbColumn().equalsIgnoreCase(matchColumn)) {
|
||||
if (props[j].dbColumn().equalsIgnoreCase(matchColumn)) {
|
||||
return new ImportedIdSimple(owner, localColumn, localSqlFormula, props[j], j, insertable, updateable);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < others.length; j++) {
|
||||
if (others[j].getDbColumn().equalsIgnoreCase(matchColumn)) {
|
||||
if (others[j].dbColumn().equalsIgnoreCase(matchColumn)) {
|
||||
return new ImportedIdSimple(owner, localColumn, localSqlFormula, others[j], j + props.length, insertable, updateable);
|
||||
}
|
||||
}
|
||||
String msg = "Error with the Join on [" + getFullBeanName()
|
||||
String msg = "Error with the Join on [" + fullName()
|
||||
+ "]. Could not find the local match for [" + matchColumn + "] "//in table["+searchTable+"]?"
|
||||
+ " Perhaps an error in a @JoinColumn";
|
||||
throw new PersistenceException(msg);
|
||||
@@ -566,7 +566,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
||||
}
|
||||
}
|
||||
|
||||
String msg = "Error with the Join on [" + getFullBeanName()
|
||||
String msg = "Error with the Join on [" + fullName()
|
||||
+ "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?"
|
||||
+ " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped? "
|
||||
+ " or a @JoinColumn needs an explicit referencedColumnName specified?";
|
||||
|
||||
+52
-52
@@ -175,9 +175,9 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
void initialisePostTarget() {
|
||||
if (childMasterProperty != null) {
|
||||
BeanProperty masterId = childMasterProperty.getTargetDescriptor().getIdProperty();
|
||||
BeanProperty masterId = childMasterProperty.targetDescriptor().idProperty();
|
||||
if (masterId != null) { // in docstore only, the master-id may be not available
|
||||
childMasterIdProperty = childMasterProperty.getName() + "." + masterId.getName();
|
||||
childMasterIdProperty = childMasterProperty.name() + "." + masterId.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
* Return the underlying collection of beans.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Collection getRawCollection(EntityBean bean) {
|
||||
return help.underlying(getVal(bean));
|
||||
public Collection rawCollection(EntityBean bean) {
|
||||
return help.underlying(value(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,11 +217,11 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
@Override
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
Object existingCollection = getVal(existing);
|
||||
Object existingCollection = value(existing);
|
||||
if (existingCollection instanceof BeanCollection<?>) {
|
||||
BeanCollection<?> toBC = (BeanCollection<?>) existingCollection;
|
||||
if (!toBC.isPopulated()) {
|
||||
Object fromCollection = getVal(bean);
|
||||
Object fromCollection = value(bean);
|
||||
if (fromCollection instanceof BeanCollection<?>) {
|
||||
BeanCollection<?> fromBC = (BeanCollection<?>) fromCollection;
|
||||
if (fromBC.isPopulated()) {
|
||||
@@ -375,7 +375,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Return the mode for listening to modifications to collections for this association.
|
||||
*/
|
||||
public ModifyListenMode getModifyListenMode() {
|
||||
public ModifyListenMode modifyListenMode() {
|
||||
return modifyListenMode;
|
||||
}
|
||||
|
||||
@@ -410,19 +410,19 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
public String assocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
boolean softDelete = targetDescriptor.isSoftDelete();
|
||||
boolean needsX2Table = softDelete || getExtraWhere() != null;
|
||||
boolean needsX2Table = softDelete || extraWhere() != null;
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
SpiQuery<?> query = request.getQueryRequest().getQuery();
|
||||
SpiQuery<?> query = request.getQueryRequest().query();
|
||||
if (hasJoinTable()) {
|
||||
sb.append(query.isAsDraft() ? intersectionDraftTable : intersectionPublishTable);
|
||||
} else {
|
||||
sb.append(targetDescriptor.getBaseTable(query.getTemporalMode()));
|
||||
sb.append(targetDescriptor.baseTable(query.getTemporalMode()));
|
||||
}
|
||||
if (needsX2Table && hasJoinTable()) {
|
||||
sb.append(" x join ");
|
||||
sb.append(targetDescriptor.getBaseTable(query.getTemporalMode()));
|
||||
sb.append(targetDescriptor.baseTable(query.getTemporalMode()));
|
||||
sb.append(" x2 on ");
|
||||
inverseJoin.addJoin("x2", "x", sb);
|
||||
} else {
|
||||
@@ -435,17 +435,17 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
}
|
||||
exportedProperties[i].appendWhere(sb, "x.", path);
|
||||
}
|
||||
if (getExtraWhere() != null) {
|
||||
if (extraWhere() != null) {
|
||||
sb.append(" and ");
|
||||
if (hasJoinTable()) {
|
||||
sb.append(getExtraWhere().replace("${ta}", "x2").replace("${mta}", "x"));
|
||||
sb.append(extraWhere().replace("${ta}", "x2").replace("${mta}", "x"));
|
||||
} else {
|
||||
sb.append(getExtraWhere().replace("${ta}", "x"));
|
||||
sb.append(extraWhere().replace("${ta}", "x"));
|
||||
}
|
||||
}
|
||||
if (softDelete) {
|
||||
String alias = hasJoinTable() ? "x2" : "x";
|
||||
sb.append(" and ").append(targetDescriptor.getSoftDeletePredicate(alias));
|
||||
sb.append(" and ").append(targetDescriptor.softDeletePredicate(alias));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -454,32 +454,32 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
* Return the Id values from the given bean.
|
||||
*/
|
||||
@Override
|
||||
public Object[] getAssocIdValues(EntityBean bean) {
|
||||
return targetDescriptor.getIdBinder().getIdValues(bean);
|
||||
public Object[] assocIdValues(EntityBean bean) {
|
||||
return targetDescriptor.idBinder().getIdValues(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Id expression to add to where clause etc.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdExpression(String prefix, String operator) {
|
||||
return targetDescriptor.getIdBinder().getAssocOneIdExpr(prefix, operator);
|
||||
public String assocIdExpression(String prefix, String operator) {
|
||||
return targetDescriptor.idBinder().getAssocOneIdExpr(prefix, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the logical id value expression taking into account embedded id's.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
||||
return targetDescriptor.getIdBinder().getIdInValueExpr(not, size);
|
||||
public String assocIdInValueExpr(boolean not, int size) {
|
||||
return targetDescriptor.idBinder().getIdInValueExpr(not, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the logical id in expression taking into account embedded id's.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
return targetDescriptor.getIdBinder().getAssocIdInExpr(prefix);
|
||||
public String assocIdInExpr(String prefix) {
|
||||
return targetDescriptor.idBinder().getAssocIdInExpr(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -521,7 +521,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Return the many type.
|
||||
*/
|
||||
public ManyType getManyType() {
|
||||
public ManyType manyType() {
|
||||
return manyType;
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
/**
|
||||
* Return the element bean descriptor (for an element collection only).
|
||||
*/
|
||||
public BeanDescriptor<T> getElementDescriptor() {
|
||||
public BeanDescriptor<T> elementDescriptor() {
|
||||
return elementDescriptor;
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
* ManyToMany only, join from local table to intersection table.
|
||||
*/
|
||||
@Override
|
||||
public TableJoin getIntersectionTableJoin() {
|
||||
public TableJoin intersectionTableJoin() {
|
||||
return intersectionJoin;
|
||||
}
|
||||
|
||||
@@ -585,21 +585,21 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
* Return the order by clause used to order the fetching of the data for
|
||||
* this list, set or map.
|
||||
*/
|
||||
public String getFetchOrderBy() {
|
||||
public String fetchOrderBy() {
|
||||
return fetchOrderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the order by for use when lazy loading the associated collection.
|
||||
*/
|
||||
public String getLazyFetchOrderBy() {
|
||||
public String lazyFetchOrderBy() {
|
||||
return lazyFetchOrderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default mapKey when returning a Map.
|
||||
*/
|
||||
public String getMapKey() {
|
||||
public String mapKey() {
|
||||
return mapKey;
|
||||
}
|
||||
|
||||
@@ -631,11 +631,11 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
return help.createEmpty(parentBean);
|
||||
}
|
||||
|
||||
private BeanCollectionAdd getBeanCollectionAdd(Object bc) {
|
||||
private BeanCollectionAdd beanCollectionAdd(Object bc) {
|
||||
return help.getBeanCollectionAdd(bc, null);
|
||||
}
|
||||
|
||||
public Object getParentId(EntityBean parentBean) {
|
||||
public Object parentId(EntityBean parentBean) {
|
||||
return descriptor.getId(parentBean);
|
||||
}
|
||||
|
||||
@@ -654,12 +654,12 @@ 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;
|
||||
try {
|
||||
for (BeanProperty emId : one.getTargetDescriptor().propertiesBaseScalar()) {
|
||||
for (BeanProperty emId : one.targetDescriptor().propertiesBaseScalar()) {
|
||||
list.add(findMatch(true, emId));
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
@@ -680,9 +680,9 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
private ExportedProperty findMatch(boolean embedded, BeanProperty prop) {
|
||||
if (hasJoinTable()) {
|
||||
// look for column going to intersection
|
||||
return findMatch(embedded, prop, prop.getDbColumn(), intersectionJoin);
|
||||
return findMatch(embedded, prop, prop.dbColumn(), intersectionJoin);
|
||||
} else {
|
||||
return findMatch(embedded, prop, prop.getDbColumn(), tableJoin);
|
||||
return findMatch(embedded, prop, prop.dbColumn(), tableJoin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,17 +697,17 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
return null;
|
||||
}
|
||||
// search for the property, to see if it exists
|
||||
Class<?> beanType = descriptor.getBeanType();
|
||||
BeanDescriptor<?> targetDesc = getTargetDescriptor();
|
||||
Class<?> beanType = descriptor.type();
|
||||
BeanDescriptor<?> targetDesc = targetDescriptor();
|
||||
for (BeanPropertyAssocOne<?> prop : targetDesc.propertiesOne()) {
|
||||
if (mappedBy != null) {
|
||||
// match using mappedBy as property name
|
||||
if (mappedBy.equalsIgnoreCase(prop.getName())) {
|
||||
if (mappedBy.equalsIgnoreCase(prop.name())) {
|
||||
return prop;
|
||||
}
|
||||
} else {
|
||||
// assume only one property that matches parent object type
|
||||
if (prop.getTargetType().equals(beanType)) {
|
||||
if (prop.targetType().equals(beanType)) {
|
||||
// found it, stop search
|
||||
return prop;
|
||||
}
|
||||
@@ -721,21 +721,21 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
*/
|
||||
private BeanProperty initMapKeyProperty() {
|
||||
// search for the property
|
||||
BeanDescriptor<?> targetDesc = getTargetDescriptor();
|
||||
BeanDescriptor<?> targetDesc = targetDescriptor();
|
||||
for (BeanProperty prop : targetDesc.propertiesAll()) {
|
||||
if (mapKey.equalsIgnoreCase(prop.getName())) {
|
||||
if (mapKey.equalsIgnoreCase(prop.name())) {
|
||||
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 + "]");
|
||||
}
|
||||
|
||||
public IntersectionRow buildManyDeleteChildren(EntityBean parentBean, List<Object> excludeDetailIds) {
|
||||
IntersectionRow row = new IntersectionRow(tableJoin.getTable(), targetDescriptor);
|
||||
if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) {
|
||||
row.setExcludeIds(excludeDetailIds, getTargetDescriptor());
|
||||
row.setExcludeIds(excludeDetailIds, targetDescriptor());
|
||||
}
|
||||
buildExport(row, parentBean);
|
||||
return row;
|
||||
@@ -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.getId((EntityBean) 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.getId((EntityBean) liveBean);
|
||||
Object id = targetDescriptor.id(liveBean);
|
||||
liveMap.put(id, (T) liveBean);
|
||||
}
|
||||
return liveMap;
|
||||
@@ -1016,7 +1016,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
return elementDescriptor.jsonReadCollection(readJson, parentBean);
|
||||
}
|
||||
BeanCollection<?> collection = createEmpty(parentBean);
|
||||
BeanCollectionAdd add = getBeanCollectionAdd(collection);
|
||||
BeanCollectionAdd add = beanCollectionAdd(collection);
|
||||
do {
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name);
|
||||
if (detailBean == null) {
|
||||
@@ -1044,7 +1044,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
* Returns true, if we must create a m2m join table.
|
||||
*/
|
||||
public boolean createJoinTable() {
|
||||
if (hasJoinTable() && getMappedBy() == null) {
|
||||
if (hasJoinTable() && mappedBy() == null) {
|
||||
// only create on other 'owning' side
|
||||
return !descriptor.isTableManaged(intersectionJoin.getTable());
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ class BeanPropertyAssocManyJsonHelp {
|
||||
*/
|
||||
BeanPropertyAssocManyJsonHelp(BeanPropertyAssocMany<?> many) {
|
||||
this.many = many;
|
||||
boolean objectMapperPresent = many.getBeanDescriptor().getConfig().getClassLoadConfig().isJacksonObjectMapperPresent();
|
||||
boolean objectMapperPresent = many.descriptor().config().getClassLoadConfig().isJacksonObjectMapperPresent();
|
||||
this.jsonTransient = !objectMapperPresent ? null : new BeanPropertyAssocManyJsonTransient();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class BeanPropertyAssocManyJsonHelp {
|
||||
*/
|
||||
private void jsonReadTransientUsingObjectMapper(SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
if (jsonTransient == null) {
|
||||
throw new IllegalStateException("Jackson ObjectMapper is required to read this Transient property " + many.getFullBeanName());
|
||||
throw new IllegalStateException("Jackson ObjectMapper is required to read this Transient property " + many.fullName());
|
||||
}
|
||||
jsonTransient.jsonReadUsingObjectMapper(many, readJson, parentBean);
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,18 +21,18 @@ class BeanPropertyAssocManyJsonTransient {
|
||||
*/
|
||||
void jsonReadUsingObjectMapper(BeanPropertyAssocMany<?> many, SpiJsonReader readJson, EntityBean parentBean) throws IOException {
|
||||
ObjectMapper mapper = readJson.getObjectMapper();
|
||||
ManyType manyType = many.getManyType();
|
||||
ManyType manyType = many.manyType();
|
||||
|
||||
Object value;
|
||||
if (manyType.isMap()) {
|
||||
// read map using Jackson object mapper with unknown key type
|
||||
TypeFactory typeFactory = mapper.getTypeFactory();
|
||||
JavaType target = typeFactory.constructType(many.getTargetType());
|
||||
JavaType target = typeFactory.constructType(many.targetType());
|
||||
MapType jacksonType = typeFactory.constructMapType(LinkedHashMap.class, TypeFactory.unknownType(), target);
|
||||
value = mapper.readValue(readJson.getParser(), jacksonType);
|
||||
} else {
|
||||
// read list or set using Jackson object mapper
|
||||
CollectionType jacksonType = mapper.getTypeFactory().constructCollectionType(manyType.getCollectionType(), many.getTargetType());
|
||||
CollectionType jacksonType = mapper.getTypeFactory().constructCollectionType(manyType.getCollectionType(), many.targetType());
|
||||
value = mapper.readValue(readJson.getParser(), jacksonType);
|
||||
}
|
||||
many.setValue(parentBean, value);
|
||||
|
||||
+7
-7
@@ -26,7 +26,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
this.many = many;
|
||||
this.exportedProperties = exportedProperties;
|
||||
this.hasJoinTable = many.hasJoinTable();
|
||||
this.descriptor = many.getBeanDescriptor();
|
||||
this.descriptor = many.descriptor();
|
||||
this.exportedPropertyBindProto = deriveExportedPropertyBindProto();
|
||||
|
||||
String delStmt;
|
||||
@@ -73,7 +73,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
|
||||
@Override
|
||||
public void visitEmbeddedScalar(BeanProperty p, BeanPropertyAssocOne<?> embedded) {
|
||||
sb.append(",").append(p.getDbColumn());
|
||||
sb.append(",").append(p.dbColumn());
|
||||
colCount++;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
|
||||
@Override
|
||||
public void visitScalar(BeanProperty p, boolean allowNonNull) {
|
||||
sb.append(",").append(p.getDbColumn());
|
||||
sb.append(",").append(p.dbColumn());
|
||||
colCount++;
|
||||
}
|
||||
|
||||
@@ -118,13 +118,13 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
query.setM2MIncludeJoin(many.inverseJoin);
|
||||
}
|
||||
String rawWhere = deriveWhereParentIdSql(true, tableAlias);
|
||||
String expr = descriptor.getParentIdInExpr(parentIds.size(), rawWhere);
|
||||
String expr = descriptor.parentIdInExpr(parentIds.size(), rawWhere);
|
||||
many.bindParentIdsIn(expr, parentIds, query);
|
||||
}
|
||||
|
||||
List<Object> findIdsByParentId(Object parentId, Transaction t, List<Object> excludeDetailIds, boolean hard) {
|
||||
String rawWhere = deriveWhereParentIdSql(false, "");
|
||||
SpiEbeanServer server = descriptor.getEbeanServer();
|
||||
SpiEbeanServer server = descriptor.ebeanServer();
|
||||
SpiQuery<?> q = many.newQuery(server);
|
||||
many.bindParentIdEq(rawWhere, parentId, q);
|
||||
if (hard) {
|
||||
@@ -141,7 +141,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
String inClause = buildInClauseBinding(parentIds.size(), exportedPropertyBindProto);
|
||||
String expr = rawWhere + inClause;
|
||||
|
||||
SpiEbeanServer server = descriptor.getEbeanServer();
|
||||
SpiEbeanServer server = descriptor.ebeanServer();
|
||||
SpiQuery<?> q = many.newQuery(server);
|
||||
//Query<?> q = server.find(propertyType);
|
||||
many.bindParentIdsIn(expr, parentIds, q);
|
||||
@@ -209,7 +209,7 @@ class BeanPropertyAssocManySqlHelp<T> {
|
||||
|
||||
private String buildInClauseBinding(int size, String bindProto) {
|
||||
if (descriptor.isSimpleId()) {
|
||||
return descriptor.getIdBinder().getIdInValueExpr(false, size);
|
||||
return descriptor.idBinder().getIdInValueExpr(false, size);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(10 + (size * (bindProto.length() + 1)));
|
||||
sb.append(" in");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
embeddedProps = overrideMeta.getProperties();
|
||||
embeddedPropsMap = new HashMap<>();
|
||||
for (BeanProperty embeddedProp : embeddedProps) {
|
||||
embeddedPropsMap.put(embeddedProp.getName(), embeddedProp);
|
||||
embeddedPropsMap.put(embeddedProp.name(), embeddedProp);
|
||||
}
|
||||
} else {
|
||||
embeddedProps = null;
|
||||
@@ -129,15 +129,15 @@ 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().dbColumn();
|
||||
if (!foreignJoinColumn.equalsIgnoreCase(foreignIdColumn)) {
|
||||
throw new PersistenceException("Mapping limitation - @JoinColumn on " + getFullBeanName() + " needs to map to a primary key as per Issue #529 "
|
||||
throw new PersistenceException("Mapping limitation - @JoinColumn on " + fullName() + " needs to map to a primary key as per Issue #529 "
|
||||
+ " - joining to " + foreignJoinColumn + " and not " + foreignIdColumn);
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
@@ -154,6 +154,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
/**
|
||||
* Return the property value as an entity bean.
|
||||
*/
|
||||
@Override
|
||||
public EntityBean getValueAsEntityBean(EntityBean owner) {
|
||||
return (EntityBean) getValue(owner);
|
||||
}
|
||||
@@ -174,13 +175,13 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
*/
|
||||
void cacheClear() {
|
||||
if (cacheNotifyRelationship) {
|
||||
targetDescriptor.cacheManyPropClear(relationshipProperty.getName());
|
||||
targetDescriptor.cacheManyPropClear(relationshipProperty.name());
|
||||
}
|
||||
}
|
||||
|
||||
void cacheClear(CacheChangeSet changeSet) {
|
||||
if (cacheNotifyRelationship) {
|
||||
changeSet.addManyClear(targetDescriptor, relationshipProperty.getName());
|
||||
changeSet.addManyClear(targetDescriptor, relationshipProperty.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,19 +191,20 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
void cacheDelete(boolean clear, EntityBean bean, CacheChangeSet changeSet) {
|
||||
if (cacheNotifyRelationship) {
|
||||
if (clear) {
|
||||
changeSet.addManyClear(targetDescriptor, relationshipProperty.getName());
|
||||
changeSet.addManyClear(targetDescriptor, relationshipProperty.name());
|
||||
} else {
|
||||
Object assocBean = getValue(bean);
|
||||
if (assocBean != null) {
|
||||
Object parentId = targetDescriptor.getId((EntityBean) assocBean);
|
||||
Object parentId = targetDescriptor.id(assocBean);
|
||||
if (parentId != null) {
|
||||
changeSet.addManyRemove(targetDescriptor, relationshipProperty.getName(), parentId);
|
||||
changeSet.addManyRemove(targetDescriptor, relationshipProperty.name(), parentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Object naturalKeyVal(Map<String, Object> values) {
|
||||
EntityBean bean = (EntityBean) values.get(name);
|
||||
if (bean == null) {
|
||||
@@ -216,7 +218,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
if (embedded) {
|
||||
BeanProperty embProp = embeddedPropsMap.get(remainder);
|
||||
if (embProp == null) {
|
||||
String msg = "Embedded Property " + remainder + " not found in " + getFullBeanName();
|
||||
String msg = "Embedded Property " + remainder + " not found in " + fullName();
|
||||
throw new PersistenceException(msg);
|
||||
}
|
||||
if (chain == null) {
|
||||
@@ -230,7 +232,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPlaceholder(boolean encrypted) {
|
||||
public String elPlaceholder(boolean encrypted) {
|
||||
return encrypted ? elPlaceHolderEncrypted : elPlaceHolder;
|
||||
}
|
||||
|
||||
@@ -266,17 +268,17 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
private List<Object> findIdsByParentId(Object parentId, Transaction t) {
|
||||
String rawWhere = deriveWhereParentIdSql(false);
|
||||
SpiEbeanServer server = server();
|
||||
Query<?> q = server.find(getPropertyType());
|
||||
Query<?> q = server.find(type());
|
||||
bindParentIdEq(rawWhere, parentId, q);
|
||||
return server.findIds(q, t);
|
||||
}
|
||||
|
||||
private List<Object> findIdsByParentIdList(List<Object> parentIds, Transaction t) {
|
||||
String rawWhere = deriveWhereParentIdSql(true);
|
||||
String inClause = getIdBinder().getIdInValueExpr(false, parentIds.size());
|
||||
String inClause = idBinder().getIdInValueExpr(false, parentIds.size());
|
||||
String expr = rawWhere + inClause;
|
||||
SpiEbeanServer server = server();
|
||||
Query<?> q = server.find(getPropertyType());
|
||||
Query<?> q = server.find(type());
|
||||
bindParentIdsIn(expr, parentIds, q);
|
||||
return server.findIds(q, t);
|
||||
}
|
||||
@@ -295,13 +297,13 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
} else {
|
||||
if (targetIdProperty != null) {
|
||||
BeanDescriptor<T> target = getTargetDescriptor();
|
||||
BeanDescriptor<T> target = targetDescriptor();
|
||||
String basePath = SplitName.add(prefix, name);
|
||||
if (dbColumn != null) {
|
||||
BeanProperty idProperty = target.getIdProperty();
|
||||
desc.registerColumn(dbColumn, SplitName.add(basePath, idProperty.getName()));
|
||||
BeanProperty idProperty = target.idProperty();
|
||||
desc.registerColumn(dbColumn, SplitName.add(basePath, idProperty.name()));
|
||||
}
|
||||
desc.registerTable(target.getBaseTable(), this);
|
||||
desc.registerTable(target.baseTable(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +312,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* Return meta data for the deployment of the embedded bean specific to this
|
||||
* property.
|
||||
*/
|
||||
public BeanProperty[] getProperties() {
|
||||
public BeanProperty[] properties() {
|
||||
return embeddedProps;
|
||||
}
|
||||
|
||||
@@ -318,7 +320,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
public void buildRawSqlSelectChain(String prefix, List<String> selectChain) {
|
||||
prefix = SplitName.add(prefix, name);
|
||||
if (!embedded) {
|
||||
InheritInfo inheritInfo = targetDescriptor.getInheritInfo();
|
||||
InheritInfo inheritInfo = targetDescriptor.inheritInfo();
|
||||
if (inheritInfo != null) {
|
||||
// expect the discriminator column to be included in order
|
||||
// to determine the inheritance type so we add it to the
|
||||
@@ -328,7 +330,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
selectChain.add(discProperty);
|
||||
}
|
||||
if (targetIdBinder == null) {
|
||||
throw new IllegalStateException("No Id binding property for " + getFullBeanName()
|
||||
throw new IllegalStateException("No Id binding property for " + fullName()
|
||||
+ ". Probably a missing @OneToOne mapping annotation on this relationship?");
|
||||
}
|
||||
targetIdBinder.buildRawSqlSelectChain(prefix, selectChain);
|
||||
@@ -339,6 +341,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasForeignKey() {
|
||||
return foreignKey == null || primaryKeyJoin || !foreignKey.isNoConstraint();
|
||||
}
|
||||
@@ -371,7 +374,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
|
||||
String nextPrefix = (prefix == null) ? name : prefix + "." + name;
|
||||
if (embedded) {
|
||||
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
|
||||
BeanDescriptor<T> targetDescriptor = targetDescriptor();
|
||||
targetDescriptor.diff(nextPrefix, map, (EntityBean) newEmb, (EntityBean) oldEmb);
|
||||
|
||||
} else {
|
||||
@@ -379,8 +382,8 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
newBean = (EntityBean) newEmb;
|
||||
oldBean = (EntityBean) oldEmb;
|
||||
|
||||
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
|
||||
BeanProperty idProperty = targetDescriptor.getIdProperty();
|
||||
BeanDescriptor<T> targetDescriptor = targetDescriptor();
|
||||
BeanProperty idProperty = targetDescriptor.idProperty();
|
||||
|
||||
Object newId = (newBean == null) ? null : idProperty.getValue(newBean);
|
||||
Object oldId = (oldBean == null) ? null : idProperty.getValue(oldBean);
|
||||
@@ -395,8 +398,8 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* represents.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getTargetType() {
|
||||
return getPropertyType();
|
||||
public Class<?> targetType() {
|
||||
return type();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,19 +424,19 @@ 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);
|
||||
return new CachedBeanId(desc.getDiscValue(), id);
|
||||
final Object id = desc.idProperty().getCacheDataValue((EntityBean) bean);
|
||||
return new CachedBeanId(desc.discValue(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(Object value) {
|
||||
return targetDescriptor.getIdBinder().cacheKey(value);
|
||||
return targetDescriptor.idBinder().cacheKey(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -460,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) {
|
||||
@@ -470,44 +473,44 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarDataReader<?> getIdReader() {
|
||||
return targetDescriptor.getIdProperty();
|
||||
public ScalarDataReader<?> idReader() {
|
||||
return targetDescriptor.idProperty();
|
||||
}
|
||||
|
||||
ScalarType<?> getIdScalarType() {
|
||||
return targetDescriptor.getIdProperty().scalarType;
|
||||
ScalarType<?> idScalarType() {
|
||||
return targetDescriptor.idProperty().scalarType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Id values from the given bean.
|
||||
*/
|
||||
@Override
|
||||
public Object[] getAssocIdValues(EntityBean bean) {
|
||||
return targetDescriptor.getIdBinder().getIdValues(bean);
|
||||
public Object[] assocIdValues(EntityBean bean) {
|
||||
return targetDescriptor.idBinder().getIdValues(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Id expression to add to where clause etc.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdExpression(String prefix, String operator) {
|
||||
return targetDescriptor.getIdBinder().getAssocOneIdExpr(prefix, operator);
|
||||
public String assocIdExpression(String prefix, String operator) {
|
||||
return targetDescriptor.idBinder().getAssocOneIdExpr(prefix, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the logical id value expression taking into account embedded id's.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
||||
return targetDescriptor.getIdBinder().getIdInValueExpr(not, size);
|
||||
public String assocIdInValueExpr(boolean not, int size) {
|
||||
return targetDescriptor.idBinder().getIdInValueExpr(not, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the logical id in expression taking into account embedded id's.
|
||||
*/
|
||||
@Override
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
return targetDescriptor.getIdBinder().getAssocIdInExpr(prefix);
|
||||
public String assocIdInExpr(String prefix) {
|
||||
return targetDescriptor.idBinder().getAssocIdInExpr(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -525,7 +528,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* value.
|
||||
*/
|
||||
public Object createEmbeddedId() {
|
||||
return getTargetDescriptor().createEntityBean();
|
||||
return targetDescriptor().createEntityBean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -538,7 +541,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
return value;
|
||||
}
|
||||
|
||||
public ImportedId getImportedId() {
|
||||
public ImportedId importedId() {
|
||||
return importedId;
|
||||
}
|
||||
|
||||
@@ -562,11 +565,11 @@ 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;
|
||||
BeanDescriptor<?> targetDesc = one.getTargetDescriptor();
|
||||
BeanDescriptor<?> targetDesc = one.targetDescriptor();
|
||||
BeanProperty[] emIds = targetDesc.propertiesBaseScalar();
|
||||
try {
|
||||
for (BeanProperty emId : emIds) {
|
||||
@@ -588,14 +591,14 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
* Find the matching foreignDbColumn for a given local property.
|
||||
*/
|
||||
private ExportedProperty findMatch(boolean embeddedProp, BeanProperty prop) {
|
||||
return findMatch(embeddedProp, prop, prop.getDbColumn(), tableJoin);
|
||||
return findMatch(embeddedProp, prop, prop.dbColumn(), tableJoin);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
@@ -729,7 +732,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
if (value instanceof EntityBean) {
|
||||
if (embedded) {
|
||||
writeJson.writeFieldName(name);
|
||||
BeanDescriptor<?> refDesc = descriptor.getBeanDescriptor(value.getClass());
|
||||
BeanDescriptor<?> refDesc = descriptor.descriptor(value.getClass());
|
||||
refDesc.jsonWriteForInsert(writeJson, (EntityBean) value);
|
||||
} else {
|
||||
jsonWriteTargetId(writeJson, (EntityBean) value);
|
||||
@@ -741,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);
|
||||
@@ -762,7 +765,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
// Hmmm, not writing complex non-entity bean
|
||||
if (value instanceof EntityBean) {
|
||||
writeJson.beginAssocOne(name, bean);
|
||||
BeanDescriptor<?> refDesc = descriptor.getBeanDescriptor(value.getClass());
|
||||
BeanDescriptor<?> refDesc = descriptor.descriptor(value.getClass());
|
||||
refDesc.jsonWrite(writeJson, (EntityBean) value, name);
|
||||
writeJson.endAssocOne();
|
||||
}
|
||||
@@ -792,7 +795,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
targetDescriptor.convertSetId(parentId, child);
|
||||
}
|
||||
if (mappedBy != null) {
|
||||
BeanProperty beanProperty = targetDescriptor.getBeanProperty(mappedBy);
|
||||
BeanProperty beanProperty = targetDescriptor.beanProperty(mappedBy);
|
||||
if (beanProperty != null && beanProperty.getValue(child) == null) {
|
||||
// set the 'parent' bean to the 'child' bean
|
||||
beanProperty.setValue(child, parent);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
public BeanCollection<T> createEmpty(EntityBean ownerBean) {
|
||||
BeanSet<T> beanSet = new BeanSet<>(loader, ownerBean, propertyName);
|
||||
if (many != null) {
|
||||
beanSet.setModifyListening(many.getModifyListenMode());
|
||||
beanSet.setModifyListening(many.modifyListenMode());
|
||||
}
|
||||
return beanSet;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
@Override
|
||||
public BeanCollection<T> createReference(EntityBean parentBean) {
|
||||
BeanSet<T> beanSet = new BeanSet<>(loader, parentBean, propertyName);
|
||||
beanSet.setModifyListening(many.getModifyListenMode());
|
||||
beanSet.setModifyListening(many.modifyListenMode());
|
||||
return beanSet;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
public void refresh(BeanCollection<?> bc, EntityBean parentBean) {
|
||||
BeanSet<?> newBeanSet = (BeanSet<?>) bc;
|
||||
Set<?> current = (Set<?>) many.getValue(parentBean);
|
||||
newBeanSet.setModifyListening(many.getModifyListenMode());
|
||||
newBeanSet.setModifyListening(many.modifyListenMode());
|
||||
if (current == null) {
|
||||
// the currentList is null? Not really expecting this...
|
||||
many.setValue(parentBean, newBeanSet);
|
||||
@@ -85,7 +85,7 @@ public class BeanSetHelp<T> extends BaseCollectionHelp<T> {
|
||||
// normally this case, replace just the underlying list
|
||||
BeanSet<?> currentBeanSet = (BeanSet<?>) current;
|
||||
currentBeanSet.setActualSet(newBeanSet.getActualSet());
|
||||
currentBeanSet.setModifyListening(many.getModifyListenMode());
|
||||
currentBeanSet.setModifyListening(many.modifyListenMode());
|
||||
|
||||
} else {
|
||||
// replace the entire set
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class BeanTable {
|
||||
}
|
||||
if (idProperty instanceof BeanPropertyAssocOne<?>) {
|
||||
BeanPropertyAssocOne<?> assocOne = (BeanPropertyAssocOne<?>) idProperty;
|
||||
BeanProperty[] props = assocOne.getProperties();
|
||||
BeanProperty[] props = assocOne.properties();
|
||||
for (BeanProperty prop : props) {
|
||||
addToJoin(foreignKeyPrefix, join, reverse, sqlFormulaSelect, true, prop);
|
||||
}
|
||||
@@ -100,10 +100,10 @@ public final class BeanTable {
|
||||
}
|
||||
|
||||
private void addToJoin(String foreignKeyPrefix, DeployTableJoin join, boolean reverse, String sqlFormulaSelect, boolean complexKey, BeanProperty prop) {
|
||||
String lc = prop.getDbColumn();
|
||||
String lc = prop.dbColumn();
|
||||
String fk = lc;
|
||||
if (foreignKeyPrefix != null) {
|
||||
fk = owner.getNamingConvention().getForeignKey(foreignKeyPrefix, fk);
|
||||
fk = owner.namingConvention().getForeignKey(foreignKeyPrefix, fk);
|
||||
}
|
||||
if (complexKey) {
|
||||
// just to copy the column name rather than prefix with the foreignKeyPrefix.
|
||||
|
||||
@@ -12,7 +12,7 @@ public final class DCacheRegion implements SpiCacheRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ final class DCacheRegionNone implements SpiCacheRegion {
|
||||
static final SpiCacheRegion INSTANCE = new DCacheRegionNone();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return "<none>";
|
||||
}
|
||||
|
||||
|
||||
@@ -56,15 +56,15 @@ public final class DeployPropertyParser extends DeployParser {
|
||||
|
||||
@Override
|
||||
public String getDeployWord(String expression) {
|
||||
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
|
||||
ElPropertyDeploy elProp = beanDescriptor.elPropertyDeploy(expression);
|
||||
if (elProp == null) {
|
||||
return null;
|
||||
} else {
|
||||
if (catchFirst && firstProp == null) {
|
||||
firstProp = elProp;
|
||||
}
|
||||
addIncludes(elProp.getElPrefix());
|
||||
return elProp.getElPlaceholder(encrypted);
|
||||
addIncludes(elProp.elPrefix());
|
||||
return elProp.elPlaceholder(encrypted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ 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;
|
||||
ElPropertyDeploy elProp = beanDescriptor.elPropertyDeploy(expression);
|
||||
return elProp != null ? elProp.dbColumn() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public final class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyA
|
||||
private final BeanPropertyAssocOne prop;
|
||||
|
||||
DynamicPropertyAggregationFormulaMTO(BeanPropertyAssocOne prop, String name, String parsedFormula, boolean aggregate, BeanProperty asTarget, String alias) {
|
||||
super(name, prop.getIdScalarType(), parsedFormula, aggregate, asTarget, alias);
|
||||
super(name, prop.idScalarType(), parsedFormula, aggregate, asTarget, alias);
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ abstract class DynamicPropertyBase implements STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullBeanName() {
|
||||
public String fullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ abstract class DynamicPropertyBase implements STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPrefix() {
|
||||
public String elPrefix() {
|
||||
return elPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarType<?> getScalarType() {
|
||||
public ScalarType<?> scalarType() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ abstract class DynamicPropertyBase implements STreeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptKeyAsString() {
|
||||
public String encryptKeyAsString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,6 @@ final class ExportedProperty {
|
||||
if (path != null) {
|
||||
sb.append(path).append(".");
|
||||
}
|
||||
sb.append(property.getName());
|
||||
sb.append(property.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,25 +97,25 @@ final class FormulaPropertyPath {
|
||||
|
||||
STreeProperty build() {
|
||||
if (cast != null) {
|
||||
ScalarType<?> scalarType = descriptor.getScalarType(cast);
|
||||
ScalarType<?> scalarType = descriptor.scalarType(cast);
|
||||
if (scalarType == null) {
|
||||
throw new IllegalStateException("Unable to find scalarType for cast of [" + cast + "] on formula [" + formula + "] for type " + descriptor);
|
||||
}
|
||||
return create(scalarType);
|
||||
}
|
||||
if (isCount()) {
|
||||
return create(descriptor.getScalarType(Types.BIGINT));
|
||||
return create(descriptor.scalarType(Types.BIGINT));
|
||||
}
|
||||
if (isConcat()) {
|
||||
return create(descriptor.getScalarType(Types.VARCHAR));
|
||||
return create(descriptor.scalarType(Types.VARCHAR));
|
||||
}
|
||||
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();
|
||||
final BeanProperty property = firstProp.beanProperty();
|
||||
if (!property.isAssocId()) {
|
||||
return create(property.getScalarType());
|
||||
return create(property.scalarType());
|
||||
} else {
|
||||
return createManyToOne(property);
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ public final class InheritInfo {
|
||||
*/
|
||||
public void appendCheckConstraintValues(final String propertyName, final Set<String> checkConstraintValues) {
|
||||
visitChildren(inheritInfo -> {
|
||||
BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName);
|
||||
BeanProperty prop = inheritInfo.desc().beanProperty(propertyName);
|
||||
if (prop != null) {
|
||||
Set<String> values = prop.getDbCheckConstraintValues();
|
||||
Set<String> values = prop.dbCheckConstraintValues();
|
||||
if (values != null) {
|
||||
checkConstraintValues.addAll(values);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public final class InheritInfo {
|
||||
* Return the IdBinder for this type.
|
||||
*/
|
||||
public IdBinder getIdBinder() {
|
||||
return descriptor.getIdBinder();
|
||||
return descriptor.idBinder();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,7 @@ public final class IntersectionRow {
|
||||
sb.append("delete from ").append(tableName);
|
||||
} else {
|
||||
sb.append("update ").append(tableName).append(" set ");
|
||||
sb.append(targetDescriptor.getSoftDeleteDbSet());
|
||||
sb.append(targetDescriptor.softDeleteDbSet());
|
||||
}
|
||||
sb.append(" where ");
|
||||
int count = setBindParams(bindParams, sb);
|
||||
|
||||
@@ -35,13 +35,13 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
public IdBinderEmbedded(boolean idInExpandedForm, BeanPropertyAssocOne<?> embIdProperty) {
|
||||
this.idInExpandedForm = idInExpandedForm;
|
||||
this.embIdProperty = embIdProperty;
|
||||
this.idClass = "_idClass".equals(embIdProperty.getName());
|
||||
this.idClass = "_idClass".equals(embIdProperty.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.idDesc = embIdProperty.getTargetDescriptor();
|
||||
this.props = embIdProperty.getProperties();
|
||||
this.idDesc = embIdProperty.targetDescriptor();
|
||||
this.props = embIdProperty.properties();
|
||||
this.idInValueSql = idInExpandedForm ? idInExpanded() : idInCompressed();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
if (i > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append(idDesc.getBaseTableAlias()).append(".").append(props[i].getDbColumn()).append("=?");
|
||||
sb.append(idDesc.baseTableAlias()).append(".").append(props[i].dbColumn()).append("=?");
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
@@ -91,9 +91,9 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
sb.append(pathPrefix).append(".");
|
||||
}
|
||||
if (!idClass) {
|
||||
sb.append(embIdProperty.getName()).append(".");
|
||||
sb.append(embIdProperty.name()).append(".");
|
||||
}
|
||||
sb.append(props[i].getName());
|
||||
sb.append(props[i].name());
|
||||
if (!ascending) {
|
||||
sb.append(" desc");
|
||||
}
|
||||
@@ -107,13 +107,13 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
|
||||
@Override
|
||||
public String getIdProperty() {
|
||||
return embIdProperty.getName();
|
||||
return embIdProperty.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildRawSqlSelectChain(String prefix, List<String> selectChain) {
|
||||
if (!idClass) {
|
||||
prefix = SplitName.add(prefix, embIdProperty.getName());
|
||||
prefix = SplitName.add(prefix, embIdProperty.name());
|
||||
}
|
||||
for (BeanProperty prop : props) {
|
||||
prop.buildRawSqlSelectChain(prefix, selectChain);
|
||||
@@ -123,7 +123,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
@Override
|
||||
public BeanProperty findBeanProperty(String dbColumnName) {
|
||||
for (BeanProperty prop : props) {
|
||||
if (dbColumnName.equalsIgnoreCase(prop.getDbColumn())) {
|
||||
if (dbColumnName.equalsIgnoreCase(prop.dbColumn())) {
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
@@ -143,9 +143,9 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
sb.append(", ");
|
||||
}
|
||||
if (!idClass) {
|
||||
sb.append(embIdProperty.getName()).append(".");
|
||||
sb.append(embIdProperty.name()).append(".");
|
||||
}
|
||||
sb.append(props[i].getName());
|
||||
sb.append(props[i].name());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
if (i > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append(props[i].getDbColumn()).append("=?");
|
||||
sb.append(props[i].dbColumn()).append("=?");
|
||||
}
|
||||
sb.append(")");
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
EntityBean ebValue = (EntityBean) embIdProperty.getValue(bean);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
for (BeanProperty prop : props) {
|
||||
map.put(prop.getName(), prop.getValue(ebValue));
|
||||
map.put(prop.name(), prop.getValue(ebValue));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
Map<String, Object> map = (Map<String, Object>) value;
|
||||
EntityBean idValue = idDesc.createEntityBean();
|
||||
for (BeanProperty prop : props) {
|
||||
prop.setValue(idValue, map.get(prop.getName()));
|
||||
prop.setValue(idValue, map.get(prop.name()));
|
||||
}
|
||||
return idValue;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
if (prefix != null) {
|
||||
sb.append(prefix).append(".");
|
||||
}
|
||||
sb.append(props[i].getName());
|
||||
sb.append(props[i].name());
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
@@ -375,9 +375,9 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
sb.append(prefix).append(".");
|
||||
}
|
||||
if (!idClass) {
|
||||
sb.append(embIdProperty.getName()).append(".");
|
||||
sb.append(embIdProperty.name()).append(".");
|
||||
}
|
||||
sb.append(props[i].getName()).append(operator);
|
||||
sb.append(props[i].name()).append(operator);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -392,7 +392,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
if (baseTableAlias != null) {
|
||||
sb.append(baseTableAlias).append(".");
|
||||
}
|
||||
sb.append(props[i].getDbColumn()).append("=?");
|
||||
sb.append(props[i].dbColumn()).append("=?");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -411,7 +411,7 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
if (baseTableAlias != null) {
|
||||
sb.append(baseTableAlias).append(".");
|
||||
}
|
||||
sb.append(props[i].getDbColumn());
|
||||
sb.append(props[i].dbColumn());
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
|
||||
@@ -34,9 +34,9 @@ public final class IdBinderSimple implements IdBinder {
|
||||
|
||||
public IdBinderSimple(BeanProperty idProperty, MultiValueBind multiValueBind) {
|
||||
this.idProperty = idProperty;
|
||||
this.scalarType = idProperty.getScalarType();
|
||||
this.expectedType = idProperty.getPropertyType();
|
||||
bindIdSql = InternString.intern(idProperty.getDbColumn() + " = ? ");
|
||||
this.scalarType = idProperty.scalarType();
|
||||
this.expectedType = idProperty.type();
|
||||
bindIdSql = InternString.intern(idProperty.dbColumn() + " = ? ");
|
||||
this.multiValueBind = multiValueBind;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class IdBinderSimple implements IdBinder {
|
||||
if (pathPrefix != null) {
|
||||
sb.append(pathPrefix).append(".");
|
||||
}
|
||||
sb.append(idProperty.getName());
|
||||
sb.append(idProperty.name());
|
||||
if (!ascending) {
|
||||
sb.append(" desc");
|
||||
}
|
||||
@@ -75,12 +75,12 @@ public final class IdBinderSimple implements IdBinder {
|
||||
|
||||
@Override
|
||||
public String getIdProperty() {
|
||||
return idProperty.getName();
|
||||
return idProperty.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanProperty findBeanProperty(String dbColumnName) {
|
||||
if (dbColumnName.equalsIgnoreCase(idProperty.getDbColumn())) {
|
||||
if (dbColumnName.equalsIgnoreCase(idProperty.dbColumn())) {
|
||||
return idProperty;
|
||||
}
|
||||
return null;
|
||||
@@ -93,15 +93,15 @@ public final class IdBinderSimple implements IdBinder {
|
||||
|
||||
@Override
|
||||
public String getDefaultOrderBy() {
|
||||
return idProperty.getName();
|
||||
return idProperty.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBindIdInSql(String baseTableAlias) {
|
||||
if (baseTableAlias == null) {
|
||||
return idProperty.getDbColumn();
|
||||
return idProperty.dbColumn();
|
||||
} else {
|
||||
return baseTableAlias + "." + idProperty.getDbColumn();
|
||||
return baseTableAlias + "." + idProperty.dbColumn();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public final class IdBinderSimple implements IdBinder {
|
||||
sb.append(prefix);
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(idProperty.getName());
|
||||
sb.append(idProperty.name());
|
||||
sb.append(operator);
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public final class IdBinderSimple implements IdBinder {
|
||||
sb.append(prefix);
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(idProperty.getName());
|
||||
sb.append(idProperty.name());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public void addFkeys(String name) {
|
||||
BeanProperty[] embeddedProps = foreignAssocOne.getProperties();
|
||||
BeanProperty[] embeddedProps = foreignAssocOne.properties();
|
||||
for (int i = 0; i < imported.length; i++) {
|
||||
String n = name + "." + foreignAssocOne.getName() + "." + embeddedProps[i].getName();
|
||||
BeanFkeyProperty fkey = new BeanFkeyProperty(n, imported[i].localDbColumn, foreignAssocOne.getDeployOrder());
|
||||
owner.getBeanDescriptor().add(fkey);
|
||||
String n = name + "." + foreignAssocOne.name() + "." + embeddedProps[i].name();
|
||||
BeanFkeyProperty fkey = new BeanFkeyProperty(n, imported[i].localDbColumn, foreignAssocOne.deployOrder());
|
||||
owner.descriptor().add(fkey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
|
||||
|
||||
@Override
|
||||
public void addFkeys(String name) {
|
||||
BeanFkeyProperty fkey = new BeanFkeyProperty(name + "." + foreignProperty.getName(), localDbColumn, owner.getDeployOrder());
|
||||
owner.getBeanDescriptor().add(fkey);
|
||||
BeanFkeyProperty fkey = new BeanFkeyProperty(name + "." + foreignProperty.name(), localDbColumn, owner.deployOrder());
|
||||
owner.descriptor().add(fkey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ public class DeployBeanDescriptor<T> {
|
||||
* Return the DeployBeanInfo for the given bean class.
|
||||
*/
|
||||
DeployBeanInfo<?> getDeploy(Class<?> cls) {
|
||||
return manager.getDeploy(cls);
|
||||
return manager.deploy(cls);
|
||||
}
|
||||
|
||||
public void setStorageEngine(String storageEngine) {
|
||||
|
||||
+10
-10
@@ -90,7 +90,7 @@ public final class DeployBeanPropertyLists {
|
||||
discProperty = null;
|
||||
}
|
||||
BeanProperty beanProp = createBeanProperty(owner, prop);
|
||||
propertyMap.put(beanProp.getName(), beanProp);
|
||||
propertyMap.put(beanProp.name(), beanProp);
|
||||
}
|
||||
|
||||
int order = 0;
|
||||
@@ -102,13 +102,13 @@ public final class DeployBeanPropertyLists {
|
||||
if (orderColumn != null) {
|
||||
orderColumn.setDeployOrder(order);
|
||||
allocateToList(orderColumn);
|
||||
propertyMap.put(orderColumn.getName(), orderColumn);
|
||||
propertyMap.put(orderColumn.name(), orderColumn);
|
||||
}
|
||||
|
||||
if (discProperty != null) {
|
||||
// put the discriminator property into the property map only
|
||||
// (after the real properties have been organised into their lists)
|
||||
propertyMap.put(discProperty.getName(), discProperty);
|
||||
propertyMap.put(discProperty.name(), discProperty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -194,7 +194,7 @@ public final class DeployBeanPropertyLists {
|
||||
mutable.add(prop);
|
||||
}
|
||||
|
||||
if (desc.getInheritInfo() != null && prop.isLocal()) {
|
||||
if (desc.inheritInfo() != null && prop.isLocal()) {
|
||||
local.add(prop);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public final class DeployBeanPropertyLists {
|
||||
if (versionProperty == null) {
|
||||
versionProperty = prop;
|
||||
} else {
|
||||
logger.warn("Multiple @Version properties - property " + prop.getFullBeanName() + " not treated as a version property");
|
||||
logger.warn("Multiple @Version properties - property " + prop.fullName() + " not treated as a version property");
|
||||
}
|
||||
} else if (prop.isDraftDirty()) {
|
||||
draftDirty = prop;
|
||||
@@ -356,7 +356,7 @@ public final class DeployBeanPropertyLists {
|
||||
public BeanProperty[] getGeneratedInsert() {
|
||||
List<BeanProperty> list = new ArrayList<>();
|
||||
for (BeanProperty prop : nonTransients) {
|
||||
GeneratedProperty gen = prop.getGeneratedProperty();
|
||||
GeneratedProperty gen = prop.generatedProperty();
|
||||
if (gen != null && gen.includeInInsert()) {
|
||||
list.add(prop);
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public final class DeployBeanPropertyLists {
|
||||
public BeanProperty[] getGeneratedUpdate() {
|
||||
List<BeanProperty> list = new ArrayList<>();
|
||||
for (BeanProperty prop : nonTransients) {
|
||||
GeneratedProperty gen = prop.getGeneratedProperty();
|
||||
GeneratedProperty gen = prop.generatedProperty();
|
||||
if (gen != null && gen.includeInUpdate()) {
|
||||
list.add(prop);
|
||||
}
|
||||
@@ -391,12 +391,12 @@ public final class DeployBeanPropertyLists {
|
||||
if (imported != prop.isOneToOneExported()) {
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave()) {
|
||||
if (prop.cascadeInfo().isSave()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete()) {
|
||||
if (prop.cascadeInfo().isDelete()) {
|
||||
list.add(prop);
|
||||
}
|
||||
break;
|
||||
|
||||
+1
-3
@@ -3,8 +3,6 @@ package io.ebeaninternal.server.deploy.meta;
|
||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import io.ebeaninternal.server.deploy.BeanTable;
|
||||
|
||||
import javax.persistence.JoinColumn;
|
||||
|
||||
/**
|
||||
* A join pair of local and foreign properties.
|
||||
*/
|
||||
@@ -87,7 +85,7 @@ public final class DeployTableJoinColumn {
|
||||
if (localDbColumn == null) {
|
||||
BeanProperty idProperty = beanTable.getIdProperty();
|
||||
if (idProperty != null) {
|
||||
localDbColumn = idProperty.getDbColumn();
|
||||
localDbColumn = idProperty.dbColumn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class AnnotationAssoc extends AnnotationParser {
|
||||
}
|
||||
|
||||
BeanTable getBeanTable(DeployBeanPropertyAssoc<?> prop) {
|
||||
return factory.getBeanTable(prop.getTargetType());
|
||||
return factory.beanTable(prop.getTargetType());
|
||||
}
|
||||
|
||||
private String errorMsgMissingBeanTable(Class<?> type, String from) {
|
||||
|
||||
+13
-13
@@ -154,13 +154,13 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
if (!prop.getTableJoin().hasJoinColumns() && beanTable != null) {
|
||||
// use naming convention to define join (based on the bean name for this side of relationship)
|
||||
// A unidirectional OneToMany or OneToMany with no mappedBy property
|
||||
NamingConvention nc = factory.getNamingConvention();
|
||||
NamingConvention nc = factory.namingConvention();
|
||||
String fkeyPrefix = null;
|
||||
if (nc.isUseForeignKeyPrefix()) {
|
||||
fkeyPrefix = nc.getColumnFromProperty(descriptor.getBeanType(), descriptor.getName());
|
||||
}
|
||||
// Use the owning bean table to define the join
|
||||
BeanTable owningBeanTable = factory.getBeanTable(descriptor.getBeanType());
|
||||
BeanTable owningBeanTable = factory.beanTable(descriptor.getBeanType());
|
||||
owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false, prop.getSqlFormulaSelect());
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
fullTableName = descriptor.getBaseTable()+"_"+ CamelCaseHelper.toUnderscoreFromCamel(prop.getName());
|
||||
}
|
||||
|
||||
BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
|
||||
BeanTable localTable = factory.beanTable(descriptor.getBeanType());
|
||||
if (collectionTable != null) {
|
||||
prop.getTableJoin().addJoinColumn(util, true, collectionTable.joinColumns(), localTable);
|
||||
}
|
||||
@@ -198,8 +198,8 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
BeanProperty localId = localTable.getIdProperty();
|
||||
if (localId != null) {
|
||||
// add foreign key based on convention
|
||||
String fkColName = namingConvention.getForeignKey(descriptor.getBaseTable(), localId.getName());
|
||||
prop.getTableJoin().addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), fkColName));
|
||||
String fkColName = namingConvention.getForeignKey(descriptor.getBaseTable(), localId.name());
|
||||
prop.getTableJoin().addJoinColumn(new DeployTableJoinColumn(localId.dbColumn(), fkColName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,8 +296,8 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
private void readJoinTable(JoinTable joinTable, DeployBeanPropertyAssocMany<?> prop) {
|
||||
String intTableName = getFullTableName(joinTable);
|
||||
if (intTableName.isEmpty()) {
|
||||
BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
|
||||
BeanTable otherTable = factory.getBeanTable(prop.getTargetType());
|
||||
BeanTable localTable = factory.beanTable(descriptor.getBeanType());
|
||||
BeanTable otherTable = factory.beanTable(prop.getTargetType());
|
||||
intTableName = getM2MJoinTableName(localTable, otherTable);
|
||||
}
|
||||
|
||||
@@ -362,8 +362,8 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
intTableName = intJoin.getTable();
|
||||
}
|
||||
|
||||
BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
|
||||
BeanTable otherTable = factory.getBeanTable(prop.getTargetType());
|
||||
BeanTable localTable = factory.beanTable(descriptor.getBeanType());
|
||||
BeanTable otherTable = factory.beanTable(prop.getTargetType());
|
||||
|
||||
final String localTableName = localTable.getUnqualifiedBaseTable();
|
||||
final String otherTableName = otherTable.getUnqualifiedBaseTable();
|
||||
@@ -386,8 +386,8 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
BeanProperty localId = localTable.getIdProperty();
|
||||
if (localId != null) {
|
||||
// add the source to intersection join columns
|
||||
String fkCol = namingConvention.deriveM2MColumn(localTableName, localId.getDbColumn());
|
||||
intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), fkCol));
|
||||
String fkCol = namingConvention.deriveM2MColumn(localTableName, localId.dbColumn());
|
||||
intJoin.addJoinColumn(new DeployTableJoinColumn(localId.dbColumn(), fkCol));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,8 +396,8 @@ final class AnnotationAssocManys extends AnnotationAssoc {
|
||||
BeanProperty otherId = otherTable.getIdProperty();
|
||||
if (otherId != null) {
|
||||
// set the intersection to dest table join columns
|
||||
String fkCol = namingConvention.deriveM2MColumn(otherTableName, otherId.getDbColumn());
|
||||
destJoin.addJoinColumn(new DeployTableJoinColumn(fkCol, otherId.getDbColumn()));
|
||||
String fkCol = namingConvention.deriveM2MColumn(otherTableName, otherId.dbColumn());
|
||||
destJoin.addJoinColumn(new DeployTableJoinColumn(fkCol, otherId.dbColumn()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ final class AnnotationAssocOnes extends AnnotationAssoc {
|
||||
|
||||
} else {
|
||||
// use naming convention to define join.
|
||||
NamingConvention nc = factory.getNamingConvention();
|
||||
NamingConvention nc = factory.namingConvention();
|
||||
|
||||
String fkeyPrefix = null;
|
||||
if (nc.isUseForeignKeyPrefix()) {
|
||||
@@ -231,7 +231,7 @@ final class AnnotationAssocOnes extends AnnotationAssoc {
|
||||
if (!primaryKeyJoin.referencedColumnName().isEmpty()) {
|
||||
log.info("Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{}] on {}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
|
||||
}
|
||||
BeanTable baseBeanTable = factory.getBeanTable(info.getDescriptor().getBeanType());
|
||||
BeanTable baseBeanTable = factory.beanTable(info.getDescriptor().getBeanType());
|
||||
String localPrimaryKey = baseBeanTable.getIdColumn();
|
||||
String foreignColumn = getBeanTable(prop).getIdColumn();
|
||||
prop.getTableJoin().addJoinColumn(new DeployTableJoinColumn(localPrimaryKey, foreignColumn, false, false));
|
||||
|
||||
+4
-4
@@ -21,11 +21,11 @@ public class VisitProperties {
|
||||
}
|
||||
|
||||
protected void visitProperties(BeanDescriptor<?> desc, BeanPropertyVisitor propertyVisitor) {
|
||||
BeanProperty idProp = desc.getIdProperty();
|
||||
BeanProperty idProp = desc.idProperty();
|
||||
if (idProp != null) {
|
||||
visit(propertyVisitor, idProp);
|
||||
}
|
||||
BeanPropertyAssocOne<?> unidirectional = desc.getUnidirectional();
|
||||
BeanPropertyAssocOne<?> unidirectional = desc.unidirectional();
|
||||
if (unidirectional != null) {
|
||||
visit(propertyVisitor, unidirectional);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class VisitProperties {
|
||||
if (assocOne.isEmbedded()) {
|
||||
// Embedded bean
|
||||
pv.visitEmbedded(assocOne);
|
||||
BeanProperty[] embProps = assocOne.getProperties();
|
||||
BeanProperty[] embProps = assocOne.properties();
|
||||
for (BeanProperty embProp : embProps) {
|
||||
pv.visitEmbeddedScalar(embProp, assocOne);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class VisitProperties {
|
||||
* Visit all the other inheritance properties that are not on the root.
|
||||
*/
|
||||
protected void visitInheritanceProperties(BeanDescriptor<?> descriptor, BeanPropertyVisitor pv) {
|
||||
InheritInfo inheritInfo = descriptor.getInheritInfo();
|
||||
InheritInfo inheritInfo = descriptor.inheritInfo();
|
||||
if (inheritInfo != null && inheritInfo.isRoot()) {
|
||||
// add all properties on the children objects
|
||||
inheritInfo.visitChildren(new InheritChildVisitor(this, pv));
|
||||
|
||||
@@ -12,7 +12,7 @@ abstract class DtoQueryPlanBase implements DtoQueryPlan {
|
||||
|
||||
DtoQueryPlanBase(DtoMappingRequest request) {
|
||||
this.planMetric = request.createMetric();
|
||||
this.metric = planMetric.getMetric();
|
||||
this.metric = planMetric.metric();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,13 +43,13 @@ public final class ElComparatorProperty<T> implements Comparator<T>, ElComparato
|
||||
return val2 == null ? 0 : nullOrder;
|
||||
}
|
||||
if (elGetValue.isAssocId()) {
|
||||
val1 = elGetValue.getAssocIdValues((EntityBean) val1)[0]; // TODO: compound key not yet supported
|
||||
val1 = elGetValue.assocIdValues((EntityBean) val1)[0]; // TODO: compound key not yet supported
|
||||
}
|
||||
if (val2 == null) {
|
||||
return -1 * nullOrder;
|
||||
}
|
||||
if (elGetValue.isAssocId()) {
|
||||
val2 = elGetValue.getAssocIdValues((EntityBean) val2)[0];
|
||||
val2 = elGetValue.assocIdValues((EntityBean) val2)[0];
|
||||
}
|
||||
Comparable c = (Comparable) val1;
|
||||
return asc * c.compareTo(val2);
|
||||
|
||||
@@ -24,18 +24,18 @@ public final class ElFilter<T> implements Filter<T> {
|
||||
|
||||
private Object convertValue(String propertyName, Object value) {
|
||||
// convert type of value to match expected type
|
||||
ElPropertyValue elGetValue = beanDescriptor.getElGetValue(propertyName);
|
||||
ElPropertyValue elGetValue = beanDescriptor.elGetValue(propertyName);
|
||||
return elGetValue.convert(value);
|
||||
}
|
||||
|
||||
private ElComparator<T> getElComparator(String propertyName) {
|
||||
|
||||
return beanDescriptor.getElComparator(propertyName);
|
||||
return beanDescriptor.elComparator(propertyName);
|
||||
}
|
||||
|
||||
private ElPropertyValue getElGetValue(String propertyName) {
|
||||
|
||||
return beanDescriptor.getElGetValue(propertyName);
|
||||
return beanDescriptor.elGetValue(propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,9 +59,9 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
this.assocId = chain[chain.length - 1].isAssocId();
|
||||
|
||||
this.last = chain.length - 1;
|
||||
this.lastBeanProperty = chain[chain.length - 1].getBeanProperty();
|
||||
this.lastBeanProperty = chain[chain.length - 1].beanProperty();
|
||||
if (lastBeanProperty != null) {
|
||||
this.scalarType = lastBeanProperty.getScalarType();
|
||||
this.scalarType = lastBeanProperty.scalarType();
|
||||
} else {
|
||||
// case for nested compound type (non-scalar)
|
||||
this.scalarType = null;
|
||||
@@ -77,8 +77,8 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchPreference() {
|
||||
return chain[0].getFetchPreference();
|
||||
public int fetchPreference() {
|
||||
return chain[0].fetchPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,9 +88,9 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
|
||||
private String getElPlaceHolder(String prefix, ElPropertyValue lastElPropertyValue, boolean encrypted) {
|
||||
if (prefix == null) {
|
||||
return lastElPropertyValue.getElPlaceholder(encrypted);
|
||||
return lastElPropertyValue.elPlaceholder(encrypted);
|
||||
}
|
||||
String el = lastElPropertyValue.getElPlaceholder(encrypted);
|
||||
String el = lastElPropertyValue.elPlaceholder(encrypted);
|
||||
if (!el.contains("${}")) {
|
||||
// typically a secondary table property
|
||||
return el.replace("${", "${" + prefix + ".");
|
||||
@@ -113,7 +113,7 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
int i = 1 + SplitName.count(sinceProperty);
|
||||
for (; i < chain.length; i++) {
|
||||
if (chain[i].getBeanProperty().containsMany()) {
|
||||
if (chain[i].beanProperty().containsMany()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -131,22 +131,22 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPrefix() {
|
||||
public String elPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElName() {
|
||||
public String elName() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElPlaceholder(boolean encrypted) {
|
||||
public String elPlaceholder(boolean encrypted) {
|
||||
return encrypted ? placeHolderEncrypted : placeHolder;
|
||||
}
|
||||
|
||||
@@ -166,30 +166,30 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
return lastElPropertyValue.getAssocIsEmpty(request, path);
|
||||
public String assocIsEmpty(SpiExpressionRequest request, String path) {
|
||||
return lastElPropertyValue.assocIsEmpty(request, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAssocIdValues(EntityBean bean) {
|
||||
public Object[] assocIdValues(EntityBean bean) {
|
||||
// Don't navigate the object graph as bean
|
||||
// is assumed to be the appropriate type
|
||||
return lastElPropertyValue.getAssocIdValues(bean);
|
||||
return lastElPropertyValue.assocIdValues(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdExpression(String prefix, String operator) {
|
||||
return lastElPropertyValue.getAssocIdExpression(expression, operator);
|
||||
public String assocIdExpression(String prefix, String operator) {
|
||||
return lastElPropertyValue.assocIdExpression(expression, operator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
return lastElPropertyValue.getAssocIdInExpr(prefix);
|
||||
public String assocIdInExpr(String prefix) {
|
||||
return lastElPropertyValue.assocIdInExpr(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
||||
return lastElPropertyValue.getAssocIdInValueExpr(not, size);
|
||||
public String assocIdInValueExpr(boolean not, int size) {
|
||||
return lastElPropertyValue.assocIdInValueExpr(not, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,7 +198,7 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
public Property property() {
|
||||
return lastBeanProperty;
|
||||
}
|
||||
|
||||
@@ -218,12 +218,12 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDbColumn() {
|
||||
return lastElPropertyValue.getDbColumn();
|
||||
public String dbColumn() {
|
||||
return lastElPropertyValue.dbColumn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanProperty getBeanProperty() {
|
||||
public BeanProperty beanProperty() {
|
||||
return lastBeanProperty;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJdbcType() {
|
||||
public int jdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringParser getStringParser() {
|
||||
public StringParser stringParser() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface ElPropertyDeploy {
|
||||
* this property.
|
||||
* </p>
|
||||
*/
|
||||
String getElPrefix();
|
||||
String elPrefix();
|
||||
|
||||
/**
|
||||
* Return the place holder in the form of ${elPrefix}dbColumn.
|
||||
@@ -48,27 +48,27 @@ public interface ElPropertyDeploy {
|
||||
* The ${elPrefix} is replaced by the appropriate table alias.
|
||||
* </p>
|
||||
*/
|
||||
String getElPlaceholder(boolean encrypted);
|
||||
String elPlaceholder(boolean encrypted);
|
||||
|
||||
/**
|
||||
* Return the name of the property.
|
||||
*/
|
||||
String getName();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The ElPrefix plus name.
|
||||
*/
|
||||
String getElName();
|
||||
String elName();
|
||||
|
||||
/**
|
||||
* Return the deployment db column for this property.
|
||||
*/
|
||||
String getDbColumn();
|
||||
String dbColumn();
|
||||
|
||||
/**
|
||||
* Return the underlying bean property.
|
||||
*/
|
||||
BeanProperty getBeanProperty();
|
||||
BeanProperty beanProperty();
|
||||
|
||||
/**
|
||||
* Return true if this is an aggregation property.
|
||||
@@ -79,5 +79,5 @@ public interface ElPropertyDeploy {
|
||||
* Return the fetch preference. This can be used to control which ToMany relationship
|
||||
* is left as a 'join' and which get converted to query join.
|
||||
*/
|
||||
int getFetchPreference();
|
||||
int fetchPreference();
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ public interface ElPropertyValue extends ElPropertyDeploy, ExpressionPath {
|
||||
/**
|
||||
* Return the logical id value expression taking into account embedded id's.
|
||||
*/
|
||||
String getAssocIdInValueExpr(boolean not, int size);
|
||||
String assocIdInValueExpr(boolean not, int size);
|
||||
|
||||
/**
|
||||
* Return the logical id in expression taking into account embedded id's.
|
||||
*/
|
||||
String getAssocIdInExpr(String prefix);
|
||||
String assocIdInExpr(String prefix);
|
||||
|
||||
/**
|
||||
* Return the logical where clause to support "Is empty".
|
||||
*/
|
||||
String getAssocIsEmpty(SpiExpressionRequest request, String path);
|
||||
String assocIsEmpty(SpiExpressionRequest request, String path);
|
||||
|
||||
/**
|
||||
* Return true if this is an ManyToOne or OneToOne associated bean property.
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class AbstractExpression implements SpiExpression {
|
||||
|
||||
protected String propertyNestedPath(String propertyName, BeanDescriptor<?> desc) {
|
||||
if (propertyName != null) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(propertyName);
|
||||
ElPropertyDeploy elProp = desc.elPropertyDeploy(propertyName);
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
return SplitName.begin(propName);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ abstract class AbstractExpression implements SpiExpression {
|
||||
*/
|
||||
protected void propertyContainsMany(String propertyName, BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
if (propertyName != null) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(propertyName);
|
||||
ElPropertyDeploy elProp = desc.elPropertyDeploy(propertyName);
|
||||
if (elProp != null) {
|
||||
if (elProp.containsFormulaWithJoin()) {
|
||||
// for findCount query select clause
|
||||
@@ -102,6 +102,6 @@ abstract class AbstractExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
protected final ElPropertyValue getElProp(SpiExpressionRequest request) {
|
||||
return request.getBeanDescriptor().getElGetValue(propName);
|
||||
return request.getBeanDescriptor().elGetValue(propName);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ final class AllEqualsExpression extends NonPrepareExpression {
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
if (propMap != null) {
|
||||
for (String propertyName : propMap.keySet()) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(propertyName));
|
||||
ElPropertyDeploy elProp = desc.elPropertyDeploy(name(propertyName));
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
manyWhereJoin.add(elProp);
|
||||
}
|
||||
|
||||
+3
-3
@@ -52,7 +52,7 @@ final class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
|
||||
@Override
|
||||
public String nestedPath(BeanDescriptor<?> desc) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(lowProperty));
|
||||
ElPropertyDeploy elProp = desc.elPropertyDeploy(name(lowProperty));
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
// assumes highProperty is also nested property which seems reasonable
|
||||
return SplitName.begin(lowProperty);
|
||||
@@ -62,11 +62,11 @@ final class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
|
||||
@Override
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(lowProperty));
|
||||
ElPropertyDeploy elProp = desc.elPropertyDeploy(name(lowProperty));
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
manyWhereJoin.add(elProp);
|
||||
}
|
||||
elProp = desc.getElPropertyDeploy(name(highProperty));
|
||||
elProp = desc.elPropertyDeploy(name(highProperty));
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
manyWhereJoin.add(elProp);
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ final class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
// bind the key as well as the value
|
||||
String encryptKey = prop.getBeanProperty().getEncryptKey().getStringValue();
|
||||
String encryptKey = prop.beanProperty().encryptKey().getStringValue();
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ final class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
||||
String pname = propName;
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
pname = prop.getBeanProperty().getDecryptProperty(propName);
|
||||
pname = prop.beanProperty().decryptProperty(propName);
|
||||
}
|
||||
if (not) {
|
||||
request.append("lower(").append(pname).append(") != ?");
|
||||
|
||||
+2
-2
@@ -276,7 +276,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
if (!beanProperty.isTransient()) {
|
||||
Object value = beanProperty.getValue(bean);
|
||||
if (value != null) {
|
||||
String propName = SplitName.add(prefix, beanProperty.getName());
|
||||
String propName = SplitName.add(prefix, beanProperty.name());
|
||||
if (beanProperty.isScalar()) {
|
||||
if (value instanceof String) {
|
||||
list.add(new LikeExpression(propName, value, caseInsensitive, likeType));
|
||||
@@ -290,7 +290,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
|
||||
} else if ((beanProperty instanceof BeanPropertyAssocOne) && (value instanceof EntityBean)) {
|
||||
BeanPropertyAssocOne<?> assocOne = (BeanPropertyAssocOne<?>) beanProperty;
|
||||
BeanDescriptor<?> targetDescriptor = assocOne.getTargetDescriptor();
|
||||
BeanDescriptor<?> targetDescriptor = assocOne.targetDescriptor();
|
||||
addExpressions(list, targetDescriptor, (EntityBean) value, propName);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user