mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge branch 'master' of github.com:ebean-orm/ebean
This commit is contained in:
@@ -12,7 +12,7 @@ public interface EncryptKeyManager {
|
||||
* This gives the EncryptKeyManager the opportunity to get keys etc.
|
||||
* </p>
|
||||
*/
|
||||
default void initialise() {};
|
||||
default void initialise() {}
|
||||
|
||||
/**
|
||||
* Return the key used to encrypt and decrypt a property mapping to the given
|
||||
|
||||
@@ -16,5 +16,5 @@ public interface TenantDataSourceProvider {
|
||||
/**
|
||||
* Shutdown all the DataSources.
|
||||
*/
|
||||
default void shutdown(boolean deregisterDriver) {};
|
||||
default void shutdown(boolean deregisterDriver) {}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class DatabasePlatform {
|
||||
* Return true if this matches the given platform.
|
||||
*/
|
||||
public boolean isPlatform(Platform platform) {
|
||||
return this.platform.equals(platform);
|
||||
return this.platform == platform;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,6 +52,8 @@ public class MigrationVersion implements Comparable<MigrationVersion> {
|
||||
* Return true if this is a "repeatable" version.
|
||||
*/
|
||||
public boolean isRepeatable() {
|
||||
// Clarification: The comparison here is intended to compare object references and not the content of the arrays.
|
||||
// This is a kind of shortcut to see if some configuration is in place that results in the use of something other than the default.
|
||||
return ordering == REPEAT_ORDERING;
|
||||
}
|
||||
|
||||
@@ -110,6 +112,8 @@ public class MigrationVersion implements Comparable<MigrationVersion> {
|
||||
*/
|
||||
private String formattedVersion(boolean normalised, boolean nextVersion) {
|
||||
|
||||
// Clarification: The comparison here is intended to compare object references and not the content of the arrays.
|
||||
// This is a kind of shortcut to see if some configuration is in place that results in the use of something other than the default.
|
||||
if (ordering == REPEAT_ORDERING) {
|
||||
return "R";
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class DefaultBeanLoader {
|
||||
if (desc.lazyLoadMany(ebi)) {
|
||||
return;
|
||||
}
|
||||
if (!draft && SpiQuery.Mode.LAZYLOAD_BEAN.equals(mode) && desc.isBeanCaching()) {
|
||||
if (!draft && Mode.LAZYLOAD_BEAN == mode && desc.isBeanCaching()) {
|
||||
// lazy loading and the bean cache is active
|
||||
if (desc.cacheBeanLoad(bean, ebi, id, pc)) {
|
||||
return;
|
||||
@@ -292,7 +292,7 @@ public class DefaultBeanLoader {
|
||||
query.setMode(mode);
|
||||
query.setId(id);
|
||||
|
||||
if (embeddedOwnerIndex > -1 || mode.equals(SpiQuery.Mode.REFRESH_BEAN)) {
|
||||
if (embeddedOwnerIndex > -1 || mode == Mode.REFRESH_BEAN) {
|
||||
// make sure the query doesn't use the cache
|
||||
query.setUseCache(false);
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class DefaultBeanLoader {
|
||||
query.setReadOnly(true);
|
||||
}
|
||||
|
||||
if (SpiQuery.Mode.REFRESH_BEAN.equals(mode)) {
|
||||
if (Mode.REFRESH_BEAN == mode) {
|
||||
// explicitly state to load all properties on REFRESH.
|
||||
// Lobs default to fetch lazy so this forces lobs to be
|
||||
// included in a 'refresh' query
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DefaultContainer implements SpiContainer {
|
||||
serverConfig.setDatabasePlatform(new H2Platform());
|
||||
} else {
|
||||
TenantMode tenantMode = serverConfig.getTenantMode();
|
||||
if (!TenantMode.DB.equals(tenantMode)) {
|
||||
if (TenantMode.DB != tenantMode) {
|
||||
setDataSource(serverConfig);
|
||||
if (!tenantMode.isDynamicDataSource()) {
|
||||
// check the autoCommit and Transaction Isolation
|
||||
|
||||
@@ -402,7 +402,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Start any services after registering with the ClusterManager.
|
||||
*/
|
||||
public void start() {
|
||||
if (!TenantMode.DB.equals(serverConfig.getTenantMode())) {
|
||||
if (TenantMode.DB != serverConfig.getTenantMode()) {
|
||||
serverConfig.runDbMigration(serverConfig.getDataSource());
|
||||
}
|
||||
}
|
||||
@@ -1162,7 +1162,7 @@ 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.equals(getPersistenceContextScope(query));
|
||||
return PersistenceContextScope.TRANSACTION == getPersistenceContextScope(query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1179,7 +1179,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
SpiQuery<T> spiQuery = (SpiQuery<T>) query;
|
||||
spiQuery.setType(Type.BEAN);
|
||||
if (SpiQuery.Mode.NORMAL.equals(spiQuery.getMode()) && !spiQuery.isLoadBeanCache()) {
|
||||
if (SpiQuery.Mode.NORMAL == spiQuery.getMode() && !spiQuery.isLoadBeanCache()) {
|
||||
// See if we can skip doing the fetch completely by getting the bean from the
|
||||
// persistence context or the bean cache
|
||||
T bean = findIdCheckPersistenceContextAndCache(t, spiQuery, spiQuery.getId());
|
||||
|
||||
@@ -39,10 +39,10 @@ public class BeanCollectionHelpFactory {
|
||||
|
||||
SpiQuery.Type manyType = request.getQuery().getType();
|
||||
|
||||
if (manyType.equals(SpiQuery.Type.LIST)) {
|
||||
if (manyType == SpiQuery.Type.LIST) {
|
||||
return LIST_HELP;
|
||||
|
||||
} else if (manyType.equals(SpiQuery.Type.SET)) {
|
||||
} else if (manyType == SpiQuery.Type.SET) {
|
||||
return SET_HELP;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -2325,7 +2325,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
* Return the property path given the db table and column.
|
||||
*/
|
||||
public String findBeanPath(String tableName, String columnName) {
|
||||
if (tableName.length() == 0 || tableName.equalsIgnoreCase(baseTable)) {
|
||||
if (tableName.isEmpty() || tableName.equalsIgnoreCase(baseTable)) {
|
||||
return columnPath.get(columnName);
|
||||
}
|
||||
BeanPropertyAssoc<?> assocProperty = tablePath.get(tableName);
|
||||
|
||||
@@ -1287,12 +1287,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IdType.SEQUENCE.equals(desc.getIdType()) && !dbIdentity.isSupportsSequence()) {
|
||||
if (IdType.SEQUENCE == desc.getIdType() && !dbIdentity.isSupportsSequence()) {
|
||||
// explicit sequence but not supported by the DatabasePlatform
|
||||
logger.info("Explicit sequence on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
||||
desc.setIdType(null);
|
||||
}
|
||||
if (IdType.IDENTITY.equals(desc.getIdType()) && !dbIdentity.isSupportsIdentity()) {
|
||||
if (IdType.IDENTITY == desc.getIdType() && !dbIdentity.isSupportsIdentity()) {
|
||||
// explicit identity but not supported by the DatabasePlatform
|
||||
logger.info("Explicit Identity on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
||||
desc.setIdType(null);
|
||||
@@ -1316,7 +1316,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IdType.IDENTITY.equals(desc.getIdType())) {
|
||||
if (IdType.IDENTITY == desc.getIdType()) {
|
||||
// used when getGeneratedKeys is not supported (SQL Server 2000)
|
||||
String selectLastInsertedId = dbIdentity.getSelectLastInsertedId(desc.getBaseTable());
|
||||
desc.setSelectLastInsertedId(selectLastInsertedId);
|
||||
|
||||
@@ -327,16 +327,16 @@ public class DeployBeanDescriptor<T> {
|
||||
}
|
||||
|
||||
public boolean isEmbedded() {
|
||||
return EntityType.EMBEDDED.equals(entityType);
|
||||
return EntityType.EMBEDDED == entityType;
|
||||
}
|
||||
|
||||
public boolean isBaseTableType() {
|
||||
EntityType et = getEntityType();
|
||||
return EntityType.ORM.equals(et);
|
||||
return EntityType.ORM == et;
|
||||
}
|
||||
|
||||
public boolean isDocStoreOnly() {
|
||||
return EntityType.DOC.equals(entityType);
|
||||
return EntityType.DOC == entityType;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
|
||||
@@ -581,7 +581,7 @@ public class DeployBeanProperty {
|
||||
* Set the default fetch type for this property.
|
||||
*/
|
||||
public void setFetchType(FetchType fetchType) {
|
||||
this.fetchEager = FetchType.EAGER.equals(fetchType);
|
||||
this.fetchEager = FetchType.EAGER == fetchType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -424,7 +424,7 @@ public class DeployBeanPropertyLists {
|
||||
switch (mode) {
|
||||
case Save:
|
||||
if (prop.getCascadeInfo().isSave() || prop.isManyToMany()
|
||||
|| ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
|| ModifyListenMode.REMOVALS == prop.getModifyListenMode()) {
|
||||
// Note ManyToMany always included as we always 'save'
|
||||
// the relationship via insert/delete of intersection table
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
@@ -432,7 +432,7 @@ public class DeployBeanPropertyLists {
|
||||
}
|
||||
break;
|
||||
case Delete:
|
||||
if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) {
|
||||
if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS == prop.getModifyListenMode()) {
|
||||
// REMOVALS means including PrivateOwned relationships
|
||||
list.add(prop);
|
||||
}
|
||||
|
||||
@@ -369,12 +369,12 @@ public class AnnotationFields extends AnnotationParser {
|
||||
if (!prop.isTransient()) {
|
||||
|
||||
EncryptDeploy encryptDeploy = util.getEncryptDeploy(info.getDescriptor().getBaseTableFull(), prop.getDbColumn());
|
||||
if (encryptDeploy == null || encryptDeploy.getMode().equals(Mode.MODE_ANNOTATION)) {
|
||||
if (encryptDeploy == null || encryptDeploy.getMode() == Mode.MODE_ANNOTATION) {
|
||||
Encrypted encrypted = get(prop, Encrypted.class);
|
||||
if (encrypted != null) {
|
||||
setEncryption(prop, encrypted.dbEncryption(), encrypted.dbLength());
|
||||
}
|
||||
} else if (Mode.MODE_ENCRYPT.equals(encryptDeploy.getMode())) {
|
||||
} else if (Mode.MODE_ENCRYPT == encryptDeploy.getMode()) {
|
||||
setEncryption(prop, encryptDeploy.isDbEncrypt(), encryptDeploy.getDbLength());
|
||||
}
|
||||
}
|
||||
@@ -570,13 +570,13 @@ public class AnnotationFields extends AnnotationParser {
|
||||
private void readTemporal(Temporal temporal, DeployBeanProperty prop) {
|
||||
|
||||
TemporalType type = temporal.value();
|
||||
if (type.equals(TemporalType.DATE)) {
|
||||
if (type == TemporalType.DATE) {
|
||||
prop.setDbType(Types.DATE);
|
||||
|
||||
} else if (type.equals(TemporalType.TIMESTAMP)) {
|
||||
} else if (type == TemporalType.TIMESTAMP) {
|
||||
prop.setDbType(Types.TIMESTAMP);
|
||||
|
||||
} else if (type.equals(TemporalType.TIME)) {
|
||||
} else if (type == TemporalType.TIME) {
|
||||
prop.setDbType(Types.TIME);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -138,7 +138,7 @@ public class DeployInheritInfo {
|
||||
* Set the sql type of the discriminator.
|
||||
*/
|
||||
public void setColumnType(DiscriminatorType type) {
|
||||
if (type.equals(DiscriminatorType.INTEGER)) {
|
||||
if (type == DiscriminatorType.INTEGER) {
|
||||
this.columnType = Types.INTEGER;
|
||||
} else {
|
||||
this.columnType = Types.VARCHAR;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class IdInExpression extends NonPrepareExpression {
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanDescriptor<?> descriptor = r.getBeanDescriptor();
|
||||
IdBinder idBinder = descriptor.getIdBinder();
|
||||
if (idCollection.size() == 0) {
|
||||
if (idCollection.isEmpty()) {
|
||||
request.append("1=0"); // append false for this stage
|
||||
} else {
|
||||
request.append(descriptor.getIdBinder().getBindIdInSql(null));
|
||||
@@ -83,7 +83,7 @@ public class IdInExpression extends NonPrepareExpression {
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanDescriptor<?> descriptor = r.getBeanDescriptor();
|
||||
IdBinder idBinder = descriptor.getIdBinder();
|
||||
if (idCollection.size() == 0) {
|
||||
if (idCollection.isEmpty()) {
|
||||
request.append("1=0"); // append false for this stage
|
||||
} else {
|
||||
request.append(descriptor.getIdBinderInLHSSql());
|
||||
|
||||
@@ -50,7 +50,7 @@ class LikeExpression extends AbstractValueExpression {
|
||||
} else {
|
||||
request.append(pname);
|
||||
}
|
||||
if (type.equals(LikeType.EQUAL_TO)) {
|
||||
if (type == LikeType.EQUAL_TO) {
|
||||
request.append(" = ? ");
|
||||
} else {
|
||||
// append db platform like clause
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SimpleExpression extends AbstractValueExpression {
|
||||
}
|
||||
|
||||
public boolean isOpEquals() {
|
||||
return Op.EQ.equals(type);
|
||||
return Op.EQ == type;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.sql.SQLException;
|
||||
*/
|
||||
public class BatchedSqlException extends Exception {
|
||||
private static final long serialVersionUID = -4374631080253580648L;
|
||||
|
||||
private SQLException cause;
|
||||
|
||||
private final SQLException cause;
|
||||
|
||||
BatchedSqlException(String message, SQLException cause) {
|
||||
super(message, cause);
|
||||
|
||||
@@ -858,7 +858,7 @@ public final class DefaultPersister implements Persister {
|
||||
}
|
||||
|
||||
private boolean isModifyListenMode() {
|
||||
return ModifyListenMode.REMOVALS.equals(many.getModifyListenMode());
|
||||
return ModifyListenMode.REMOVALS == many.getModifyListenMode();
|
||||
}
|
||||
|
||||
private boolean isDeleteMissingChildren() {
|
||||
@@ -988,7 +988,7 @@ public final class DefaultPersister implements Persister {
|
||||
}
|
||||
|
||||
SpiTransaction t = saveMany.getTransaction();
|
||||
boolean isMap = ManyType.MAP.equals(prop.getManyType());
|
||||
boolean isMap = ManyType.MAP == prop.getManyType();
|
||||
EntityBean parentBean = saveMany.getParentBean();
|
||||
|
||||
if (deleteMissingChildren) {
|
||||
@@ -1229,7 +1229,7 @@ public final class DefaultPersister implements Persister {
|
||||
}
|
||||
} else {
|
||||
|
||||
if (ModifyListenMode.REMOVALS.equals(many.getModifyListenMode())) {
|
||||
if (ModifyListenMode.REMOVALS == many.getModifyListenMode()) {
|
||||
// PrivateOwned ...
|
||||
// if soft delete then check target also supports soft delete
|
||||
if (!softDelete || many.getTargetDescriptor().isSoftDelete()) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public final class DeleteMeta {
|
||||
tenantId.dmlAppend(request);
|
||||
}
|
||||
|
||||
if (ConcurrencyMode.VERSION.equals(conMode)) {
|
||||
if (ConcurrencyMode.VERSION == conMode) {
|
||||
if (version != null) {
|
||||
version.dmlAppend(request);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public final class UpdateMeta {
|
||||
if (tenantId != null) {
|
||||
tenantId.dmlAppend(request);
|
||||
}
|
||||
if (ConcurrencyMode.VERSION.equals(conMode)) {
|
||||
if (ConcurrencyMode.VERSION == conMode) {
|
||||
if (version != null) {
|
||||
version.dmlAppend(request);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class FactoryProperty {
|
||||
*/
|
||||
public Bindable create(BeanProperty prop, DmlMode mode, boolean withLobs) {
|
||||
|
||||
if (DmlMode.INSERT.equals(mode) && !prop.isDbInsertable()) {
|
||||
if (DmlMode.INSERT == mode && !prop.isDbInsertable()) {
|
||||
return null;
|
||||
}
|
||||
if (DmlMode.UPDATE.equals(mode) && !prop.isDbUpdatable()) {
|
||||
if (DmlMode.UPDATE == mode && !prop.isDbUpdatable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ public class SqlBeanLoad {
|
||||
this.ctx = ctx;
|
||||
this.rawSql = ctx.isRawSql();
|
||||
this.type = type;
|
||||
this.lazyLoading = queryMode.equals(Mode.LAZYLOAD_BEAN);
|
||||
this.refreshLoading = queryMode.equals(Mode.REFRESH_BEAN);
|
||||
this.lazyLoading = queryMode == Mode.LAZYLOAD_BEAN;
|
||||
this.refreshLoading = queryMode == Mode.REFRESH_BEAN;
|
||||
this.bean = bean;
|
||||
this.ebi = bean == null ? null : bean._ebean_getIntercept();
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public final class SqlTreeBuilder {
|
||||
this.query = request.getQuery();
|
||||
this.temporalMode = SpiQuery.TemporalMode.of(query);
|
||||
this.disableLazyLoad = query.isDisableLazyLoading();
|
||||
this.subQuery = Type.SUBQUERY.equals(query.getType()) || Type.ID_LIST.equals(query.getType());
|
||||
this.subQuery = Type.SUBQUERY == query.getType() || Type.ID_LIST == query.getType();
|
||||
this.includeJoin = query.getM2mIncludeJoin();
|
||||
this.manyWhereJoins = query.getManyWhereJoins();
|
||||
this.queryDetail = query.getDetail();
|
||||
|
||||
@@ -308,7 +308,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
}
|
||||
|
||||
boolean lazyLoadMany = false;
|
||||
if (localBean == null && queryMode.equals(Mode.LAZYLOAD_MANY)) {
|
||||
if (localBean == null && queryMode == Mode.LAZYLOAD_MANY) {
|
||||
// batch lazy load many into existing contextBean
|
||||
localBean = contextBean;
|
||||
lazyLoadMany = true;
|
||||
@@ -321,7 +321,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
aChildren.load(ctx, localBean, contextBean);
|
||||
}
|
||||
|
||||
if (queryMode.equals(Mode.LAZYLOAD_MANY) && isRoot()) {
|
||||
if (queryMode == Mode.LAZYLOAD_MANY && isRoot()) {
|
||||
return contextBean;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
|
||||
EntityBeanIntercept ebi = localBean._ebean_getIntercept();
|
||||
ebi.setPersistenceContext(persistenceContext);
|
||||
if (Mode.LAZYLOAD_BEAN.equals(queryMode)) {
|
||||
if (Mode.LAZYLOAD_BEAN == queryMode) {
|
||||
// Lazy Load does not reset the dirty state
|
||||
ebi.setLoadedLazy();
|
||||
} else if (readId) {
|
||||
|
||||
@@ -528,7 +528,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
private boolean isAllowOneManyFetch() {
|
||||
|
||||
if (Mode.LAZYLOAD_MANY.equals(getMode())) {
|
||||
if (Mode.LAZYLOAD_MANY == getMode()) {
|
||||
return false;
|
||||
} else if (hasMaxRowsOrFirstRow() && !isRawSql()) {
|
||||
return false;
|
||||
|
||||
@@ -184,17 +184,20 @@ public class BindParamsParser {
|
||||
* Find the next named parameter start position (based on colon).
|
||||
*/
|
||||
static int findNameStart(String sql, int startPos) {
|
||||
int colonPos = sql.indexOf(colon, startPos);
|
||||
if (colonPos > -1) {
|
||||
// validate the next character after the colon (ignore postgres cast)
|
||||
char c = sql.charAt(colonPos + 1);
|
||||
if (c == '_' || Character.isLetterOrDigit(c)) {
|
||||
return colonPos;
|
||||
} else {
|
||||
return findNameStart(sql, colonPos + 2);
|
||||
while (true) {
|
||||
int colonPos = sql.indexOf(colon, startPos);
|
||||
if (colonPos > -1) {
|
||||
// validate the next character after the colon (ignore postgres cast)
|
||||
char c = sql.charAt(colonPos + 1);
|
||||
if (c == '_' || Character.isLetterOrDigit(c)) {
|
||||
return colonPos;
|
||||
} else {
|
||||
startPos = colonPos + 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ParamTypeHelper {
|
||||
}
|
||||
|
||||
public boolean isManyType() {
|
||||
return !ManyType.NONE.equals(manyType);
|
||||
return ManyType.NONE != manyType;
|
||||
}
|
||||
|
||||
public ManyType getManyType() {
|
||||
@@ -66,7 +66,7 @@ public class ParamTypeHelper {
|
||||
Type rawType = paramType.getRawType();
|
||||
|
||||
ManyType manyType = getManyType(rawType);
|
||||
if (ManyType.NONE.equals(manyType)) {
|
||||
if (ManyType.NONE == manyType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user