mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2354 - Refactor internals - refactor rename methods in BeanRequest etc
This commit is contained in:
@@ -28,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).
|
||||
*/
|
||||
|
||||
@@ -1227,7 +1227,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) {
|
||||
@@ -1341,7 +1341,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (ids.isEmpty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return persister.deleteByIds(request.getBeanDescriptor(), ids, request.transaction(), false);
|
||||
return persister.deleteByIds(request.descriptor(), ids, request.transaction(), false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -1504,7 +1504,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();
|
||||
|
||||
@@ -60,38 +60,21 @@ 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();
|
||||
@@ -145,7 +128,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* Return the database platform like clause.
|
||||
*/
|
||||
@Override
|
||||
public String getDBLikeClause(boolean rawLikeExpression) {
|
||||
public String dbLikeClause(boolean rawLikeExpression) {
|
||||
return server.getDatabasePlatform().getLikeClause(rawLikeExpression);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -279,7 +261,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
}
|
||||
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,7 +318,7 @@ 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();
|
||||
@@ -504,7 +486,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -524,7 +506,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* 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,7 +514,7 @@ 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() {
|
||||
public CQueryPlan queryPlan() {
|
||||
return beanDescriptor.getQueryPlan(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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
@@ -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();
|
||||
@@ -693,13 +673,11 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
} 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
|
||||
@@ -711,7 +689,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
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,7 +743,7 @@ 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 : server.getLazyLoadBatchSize();
|
||||
}
|
||||
@@ -775,7 +752,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
* 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,7 +760,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
||||
/**
|
||||
* Return the base table alias for this query.
|
||||
*/
|
||||
public String getBaseTableAlias() {
|
||||
public String baseTableAlias() {
|
||||
return query.getAlias(beanDescriptor.getBaseTableAlias());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -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,7 +617,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
* Used to determine common persist requests for queueing and statement batching.
|
||||
* </p>
|
||||
*/
|
||||
public String getFullName() {
|
||||
public String fullName() {
|
||||
return beanDescriptor.getFullName();
|
||||
}
|
||||
|
||||
@@ -679,14 +629,14 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,7 +1147,7 @@ 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();
|
||||
@@ -1219,7 +1169,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
/**
|
||||
* Return the table to update depending if the request is a 'publish' one or normal.
|
||||
*/
|
||||
public String getUpdateTable() {
|
||||
public String updateTable() {
|
||||
return publish ? beanDescriptor.getBaseTable() : beanDescriptor.getDraftTable();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1383,7 +1333,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
|
||||
String key = beanDescriptor.cacheKey(idValue);
|
||||
Map<String, Object> changes = new LinkedHashMap<>();
|
||||
EntityBean bean = getEntityBean();
|
||||
EntityBean bean = entityBean();
|
||||
boolean[] dirtyProperties = dirtyProperties();
|
||||
if (dirtyProperties != null) {
|
||||
for (int i = 0; i < dirtyProperties.length; i++) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+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;
|
||||
@@ -37,7 +29,7 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||
profileBase(EVT_ORMUPDATE, offset, beanDescriptor.getName(), 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;
|
||||
}
|
||||
|
||||
@@ -171,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
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
||||
/**
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public final class BeanCollectionHelpFactory {
|
||||
return SET_HELP;
|
||||
|
||||
} else if (manyType == SpiQuery.Type.MAP) {
|
||||
BeanDescriptor<T> target = request.getBeanDescriptor();
|
||||
BeanDescriptor<T> target = request.descriptor();
|
||||
ElPropertyValue elProperty = target.getElGetValue(request.query().getMapKey());
|
||||
return new BeanMapQueryHelp<>(elProperty);
|
||||
|
||||
|
||||
@@ -799,7 +799,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* Return the bean change for a delete.
|
||||
*/
|
||||
private BeanChange deleteBeanChange(PersistRequestBean<T> request) {
|
||||
return beanChange(ChangeType.DELETE, request.getBeanId(), null, null);
|
||||
return beanChange(ChangeType.DELETE, request.beanId(), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -808,9 +808,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
private BeanChange updateBeanChange(PersistRequestBean<T> request) {
|
||||
try {
|
||||
BeanChangeJson changeJson = new BeanChangeJson(this, request.isStatelessUpdate());
|
||||
request.getEntityBeanIntercept().addDirtyPropertyValues(changeJson);
|
||||
request.intercept().addDirtyPropertyValues(changeJson);
|
||||
changeJson.flush();
|
||||
return beanChange(ChangeType.UPDATE, request.getBeanId(), changeJson.newJson(), changeJson.oldJson());
|
||||
return beanChange(ChangeType.UPDATE, request.beanId(), changeJson.newJson(), changeJson.oldJson());
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("Failed to write ChangeLog entry for update", e);
|
||||
return null;
|
||||
@@ -824,9 +824,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
try {
|
||||
StringWriter writer = new StringWriter(200);
|
||||
SpiJsonWriter jsonWriter = createJsonWriter(writer);
|
||||
jsonWriteForInsert(jsonWriter, request.getEntityBean());
|
||||
jsonWriteForInsert(jsonWriter, request.entityBean());
|
||||
jsonWriter.flush();
|
||||
return beanChange(ChangeType.INSERT, request.getBeanId(), writer.toString(), null);
|
||||
return beanChange(ChangeType.INSERT, request.beanId(), writer.toString(), null);
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to write ChangeLog entry for insert", e);
|
||||
return null;
|
||||
|
||||
+4
-4
@@ -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,7 +815,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
changeSet.addInvalidate(desc);
|
||||
} else {
|
||||
queryCacheClear(changeSet);
|
||||
cacheDeleteImported(false, insertRequest.getEntityBean(), changeSet);
|
||||
cacheDeleteImported(false, insertRequest.entityBean(), changeSet);
|
||||
changeSet.addBeanInsert(desc.getBaseTable());
|
||||
}
|
||||
}
|
||||
@@ -839,10 +839,10 @@ 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);
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ public final class DefaultExpressionRequest implements SpiExpressionRequest {
|
||||
|
||||
public DefaultExpressionRequest(SpiOrmQueryRequest<?> queryRequest, DeployParser deployParser, Binder binder, SpiExpressionList<?> expressionList) {
|
||||
this.queryRequest = queryRequest;
|
||||
this.beanDescriptor = queryRequest.getBeanDescriptor();
|
||||
this.beanDescriptor = queryRequest.descriptor();
|
||||
this.deployParser = deployParser;
|
||||
this.binder = binder;
|
||||
this.expressionList = expressionList;
|
||||
@@ -84,7 +84,7 @@ public final class DefaultExpressionRequest implements SpiExpressionRequest {
|
||||
@Override
|
||||
public void appendLike(boolean rawLikeExpression) {
|
||||
sql.append(" ");
|
||||
sql.append(queryRequest.getDBLikeClause(rawLikeExpression));
|
||||
sql.append(queryRequest.dbLikeClause(rawLikeExpression));
|
||||
sql.append(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ public final class DLoadContext implements LoadContext {
|
||||
}
|
||||
|
||||
public DLoadContext(OrmQueryRequest<?> request, SpiQuerySecondary secondaryQueries) {
|
||||
this.tenantId = request.getTenantId();
|
||||
this.persistenceContext = request.getPersistenceContext();
|
||||
this.tenantId = request.tenantId();
|
||||
this.persistenceContext = request.persistenceContext();
|
||||
this.ebeanServer = request.server();
|
||||
this.defaultBatchSize = request.getLazyLoadBatchSize();
|
||||
this.rootDescriptor = request.getBeanDescriptor();
|
||||
this.defaultBatchSize = request.lazyLoadBatchSize();
|
||||
this.rootDescriptor = request.descriptor();
|
||||
|
||||
SpiQuery<?> query = request.query();
|
||||
this.useDocStore = query.isUseDocStore();
|
||||
|
||||
@@ -181,7 +181,7 @@ public final class BatchControl {
|
||||
* Add the request to the batch and return true if we should flush.
|
||||
*/
|
||||
private boolean addToBatch(PersistRequestBean<?> request) {
|
||||
Object alreadyInBatch = persistedBeans.put(request.getEntityBean(), DUMMY);
|
||||
Object alreadyInBatch = persistedBeans.put(request.entityBean(), DUMMY);
|
||||
if (alreadyInBatch != null) {
|
||||
// special case where the same bean instance has already been
|
||||
// added to the batch (doesn't really occur with non-batching
|
||||
@@ -345,7 +345,7 @@ public final class BatchControl {
|
||||
private BatchedBeanHolder getBeanHolder(PersistRequestBean<?> request) {
|
||||
|
||||
int depth = transaction.depth();
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
|
||||
// batching by bean type AND depth
|
||||
String key = desc.rootName() + ":" + depth;
|
||||
|
||||
@@ -906,11 +906,11 @@ public final class DefaultPersister implements Persister {
|
||||
*/
|
||||
private void saveAssocMany(PersistRequestBean<?> request) {
|
||||
|
||||
EntityBean parentBean = request.getEntityBean();
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
EntityBean parentBean = request.entityBean();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
SpiTransaction t = request.transaction();
|
||||
|
||||
EntityBean orphanForRemoval = request.getImportedOrphanForRemoval();
|
||||
EntityBean orphanForRemoval = request.importedOrphanForRemoval();
|
||||
if (orphanForRemoval != null) {
|
||||
delete(orphanForRemoval, request.transaction(), true);
|
||||
}
|
||||
@@ -924,7 +924,7 @@ public final class DefaultPersister implements Persister {
|
||||
if (!prop.isSaveRecurseSkippable(detailBean)) {
|
||||
t.depth(+1);
|
||||
prop.setParentBeanToChild(parentBean, detailBean);
|
||||
saveRecurse(detailBean, t, parentBean, request.getFlags());
|
||||
saveRecurse(detailBean, t, parentBean, request.flags());
|
||||
t.depth(-1);
|
||||
}
|
||||
}
|
||||
@@ -980,8 +980,8 @@ public final class DefaultPersister implements Persister {
|
||||
SpiTransaction t = request.transaction();
|
||||
t.depth(-1);
|
||||
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
EntityBean parentBean = request.getEntityBean();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
EntityBean parentBean = request.entityBean();
|
||||
DeleteMode deleteMode = request.deleteMode();
|
||||
|
||||
BeanPropertyAssocOne<?>[] expOnes = desc.propertiesOneExportedDelete();
|
||||
@@ -1107,7 +1107,7 @@ public final class DefaultPersister implements Persister {
|
||||
*/
|
||||
private void saveAssocOne(PersistRequestBean<?> request) {
|
||||
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
|
||||
// imported ones with save cascade
|
||||
for (BeanPropertyAssocOne<?> prop : desc.propertiesOneImportedSave()) {
|
||||
@@ -1117,14 +1117,14 @@ public final class DefaultPersister implements Persister {
|
||||
}
|
||||
|
||||
if (request.isLoadedProperty(prop)) {
|
||||
EntityBean detailBean = prop.getValueAsEntityBean(request.getEntityBean());
|
||||
EntityBean detailBean = prop.getValueAsEntityBean(request.entityBean());
|
||||
if (detailBean != null
|
||||
&& !prop.isSaveRecurseSkippable(detailBean)
|
||||
&& !prop.isReference(detailBean)
|
||||
&& !request.isParent(detailBean)) {
|
||||
SpiTransaction t = request.transaction();
|
||||
t.depth(-1);
|
||||
saveRecurse(detailBean, t, null, request.getFlags());
|
||||
saveRecurse(detailBean, t, null, request.flags());
|
||||
t.depth(+1);
|
||||
}
|
||||
}
|
||||
@@ -1152,7 +1152,7 @@ public final class DefaultPersister implements Persister {
|
||||
|
||||
DeleteUnloadedForeignKeys fkeys = null;
|
||||
|
||||
for (BeanPropertyAssocOne<?> one : request.getBeanDescriptor().propertiesOneImportedDelete()) {
|
||||
for (BeanPropertyAssocOne<?> one : request.descriptor().propertiesOneImportedDelete()) {
|
||||
if (!request.isLoadedProperty(one)) {
|
||||
// we have cascade Delete on a partially populated bean and
|
||||
// this property was not loaded (so we are going to have to fetch it)
|
||||
@@ -1173,10 +1173,10 @@ public final class DefaultPersister implements Persister {
|
||||
|
||||
DeleteMode deleteMode = request.deleteMode();
|
||||
|
||||
for (BeanPropertyAssocOne<?> prop : request.getBeanDescriptor().propertiesOneImportedDelete()) {
|
||||
for (BeanPropertyAssocOne<?> prop : request.descriptor().propertiesOneImportedDelete()) {
|
||||
if (deleteMode.isHard() || prop.isTargetSoftDelete()) {
|
||||
if (request.isLoadedProperty(prop)) {
|
||||
Object detailBean = prop.getValue(request.getEntityBean());
|
||||
Object detailBean = prop.getValue(request.entityBean());
|
||||
if (detailBean != null) {
|
||||
EntityBean detail = (EntityBean) detailBean;
|
||||
if (prop.hasId(detail)) {
|
||||
|
||||
+2
-2
@@ -49,10 +49,10 @@ final class DeleteUnloadedForeignKeys {
|
||||
*/
|
||||
void queryForeignKeys() {
|
||||
|
||||
BeanDescriptor<?> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> descriptor = request.descriptor();
|
||||
SpiQuery<?> q = (SpiQuery<?>) server.createQuery(descriptor.getBeanType());
|
||||
|
||||
Object id = request.getBeanId();
|
||||
Object id = request.beanId();
|
||||
|
||||
StringBuilder sb = new StringBuilder(30);
|
||||
for (BeanPropertyAssocOne<?> aPropList : propList) {
|
||||
|
||||
@@ -56,7 +56,7 @@ final class ExeCallableSql {
|
||||
|
||||
private CallableStatement bindStmt(PersistRequestCallableSql request, boolean batchThisRequest) throws SQLException {
|
||||
request.startBind(batchThisRequest);
|
||||
SpiCallableSql callableSql = request.getCallableSql();
|
||||
SpiCallableSql callableSql = request.callableSql();
|
||||
SpiTransaction t = request.transaction();
|
||||
|
||||
String sql = callableSql.getSql();
|
||||
|
||||
@@ -38,7 +38,7 @@ final class ExeOrmUpdate {
|
||||
// return -1 to indicate batch mode
|
||||
return -1;
|
||||
} else {
|
||||
SpiUpdate<?> ormUpdate = request.getOrmUpdate();
|
||||
SpiUpdate<?> ormUpdate = request.ormUpdate();
|
||||
if (ormUpdate.getTimeout() > 0) {
|
||||
pstmt.setQueryTimeout(ormUpdate.getTimeout());
|
||||
}
|
||||
@@ -49,7 +49,7 @@ final class ExeOrmUpdate {
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
throw new PersistenceException("Error executing: " + request.getOrmUpdate().getGeneratedSql(), ex);
|
||||
throw new PersistenceException("Error executing: " + request.ormUpdate().getGeneratedSql(), ex);
|
||||
|
||||
} finally {
|
||||
if (!batchThisRequest) {
|
||||
@@ -62,13 +62,13 @@ final class ExeOrmUpdate {
|
||||
* Convert bean and property names to db table and columns.
|
||||
*/
|
||||
private String translate(PersistRequestOrmUpdate request, String sql) {
|
||||
BeanDescriptor<?> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> descriptor = request.descriptor();
|
||||
return descriptor.convertOrmUpdateToSql(sql);
|
||||
}
|
||||
|
||||
private PreparedStatement bindStmt(PersistRequestOrmUpdate request, boolean batchThisRequest) throws SQLException {
|
||||
request.startBind(batchThisRequest);
|
||||
SpiUpdate<?> ormUpdate = request.getOrmUpdate();
|
||||
SpiUpdate<?> ormUpdate = request.ormUpdate();
|
||||
SpiTransaction t = request.transaction();
|
||||
|
||||
String sql = ormUpdate.getUpdateStatement();
|
||||
|
||||
@@ -74,7 +74,7 @@ final class ExeUpdateSql {
|
||||
|
||||
private PreparedStatement bindStmt(PersistRequestUpdateSql request, boolean batchThisRequest) throws SQLException {
|
||||
request.startBind(batchThisRequest);
|
||||
SpiSqlUpdate updateSql = request.getUpdateSql();
|
||||
SpiSqlUpdate updateSql = request.updateSql();
|
||||
SpiTransaction t = request.transaction();
|
||||
|
||||
BindParams bindParams = updateSql.getBindParams();
|
||||
|
||||
@@ -49,7 +49,7 @@ abstract class SaveManyBase implements SaveMany {
|
||||
final void preElementCollectionUpdate() {
|
||||
if (!insertedParent) {
|
||||
request.preElementCollectionUpdate();
|
||||
persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 1);
|
||||
persister.addToFlushQueue(many.deleteByParentId(request.beanId(), null), transaction, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public final class SaveManyBeans extends SaveManyBase {
|
||||
}
|
||||
|
||||
if (!skipSavingThisBean) {
|
||||
persister.saveRecurse(detail, transaction, parentBean, request.getFlags());
|
||||
persister.saveRecurse(detail, transaction, parentBean, request.flags());
|
||||
if (many.hasOrderColumn()) {
|
||||
// Clear the bean from the PersistenceContext (L1 cache), because the order of referenced beans might have changed
|
||||
final BeanDescriptor<?> beanDescriptor = many.getBeanDescriptor();
|
||||
@@ -344,7 +344,7 @@ public final class SaveManyBeans extends SaveManyBase {
|
||||
}
|
||||
if (!(value instanceof BeanCollection<?>)) {
|
||||
if (!insertedParent && cascade && isChangedProperty()) {
|
||||
persister.addToFlushQueue(many.deleteByParentId(request.getBeanId(), null), transaction, 0);
|
||||
persister.addToFlushQueue(many.deleteByParentId(request.beanId(), null), transaction, 0);
|
||||
}
|
||||
} else {
|
||||
BeanCollection<?> c = (BeanCollection<?>) value;
|
||||
@@ -363,7 +363,7 @@ public final class SaveManyBeans extends SaveManyBase {
|
||||
EntityBean eb = (EntityBean) removedBean;
|
||||
if (eb._ebean_intercept().isOrphanDelete()) {
|
||||
// only delete if the bean was loaded meaning that it is known to exist in the DB
|
||||
persister.deleteRequest(persister.createDeleteRemoved(removedBean, transaction, request.getFlags()));
|
||||
persister.deleteRequest(persister.createDeleteRemoved(removedBean, transaction, request.flags()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ final class SaveManyElementCollection extends SaveManyBase {
|
||||
|
||||
private void saveCollection() {
|
||||
SpiSqlUpdate proto = many.insertElementCollection();
|
||||
Object parentId = request.getBeanId();
|
||||
Object parentId = request.beanId();
|
||||
for (Object value : collection) {
|
||||
final SpiSqlUpdate sqlInsert = proto.copy();
|
||||
sqlInsert.setParameter(parentId);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ final class SaveManyElementCollectionMap extends SaveManyBase {
|
||||
|
||||
private void saveCollection() {
|
||||
SpiSqlUpdate proto = many.insertElementCollection();
|
||||
Object parentId = request.getBeanId();
|
||||
Object parentId = request.beanId();
|
||||
for (Map.Entry<?, ?> entry : entries) {
|
||||
final SpiSqlUpdate sqlInsert = proto.copy();
|
||||
sqlInsert.setParameter(parentId);
|
||||
|
||||
@@ -40,13 +40,13 @@ final class DeleteMeta extends BaseMeta {
|
||||
* Bind the request based on the concurrency mode.
|
||||
*/
|
||||
public void bind(PersistRequestBean<?> persist, DmlHandler bind) throws SQLException {
|
||||
EntityBean bean = persist.getEntityBean();
|
||||
EntityBean bean = persist.entityBean();
|
||||
id.dmlBind(bind, bean);
|
||||
if (tenantId != null) {
|
||||
tenantId.dmlBind(bind, bean);
|
||||
}
|
||||
|
||||
if (persist.getConcurrencyMode() == ConcurrencyMode.VERSION) {
|
||||
if (persist.concurrencyMode() == ConcurrencyMode.VERSION) {
|
||||
version.dmlBind(bind, bean);
|
||||
}
|
||||
}
|
||||
@@ -56,11 +56,11 @@ final class DeleteMeta extends BaseMeta {
|
||||
*/
|
||||
public String getSql(PersistRequestBean<?> request) {
|
||||
if (id.isEmpty()) {
|
||||
throw new IllegalStateException("Can not deleteById on " + request.getFullName() + " as no @Id property");
|
||||
throw new IllegalStateException("Can not deleteById on " + request.fullName() + " as no @Id property");
|
||||
}
|
||||
|
||||
boolean publish = request.isPublish();
|
||||
switch (request.getConcurrencyMode()) {
|
||||
switch (request.concurrencyMode()) {
|
||||
case NONE:
|
||||
return publish ? sqlNone : sqlDraftNone;
|
||||
|
||||
@@ -68,7 +68,7 @@ final class DeleteMeta extends BaseMeta {
|
||||
return publish ? sqlVersion : sqlDraftVersion;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Invalid mode " + request.getConcurrencyMode());
|
||||
throw new RuntimeException("Invalid mode " + request.concurrencyMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -19,13 +19,13 @@ final class DocStoreBeanPersister implements BeanPersister {
|
||||
@Override
|
||||
public void insert(PersistRequestBean<?> request) throws PersistenceException {
|
||||
//request.setIdValueForDocStore();
|
||||
generatedProperties.preInsert(request.getEntityBean(), request.now());
|
||||
generatedProperties.preInsert(request.entityBean(), request.now());
|
||||
request.docStorePersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PersistRequestBean<?> request) throws PersistenceException {
|
||||
generatedProperties.preUpdate(request.getEntityBean(), request.now());
|
||||
generatedProperties.preUpdate(request.entityBean(), request.now());
|
||||
request.docStorePersist();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ public final class InsertHandler extends DmlHandler {
|
||||
*/
|
||||
@Override
|
||||
public void bind() throws SQLException {
|
||||
BeanDescriptor<?> desc = persistRequest.getBeanDescriptor();
|
||||
EntityBean bean = persistRequest.getEntityBean();
|
||||
BeanDescriptor<?> desc = persistRequest.descriptor();
|
||||
EntityBean bean = persistRequest.entityBean();
|
||||
Object idValue = desc.getId(bean);
|
||||
boolean withId = !isNullOrZero(idValue);
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ final class UpdateMeta extends BaseMeta {
|
||||
* Bind the request based on the concurrency mode.
|
||||
*/
|
||||
public void bind(PersistRequestBean<?> persist, DmlHandler bind, SpiUpdatePlan updatePlan) throws SQLException {
|
||||
EntityBean bean = persist.getEntityBean();
|
||||
EntityBean bean = persist.entityBean();
|
||||
updatePlan.bindSet(bind, bean);
|
||||
id.dmlBind(bind, bean);
|
||||
if (tenantId != null) {
|
||||
tenantId.dmlBind(bind, bean);
|
||||
}
|
||||
if (persist.getConcurrencyMode() == ConcurrencyMode.VERSION) {
|
||||
if (persist.concurrencyMode() == ConcurrencyMode.VERSION) {
|
||||
version.dmlBind(bind, bean);
|
||||
}
|
||||
}
|
||||
@@ -49,9 +49,9 @@ final class UpdateMeta extends BaseMeta {
|
||||
}
|
||||
|
||||
private SpiUpdatePlan getDynamicUpdatePlan(PersistRequestBean<?> persistRequest) {
|
||||
String key = persistRequest.getUpdatePlanHash();
|
||||
String key = persistRequest.updatePlanHash();
|
||||
// check if we can use a cached UpdatePlan
|
||||
BeanDescriptor<?> beanDescriptor = persistRequest.getBeanDescriptor();
|
||||
BeanDescriptor<?> beanDescriptor = persistRequest.descriptor();
|
||||
SpiUpdatePlan updatePlan = beanDescriptor.getUpdatePlan(key);
|
||||
if (updatePlan != null) {
|
||||
return updatePlan;
|
||||
@@ -64,9 +64,9 @@ final class UpdateMeta extends BaseMeta {
|
||||
set.addToUpdate(persistRequest, list);
|
||||
BindableList bindableList = new BindableList(list);
|
||||
|
||||
ConcurrencyMode mode = persistRequest.getConcurrencyMode();
|
||||
ConcurrencyMode mode = persistRequest.concurrencyMode();
|
||||
// build the SQL for this update statement
|
||||
String sql = genSql(mode, bindableList, persistRequest.getUpdateTable());
|
||||
String sql = genSql(mode, bindableList, persistRequest.updateTable());
|
||||
|
||||
updatePlan = new UpdatePlan(key, mode, sql, bindableList);
|
||||
// add the UpdatePlan to the cache
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ final class BindableIdEmbedded implements BindableId {
|
||||
throw new PersistenceException(m);
|
||||
}
|
||||
|
||||
EntityBean bean = persist.getEntityBean();
|
||||
EntityBean bean = persist.entityBean();
|
||||
|
||||
// create the new id
|
||||
EntityBean newId = (EntityBean) embId.createEmbeddedId();
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public final class BindableOrderColumn extends BindableProperty {
|
||||
|
||||
@Override
|
||||
public void addToUpdate(PersistRequestBean<?> request, List<Bindable> list) {
|
||||
int sortOrder = request.getEntityBeanIntercept().getSortOrder();
|
||||
int sortOrder = request.intercept().getSortOrder();
|
||||
if (sortOrder > 0) {
|
||||
list.add(this);
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public final class BindableUnidirectional implements Bindable {
|
||||
@Override
|
||||
public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
PersistRequestBean<?> persistRequest = request.getPersistRequest();
|
||||
Object parentBean = persistRequest.getParentBean();
|
||||
Object parentBean = persistRequest.parentBean();
|
||||
if (parentBean == null) {
|
||||
Class<?> localType = desc.getBeanType();
|
||||
Class<?> targetType = unidirectional.getTargetType();
|
||||
|
||||
@@ -202,7 +202,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
this.sql = queryPlan.getSql();
|
||||
this.rawSql = queryPlan.isRawSql();
|
||||
this.logWhereSql = queryPlan.getLogWhereSql();
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
if (lazyLoadManyProperty != null) {
|
||||
this.help = NOOP_ADD;
|
||||
@@ -370,7 +370,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
*/
|
||||
@Override
|
||||
public PersistenceContext getPersistenceContext() {
|
||||
return request.getPersistenceContext();
|
||||
return request.persistenceContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -586,19 +586,19 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
@Override
|
||||
public void registerBeanInherit(BeanPropertyAssocOne<?> property, EntityBeanIntercept ebi) {
|
||||
String path = getPath(property.getName());
|
||||
request.getGraphContext().register(path, ebi, property);
|
||||
request.loadContext().register(path, ebi, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(String path, EntityBeanIntercept ebi) {
|
||||
path = getPath(path);
|
||||
request.getGraphContext().register(path, ebi);
|
||||
request.loadContext().register(path, ebi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(BeanPropertyAssocMany<?> many, BeanCollection<?> bc) {
|
||||
String path = getPath(many.getName());
|
||||
request.getGraphContext().register(path, many, bc);
|
||||
request.loadContext().register(path, many, bc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,7 +683,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
||||
|
||||
@Override
|
||||
public void profileBean(EntityBeanIntercept ebi, String prefix) {
|
||||
ObjectGraphNode node = request.getGraphContext().getObjectGraphNode(prefix);
|
||||
ObjectGraphNode node = request.loadContext().getObjectGraphNode(prefix);
|
||||
ebi.setNodeUsageCollector(new NodeUsageCollector(node, profilingListenerRef));
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ final class CQueryBuilder {
|
||||
query.setupForDeleteOrUpdate();
|
||||
|
||||
CQueryPredicates predicates = new CQueryPredicates(binder, request);
|
||||
CQueryPlan queryPlan = request.getQueryPlan();
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
// skip building the SqlTree and Sql string
|
||||
predicates.prepare(false);
|
||||
@@ -130,7 +130,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
// wrap as - delete from table where id in (select id ...)
|
||||
String sql = buildSqlDelete(null, request, predicates, sqlTree).getSql();
|
||||
sql = request.getBeanDescriptor().getDeleteByIdInSql() + "in (" + sql + ")";
|
||||
sql = request.descriptor().getDeleteByIdInSql() + "in (" + sql + ")";
|
||||
sql = aliasReplace(sql, alias);
|
||||
return sql;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ final class CQueryBuilder {
|
||||
|
||||
private <T> String buildUpdateSql(OrmQueryRequest<T> request, String rootTableAlias, CQueryPredicates predicates, SqlTree sqlTree) {
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("update ").append(request.getBeanDescriptor().getBaseTable());
|
||||
sb.append("update ").append(request.descriptor().getBaseTable());
|
||||
if (rootTableAlias != null) {
|
||||
sb.append(" ").append(rootTableAlias);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
// wrap as - update table set ... where id in (select id ...)
|
||||
String sql = buildSqlUpdate(null, request, predicates, sqlTree).getSql();
|
||||
sql = updateClause + " " + request.getBeanDescriptor().getWhereIdInSql() + "in (" + sql + ")";
|
||||
sql = updateClause + " " + request.descriptor().getWhereIdInSql() + "in (" + sql + ")";
|
||||
sql = aliasReplace(sql, alias(rootTableAlias));
|
||||
return sql;
|
||||
}
|
||||
@@ -180,14 +180,14 @@ final class CQueryBuilder {
|
||||
SpiQuery<?> query = request.query();
|
||||
query.setSingleAttribute();
|
||||
if (!query.isIncludeSoftDeletes()) {
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
if (desc.isSoftDelete()) {
|
||||
query.addSoftDeletePredicate(desc.getSoftDeletePredicate(alias(query.getAlias())));
|
||||
}
|
||||
}
|
||||
|
||||
CQueryPredicates predicates = new CQueryPredicates(binder, request);
|
||||
CQueryPlan queryPlan = request.getQueryPlan();
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
predicates.prepare(false);
|
||||
return new CQueryFetchSingleAttribute(request, predicates, queryPlan, query.isCountDistinct());
|
||||
@@ -210,7 +210,7 @@ final class CQueryBuilder {
|
||||
<T> CQueryFetchSingleAttribute buildFetchIdsQuery(OrmQueryRequest<T> request) {
|
||||
SpiQuery<T> query = request.query();
|
||||
query.setSelectId();
|
||||
BeanDescriptor<T> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<T> desc = request.descriptor();
|
||||
if (!query.isIncludeSoftDeletes() && desc.isSoftDelete()) {
|
||||
query.addSoftDeletePredicate(desc.getSoftDeletePredicate(alias(query.getAlias())));
|
||||
}
|
||||
@@ -252,7 +252,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
|
||||
CQueryPredicates predicates = new CQueryPredicates(binder, request);
|
||||
CQueryPlan queryPlan = request.getQueryPlan();
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
// skip building the SqlTree and Sql string
|
||||
predicates.prepare(false);
|
||||
@@ -304,7 +304,7 @@ final class CQueryBuilder {
|
||||
* Return true if the query includes an aggregation property.
|
||||
*/
|
||||
private <T> boolean includesAggregation(OrmQueryRequest<T> request, SpiQuery<T> query) {
|
||||
return request.getBeanDescriptor().includesAggregation(query.getDetail());
|
||||
return request.descriptor().includesAggregation(query.getDetail());
|
||||
}
|
||||
|
||||
private String wrapSelectCount(String sql) {
|
||||
@@ -321,7 +321,7 @@ final class CQueryBuilder {
|
||||
*/
|
||||
<T> CQuery<T> buildQuery(OrmQueryRequest<T> request) {
|
||||
CQueryPredicates predicates = new CQueryPredicates(binder, request);
|
||||
CQueryPlan queryPlan = request.getQueryPlan();
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
// Reuse the query plan so skip generating SqlTree and SQL.
|
||||
// We do prepare and bind the new parameters
|
||||
@@ -358,7 +358,7 @@ final class CQueryBuilder {
|
||||
queryPlan = new CQueryPlan(request, res, sqlTree, false, predicates.getLogWhereSql());
|
||||
}
|
||||
|
||||
BeanDescriptor<T> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<T> desc = request.descriptor();
|
||||
if (desc.isReadAuditing()) {
|
||||
// log the query plan based bean type (i.e. ignoring query disabling for logging the sql/plan)
|
||||
desc.getReadAuditLogger().queryPlan(new ReadAuditQueryPlan(desc.getFullName(), queryPlan.getAuditQueryKey(), queryPlan.getSql()));
|
||||
@@ -411,7 +411,7 @@ final class CQueryBuilder {
|
||||
|
||||
Connection connection = request.transaction().getConnection();
|
||||
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
try {
|
||||
// For SqlServer we need either "selectMethod=cursor" in the connection string or fetch explicitly a cursorable
|
||||
// statement here by specifying ResultSet.CONCUR_UPDATABLE
|
||||
@@ -445,7 +445,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
|
||||
private SqlTree createRawSqlSqlTree(OrmQueryRequest<?> request, CQueryPredicates predicates) {
|
||||
BeanDescriptor<?> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> descriptor = request.descriptor();
|
||||
ColumnMapping columnMapping = request.query().getRawSql().getColumnMapping();
|
||||
PathProperties pathProps = new PathProperties();
|
||||
|
||||
@@ -583,7 +583,7 @@ final class CQueryBuilder {
|
||||
sb.append("r1.attribute_, count(*) from (select ");
|
||||
if (distinct) {
|
||||
sb.append("distinct t0.");
|
||||
sb.append(request.getBeanDescriptor().getIdProperty().getDbColumn()).append(", ");
|
||||
sb.append(request.descriptor().getIdProperty().getDbColumn()).append(", ");
|
||||
}
|
||||
sb.append(select.getSelectSql()).append(" as attribute_");
|
||||
} else {
|
||||
@@ -652,7 +652,7 @@ final class CQueryBuilder {
|
||||
private void appendHistoryAsOfPredicate() {
|
||||
if (query.isAsOfBaseTable() && !historySupport.isStandardsBased()) {
|
||||
appendAndOrWhere();
|
||||
sb.append(historySupport.getAsOfPredicate(request.getBaseTableAlias()));
|
||||
sb.append(historySupport.getAsOfPredicate(request.baseTableAlias()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ final class CQueryBuilder {
|
||||
if (request.isFindById() || query.getId() != null) {
|
||||
appendAndOrWhere();
|
||||
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
String idSql = desc.getIdBinderIdSql(query.getAlias());
|
||||
if (idSql.isEmpty()) {
|
||||
throw new IllegalStateException("Executing FindById query on entity bean " + desc.getName()
|
||||
|
||||
@@ -82,7 +82,7 @@ final class CQueryBuilderRawSql {
|
||||
// assumption that id has its proper dbColumn assigned
|
||||
// which may change if using multiple raw sql statements
|
||||
// against the same bean.
|
||||
BeanDescriptor<?> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> descriptor = request.descriptor();
|
||||
//FIXME: I think this is broken... needs to be logical
|
||||
// and then parsed for RawSqlSelect...
|
||||
dynamicWhere = descriptor.getIdBinderIdSql(null);
|
||||
|
||||
@@ -198,7 +198,7 @@ public final class CQueryEngine {
|
||||
logSql(cquery);
|
||||
}
|
||||
// first check batch sizes set on query joins
|
||||
int iterateBufferSize = request.getSecondaryQueriesMinBatchSize();
|
||||
int iterateBufferSize = request.secondaryQueriesMinBatchSize();
|
||||
if (iterateBufferSize < 1) {
|
||||
// not set on query joins so check if batch size set on query itself
|
||||
int queryBatch = request.query().getLazyLoadBatchSize();
|
||||
@@ -274,7 +274,7 @@ public final class CQueryEngine {
|
||||
}
|
||||
|
||||
private <T> void deriveVersionDiffs(List<Version<T>> versions, OrmQueryRequest<T> request) {
|
||||
BeanDescriptor<T> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<T> descriptor = request.descriptor();
|
||||
if (!versions.isEmpty()) {
|
||||
Version<T> current = versions.get(0);
|
||||
if (versions.size() > 1) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
||||
this.queryPlan = queryPlan;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
this.containsCounts = containsCounts;
|
||||
this.reader = queryPlan.getSingleAttributeScalarType();
|
||||
|
||||
@@ -87,13 +87,13 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
CQueryPlan(OrmQueryRequest<?> request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) {
|
||||
this.server = request.server();
|
||||
this.dataTimeZone = server.getDataTimeZone();
|
||||
this.beanType = request.getBeanDescriptor().getBeanType();
|
||||
this.planKey = request.getQueryPlanKey();
|
||||
this.beanType = request.descriptor().getBeanType();
|
||||
this.planKey = request.queryPlanKey();
|
||||
SpiQuery<?> query = request.query();
|
||||
this.profileLocation = query.getProfileLocation();
|
||||
this.location = (profileLocation == null) ? null : profileLocation.location();
|
||||
this.label = query.getPlanLabel();
|
||||
this.name = deriveName(label, query.getType(), request.getBeanDescriptor().getSimpleName());
|
||||
this.name = deriveName(label, query.getType(), request.descriptor().getSimpleName());
|
||||
this.asOfTableCount = query.getAsOfTableCount();
|
||||
this.sql = sqlRes.getSql();
|
||||
this.sqlTree = sqlTree;
|
||||
@@ -112,12 +112,12 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
CQueryPlan(OrmQueryRequest<?> request, String sql, SqlTree sqlTree, String logWhereSql) {
|
||||
this.server = request.server();
|
||||
this.dataTimeZone = server.getDataTimeZone();
|
||||
this.beanType = request.getBeanDescriptor().getBeanType();
|
||||
this.beanType = request.descriptor().getBeanType();
|
||||
SpiQuery<?> query = request.query();
|
||||
this.profileLocation = query.getProfileLocation();
|
||||
this.location = (profileLocation == null) ? null : profileLocation.location();
|
||||
this.label = query.getPlanLabel();
|
||||
this.name = deriveName(label, query.getType(), request.getBeanDescriptor().getSimpleName());
|
||||
this.name = deriveName(label, query.getType(), request.descriptor().getSimpleName());
|
||||
this.planKey = buildPlanKey(sql, logWhereSql);
|
||||
this.asOfTableCount = 0;
|
||||
this.sql = sql;
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class CQueryPredicates {
|
||||
dataBind.append(", ");
|
||||
}
|
||||
|
||||
CQueryPlan queryPlan = request.getQueryPlan();
|
||||
CQueryPlan queryPlan = request.queryPlan();
|
||||
if (queryPlan != null) {
|
||||
int asOfTableCount = queryPlan.getAsOfTableCount();
|
||||
if (asOfTableCount > 0) {
|
||||
@@ -132,7 +132,7 @@ public final class CQueryPredicates {
|
||||
|
||||
if (idValue != null) {
|
||||
// this is a find by id type query...
|
||||
request.getBeanDescriptor().bindId(dataBind, idValue);
|
||||
request.descriptor().bindId(dataBind, idValue);
|
||||
dataBind.append(idValue);
|
||||
dataBind.append(", ");
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public final class CQueryPredicates {
|
||||
private void parsePropertiesToDbColumns(DeployParser deployParser) {
|
||||
|
||||
// order by is dependent on the manyProperty (if there is one)
|
||||
String logicalOrderBy = deriveOrderByWithMany(request.getManyProperty());
|
||||
String logicalOrderBy = deriveOrderByWithMany(request.manyProperty());
|
||||
if (logicalOrderBy != null) {
|
||||
dbOrderBy = deployParser.parse(logicalOrderBy);
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public final class CQueryPredicates {
|
||||
if (orderBy == null) {
|
||||
return null;
|
||||
}
|
||||
return CQueryOrderBy.parse(request.getBeanDescriptor(), orderBy);
|
||||
return CQueryOrderBy.parse(request.descriptor(), orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +327,7 @@ public final class CQueryPredicates {
|
||||
|
||||
String orderBy = parseOrderBy();
|
||||
|
||||
BeanDescriptor<?> desc = request.getBeanDescriptor();
|
||||
BeanDescriptor<?> desc = request.descriptor();
|
||||
String orderById = desc.getDefaultOrderBy();
|
||||
|
||||
if (orderBy == null) {
|
||||
|
||||
@@ -43,7 +43,7 @@ final class CQueryRowCount implements SpiProfileTransactionEvent, CancelableQuer
|
||||
this.request = request;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
query.setGeneratedSql(sql);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ final class CQueryUpdate implements SpiProfileTransactionEvent, CancelableQuery
|
||||
this.queryPlan = queryPlan;
|
||||
this.query = request.query();
|
||||
this.sql = queryPlan.getSql();
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.predicates = predicates;
|
||||
query.setGeneratedSql(sql);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
|
||||
flushJdbcBatchOnQuery(request);
|
||||
|
||||
BeanFindController finder = request.getBeanFinder();
|
||||
BeanFindController finder = request.finder();
|
||||
|
||||
BeanCollection<T> result;
|
||||
if (finder != null && finder.isInterceptFindMany(request)) {
|
||||
@@ -135,7 +135,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
|
||||
if (result != null && request.isBeanCachePutMany()) {
|
||||
// load the individual beans into the bean cache
|
||||
BeanDescriptor<T> descriptor = request.getBeanDescriptor();
|
||||
BeanDescriptor<T> descriptor = request.descriptor();
|
||||
Collection<T> c = result.getActualDetails();
|
||||
descriptor.cacheBeanPutAll(c);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
|
||||
flushJdbcBatchOnQuery(request);
|
||||
|
||||
BeanFindController finder = request.getBeanFinder();
|
||||
BeanFindController finder = request.finder();
|
||||
|
||||
T result;
|
||||
if (finder != null && finder.isInterceptFind(request)) {
|
||||
@@ -172,7 +172,7 @@ public final class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
}
|
||||
|
||||
if (result != null && request.isBeanCachePut()) {
|
||||
request.getBeanDescriptor().cacheBeanPut((EntityBean) result);
|
||||
request.descriptor().cacheBeanPut((EntityBean) result);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class SqlTreeBuilder {
|
||||
*/
|
||||
SqlTreeBuilder(OrmQueryRequest<?> request, CQueryPredicates predicates, OrmQueryDetail queryDetail, boolean rawNoId) {
|
||||
this.rawSql = true;
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.rawNoId = rawNoId;
|
||||
this.disableLazyLoad = request.query().isDisableLazyLoading();
|
||||
this.query = null;
|
||||
@@ -82,7 +82,7 @@ public final class SqlTreeBuilder {
|
||||
SqlTreeBuilder(String columnAliasPrefix, CQueryBuilder builder, OrmQueryRequest<?> request, CQueryPredicates predicates) {
|
||||
this.rawSql = false;
|
||||
this.rawNoId = false;
|
||||
this.desc = request.getBeanDescriptor();
|
||||
this.desc = request.descriptor();
|
||||
this.query = request.query();
|
||||
this.temporalMode = SpiQuery.TemporalMode.of(query);
|
||||
this.disableLazyLoad = query.isDisableLazyLoading();
|
||||
@@ -95,7 +95,7 @@ public final class SqlTreeBuilder {
|
||||
this.manyWhereJoins = query.getManyWhereJoins();
|
||||
this.queryDetail = query.getDetail();
|
||||
this.predicates = predicates;
|
||||
this.alias = new SqlTreeAlias(request.getBaseTableAlias(), temporalMode);
|
||||
this.alias = new SqlTreeAlias(request.baseTableAlias(), temporalMode);
|
||||
this.distinctOnPlatform = builder.isPlatformDistinctOn();
|
||||
String fromForUpdate = builder.fromForUpdate(query);
|
||||
CQueryHistorySupport historySupport = builder.getHistorySupport(query);
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public class DocStoreEmbeddedInvalidation {
|
||||
}
|
||||
|
||||
public void embeddedInvalidate(PersistRequestBean<?> request, DocStoreUpdates docStoreUpdates) {
|
||||
docStoreUpdates.addNested(queueId, path, request.getBeanId());
|
||||
docStoreUpdates.addNested(queueId, path, request.beanId());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public final class DocStoreEmbeddedInvalidationProperties extends DocStoreEmbedd
|
||||
@Override
|
||||
public void embeddedInvalidate(PersistRequestBean<?> request, DocStoreUpdates docStoreUpdates) {
|
||||
if (request.hasDirtyProperty(properties)) {
|
||||
docStoreUpdates.addNested(queueId, path, request.getBeanId());
|
||||
docStoreUpdates.addNested(queueId, path, request.beanId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user