Merge branch 'master' of github.com:ebean-orm/ebean

This commit is contained in:
rob bygrave
2018-11-13 17:52:09 +13:00
50 changed files with 67 additions and 53 deletions
-4
View File
@@ -11,17 +11,13 @@ import io.ebean.text.json.JsonContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.NonUniqueResultException;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Predicate;
/**
* Provides the API for fetching and saving beans to a particular DataSource.
@@ -78,6 +78,7 @@ public class MergeOptionsBuilder {
this.deletePermanent = deletePermanent;
}
@Override
public Set<String> paths() {
return paths;
}
-1
View File
@@ -2,7 +2,6 @@ package io.ebean;
import io.ebean.bean.EntityBean;
import javax.persistence.MappedSuperclass;
/**
* A MappedSuperclass base class that provides convenience methods for inserting, updating and
@@ -7,6 +7,8 @@ package io.ebean.config;
*/
public class BeanNotEnhancedException extends IllegalStateException {
private static final long serialVersionUID = 3008101919425876799L;
public BeanNotEnhancedException(String msg) {
super(msg);
}
@@ -7,6 +7,8 @@ package io.ebean.config;
*/
public class BeanNotRegisteredException extends IllegalStateException {
private static final long serialVersionUID = -1411298126011136552L;
public BeanNotRegisteredException(String msg) {
super(msg);
}
@@ -37,6 +37,7 @@ public interface SpiDtoQuery<T> extends DtoQuery<T>, SpiSqlBinding {
/**
* Return the label for the query.
*/
@Override
String getLabel();
/**
@@ -7,7 +7,6 @@ import io.ebean.bean.PersistenceContext;
import io.ebean.event.changelog.BeanChange;
import io.ebean.event.changelog.ChangeSet;
import io.ebeaninternal.server.core.PersistDeferredRelationship;
import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeaninternal.server.transaction.ProfileStream;
@@ -8,7 +8,6 @@ import io.ebean.bean.PersistenceContext;
import io.ebean.event.changelog.BeanChange;
import io.ebean.event.changelog.ChangeSet;
import io.ebeaninternal.server.core.PersistDeferredRelationship;
import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeaninternal.server.transaction.ProfileStream;
@@ -909,7 +909,7 @@ public class BaseTableDdl implements TableDdl {
if (hasValue(ddl)) {
writer.apply().append(ddl).endOfStatement();
if (isTrue(alter.isWithHistory()) && alter.getType() != null && historySupport == historySupport.TRIGGER_BASED) {
if (isTrue(alter.isWithHistory()) && alter.getType() != null && historySupport == HistorySupport.TRIGGER_BASED) {
// mysql and sql server column type change allowing nulls in the history table column
regenerateHistoryTriggers(alter.getTableName(), HistoryTableUpdate.Change.ALTER, alter.getColumnName());
AlterColumn alterHistoryColumn = new AlterColumn();
@@ -1,6 +1,5 @@
package io.ebeaninternal.dbmigration.model;
import io.ebean.annotation.PartitionMode;
import io.ebeaninternal.dbmigration.ddlgeneration.platform.DdlHelp;
import io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns;
import io.ebeaninternal.dbmigration.migration.AddColumn;
@@ -19,6 +19,7 @@ public class DefaultServerQueryCache extends DefaultServerCache {
this.queryCacheEntryValidate = config.getQueryCacheEntryValidate();
}
@Override
protected Object unwrapEntry(CacheEntry entry) {
return ((QueryCacheEntry) entry.getValue()).getValue();
}
@@ -59,6 +59,7 @@ public class ClusterManager implements ServerLookup {
}
}
@Override
public EbeanServer getServer(String name) {
synchronized (monitor) {
return serverMap.get(name);
@@ -11,7 +11,6 @@ import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.lib.util.Str;
import io.ebeaninternal.server.persist.Binder;
import io.ebeaninternal.server.persist.TrimLogSql;
import io.ebeaninternal.server.transaction.TransactionManager;
import io.ebeaninternal.server.util.BindParamsParser;
import java.sql.Connection;
@@ -239,6 +239,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
return this;
}
@Override
public SqlUpdate setNextParameter(Object value) {
setParameter(++addPos, value);
return this;
@@ -42,6 +42,7 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
}
}
@SuppressWarnings("rawtypes")
@Override
public Collection underlying(Object value) {
if (value instanceof BeanCollection) {
@@ -39,6 +39,7 @@ public interface BeanCollectionHelp<T> extends CQueryCollectionAdd<T> {
/**
* Create an empty collection of the correct type without a parent bean.
*/
@Override
BeanCollection<T> createEmptyNoParent();
/**
@@ -49,6 +50,7 @@ public interface BeanCollectionHelp<T> extends CQueryCollectionAdd<T> {
/**
* Add a bean to the List Set or Map.
*/
@Override
void add(BeanCollection<?> collection, EntityBean bean, boolean withCheck);
/**
@@ -1834,6 +1834,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the IdBinder which is helpful for handling the various types of Id.
*/
@Override
public IdBinder getIdBinder() {
return idBinder;
}
@@ -1942,6 +1943,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Creates a new entity bean without invoking {@link BeanPostConstructListener#postCreate(Object)}
*/
@Override
public EntityBean createEntityBean() {
return createEntityBean(false);
}
@@ -2212,6 +2214,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Put the bean into the persistence context if it is absent.
*/
@Override
public Object contextPutIfAbsent(PersistenceContext pc, Object id, EntityBean localBean) {
return pc.putIfAbsent(rootBeanType, id, localBean);
}
@@ -2638,6 +2641,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return autoTunable;
}
@Override
public boolean isElementType() {
return false;
}
@@ -2646,6 +2650,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Returns the Inheritance mapping information. This will be null if this type
* of bean is not involved in any ORM inheritance mapping.
*/
@Override
public InheritInfo getInheritInfo() {
return inheritInfo;
}
@@ -2814,6 +2819,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Returns true if this bean is based on RawSql.
*/
@Override
public boolean isRawSqlBased() {
return EntityType.SQL == entityType;
}
@@ -2868,6 +2874,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the base table to use given the query temporal mode.
*/
@Override
public String getBaseTable(SpiQuery.TemporalMode mode) {
switch (mode) {
case DRAFT:
@@ -2895,6 +2902,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return readAuditing;
}
@Override
public boolean isSoftDelete() {
return softDelete;
}
@@ -2907,6 +2915,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return softDeleteProperty.getSoftDeleteDbSet();
}
@Override
public String getSoftDeletePredicate(String tableAlias) {
return softDeleteProperty.getSoftDeleteDbPredicate(tableAlias);
}
@@ -2979,6 +2988,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Set the draft to true for this entity bean instance.
* This bean is being loaded via asDraft() query.
*/
@Override
public void setDraft(EntityBean entityBean) {
if (draft != null) {
draft.setValue(entityBean, true);
@@ -3032,6 +3042,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return true if this entity bean has history support.
*/
@Override
public boolean isHistorySupport() {
return historySupport;
}
@@ -46,6 +46,7 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
return (EntityBean)prototype._ebean_newInstance();
}
@Override
public void bindElementValue(SqlUpdate insert, Object value) {
targetDescriptor.bindElementValue(insert, value);
}
@@ -24,6 +24,7 @@ class BeanDescriptorElementScalar<T> extends BeanDescriptorElement<T> {
this.scalarType = firstBaseScalarType();
}
@Override
public void bindElementValue(SqlUpdate insert, Object value) {
insert.setNextParameter(value);
}
@@ -1014,7 +1014,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
* into the order_id column on the order_lines table).
* </p>
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private void makeUnidirectional(DeployBeanPropertyAssocMany<?> oneToMany) {
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.deploy;
import io.ebean.config.BeanNotRegisteredException;
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
import javax.persistence.PersistenceException;
import java.util.Map;
/**
@@ -292,6 +292,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
* Return an extra clause to add to the query for loading or joining
* to this bean type.
*/
@Override
public String getExtraWhere() {
return extraWhere;
}
@@ -255,6 +255,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Add the bean to the appropriate collection on the parent bean.
*/
@Override
public void addBeanToCollectionWithCreate(EntityBean parentBean, EntityBean detailBean, boolean withCheck) {
BeanCollection<?> bc = (BeanCollection<?>) super.getValue(parentBean);
if (bc == null) {
@@ -538,6 +539,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Return true if this is many to many.
*/
@Override
public boolean hasJoinTable() {
return manyToMany || o2mJoinTable;
}
@@ -563,6 +565,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* ManyToMany only, join from local table to intersection table.
*/
@Override
public TableJoin getIntersectionTableJoin() {
return intersectionJoin;
}
@@ -606,6 +609,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return mapKey;
}
@Override
public BeanCollection<?> createReferenceIfNull(EntityBean parentBean) {
Object v = getValue(parentBean);
@@ -638,6 +642,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return descriptor.getId(parentBean);
}
@Override
public void addSelectExported(DbSqlContext ctx, String tableAlias) {
String alias = hasJoinTable() ? "int_" : tableAlias;
@@ -5,6 +5,8 @@ import io.ebean.bean.EntityBeanIntercept;
class ElementEntityBean implements EntityBean {
private static final long serialVersionUID = 8742536671024715601L;
private final String[] properties;
private Object[] data;
@@ -517,6 +517,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return query.setUseQueryCache(useCache);
}
@Override
public Query<T> setCountDistinct(CountDistinctOrder orderBy) {
return query.setCountDistinct(orderBy);
}
@@ -7,7 +7,6 @@ import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.core.PersistRequestCallableSql;
import io.ebeaninternal.server.util.BindParamsParser;
import javax.persistence.PersistenceException;
import java.sql.CallableStatement;
import java.sql.SQLException;
@@ -24,6 +24,7 @@ class MergeNodeAssocManyToMany extends MergeNode {
this.many = property;
}
@Override
public void merge(MergeRequest request) {
EntityBean parentBean = request.getBean();
@@ -17,6 +17,7 @@ class MergeNodeAssocOne extends MergeNode {
this.one = property;
}
@Override
public void merge(MergeRequest request) {
EntityBean entityBean = getEntityBean(request.getBean());
@@ -4,7 +4,6 @@ import io.ebean.bean.EntityBean;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
@@ -19,6 +18,7 @@ class MergeNodeAssocOneToMany extends MergeNode {
this.many = property;
}
@Override
public void merge(MergeRequest request) {
Collection beans = many.getRawCollection(request.getBean());
@@ -15,9 +15,7 @@ import io.ebeaninternal.server.persist.Binder;
import javax.persistence.PersistenceException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@@ -7,7 +7,6 @@ import io.ebeaninternal.server.deploy.DbSqlContext;
import java.sql.SQLException;
import java.util.List;
import java.util.Set;
final class SqlTreeNodeManyRoot extends SqlTreeNodeBean {
@@ -139,6 +139,7 @@ public class DefaultDtoQuery<T> implements SpiDtoQuery<T> {
return descriptor.getType();
}
@Override
public SpiQuery<?> getOrmQuery() {
return ormQuery;
}
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.transaction;
import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import java.io.Serializable;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -12,7 +12,6 @@ import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.api.TransactionEvent;
import io.ebeaninternal.api.TxnProfileEventCodes;
import io.ebeaninternal.server.core.PersistDeferredRelationship;
import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeanservice.docstore.api.DocStoreTransaction;
@@ -11,7 +11,6 @@ import io.ebeaninternal.api.SpiProfileTransactionEvent;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.api.TransactionEvent;
import io.ebeaninternal.server.core.PersistDeferredRelationship;
import io.ebeaninternal.server.core.PersistRequest;
import io.ebeaninternal.server.core.PersistRequestBean;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeanservice.docstore.api.DocStoreTransaction;