From 3701b314a091b531c47437982c93650140b49c17 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Fri, 4 Nov 2016 12:19:38 +0100 Subject: [PATCH 01/87] FIX some java warnings / rawtypes --- src/main/java/com/avaje/ebean/EbeanServer.java | 4 ++-- .../java/com/avaje/ebean/FutureRowCount.java | 1 + .../avaje/ebean/PersistenceIOException.java | 2 ++ .../java/com/avaje/ebean/common/BeanMap.java | 1 - .../com/avaje/ebean/config/ServerConfig.java | 2 +- .../ebean/config/dbplatform/DbIdentity.java | 4 ++-- .../dbplatform/DbPlatformTypeMapping.java | 1 - .../migrationreader/MigrationXmlReader.java | 6 +++--- .../ebean/event/BeanPostConstructListener.java | 1 - .../avaje/ebean/plugin/ExtraTypeFactory.java | 2 +- .../avaje/ebean/text/json/JsonIOException.java | 2 ++ .../ebeaninternal/api/SpiEbeanServer.java | 2 +- .../service/DefaultAutoTuneService.java | 2 +- .../autotune/service/TunedQueryInfo.java | 2 ++ .../server/cache/CacheChangeSet.java | 4 ++-- .../server/cache/CachedBeanData.java | 1 - .../server/core/DefaultBeanLoader.java | 4 ++-- .../server/core/DefaultServer.java | 18 +++++++++++------- .../ebeaninternal/server/core/DiffHelp.java | 4 ++-- .../server/core/PersistRequestBean.java | 2 ++ .../server/deploy/AssocOneHelp.java | 6 +++--- .../server/deploy/AssocOneHelpEmbedded.java | 2 +- .../server/deploy/AssocOneHelpRefExported.java | 2 +- .../server/deploy/AssocOneHelpRefInherit.java | 2 +- .../server/deploy/AssocOneHelpRefSimple.java | 2 +- .../server/deploy/BeanDescriptorDraftHelp.java | 1 + .../server/deploy/BeanDescriptorManager.java | 1 + .../server/deploy/BeanMapHelp.java | 6 ++---- .../server/deploy/BeanPropertyAssocMany.java | 1 + .../server/deploy/BeanPropertyCompound.java | 2 -- .../deploy/BeanPropertyCompoundScalar.java | 3 --- .../server/deploy/BeanSetHelp.java | 3 +-- .../server/deploy/id/IdBinderEmbedded.java | 1 + .../expression/DefaultExampleExpression.java | 6 +++--- .../server/expression/NamedParamHelp.java | 2 +- .../server/grammer/EqlAdapterHelper.java | 7 +++---- .../server/type/ArrayElementConverter.java | 11 ++++++----- .../server/util/BeanCollectionFactory.java | 7 +++---- .../api/DocumentNotFoundException.java | 2 ++ .../ebeaninternal/api/TDSpiEbeanServer.java | 6 +++--- 40 files changed, 72 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java index a2bb1f4b4..f09304f87 100644 --- a/src/main/java/com/avaje/ebean/EbeanServer.java +++ b/src/main/java/com/avaje/ebean/EbeanServer.java @@ -752,7 +752,7 @@ public interface EbeanServer { * * @see Query#findIds() */ - List findIds(Query query, Transaction transaction); + List findIds(Query query, Transaction transaction); /** * Return a QueryIterator for the query. @@ -1024,7 +1024,7 @@ public interface EbeanServer { * * @see Query#findSingleAttributeList() */ - List findSingleAttributeList(Query query, Transaction transaction); + List findSingleAttributeList(Query query, Transaction transaction); /** * Execute the query returning at most one entity bean or null (if no matching diff --git a/src/main/java/com/avaje/ebean/FutureRowCount.java b/src/main/java/com/avaje/ebean/FutureRowCount.java index 36aa6ab33..7c9bc747c 100644 --- a/src/main/java/com/avaje/ebean/FutureRowCount.java +++ b/src/main/java/com/avaje/ebean/FutureRowCount.java @@ -9,6 +9,7 @@ import java.util.concurrent.Future; * It extends the java.util.concurrent.Future. *

* + * @param the BeanType * @author rbygrave */ public interface FutureRowCount extends Future { diff --git a/src/main/java/com/avaje/ebean/PersistenceIOException.java b/src/main/java/com/avaje/ebean/PersistenceIOException.java index 08c26556f..bef4da6da 100644 --- a/src/main/java/com/avaje/ebean/PersistenceIOException.java +++ b/src/main/java/com/avaje/ebean/PersistenceIOException.java @@ -7,6 +7,8 @@ import javax.persistence.PersistenceException; */ public class PersistenceIOException extends PersistenceException { + private static final long serialVersionUID = -7630050437148176148L; + public PersistenceIOException(String msg, Exception cause) { super(msg, cause); } diff --git a/src/main/java/com/avaje/ebean/common/BeanMap.java b/src/main/java/com/avaje/ebean/common/BeanMap.java index f046c83f9..2ad9feadf 100644 --- a/src/main/java/com/avaje/ebean/common/BeanMap.java +++ b/src/main/java/com/avaje/ebean/common/BeanMap.java @@ -265,7 +265,6 @@ public final class BeanMap extends AbstractBeanCollection implements Ma return map.put(key, value); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public void putAll(Map puts) { checkReadOnly(); init(); diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 2f0230220..5a16413b2 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -2311,7 +2311,6 @@ public class ServerConfig { * @param key properties key * @param instance existing instance */ - @SuppressWarnings("unchecked") protected T createInstance(PropertiesWrapper properties, Class pluginType, String key, T instance) { if (instance != null) { @@ -2327,6 +2326,7 @@ public class ServerConfig { * @param pluginType the type of plugin * @param classname the implementation class as per properties */ + @SuppressWarnings("unchecked") protected T createInstance(Class pluginType, String classname) { return classname == null ? null : (T) classLoadConfig.newInstance(classname); } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java index 9c20467dc..442493059 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbIdentity.java @@ -135,9 +135,9 @@ public class DbIdentity { return supportsSequence ? IdType.SEQUENCE : idType; case IDENTITY: return supportsIdentity ? IdType.IDENTITY : idType; + default: + return idType; } - // use the default - return idType; } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java index 8906f911a..94c3f3a8a 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java @@ -2,7 +2,6 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.config.ServerConfig; -import java.sql.Types; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java index 5fce3ba11..68e67323f 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java @@ -16,8 +16,8 @@ import java.io.InputStream; */ public class MigrationXmlReader { - private static final MigrationXmlReader INSTANCE = new MigrationXmlReader(); - + private MigrationXmlReader() {} + /** * Read and return a Migration from an xml document at the given resource path. */ @@ -28,7 +28,7 @@ public class MigrationXmlReader { throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]"); } - return INSTANCE.read(is); + return read(is); } /** diff --git a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java index 1893b480e..c1b4cca99 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java @@ -1,7 +1,6 @@ package com.avaje.ebean.event; import com.avaje.ebean.EbeanServer; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; /** * Fired after a bean is constructed, but not yet loaded from database. diff --git a/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java b/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java index be43b26a9..9ea259668 100644 --- a/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java +++ b/src/main/java/com/avaje/ebean/plugin/ExtraTypeFactory.java @@ -13,5 +13,5 @@ public interface ExtraTypeFactory { /** * Provide extra types to Ebean. */ - List createTypes(ServerConfig config, Object objectMapper); + List> createTypes(ServerConfig config, Object objectMapper); } diff --git a/src/main/java/com/avaje/ebean/text/json/JsonIOException.java b/src/main/java/com/avaje/ebean/text/json/JsonIOException.java index d14fc7c06..58f0a46eb 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonIOException.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonIOException.java @@ -8,6 +8,8 @@ package com.avaje.ebean.text.json; */ public class JsonIOException extends RuntimeException { + private static final long serialVersionUID = 3062982368161342209L; + /** * Construct with an underlying cause. */ diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java index cc98af802..f375d7cab 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java @@ -145,7 +145,7 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL * the query has finished (if executing in a background thread). *

*/ -
List findIdsWithCopy(Query query, Transaction t); + List findIdsWithCopy(Query query, Transaction t); /** * Execute the findRowCount query but without copying the query. diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java index 5a7942259..da8ebf80c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java @@ -63,7 +63,7 @@ public class DefaultAutoTuneService implements AutoTuneService { this.queryTuner = new BaseQueryTuner(config, server, profileManager); this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown(); this.skipProfileReportingOnShutdown = config.isSkipProfileReportingOnShutdown(); - this.defaultGarbageCollectionWait = (long) config.getGarbageCollectionWait(); + this.defaultGarbageCollectionWait = config.getGarbageCollectionWait(); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java index e6b0bce46..55ab0956c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/TunedQueryInfo.java @@ -13,6 +13,8 @@ import java.io.Serializable; */ public class TunedQueryInfo implements Serializable { + private static final long serialVersionUID = 8661702592481810396L; + private final Origin origin; private final OrmQueryDetail tunedDetail; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java index 30b1dc833..7b5a06946 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java @@ -17,7 +17,7 @@ public class CacheChangeSet { private final List entries = new ArrayList(); - private final Set queryCaches = new HashSet(); + private final Set> queryCaches = new HashSet<>(); private final Map manyChangeMap = new HashMap(); @@ -41,7 +41,7 @@ public class CacheChangeSet { * Return the set of table changes to process invalidation for entities based on views. */ public Set apply() { - for (BeanDescriptor entry : queryCaches) { + for (BeanDescriptor entry : queryCaches) { entry.queryCacheClear(); } for (CacheChange entry : entries) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java index 4088a9faa..16f1d3d78 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java @@ -57,7 +57,6 @@ public class CachedBeanData implements Externalizable { } @Override - @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { version = in.readLong(); whenCreated = in.readLong(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java index 50ad811d5..fb904faeb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBeanLoader.java @@ -140,7 +140,7 @@ public class DefaultBeanLoader { } } - SpiQuery query = (SpiQuery) server.createQuery(parentDesc.getBeanType()); + SpiQuery query = server.createQuery(parentDesc.getBeanType()); if (refresh) { // populate a new collection @@ -205,7 +205,7 @@ public class DefaultBeanLoader { return; } - SpiQuery query = (SpiQuery) server.createQuery(loadRequest.getBeanType()); + SpiQuery query = server.createQuery(loadRequest.getBeanType()); loadRequest.configureQuery(query, idList); List list = executeQuery(loadRequest, query); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 99aab043f..437aa4c88 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -273,6 +273,10 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public int getLazyLoadBatchSize() { return lazyLoadBatchSize; } + + public int getQueryBatchSize() { + return queryBatchSize; + } public ServerConfig getServerConfig() { return serverConfig; @@ -1124,7 +1128,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); - return (Set) request.findSet(); + return request.findSet(); } finally { request.endTransIfRequired(); @@ -1143,7 +1147,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); - return (Map) request.findMap(); + return request.findMap(); } finally { request.endTransIfRequired(); @@ -1152,9 +1156,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { @Override @SuppressWarnings("unchecked") - public List findSingleAttributeList(Query query, Transaction t) { + public List findSingleAttributeList(Query query, Transaction t) { - SpiOrmQueryRequest request = createQueryRequest(Type.ATTRIBUTE, query, t); + SpiOrmQueryRequest request = createQueryRequest(Type.ATTRIBUTE, query, t); Object result = request.getFromQueryCache(); if (result != null) { return (List) result; @@ -1190,12 +1194,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } - public List findIds(Query query, Transaction t) { + public List findIds(Query query, Transaction t) { - return findIdsWithCopy(((SpiQuery) query).copy(), t); + return findIdsWithCopy(((SpiQuery) query).copy(), t); } - public List findIdsWithCopy(Query query, Transaction t) { + public List findIdsWithCopy(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.ID_LIST, query, t); try { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java index a59866716..0f6c5d0ea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java @@ -71,7 +71,7 @@ public class DiffHelp { iterator.remove(); } else if (beanProperty instanceof BeanPropertyAssocOne) { - BeanPropertyAssocOne assoc = (BeanPropertyAssocOne)beanProperty; + BeanPropertyAssocOne assoc = (BeanPropertyAssocOne)beanProperty; if (!assoc.isEmbedded()) { // flatten for assoc one beans if (flattened == null) { @@ -90,7 +90,7 @@ public class DiffHelp { return values; } - private static void flattenToId(Map flattened, Map.Entry entry, BeanProperty beanProperty, BeanPropertyAssocOne assoc) { + private static void flattenToId(Map flattened, Map.Entry entry, BeanProperty beanProperty, BeanPropertyAssocOne assoc) { BeanDescriptor oneDesc = assoc.getTargetDescriptor(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index c38f9b257..c4fd5a141 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -968,6 +968,8 @@ public final class PersistRequestBean extends PersistRequest implements BeanP docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue); } } + default: + break; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java index 4fe99bdb9..307698334 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelp.java @@ -12,11 +12,11 @@ import java.sql.SQLException; */ abstract class AssocOneHelp { - protected final BeanPropertyAssocOne property; + protected final BeanPropertyAssocOne property; - protected final BeanDescriptor target; + protected final BeanDescriptor target; - AssocOneHelp(BeanPropertyAssocOne property) { + AssocOneHelp(BeanPropertyAssocOne property) { this.property = property; this.target = property.targetDescriptor; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java index ba69d7b2e..b1e3bd45b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpEmbedded.java @@ -9,7 +9,7 @@ import java.sql.SQLException; */ final class AssocOneHelpEmbedded extends AssocOneHelp { - public AssocOneHelpEmbedded(BeanPropertyAssocOne property) { + public AssocOneHelpEmbedded(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java index c0ff608f2..318a158a3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefExported.java @@ -7,7 +7,7 @@ import com.avaje.ebeaninternal.server.query.SqlJoinType; */ class AssocOneHelpRefExported extends AssocOneHelp { - public AssocOneHelpRefExported(BeanPropertyAssocOne property) { + public AssocOneHelpRefExported(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java index 4791cb641..6ec408677 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefInherit.java @@ -13,7 +13,7 @@ class AssocOneHelpRefInherit extends AssocOneHelp { private final InheritInfo inherit; - AssocOneHelpRefInherit(BeanPropertyAssocOne property) { + AssocOneHelpRefInherit(BeanPropertyAssocOne property) { super(property); this.inherit = property.targetInheritInfo; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java index 72dd6a533..f84e861cf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/AssocOneHelpRefSimple.java @@ -5,7 +5,7 @@ package com.avaje.ebeaninternal.server.deploy; */ class AssocOneHelpRefSimple extends AssocOneHelp { - AssocOneHelpRefSimple(BeanPropertyAssocOne property) { + AssocOneHelpRefSimple(BeanPropertyAssocOne property) { super(property); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java index 6fcc8319c..a4589ec53 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java @@ -69,6 +69,7 @@ public final class BeanDescriptorDraftHelp { * This will recursive transfer values to all @DraftableElement properties. *

*/ + @SuppressWarnings("unchecked") public T publish(T draftBean, T liveBean) { if (liveBean == null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index ab4ef1c81..4f7e79b1e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -645,6 +645,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { /** * Return the bean deploy info for the given class. */ + @SuppressWarnings("unchecked") public DeployBeanInfo getDeploy(Class cls) { return (DeployBeanInfo) deployInfoMap.get(cls); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java index 9b31e7556..6340c9fb0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java @@ -92,16 +92,14 @@ public final class BeanMapHelp implements BeanCollectionHelp { } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmptyNoParent() { - return new BeanMap(); + return new BeanMap<>(); } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmpty(EntityBean ownerBean) { - BeanMap beanMap = new BeanMap(loader, ownerBean, propertyName); + BeanMap beanMap = new BeanMap<>(loader, ownerBean, propertyName); if (many != null) { beanMap.setModifyListening(many.getModifyListenMode()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index a64586646..5c68c35b5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -1032,6 +1032,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { } } + @SuppressWarnings("unchecked") private Map liveBeansAsMap(BeanCollection liveVal) { liveVal.size(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java index 39a22f58e..1b0b384c0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java @@ -125,10 +125,8 @@ public class BeanPropertyCompound extends BeanProperty { * Read the data from the resultSet effectively ignoring it and returning * null. */ - @SuppressWarnings("unchecked") @Override public Object read(DbReadContext ctx) throws SQLException { - return compoundType.read(ctx.getDataReader()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java index 902dad24b..3df6100df 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundScalar.java @@ -23,12 +23,10 @@ public class BeanPropertyCompoundScalar extends BeanProperty { /** * Return one of the scalar values from a compound type. */ - @SuppressWarnings("unchecked") public Object getValueObject(Object compoundValue) { return ctProperty.getValue(compoundValue); } - @SuppressWarnings("unchecked") @Override public Object getValue(EntityBean valueObject) { return ctProperty.getValue(valueObject); @@ -39,7 +37,6 @@ public class BeanPropertyCompoundScalar extends BeanProperty { setValueInCompound(bean, value, false); } - @SuppressWarnings("unchecked") public void setValueInCompound(EntityBean bean, Object value, boolean intercept) { Object compoundValue = ctProperty.setValue(bean, value); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java index b1f88c4db..1990c30ed 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java @@ -70,9 +70,8 @@ public final class BeanSetHelp implements BeanCollectionHelp { } @Override - @SuppressWarnings("unchecked") public BeanCollection createEmptyNoParent() { - return new BeanSet(); + return new BeanSet<>(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index 1dc7f4a88..43579af80 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -244,6 +244,7 @@ public final class IdBinderEmbedded implements IdBinder { /** * Convert back from a Map to embedded bean. */ + @SuppressWarnings("unchecked") public Object convertIdFromJson(Object value) { Map map = (Map)value; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index f8491c300..a979879a2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -291,7 +291,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio String propName = SplitName.add(prefix, beanProperty.getName()); if (beanProperty.isScalar()) { if (value instanceof String) { - list.add(new LikeExpression(propName, (String) value, caseInsensitive, likeType)); + list.add(new LikeExpression(propName, value, caseInsensitive, likeType)); } else { // exclude the zero values typically to weed out // primitive int and long that initialise to 0 @@ -301,8 +301,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio } } else if ((beanProperty instanceof BeanPropertyAssocOne) && (value instanceof EntityBean)) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) beanProperty; - BeanDescriptor targetDescriptor = assocOne.getTargetDescriptor(); + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) beanProperty; + BeanDescriptor targetDescriptor = assocOne.getTargetDescriptor(); addExpressions(list, targetDescriptor, (EntityBean) value, propName); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java index 1defe77e5..b35005020 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java @@ -35,7 +35,7 @@ class NamedParamHelp { Object value = value(sourceValue); if (value instanceof Collection) { - values.addAll((Collection)value); + values.addAll((Collection)value); } else { values.add(value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java index 1733d132f..93d84b882 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java @@ -8,9 +8,9 @@ import java.util.List; class EqlAdapterHelper { - private final EqlAdapter owner; + private final EqlAdapter owner; - public EqlAdapterHelper(EqlAdapter owner) { + public EqlAdapterHelper(EqlAdapter owner) { this.owner = owner; } @@ -49,7 +49,6 @@ class EqlAdapterHelper { peekExprList().between(path, bind(value1), bind(value2)); } - @SuppressWarnings("unchecked") protected void addIn(String path, List inValues) { peekExprList().in(path, inValues); } @@ -117,7 +116,7 @@ class EqlAdapterHelper { return getBindValue(valueType, value); } - private ExpressionList peekExprList() { + private ExpressionList peekExprList() { return owner.peekExprList(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java index 9bd2d23b7..349c3757b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java @@ -15,27 +15,27 @@ interface ArrayElementConverter { /** * The UUID converter implementation. */ - ArrayElementConverter UUID = new UuidConverter(); + ArrayElementConverter UUID = new UuidConverter(); /** * The String converter implementation. */ - ArrayElementConverter STRING = new StringConverter(); + ArrayElementConverter STRING = new StringConverter(); /** * The Long converter implementation. */ - ArrayElementConverter LONG = new LongConverter(); + ArrayElementConverter LONG = new LongConverter(); /** * The Integer converter implementation. */ - ArrayElementConverter INTEGER = new IntegerConverter(); + ArrayElementConverter INTEGER = new IntegerConverter(); /** * The Double converter implementation. */ - ArrayElementConverter DOUBLE = new DoubleConverter(); + ArrayElementConverter DOUBLE = new DoubleConverter(); class LongConverter implements ArrayElementConverter { @@ -87,6 +87,7 @@ interface ArrayElementConverter { class NoopConverter implements ArrayElementConverter { + @SuppressWarnings("unchecked") @Override public T toElement(Object rawValue) { return (T) rawValue; diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java b/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java index 04a496647..0bb17902e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java @@ -25,16 +25,15 @@ public class BeanCollectionFactory { /** * Create a BeanCollection for the given parameters. */ - @SuppressWarnings("unchecked") public static BeanCollection create(SpiQuery.Type manyType) { switch (manyType) { case MAP: - return new BeanMap(new LinkedHashMap(defaultMapInitialCapacity)); + return new BeanMap<>(new LinkedHashMap<>(defaultMapInitialCapacity)); case LIST: - return new BeanList(new ArrayList(defaultListInitialCapacity)); + return new BeanList<>(new ArrayList<>(defaultListInitialCapacity)); case SET: - return new BeanSet(new LinkedHashSet(defaultSetInitialCapacity)); + return new BeanSet<>(new LinkedHashSet<>(defaultSetInitialCapacity)); default: throw new RuntimeException("Invalid Arg " + manyType); diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/DocumentNotFoundException.java b/src/main/java/com/avaje/ebeanservice/docstore/api/DocumentNotFoundException.java index 59f51e546..0bf95b34e 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/DocumentNotFoundException.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/DocumentNotFoundException.java @@ -5,6 +5,8 @@ package com.avaje.ebeanservice.docstore.api; */ public class DocumentNotFoundException extends RuntimeException { + private static final long serialVersionUID = 2066138180892685276L; + /** * Construct with a message. */ diff --git a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java index 878c487e7..aeb4dc840 100644 --- a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java +++ b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java @@ -186,7 +186,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer { } @Override - public List findIdsWithCopy(Query query, Transaction t) { + public List findIdsWithCopy(Query query, Transaction t) { return null; } @@ -461,7 +461,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer { } @Override - public List findIds(Query query, Transaction transaction) { + public List findIds(Query query, Transaction transaction) { return null; } @@ -516,7 +516,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer { } @Override - public List findSingleAttributeList(Query query, Transaction transaction) { + public List findSingleAttributeList(Query query, Transaction transaction) { return null; } From 4663162f95d284623a43133e23cace86c62393f1 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 14:48:03 +1300 Subject: [PATCH 02/87] Refactor - no effective chang - Add SpiQuery getOriginKey() --- src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java | 5 +++++ .../ebeaninternal/server/querydefn/DefaultOrmQuery.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java index b0254617b..d963fcbfe 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java @@ -166,6 +166,11 @@ public interface SpiQuery extends Query { */ PersistenceContextScope getPersistenceContextScope(); + /** + * Return the origin key. + */ + String getOriginKey(); + /** * Return the default lazy load batch size. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 8ffb97800..d47ed43e3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -339,6 +339,15 @@ public class DefaultOrmQuery implements SpiQuery { return this; } + @Override + public String getOriginKey() { + if (parentNode == null || parentNode.getOriginQueryPoint() == null) { + return null; + } else { + return parentNode.getOriginQueryPoint().getKey(); + } + } + @Override public int getLazyLoadBatchSize() { return lazyLoadBatchSize; From 77e3346d9ea1588549ccb90d0584f4dace9efbad Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 15:11:17 +1300 Subject: [PATCH 03/87] Refactor - clean up CQueryPlan, CQueryPlanStats --- .../server/query/CQueryPlan.java | 55 ++++++------------- .../server/query/CQueryPlanStats.java | 14 ++--- .../avaje/ebeaninternal/server/util/Md5.java | 33 +++++++++++ .../ebeaninternal/server/util/Md5Test.java | 18 ++++++ 4 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/avaje/ebeaninternal/server/util/Md5.java create mode 100644 src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java index 6c490bf17..93cf4d102 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java @@ -11,10 +11,10 @@ import com.avaje.ebeaninternal.server.type.DataBind; import com.avaje.ebeaninternal.server.type.DataReader; import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.type.RsetDataReader; +import com.avaje.ebeaninternal.server.util.Md5; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.security.MessageDigest; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -80,38 +80,32 @@ public class CQueryPlan { /** * Create a query plan based on a OrmQueryRequest. */ - public CQueryPlan(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) { + CQueryPlan(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, boolean rawSql, String logWhereSql) { this.server = request.getServer(); this.dataTimeZone = server.getDataTimeZone(); this.beanType = request.getBeanDescriptor().getBeanType(); - this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); this.planKey = request.getQueryPlanKey(); this.autoTuned = request.getQuery().isAutoTuned(); this.asOfTableCount = request.getQuery().getAsOfTableCount(); - if (sqlRes != null) { - this.sql = sqlRes.getSql(); - this.rowNumberIncluded = sqlRes.isIncludesRowNumberColumn(); - } else { - this.sql = null; - this.rowNumberIncluded = false; - } + this.sql = sqlRes.getSql(); + this.rowNumberIncluded = sqlRes.isIncludesRowNumberColumn(); this.sqlTree = sqlTree; this.rawSql = rawSql; this.logWhereSql = logWhereSql; this.encryptedProps = sqlTree.getEncryptedProps(); + this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); } /** * Create a query plan for a raw sql query. */ - public CQueryPlan(OrmQueryRequest request, String sql, SqlTree sqlTree, + CQueryPlan(OrmQueryRequest request, String sql, SqlTree sqlTree, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { this.server = request.getServer(); this.dataTimeZone = server.getDataTimeZone(); this.beanType = request.getBeanDescriptor().getBeanType(); - this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); this.planKey = buildPlanKey(sql, rawSql, rowNumberIncluded, logWhereSql); this.autoTuned = false; this.asOfTableCount = 0; @@ -121,6 +115,7 @@ public class CQueryPlan { this.rowNumberIncluded = rowNumberIncluded; this.logWhereSql = logWhereSql; this.encryptedProps = sqlTree.getEncryptedProps(); + this.stats = new CQueryPlanStats(this, server.isCollectQueryOrigins()); } @@ -144,7 +139,7 @@ public class CQueryPlan { /** * Bind keys for encrypted properties if necessary returning the DataBind. */ - public DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { + DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { DataBind dataBind = new DataBind(dataTimeZone, stmt, conn); if (encryptedProps != null) { for (int i = 0; i < encryptedProps.length; i++) { @@ -155,22 +150,22 @@ public class CQueryPlan { return dataBind; } - public int getAsOfTableCount() { + int getAsOfTableCount() { return asOfTableCount; } - public boolean isAutoTuned() { + boolean isAutoTuned() { return autoTuned; } - public CQueryPlanKey getPlanKey() { + CQueryPlanKey getPlanKey() { return planKey; } /** * Return a key used in audit logging to identify the query. */ - public String getAuditQueryKey() { + String getAuditQueryKey() { if (auditQueryHash == null) { // volatile object assignment (so happy for multithreaded access) auditQueryHash = calcAuditQueryKey(); @@ -188,32 +183,18 @@ public class CQueryPlan { */ private String getSqlMd5Hash() { try { - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] digest = md.digest(sql.getBytes("UTF-8")); - return digestToHex(digest); + return Md5.hash(sql); } catch (Exception e) { logger.error("Failed to MD5 hash the rawSql query", e); return "error"; } } - /** - * Convert the digest into a hex value. - */ - private String digestToHex(byte[] digest) { - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < digest.length; i++) { - sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); - } - return sb.toString(); - } - public String getSql() { return sql; } - public SqlTree getSqlTree() { + SqlTree getSqlTree() { return sqlTree; } @@ -221,11 +202,11 @@ public class CQueryPlan { return rawSql; } - public boolean isRowNumberIncluded() { + boolean isRowNumberIncluded() { return rowNumberIncluded; } - public String getLogWhereSql() { + String getLogWhereSql() { return logWhereSql; } @@ -239,7 +220,7 @@ public class CQueryPlan { /** * Register an execution time against this query plan; */ - public void executionTime(long loadedBeanCount, long timeMicros, ObjectGraphNode objectGraphNode) { + void executionTime(long loadedBeanCount, long timeMicros, ObjectGraphNode objectGraphNode) { stats.add(loadedBeanCount, timeMicros, objectGraphNode); if (objectGraphNode != null) { @@ -266,7 +247,7 @@ public class CQueryPlan { return stats.getLastQueryTime(); } - public BeanProperty getSingleProperty() { + BeanProperty getSingleProperty() { return sqlTree.getRootNode().getSingleProperty(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java index 88389ed8a..a46162571 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java @@ -37,10 +37,10 @@ public final class CQueryPlanStats { /** * Construct for a given query plan. */ - public CQueryPlanStats(CQueryPlan queryPlan, boolean collectQueryOrigins) { + CQueryPlanStats(CQueryPlan queryPlan, boolean collectQueryOrigins) { this.queryPlan = queryPlan; - this.origins = !collectQueryOrigins ? null : new ConcurrentHashMap(); + this.origins = !collectQueryOrigins ? null : new ConcurrentHashMap<>(); } /** @@ -92,14 +92,14 @@ public final class CQueryPlanStats { /** * Return the last time this query was executed. */ - public long getLastQueryTime() { + long getLastQueryTime() { return lastQueryTime; } /** * Return a Snapshot of the query execution statistics potentially resetting the internal counters. */ - public Snapshot getSnapshot(boolean reset) { + Snapshot getSnapshot(boolean reset) { List origins = getOrigins(reset); @@ -119,7 +119,7 @@ public final class CQueryPlanStats { return Collections.emptyList(); } - List list = new ArrayList(); + List list = new ArrayList<>(); for (Entry entry : origins.entrySet()) { if (reset) { @@ -138,7 +138,7 @@ public final class CQueryPlanStats { private final ObjectGraphNode objectGraphNode; private final long count; - public OriginSnapshot(ObjectGraphNode objectGraphNode, long count) { + OriginSnapshot(ObjectGraphNode objectGraphNode, long count) { this.objectGraphNode = objectGraphNode; this.count = count; } @@ -172,7 +172,7 @@ public final class CQueryPlanStats { private final long lastQueryTime; private final List origins; - public Snapshot(CQueryPlan queryPlan, long count, long totalTime, long totalBeans, long maxTime, long startTime, long lastQueryTime, + Snapshot(CQueryPlan queryPlan, long count, long totalTime, long totalBeans, long maxTime, long startTime, long lastQueryTime, List origins) { this.queryPlan = queryPlan; diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java new file mode 100644 index 000000000..448c4b239 --- /dev/null +++ b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java @@ -0,0 +1,33 @@ +package com.avaje.ebeaninternal.server.util; + +import java.security.MessageDigest; + +public class Md5 { + + /** + * Return the MD5 hash of the underlying sql. + */ + public static String hash(String content) { + + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] digest = md.digest(content.getBytes("UTF-8")); + return digestToHex(digest); + } catch (Exception e) { + throw new RuntimeException("MD5 hashing failed", e); + } + } + + /** + * Convert the digest into a hex value. + */ + private static String digestToHex(byte[] digest) { + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < digest.length; i++) { + sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); + } + return sb.toString(); + } + +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java b/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java new file mode 100644 index 000000000..2d676d13a --- /dev/null +++ b/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java @@ -0,0 +1,18 @@ +package com.avaje.ebeaninternal.server.util; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class Md5Test { + + @Test + public void hash() throws Exception { + + String content = "some random content we wish to hash"; + String hash1 = Md5.hash(content); + String hash2 = Md5.hash(content); + assertEquals(hash1, hash2); + } + +} \ No newline at end of file From 670bac52f849c82c1fddb2a6c1c87f361b055924 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 22:32:36 +1300 Subject: [PATCH 04/87] Refactor - tidy up in com.avaje.ebeaninternal.server.query, no effective change --- .../server/query/BaseFuture.java | 10 ++--- .../ebeaninternal/server/query/CQuery.java | 44 +++++++++---------- .../server/query/CQueryBuilder.java | 20 ++++----- .../server/query/CQueryBuilderRawSql.java | 4 +- .../server/query/CQueryDraftSupport.java | 6 +-- .../server/query/CQueryEngine.java | 5 +-- .../query/CQueryFetchSingleAttribute.java | 4 +- .../server/query/CQueryHistorySupport.java | 14 +++--- .../query/CQueryIteratorWithBuffer.java | 2 +- .../server/query/CQueryOrderBy.java | 2 +- .../server/query/CQueryPlanRawSql.java | 4 +- .../server/query/CQueryPredicates.java | 22 +++++----- .../server/query/CQueryRowCount.java | 7 +-- .../server/query/CQueryUpdate.java | 4 +- .../server/query/CallableQuery.java | 4 +- .../server/query/DefaultDbSqlContext.java | 16 +++---- .../query/DefaultRelationalQueryEngine.java | 4 +- .../server/query/DefaultSqlRow.java | 2 +- .../server/query/QueryFutureIds.java | 2 +- .../server/query/QueryFutureList.java | 2 +- .../server/query/QueryFutureRowCount.java | 2 +- .../server/query/RawSqlQueryPlanKey.java | 4 +- .../server/query/SqlBeanLoad.java | 2 +- .../ebeaninternal/server/query/SqlTree.java | 28 ++++++------ .../server/query/SqlTreeAlias.java | 26 +++++------ .../server/query/SqlTreeBuilder.java | 12 +++-- .../server/query/SqlTreeNodeBean.java | 4 +- .../server/query/SqlTreeNodeExtraJoin.java | 4 +- .../query/SqlTreeNodeManyWhereJoin.java | 4 +- .../server/query/SqlTreeNodeRoot.java | 2 +- .../server/query/SqlTreeProperties.java | 33 +++++--------- 31 files changed, 139 insertions(+), 160 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java b/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java index 05fdfc337..e00a98f78 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/BaseFuture.java @@ -12,11 +12,11 @@ import java.util.concurrent.TimeoutException; * @param the entity bean type * @author rbygrave */ -public abstract class BaseFuture implements Future { +abstract class BaseFuture implements Future { - protected final FutureTask futureTask; + final FutureTask futureTask; - public BaseFuture(FutureTask futureTask) { + BaseFuture(FutureTask futureTask) { this.futureTask = futureTask; } @@ -28,9 +28,7 @@ public abstract class BaseFuture implements Future { return futureTask.get(); } - public T get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return futureTask.get(timeout, unit); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java index 7fd6a16a1..0dee1d36a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java @@ -209,7 +209,7 @@ public class CQuery implements DbReadContext, CancelableQuery { this.objectGraphNode = query.getParentNode(); this.profilingListener = query.getProfilingListener(); this.autoTuneProfiling = profilingListener != null; - this.profilingListenerRef = autoTuneProfiling ? new WeakReference(profilingListener) : null; + this.profilingListenerRef = autoTuneProfiling ? new WeakReference<>(profilingListener) : null; // set the generated sql back to the query // so its available to the user... @@ -276,7 +276,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return predicates; } - public SpiOrmQueryRequest getQueryRequest() { + SpiOrmQueryRequest getQueryRequest() { return request; } @@ -297,14 +297,14 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Prepare bind and execute query with Forward only hints. */ - public boolean prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint) throws SQLException { + boolean prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint) throws SQLException { return prepareBindExecuteQueryWithOption(dbPlatformForwardOnlyHint); } /** * Prepare bind and execute the query normally. */ - public boolean prepareBindExecuteQuery() throws SQLException { + boolean prepareBindExecuteQuery() throws SQLException { return prepareBindExecuteQueryWithOption(false); } @@ -494,11 +494,11 @@ public class CQuery implements DbReadContext, CancelableQuery { return true; } - public long getQueryExecutionTimeMicros() { + long getQueryExecutionTimeMicros() { return executionTimeMicros; } - public boolean readBean() throws SQLException { + boolean readBean() throws SQLException { boolean result = hasNext(); updateExecutionStatistics(); @@ -531,9 +531,9 @@ public class CQuery implements DbReadContext, CancelableQuery { * Read version beans and their effective dates. */ @SuppressWarnings("unchecked") - public List> readVersions() throws SQLException { + List> readVersions() throws SQLException { - List> versionList = new ArrayList>(); + List> versionList = new ArrayList<>(); Version version; while ((version = readNextVersion()) != null) { @@ -552,7 +552,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return null; } - public BeanCollection readCollection() throws SQLException { + BeanCollection readCollection() throws SQLException { while (hasNext()) { EntityBean bean = next(); @@ -563,7 +563,7 @@ public class CQuery implements DbReadContext, CancelableQuery { return collection; } - protected void updateExecutionStatistics() { + void updateExecutionStatistics() { try { long exeNano = System.nanoTime() - startNano; executionTimeMicros = TimeUnit.NANOSECONDS.toMicros(exeNano); @@ -578,17 +578,17 @@ public class CQuery implements DbReadContext, CancelableQuery { } } - public QueryIterator readIterate(int bufferSize, OrmQueryRequest request) { + QueryIterator readIterate(int bufferSize, OrmQueryRequest request) { if (bufferSize > 0) { - return new CQueryIteratorWithBuffer(this, request, bufferSize); + return new CQueryIteratorWithBuffer<>(this, request, bufferSize); } else { - return new CQueryIteratorSimple(this, request); + return new CQueryIteratorSimple<>(this, request); } } - public String getLoadedRowDetail() { + String getLoadedRowDetail() { if (manyProperty == null) { return String.valueOf(rowCount); } else { @@ -618,7 +618,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Return the where predicate for display in the transaction log. */ - public String getLogWhereSql() { + String getLogWhereSql() { return logWhereSql; } @@ -641,7 +641,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Return the short bean name. */ - public String getBeanName() { + String getBeanName() { return desc.getName(); } @@ -655,7 +655,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Create a PersistenceException including interesting information like the bindLog and sql used. */ - public PersistenceException createPersistenceException(SQLException e) { + PersistenceException createPersistenceException(SQLException e) { return createPersistenceException(e, getTransaction(), bindLog, sql); } @@ -663,7 +663,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Create a PersistenceException including interesting information like the bindLog and sql used. */ - public static PersistenceException createPersistenceException(SQLException e, SpiTransaction t, String bindLog, String sql) { + static PersistenceException createPersistenceException(SQLException e, SpiTransaction t, String bindLog, String sql) { if (t.isLogSummary()) { // log the error to the transaction log @@ -723,7 +723,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * A find bean query with read auditing so build and log the ReadEvent. */ - public void auditFind(EntityBean bean) { + void auditFind(EntityBean bean) { if (bean != null) { // only audit when a bean was actually found desc.readAuditBean(queryPlan.getAuditQueryKey(), bindLog, bean); @@ -733,7 +733,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * a find many query with read auditing so build the ReadEvent and log it. */ - public void auditFindMany() { + void auditFindMany() { if (!collection.isEmpty()) { // get the id values of the underlying collection @@ -760,7 +760,7 @@ public class CQuery implements DbReadContext, CancelableQuery { /** * Indicate that read auditing is occurring on a this findIterate query. */ - public void auditFindIterate() { + void auditFindIterate() { auditFindIterate = true; } @@ -779,7 +779,7 @@ public class CQuery implements DbReadContext, CancelableQuery { private void auditIterateNextBean() { if (auditFindIterateIds == null) { - auditFindIterateIds = new ArrayList(100); + auditFindIterateIds = new ArrayList<>(100); } auditFindIterateIds.add(desc.getIdForJson(nextBean)); if (auditFindIterateIds.size() >= 100) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java index 4121f8dee..e83847952 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java @@ -31,7 +31,7 @@ import java.util.List; * Generates the SQL SELECT statements taking into account the physical * deployment properties. */ -public class CQueryBuilder { +class CQueryBuilder { private final String tableAliasPlaceHolder; private final String columnAliasPrefix; @@ -53,7 +53,7 @@ public class CQueryBuilder { /** * Create the SqlGenSelect. */ - public CQueryBuilder(DatabasePlatform dbPlatform, Binder binder, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { + CQueryBuilder(DatabasePlatform dbPlatform, Binder binder, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { this.dbPlatform = dbPlatform; this.binder = binder; @@ -70,7 +70,7 @@ public class CQueryBuilder { * split the order by claus on the field delimiter and prefix each field with * the relation name */ - public static String prefixOrderByFields(String name, String orderBy) { + static String prefixOrderByFields(String name, String orderBy) { StringBuilder sb = new StringBuilder(); for (String token : orderBy.split(",")) { if (sb.length() > 0) { @@ -88,7 +88,7 @@ public class CQueryBuilder { /** * Build the delete query. */ - public CQueryUpdate buildUpdateQuery(String type, OrmQueryRequest request) { + CQueryUpdate buildUpdateQuery(String type, OrmQueryRequest request) { SpiQuery query = request.getQuery(); String rootTableAlias = query.getAlias(); @@ -165,7 +165,7 @@ public class CQueryBuilder { return StringHelper.replaceString(sql, "${RTA}", replaceWith); } - public CQueryFetchSingleAttribute buildFetchAttributeQuery(OrmQueryRequest request) { + CQueryFetchSingleAttribute buildFetchAttributeQuery(OrmQueryRequest request) { SpiQuery query = request.getQuery(); query.setSingleAttribute(); @@ -191,7 +191,7 @@ public class CQueryBuilder { /** * Build the find ids query. */ - public CQueryFetchSingleAttribute buildFetchIdsQuery(OrmQueryRequest request) { + CQueryFetchSingleAttribute buildFetchIdsQuery(OrmQueryRequest request) { request.getQuery().setSelectId(); return buildFetchAttributeQuery(request); @@ -214,7 +214,7 @@ public class CQueryBuilder { /** * Build the row count query. */ - public CQueryRowCount buildRowCountQuery(OrmQueryRequest request) { + CQueryRowCount buildRowCountQuery(OrmQueryRequest request) { SpiQuery query = request.getQuery(); @@ -275,7 +275,7 @@ public class CQueryBuilder { * Return the SQL Select statement as a String. Converts logical property * names to physical deployment column names. */ - public CQuery buildQuery(OrmQueryRequest request) { + CQuery buildQuery(OrmQueryRequest request) { CQueryPredicates predicates = new CQueryPredicates(binder, request); @@ -284,7 +284,7 @@ public class CQueryBuilder { // Reuse the query plan so skip generating SqlTree and SQL. // We do prepare and bind the new parameters predicates.prepare(false); - return new CQuery(request, predicates, queryPlan); + return new CQuery<>(request, predicates, queryPlan); } // RawSql or Generated Sql query @@ -327,7 +327,7 @@ public class CQueryBuilder { // gather query performance statistics based on it. request.putQueryPlan(queryPlan); - return new CQuery(request, predicates, queryPlan); + return new CQuery<>(request, predicates, queryPlan); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java index 296f53f83..c342731c3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilderRawSql.java @@ -11,7 +11,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.querydefn.OrmQueryLimitRequest; import com.avaje.ebeaninternal.server.util.BindParamsParser; -public class CQueryBuilderRawSql { +class CQueryBuilderRawSql { private final SqlLimiter sqlLimiter; private final DatabasePlatform dbPlatform; @@ -24,7 +24,7 @@ public class CQueryBuilderRawSql { /** * Build the full SQL Select statement for the request. */ - public SqlLimitResponse buildSql(OrmQueryRequest request, CQueryPredicates predicates, RawSql.Sql rsql) { + SqlLimitResponse buildSql(OrmQueryRequest request, CQueryPredicates predicates, RawSql.Sql rsql) { if (rsql == null) { // this is a ResultSet based RawSql query - just use some placeholder for the SQL diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java index 50c6e62fd..be5a171a6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java @@ -5,14 +5,14 @@ import java.util.Map; /** * Support 'asDraft' queries. */ -public class CQueryDraftSupport { +class CQueryDraftSupport { /** * The mapping of base tables to their matching 'draft' table. */ private final Map tableMap; - public CQueryDraftSupport(Map tableMap) { + CQueryDraftSupport(Map tableMap) { this.tableMap = tableMap; } @@ -22,7 +22,7 @@ public class CQueryDraftSupport { * This returns null for entities that are not draftable and in that case * the usual base table is used. */ - public String getDraftTable(String table) { + String getDraftTable(String table) { return tableMap.get(table); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java index 49d8625f9..1c07a868e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java @@ -275,7 +275,7 @@ public class CQueryEngine { } } // put an empty map into the last one - current.setDiff(new LinkedHashMap()); + current.setDiff(new LinkedHashMap<>()); } } @@ -299,8 +299,7 @@ public class CQueryEngine { /** * Find a list/map/set of beans. */ - public BeanCollection findMany(OrmQueryRequest request) { - + BeanCollection findMany(OrmQueryRequest request) { SpiQuery query = request.getQuery(); if (!query.isDistinct() && (query.getMaxRows() > 1 || query.getFirstRow() > 0)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java index 431d84edd..6e901c29a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java @@ -59,7 +59,7 @@ class CQueryFetchSingleAttribute { /** * Create the Sql select based on the request. */ - public CQueryFetchSingleAttribute(OrmQueryRequest request, CQueryPredicates predicates, CQueryPlan plan) { + CQueryFetchSingleAttribute(OrmQueryRequest request, CQueryPredicates predicates, CQueryPlan plan) { this.request = request; this.query = request.getQuery(); this.sql = plan.getSql(); @@ -94,7 +94,7 @@ class CQueryFetchSingleAttribute { prepareExecute(); - List result = new ArrayList(); + List result = new ArrayList<>(); while (dataReader.next()) { result.add(scalarType.read(dataReader)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java index 3b5e8e683..6a4e38437 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java @@ -7,7 +7,7 @@ import java.util.Map; /** * Helper to support history functions. */ -public class CQueryHistorySupport { +class CQueryHistorySupport { /** * The DB specific support. @@ -24,7 +24,7 @@ public class CQueryHistorySupport { */ private final String sysPeriod; - public CQueryHistorySupport(DbHistorySupport dbHistorySupport, Map asOfTableMap, String sysPeriod) { + CQueryHistorySupport(DbHistorySupport dbHistorySupport, Map asOfTableMap, String sysPeriod) { this.dbHistorySupport = dbHistorySupport; this.asOfTableMap = asOfTableMap; this.sysPeriod = sysPeriod; @@ -33,28 +33,28 @@ public class CQueryHistorySupport { /** * Return true if the underlying history support is standards based. */ - public boolean isStandardsBased() { + boolean isStandardsBased() { return dbHistorySupport.isStandardsBased(); } /** * Return the 'as of' history view for the given base table. */ - public String getAsOfView(String table) { + String getAsOfView(String table) { return asOfTableMap.get(table); } /** * Return the lower bound column. */ - public String getSysPeriodLower(String tableAlias) { + String getSysPeriodLower(String tableAlias) { return dbHistorySupport.getSysPeriodLower(tableAlias, sysPeriod); } /** * Return the upper bound column. */ - public String getSysPeriodUpper(String tableAlias) { + String getSysPeriodUpper(String tableAlias) { return dbHistorySupport.getSysPeriodUpper(tableAlias, sysPeriod); } @@ -63,7 +63,7 @@ public class CQueryHistorySupport { * * Note used for Oracle total recall etc with the more standard approach. */ - public String getAsOfPredicate(String tableAlias) { + String getAsOfPredicate(String tableAlias) { return dbHistorySupport.getAsOfPredicate(tableAlias, sysPeriod); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java index 163fdfc2f..889912202 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java @@ -24,7 +24,7 @@ class CQueryIteratorWithBuffer implements QueryIterator { this.cquery = cquery; this.request = request; this.bufferSize = bufferSize; - this.buffer = new ArrayList(bufferSize); + this.buffer = new ArrayList<>(bufferSize); } @SuppressWarnings("unchecked") diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java index 9e925fb52..9bde80ff9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java @@ -14,7 +14,7 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue; /** * Creates the order by expression clause. */ -public class CQueryOrderBy { +class CQueryOrderBy { private final BeanDescriptor desc; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java index b23cc79ac..11ce4a076 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java @@ -12,11 +12,11 @@ import java.util.List; /** * RawSql based query plan. */ -public class CQueryPlanRawSql extends CQueryPlan { +class CQueryPlanRawSql extends CQueryPlan { private final int[] rsetIndexPositions; - public CQueryPlanRawSql(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, String logWhereSql) { + CQueryPlanRawSql(OrmQueryRequest request, SqlLimitResponse sqlRes, SqlTree sqlTree, String logWhereSql) { super(request, sqlRes, sqlTree, true, logWhereSql); this.rsetIndexPositions = createIndexPositions(request, sqlTree); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java index 52f4aec9d..3465ffe8f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java @@ -106,7 +106,7 @@ public class CQueryPredicates { private Set orderByIncludes; - public CQueryPredicates(Binder binder, OrmQueryRequest request) { + CQueryPredicates(Binder binder, OrmQueryRequest request) { this.binder = binder; this.request = request; this.query = request.getQuery(); @@ -252,7 +252,7 @@ public class CQueryPredicates { } // create a copy of the includes required to support the orderBy - orderByIncludes = new HashSet(deployParser.getIncludes()); + orderByIncludes = new HashSet<>(deployParser.getIncludes()); dbWhere = deriveWhere(deployParser); dbFilterMany = deriveFilterMany(deployParser); @@ -277,7 +277,7 @@ public class CQueryPredicates { /** * Replace the table alias place holders. */ - public void parseTableAlias(SqlTreeAlias alias) { + void parseTableAlias(SqlTreeAlias alias) { if (dbWhere != null) { // use the where table alias dbWhere = alias.parseWhere(dbWhere); @@ -399,53 +399,53 @@ public class CQueryPredicates { /** * Return the db update set clause for an UpdateQuery. */ - public String getDbUpdateClause() { + String getDbUpdateClause() { return dbUpdateClause; } /** * Return the db column version of the combined where clause. */ - public String getDbHaving() { + String getDbHaving() { return dbHaving; } /** * Return the db column version of the combined where clause. */ - public String getDbWhere() { + String getDbWhere() { return dbWhere; } /** * Return a db filter for filtering many fetch joins. */ - public String getDbFilterMany() { + String getDbFilterMany() { return dbFilterMany; } /** * Return the db column version of the order by clause. */ - public String getDbOrderBy() { + String getDbOrderBy() { return dbOrderBy; } /** * Return the includes required for the where and order by clause. */ - public Set getPredicateIncludes() { + Set getPredicateIncludes() { return predicateIncludes; } /** * Return the orderBy includes. */ - public Set getOrderByIncludes() { + Set getOrderByIncludes() { return orderByIncludes; } - public String getLogWhereSql() { + String getLogWhereSql() { if (dbWhere == null && dbFilterMany == null) { return ""; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java index 8949b4868..58d2a3b75 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java @@ -14,7 +14,7 @@ import java.sql.SQLException; /** * Executes the select row count query. */ -public class CQueryRowCount { +class CQueryRowCount { /** * The overall find request wrapper object. @@ -54,16 +54,13 @@ public class CQueryRowCount { /** * Create the Sql select based on the request. */ - public CQueryRowCount(OrmQueryRequest request, CQueryPredicates predicates, String sql) { + CQueryRowCount(OrmQueryRequest request, CQueryPredicates predicates, String sql) { this.request = request; this.query = request.getQuery(); this.sql = sql; - query.setGeneratedSql(sql); - this.desc = request.getBeanDescriptor(); this.predicates = predicates; - } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java index e8a012af4..91b757d35 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java @@ -12,7 +12,7 @@ import java.sql.SQLException; /** * Executes the delete query. */ -public class CQueryUpdate { +class CQueryUpdate { private final OrmQueryRequest request; @@ -46,7 +46,7 @@ public class CQueryUpdate { /** * Create the Sql select based on the request. */ - public CQueryUpdate(String type, OrmQueryRequest request, CQueryPredicates predicates, String sql) { + CQueryUpdate(String type, OrmQueryRequest request, CQueryPredicates predicates, String sql) { this.type = type; this.request = request; this.query = request.getQuery(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java index 2afca3a7b..31683d361 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQuery.java @@ -10,7 +10,7 @@ import com.avaje.ebeaninternal.api.SpiQuery; * @param the entity bean type * @author rbygrave */ -public abstract class CallableQuery { +abstract class CallableQuery { protected final SpiQuery query; @@ -18,7 +18,7 @@ public abstract class CallableQuery { protected final Transaction transaction; - public CallableQuery(SpiEbeanServer server, SpiQuery query, Transaction t) { + CallableQuery(SpiEbeanServer server, SpiQuery query, Transaction t) { this.server = server; this.query = query; this.transaction = t; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java index ddba62116..67a3e7ceb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java @@ -9,7 +9,7 @@ import com.avaje.ebeaninternal.server.util.ArrayStack; import java.util.ArrayList; import java.util.HashSet; -public class DefaultDbSqlContext implements DbSqlContext { +class DefaultDbSqlContext implements DbSqlContext { private static final String COMMA = ", "; @@ -20,11 +20,11 @@ public class DefaultDbSqlContext implements DbSqlContext { private final String columnAliasPrefix; - private final ArrayStack tableAliasStack = new ArrayStack(); + private final ArrayStack tableAliasStack = new ArrayStack<>(); - private final ArrayStack joinStack = new ArrayStack(); + private final ArrayStack joinStack = new ArrayStack<>(); - private final ArrayStack prefixStack = new ArrayStack(); + private final ArrayStack prefixStack = new ArrayStack<>(); private boolean useColumnAlias; @@ -54,7 +54,7 @@ public class DefaultDbSqlContext implements DbSqlContext { /** * Construct for SELECT clause (with column alias settings). */ - public DefaultDbSqlContext(SqlTreeAlias alias, String tableAliasPlaceHolder, + DefaultDbSqlContext(SqlTreeAlias alias, String tableAliasPlaceHolder, String columnAliasPrefix, boolean alwaysUseColumnAlias, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { this.alias = alias; @@ -73,7 +73,7 @@ public class DefaultDbSqlContext implements DbSqlContext { public void addEncryptedProp(BeanProperty p) { if (encryptedProps == null) { - encryptedProps = new ArrayList(); + encryptedProps = new ArrayList<>(); } encryptedProps.add(p); } @@ -101,7 +101,7 @@ public class DefaultDbSqlContext implements DbSqlContext { public void addJoin(String type, String table, TableJoinColumn[] cols, String a1, String a2, String inheritance) { if (tableJoins == null) { - tableJoins = new HashSet(); + tableJoins = new HashSet<>(); } String joinKey = table + "-" + a1 + "-" + a2; @@ -213,7 +213,7 @@ public class DefaultDbSqlContext implements DbSqlContext { String converted = StringHelper.replaceString(sqlFormulaJoin, tableAliasPlaceHolder, tableAlias); if (formulaJoins == null) { - formulaJoins = new HashSet(); + formulaJoins = new HashSet<>(); } else if (formulaJoins.contains(converted)) { // skip adding a formula join because diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java index 497e2f173..4193e1ac1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultRelationalQueryEngine.java @@ -74,7 +74,7 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine { try { request.executeSql(binder); - List rows = new ArrayList(); + List rows = new ArrayList<>(); while (request.next()) { rows.add(readRow(request)); } @@ -102,7 +102,7 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine { /** * Read the row from the ResultSet and return as a MapBean. */ - protected SqlRow readRow(RelationalQueryRequest request) throws SQLException { + private SqlRow readRow(RelationalQueryRequest request) throws SQLException { return request.createNewRow(dbTrueValue); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java index 80e7e8ff6..ee4024ee7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java @@ -51,7 +51,7 @@ public class DefaultSqlRow implements SqlRow { *

*/ public DefaultSqlRow(int initialCapacity, float loadFactor, String dbTrueValue) { - this.map = new LinkedHashMap(initialCapacity, loadFactor); + this.map = new LinkedHashMap<>(initialCapacity, loadFactor); this.dbTrueValue = dbTrueValue; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java index bf0d595cf..a96a524c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureIds.java @@ -15,7 +15,7 @@ public class QueryFutureIds extends BaseFuture> implements Futur private final CallableQueryIds call; public QueryFutureIds(CallableQueryIds call) { - super(new FutureTask>(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java index 74779df8c..73dc46a65 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java @@ -20,7 +20,7 @@ public class QueryFutureList extends BaseFuture> implements FutureLis private final CallableQueryList call; public QueryFutureList(CallableQueryList call) { - super(new FutureTask>(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java index 970e3fe91..a19626bc1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java @@ -14,7 +14,7 @@ public class QueryFutureRowCount extends BaseFuture implements Futur private final CallableQueryRowCount call; public QueryFutureRowCount(CallableQueryRowCount call) { - super(new FutureTask(call)); + super(new FutureTask<>(call)); this.call = call; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java index f26301ba3..476c3d118 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java @@ -5,14 +5,14 @@ import com.avaje.ebeaninternal.api.CQueryPlanKey; /** * QueryPlanKey for RawSql queries. */ -public class RawSqlQueryPlanKey implements CQueryPlanKey { +class RawSqlQueryPlanKey implements CQueryPlanKey { private final String sql; private final boolean rawSql; private final boolean rowNumberIncluded; private final String logWhereSql; - public RawSqlQueryPlanKey(String sql, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { + RawSqlQueryPlanKey(String sql, boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { this.sql = sql; this.rawSql = rawSql; this.rowNumberIncluded = rowNumberIncluded; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java index c6395dd37..c61077d6c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java @@ -26,7 +26,7 @@ public class SqlBeanLoad { private final boolean refreshLoading; private final boolean rawSql; - public SqlBeanLoad(DbReadContext ctx, Class type, EntityBean bean, Mode queryMode) { + SqlBeanLoad(DbReadContext ctx, Class type, EntityBean bean, Mode queryMode) { this.ctx = ctx; this.rawSql = ctx.isRawSql(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java index 523414f2a..97d64134f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java @@ -11,7 +11,7 @@ import java.util.Set; /** * Represents the SELECT clause part of the SQL query. */ -public class SqlTree { +class SqlTree { private final SqlTreeNode rootNode; @@ -48,7 +48,7 @@ public class SqlTree { /** * Create the SqlSelectClause. */ - public SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String groupBy, String inheritanceWhereSql, + SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String groupBy, String inheritanceWhereSql, BeanProperty[] encryptedProps, BeanPropertyAssocMany manyProperty, Set includes, boolean includeJoins) { this.summary = summary; @@ -66,21 +66,21 @@ public class SqlTree { /** * Return true if the query includes joins (not valid for rawSql). */ - public boolean isIncludeJoins() { + boolean isIncludeJoins() { return includeJoins; } /** * Recurse through the tree adding an table alias' for @History entity beans. */ - public void addAsOfTableAlias(SpiQuery query) { + void addAsOfTableAlias(SpiQuery query) { rootNode.addAsOfTableAlias(query); } /** * Recurse through the tree adding soft delete predicates as necessary. */ - public void addSoftDeletePredicate(SpiQuery query) { + void addSoftDeletePredicate(SpiQuery query) { rootNode.addSoftDeletePredicate(query); } @@ -88,7 +88,7 @@ public class SqlTree { * Build a select expression chain for RawSql. */ public List buildRawSqlSelectChain() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); rootNode.buildRawSqlSelectChain(list); return list; } @@ -103,25 +103,25 @@ public class SqlTree { /** * Return the String for the actual SQL. */ - public String getSelectSql() { + String getSelectSql() { return selectSql; } - public String getFromSql() { + String getFromSql() { return fromSql; } /** * Return the groupBy clause. */ - public String getGroupBy() { + String getGroupBy() { return groupBy; } /** * Return the where clause for inheritance. */ - public String getInheritanceWhereSql() { + String getInheritanceWhereSql() { return inheritanceWhereSql; } @@ -132,7 +132,7 @@ public class SqlTree { return summary; } - public SqlTreeNode getRootNode() { + SqlTreeNode getRootNode() { return rootNode; } @@ -140,18 +140,18 @@ public class SqlTree { * Return the property that is associated with the many. There can only be one * per SqlSelect. This can be null. */ - public BeanPropertyAssocMany getManyProperty() { + BeanPropertyAssocMany getManyProperty() { return manyProperty; } - public BeanProperty[] getEncryptedProps() { + BeanProperty[] getEncryptedProps() { return encryptedProps; } /** * Return true if the query has a many join. */ - public boolean hasMany() { + boolean hasMany() { return manyProperty != null || rootNode.hasMany(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java index 1fe2b1a7f..5f06cb226 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeAlias.java @@ -13,32 +13,32 @@ import java.util.TreeSet; /** * Special Map of the logical property joins to table alias. */ -public class SqlTreeAlias { +class SqlTreeAlias { private int counter; private int manyWhereCounter; - private final TreeSet joinProps = new TreeSet(); + private final TreeSet joinProps = new TreeSet<>(); private HashSet embeddedPropertyJoins; - private final TreeSet manyWhereJoinProps = new TreeSet(); + private final TreeSet manyWhereJoinProps = new TreeSet<>(); - private final HashMap aliasMap = new HashMap(); + private final HashMap aliasMap = new HashMap<>(); - private final HashMap manyWhereAliasMap = new HashMap(); + private final HashMap manyWhereAliasMap = new HashMap<>(); private final String rootTableAlias; - public SqlTreeAlias(String rootTableAlias) { + SqlTreeAlias(String rootTableAlias) { this.rootTableAlias = rootTableAlias; } /** * Add joins to support where predicates */ - public void addManyWhereJoins(Set manyWhereJoins) { + void addManyWhereJoins(Set manyWhereJoins) { if (manyWhereJoins != null) { for (String include : manyWhereJoins) { addPropertyJoin(include, manyWhereJoinProps); @@ -48,7 +48,7 @@ public class SqlTreeAlias { private void addEmbeddedPropertyJoin(String embProp) { if (embeddedPropertyJoins == null) { - embeddedPropertyJoins = new HashSet(); + embeddedPropertyJoins = new HashSet<>(); } embeddedPropertyJoins.add(embProp); } @@ -85,7 +85,7 @@ public class SqlTreeAlias { /** * Build a set of table alias for the given bean and fetch joined properties. */ - public void buildAlias() { + void buildAlias() { for (String joinProp : joinProps) { calcAlias(joinProp); @@ -125,7 +125,7 @@ public class SqlTreeAlias { /** * Return the table alias for a given property name. */ - public String getTableAlias(String prefix) { + String getTableAlias(String prefix) { if (prefix == null) { return rootTableAlias; } else { @@ -140,7 +140,7 @@ public class SqlTreeAlias { /** * Return an alias using "Many where joins". */ - public String getTableAliasManyWhere(String prefix) { + String getTableAliasManyWhere(String prefix) { if (prefix == null) { return rootTableAlias; } @@ -158,7 +158,7 @@ public class SqlTreeAlias { /** * Parse for where clauses that uses "Many where joins" */ - public String parseWhere(String clause) { + String parseWhere(String clause) { clause = parseRootAlias(clause); clause = parseAliasMap(clause, manyWhereAliasMap); return parseAliasMap(clause, aliasMap); @@ -211,7 +211,7 @@ public class SqlTreeAlias { /** * Return true if there are joins included in the query. */ - public boolean isIncludeJoins() { + boolean isIncludeJoins() { return !aliasMap.isEmpty() || !manyWhereAliasMap.isEmpty(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index ff3597337..519b6d88c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -55,7 +55,7 @@ public class SqlTreeBuilder { private final DefaultDbSqlContext ctx; - private final HashSet selectIncludes = new HashSet(); + private final HashSet selectIncludes = new HashSet<>(); private final ManyWhereJoins manyWhereJoins; @@ -139,7 +139,7 @@ public class SqlTreeBuilder { encryptedProps = ctx.getEncryptedProps(); } - boolean includeJoins = (alias == null) ? false : alias.isIncludeJoins(); + boolean includeJoins = alias != null && alias.isIncludeJoins(); return new SqlTree(summary.toString(), rootNode, selectSql, fromSql, groupBy, inheritanceWhereSql, encryptedProps, manyProperty, queryDetail.getFetchPaths(), includeJoins); @@ -216,7 +216,7 @@ public class SqlTreeBuilder { private SqlTreeNode buildSelectChain(String prefix, BeanPropertyAssoc prop, BeanDescriptor desc, List joinList) { - List myJoinList = new ArrayList(); + List myJoinList = new ArrayList<>(); BeanPropertyAssocOne[] ones = desc.propertiesOne(); for (int i = 0; i < ones.length; i++) { @@ -468,8 +468,6 @@ public class SqlTreeBuilder { } } - selectProps.setTableJoins(desc.tableJoins()); - InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { // add sub type properties @@ -542,12 +540,12 @@ public class SqlTreeBuilder { /** * Contains the 'root' extra joins. We only return the roots back. */ - private final Map joinRegister = new HashMap(); + private final Map joinRegister = new HashMap<>(); /** * Register of all the extra join nodes. */ - private final Map rootRegister = new HashMap(); + private final Map rootRegister = new HashMap<>(); private final BeanDescriptor desc; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java index aa7031b1b..c739fa3f6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -142,7 +142,7 @@ class SqlTreeNodeBean implements SqlTreeNode { BeanPropertyAssocMany[] manys = desc.propertiesMany(); - HashMap m = new HashMap(); + HashMap m = new HashMap<>(); for (int i = 0; i < manys.length; i++) { String name = manys[i].getName(); m.put(name, getPath(prefix, name)); @@ -190,7 +190,7 @@ class SqlTreeNodeBean implements SqlTreeNode { Timestamp end = ctx.getDataReader().getTimestamp(); T bean = (T) load(ctx, null, null); - return new Version(bean, start, end); + return new Version<>(bean, start, end); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index cd31bc405..e5977e4a5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -77,7 +77,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { * This means we need to add distinct to the sql query. *

*/ - public boolean isManyJoin() { + boolean isManyJoin() { return manyJoin; } @@ -87,7 +87,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { public void addChild(SqlTreeNodeExtraJoin child) { if (children == null) { - children = new ArrayList(); + children = new ArrayList<>(); } children.add(child); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java index a753d5a25..30d0d2301 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeManyWhereJoin.java @@ -30,7 +30,7 @@ class SqlTreeNodeManyWhereJoin implements SqlTreeNode { */ private final SqlJoinType manyJoinType; - public SqlTreeNodeManyWhereJoin(String prefix, BeanPropertyAssoc prop, SqlJoinType manyJoinType) { + SqlTreeNodeManyWhereJoin(String prefix, BeanPropertyAssoc prop, SqlJoinType manyJoinType) { this.nodeBeanProp = prop; this.prefix = prefix; @@ -80,7 +80,7 @@ class SqlTreeNodeManyWhereJoin implements SqlTreeNode { * Join to base table for this node. This includes a join to the * intersection table if this is a ManyToMany node. */ - public void appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { + void appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) { String alias = ctx.getTableAliasManyWhere(prefix); String parentAlias = ctx.getTableAliasManyWhere(parentPrefix); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java index a0b386b81..9d03aae91 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -18,7 +18,7 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { /** * Specify for SqlSelect to include an Id property or not. */ - public SqlTreeNodeRoot(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, + SqlTreeNodeRoot(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, TableJoin includeJoin, BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { super(desc, props, myList, withId, many, temporalMode, disableLazyLoad); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java index 8b519f851..df298ab4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java @@ -1,45 +1,40 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebeaninternal.api.ManyWhereJoins; +import com.avaje.ebeaninternal.server.deploy.BeanProperty; + import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; -import com.avaje.ebeaninternal.api.ManyWhereJoins; -import com.avaje.ebeaninternal.server.deploy.BeanProperty; -import com.avaje.ebeaninternal.server.deploy.TableJoin; - /** * The select properties for a node in the SqlTree. */ public class SqlTreeProperties { - private static final TableJoin[] EMPTY_TABLE_JOINS = new TableJoin[0]; - /** * True if this node of the tree should have read only entity beans. */ private boolean readOnly; - private TableJoin[] tableJoins = EMPTY_TABLE_JOINS; - /** * The bean properties in order. */ - private final List propsList = new ArrayList(); + private final List propsList = new ArrayList<>(); /** * Maintain a list of property names to detect embedded bean additions. */ - private final LinkedHashSet propNames = new LinkedHashSet(); + private final LinkedHashSet propNames = new LinkedHashSet<>(); private boolean allProperties; private boolean aggregation; - public SqlTreeProperties() { + SqlTreeProperties() { } - public boolean containsProperty(String propName) { + boolean containsProperty(String propName) { return propNames.contains(propName); } @@ -59,7 +54,7 @@ public class SqlTreeProperties { return propsList.toArray(new BeanProperty[propsList.size()]); } - public boolean isPartialObject() { + boolean isPartialObject() { return !allProperties; } @@ -71,15 +66,7 @@ public class SqlTreeProperties { this.readOnly = readOnly; } - public TableJoin[] getTableJoins() { - return tableJoins; - } - - public void setTableJoins(TableJoin[] tableJoins) { - this.tableJoins = tableJoins; - } - - public void setAllProperties() { + void setAllProperties() { this.allProperties = true; } @@ -89,7 +76,7 @@ public class SqlTreeProperties { * Return true if a Sql distinct is required. *

*/ - public boolean requireSqlDistinct(ManyWhereJoins manyWhereJoins) { + boolean requireSqlDistinct(ManyWhereJoins manyWhereJoins) { String joinProperty = aggregationJoin(); if (joinProperty != null) { aggregation = true; From 201a2826aba32169504a8f71fab7322fa9316d54 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 22:46:43 +1300 Subject: [PATCH 05/87] Refactor - tidy up in com.avaje.ebeaninternal.server.querydefn, no effective change --- .../avaje/ebeaninternal/api/SpiSqlQuery.java | 5 --- .../server/querydefn/DefaultOrmQuery.java | 30 +++++++-------- .../querydefn/DefaultRelationalQuery.java | 12 ------ .../server/querydefn/ONamedParam.java | 6 +-- .../server/querydefn/OrmQueryDetail.java | 20 +++++----- .../server/querydefn/OrmQueryPlanKey.java | 4 +- .../server/querydefn/OrmQueryProperties.java | 38 +++++++++---------- .../querydefn/OrmQueryPropertiesParser.java | 10 ++--- .../server/querydefn/OrmQuerySecondary.java | 4 +- .../server/querydefn/OrmUpdateProperties.java | 16 ++++---- .../server/querydefn/SimpleTextParser.java | 4 +- 11 files changed, 64 insertions(+), 85 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java index 292d47bf3..51a7f1c0e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java @@ -39,9 +39,4 @@ public interface SpiSqlQuery extends SqlQuery { */ int getBufferFetchSizeHint(); - /** - * Set the PreparedStatement for the purposes of supporting cancel. - */ - void setPreparedStatement(PreparedStatement pstmt); - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index d47ed43e3..240cf50c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -41,7 +41,7 @@ import java.util.Set; */ public class DefaultOrmQuery implements SpiQuery { - public static final String DEFAULT_QUERY_NAME = "default"; + private static final String DEFAULT_QUERY_NAME = "default"; private static final FetchConfig FETCH_QUERY = new FetchConfig().query(); @@ -276,7 +276,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public void addSoftDeletePredicate(String softDeletePredicate) { if (softDeletePredicates == null) { - softDeletePredicates = new ArrayList(); + softDeletePredicates = new ArrayList<>(); } softDeletePredicates.add(softDeletePredicate); } @@ -407,7 +407,7 @@ public class DefaultOrmQuery implements SpiQuery { return false; } - protected List removeQueryJoins() { + private List removeQueryJoins() { List queryJoins = detail.removeSecondaryQueries(); if (queryJoins != null) { if (orderBy != null) { @@ -435,7 +435,7 @@ public class DefaultOrmQuery implements SpiQuery { return queryJoins; } - protected List removeLazyJoins() { + private List removeLazyJoins() { return detail.removeSecondaryLazyQueries(); } @@ -470,10 +470,6 @@ public class DefaultOrmQuery implements SpiQuery { return true; } - protected void setOrmQueryDetail(OrmQueryDetail detail) { - this.detail = detail; - } - @Override public void setDefaultSelectClause() { detail.setDefaultSelectClause(beanDescriptor); @@ -603,7 +599,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public DefaultOrmQuery copy(EbeanServer server) { - DefaultOrmQuery copy = new DefaultOrmQuery(beanDescriptor, server, expressionFactory); + DefaultOrmQuery copy = new DefaultOrmQuery<>(beanDescriptor, server, expressionFactory); copy.m2mIncludeJoin = m2mIncludeJoin; copy.profilingListener = profilingListener; @@ -833,7 +829,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public void logSecondaryQuery(SpiQuery query) { if (loggedSecondaryQueries == null) { - loggedSecondaryQueries = new ArrayList>(); + loggedSecondaryQueries = new ArrayList<>(); } loggedSecondaryQueries.add(query); } @@ -1093,7 +1089,7 @@ public class DefaultOrmQuery implements SpiQuery { } @Override - public List findIds() { + public List findIds() { // a copy of this query is made in the server // as the query needs to modified (so we modify // the copy rather than this query instance) @@ -1234,7 +1230,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public OrderBy order() { if (orderBy == null) { - orderBy = new OrderBy(this, null); + orderBy = new OrderBy<>(this, null); } return orderBy; } @@ -1249,7 +1245,7 @@ public class DefaultOrmQuery implements SpiQuery { if (orderByClause == null || orderByClause.trim().isEmpty()) { this.orderBy = null; } else { - this.orderBy = new OrderBy(this, orderByClause); + this.orderBy = new OrderBy<>(this, orderByClause); } return this; } @@ -1393,7 +1389,7 @@ public class DefaultOrmQuery implements SpiQuery { public ExpressionList text() { if (textExpressions == null) { useDocStore = true; - textExpressions = new DefaultExpressionList(this); + textExpressions = new DefaultExpressionList<>(this); } return textExpressions; } @@ -1401,7 +1397,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public ExpressionList where() { if (whereExpressions == null) { - whereExpressions = new DefaultExpressionList(this, null); + whereExpressions = new DefaultExpressionList<>(this, null); } return whereExpressions; } @@ -1465,7 +1461,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public SpiNamedParam createNamedParameter(String name) { if (namedParams == null) { - namedParams = new HashMap(); + namedParams = new HashMap<>(); } ONamedParam param = namedParams.get(name); @@ -1586,7 +1582,7 @@ public class DefaultOrmQuery implements SpiQuery { return validation.getUnknownProperties(); } - public void setUpdateProperties(OrmUpdateProperties updateProperties) { + void setUpdateProperties(OrmUpdateProperties updateProperties) { this.updateProperties = updateProperties; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java index 97eed9b0f..578adc703 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultRelationalQuery.java @@ -7,7 +7,6 @@ import com.avaje.ebean.SqlRow; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiSqlQuery; -import java.sql.PreparedStatement; import java.util.List; /** @@ -27,11 +26,6 @@ public class DefaultRelationalQuery implements SpiSqlQuery { private int timeout; - /** - * For the purposes of cancelling the query. - */ - private transient PreparedStatement pstmt; - private int bufferFetchSizeHint; /** @@ -128,10 +122,4 @@ public class DefaultRelationalQuery implements SpiSqlQuery { return query; } - public void setPreparedStatement(PreparedStatement pstmt) { - synchronized (this) { - this.pstmt = pstmt; - } - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java index 66975ab2d..004aea830 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java @@ -7,7 +7,7 @@ import javax.persistence.PersistenceException; /** * Named parameter used as placeholder in expressions created by EQL language parsing. */ -public class ONamedParam implements SpiNamedParam { +class ONamedParam implements SpiNamedParam { private final String name; @@ -16,7 +16,7 @@ public class ONamedParam implements SpiNamedParam { /** * Create with the given name. */ - public ONamedParam(String name) { + ONamedParam(String name) { this.name = name; } @@ -37,7 +37,7 @@ public class ONamedParam implements SpiNamedParam { /** * Check the bind value has been set (so does not support null value). */ - public void checkValueSet() { + void checkValueSet() { if (value == null) { throw new PersistenceException("Named parameter ["+name+"] has not had it's value set."); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index dc284e24b..a1c388355 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -42,7 +42,7 @@ public class OrmQueryDetail implements Serializable { /** * Contains the fetch/lazy/query joins and their properties. */ - private LinkedHashMap fetchPaths = new LinkedHashMap(); + private LinkedHashMap fetchPaths = new LinkedHashMap<>(); /** * Return a deep copy of the OrmQueryDetail. @@ -168,7 +168,7 @@ public class OrmQueryDetail implements Serializable { baseProps = new OrmQueryProperties(null, columns, null); } - public boolean containsProperty(String property) { + boolean containsProperty(String property) { return baseProps.isIncluded(property); } @@ -179,17 +179,17 @@ public class OrmQueryDetail implements Serializable { this.baseProps = baseProps; } - public List removeSecondaryQueries() { + List removeSecondaryQueries() { return removeSecondaryQueries(false); } - public List removeSecondaryLazyQueries() { + List removeSecondaryLazyQueries() { return removeSecondaryQueries(true); } private List removeSecondaryQueries(boolean lazyQuery) { - ArrayList matchingPaths = new ArrayList(2); + ArrayList matchingPaths = new ArrayList<>(2); for (OrmQueryProperties chunk : fetchPaths.values()) { boolean match = lazyQuery ? chunk.isLazyFetch() : chunk.isQueryFetch(); @@ -206,7 +206,7 @@ public class OrmQueryDetail implements Serializable { Collections.sort(matchingPaths); // the list of secondary queries - ArrayList props = new ArrayList(); + ArrayList props = new ArrayList<>(); for (int i = 0; i < matchingPaths.size(); i++) { String path = matchingPaths.get(i); @@ -243,7 +243,7 @@ public class OrmQueryDetail implements Serializable { return props; } - public boolean tuneFetchProperties(OrmQueryDetail tunedDetail) { + boolean tuneFetchProperties(OrmQueryDetail tunedDetail) { boolean tuned = false; @@ -304,7 +304,7 @@ public class OrmQueryDetail implements Serializable { public void sortFetchPaths(BeanDescriptor d) { if (!fetchPaths.isEmpty()) { - LinkedHashMap sorted = new LinkedHashMap(); + LinkedHashMap sorted = new LinkedHashMap<>(); for (OrmQueryProperties p : fetchPaths.values()) { sortFetchPaths(d, p, sorted); } @@ -341,7 +341,7 @@ public class OrmQueryDetail implements Serializable { /** * Mark 'fetch joins' to 'many' properties over to 'query joins' where needed. */ - public void markQueryJoins(BeanDescriptor beanDescriptor, String lazyLoadManyPath, boolean allowOne) { + void markQueryJoins(BeanDescriptor beanDescriptor, String lazyLoadManyPath, boolean allowOne) { // the name of the many fetch property if there is one String manyFetchProperty = null; @@ -439,7 +439,7 @@ public class OrmQueryDetail implements Serializable { } } - public boolean hasSelectClause() { + private boolean hasSelectClause() { return baseProps.hasSelectClause(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java index 60b15fe5d..be40243d1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java @@ -12,7 +12,7 @@ import com.avaje.ebeaninternal.server.deploy.TableJoin; /** * Query plan key for ORM queries. */ -public class OrmQueryPlanKey implements CQueryPlanKey { +class OrmQueryPlanKey implements CQueryPlanKey { private final String m2mIncludeTable; private final String orderByAsSting; @@ -35,7 +35,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey { private final int planHash; private final int bindCount; - public OrmQueryPlanKey(TableJoin m2mIncludeTable, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) { + OrmQueryPlanKey(TableJoin m2mIncludeTable, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) { this.m2mIncludeTable = m2mIncludeTable == null ? null : m2mIncludeTable.getTable(); this.type = type; diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index 838dc8f4d..e41534c31 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -28,7 +28,7 @@ public class OrmQueryProperties implements Serializable { private static final long serialVersionUID = -8785582703966455658L; - protected static final FetchConfig DEFAULT_FETCH = new FetchConfig(); + static final FetchConfig DEFAULT_FETCH = new FetchConfig(); private final String parentPath; private final String path; @@ -160,9 +160,9 @@ public class OrmQueryProperties implements Serializable { this.readOnly = source.readOnly; this.fetchConfig = source.fetchConfig; this.filterMany = source.filterMany; - this.included = (source.included == null) ? null : new LinkedHashSet(source.included); + this.included = (source.included == null) ? null : new LinkedHashSet<>(source.included); if (includedBeanJoin != null) { - this.includedBeanJoin = new HashSet(source.includedBeanJoin); + this.includedBeanJoin = new HashSet<>(source.includedBeanJoin); } } @@ -177,7 +177,7 @@ public class OrmQueryProperties implements Serializable { * Move a OrderBy.Property from the main query to this query join. */ @SuppressWarnings("rawtypes") - public void addSecJoinOrderProperty(OrderBy.Property orderProp) { + void addSecJoinOrderProperty(OrderBy.Property orderProp) { if (orderBy == null) { orderBy = new OrderBy(); } @@ -208,7 +208,7 @@ public class OrmQueryProperties implements Serializable { /** * Return the filterMany expression list (can be null). */ - public SpiExpressionList getFilterManyTrimPath(int trimPath) { + private SpiExpressionList getFilterManyTrimPath(int trimPath) { if (filterMany == null) { return null; } @@ -264,7 +264,7 @@ public class OrmQueryProperties implements Serializable { } } - public boolean hasSelectClause() { + boolean hasSelectClause() { if ("*".equals(trimmedProperties)) { // explicitly selected all properties return true; @@ -297,7 +297,7 @@ public class OrmQueryProperties implements Serializable { return sb.toString(); } - public boolean isChild(OrmQueryProperties possibleChild) { + boolean isChild(OrmQueryProperties possibleChild) { return possibleChild.getPath().startsWith(path + "."); } @@ -306,7 +306,7 @@ public class OrmQueryProperties implements Serializable { */ public void add(OrmQueryProperties child) { if (secondaryChildren == null) { - secondaryChildren = new ArrayList(); + secondaryChildren = new ArrayList<>(); } secondaryChildren.add(child); } @@ -339,9 +339,9 @@ public class OrmQueryProperties implements Serializable { /** * Add a bean join property. */ - public void includeBeanJoin(String propertyName) { + void includeBeanJoin(String propertyName) { if (includedBeanJoin == null) { - includedBeanJoin = new HashSet(); + includedBeanJoin = new HashSet<>(); } includedBeanJoin.add(propertyName); } @@ -358,15 +358,15 @@ public class OrmQueryProperties implements Serializable { return included; } - LinkedHashSet temp = new LinkedHashSet(2 * (secondaryQueryJoins.size() + included.size())); + LinkedHashSet temp = new LinkedHashSet<>(2 * (secondaryQueryJoins.size() + included.size())); temp.addAll(included); temp.addAll(secondaryQueryJoins); return temp; } - public void addSecondaryQueryJoin(String property) { + void addSecondaryQueryJoin(String property) { if (secondaryQueryJoins == null) { - secondaryQueryJoins = new HashSet(4); + secondaryQueryJoins = new HashSet<>(4); } secondaryQueryJoins.add(property); } @@ -378,7 +378,7 @@ public class OrmQueryProperties implements Serializable { return included; } - public boolean isIncluded(String propName) { + boolean isIncluded(String propName) { if (includedBeanJoin != null && includedBeanJoin.contains(propName)) { return false; @@ -390,7 +390,7 @@ public class OrmQueryProperties implements Serializable { /** * Mark this path as needing to be a query join. */ - public void markForQueryJoin() { + void markForQueryJoin() { markForQueryJoin = true; } @@ -404,14 +404,14 @@ public class OrmQueryProperties implements Serializable { /** * Return true if this path is a 'fetch join'. */ - public boolean isFetchJoin() { + boolean isFetchJoin() { return !isQueryFetch() && !isLazyFetch(); } /** * Return true if this path is a lazy fetch. */ - public boolean isLazyFetch() { + boolean isLazyFetch() { return getLazyFetchBatch() > -1; } @@ -453,7 +453,7 @@ public class OrmQueryProperties implements Serializable { /** * Return the parent path. */ - public String getParentPath() { + String getParentPath() { return parentPath; } @@ -467,7 +467,7 @@ public class OrmQueryProperties implements Serializable { /** * Return true if the properties are the same for autoTune purposes. */ - public boolean isSameByAutoTune(OrmQueryProperties p2) { + boolean isSameByAutoTune(OrmQueryProperties p2) { if (included == null) { return p2 == null || p2.included == null; } else if (p2 == null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index eeeacc39c..b6d475c53 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -8,14 +8,14 @@ import java.util.LinkedHashSet; /** * Parses the path properties string. */ -public class OrmQueryPropertiesParser { +class OrmQueryPropertiesParser { private static Response EMPTY = new Response(); /** * Immutable response of the parsed properties and options. */ - public static class Response { + static class Response { final boolean readOnly; final boolean cache; @@ -23,7 +23,7 @@ public class OrmQueryPropertiesParser { final String properties; final LinkedHashSet included; - public Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, LinkedHashSet included) { + Response(boolean readOnly, boolean cache, int queryFetchBatch, int lazyFetchBatch, String properties, LinkedHashSet included) { this.readOnly = readOnly; this.cache = cache; this.properties = properties; @@ -35,7 +35,7 @@ public class OrmQueryPropertiesParser { } } - public Response() { + Response() { this.readOnly = false; this.cache = false; this.fetchConfig = OrmQueryProperties.DEFAULT_FETCH; @@ -116,7 +116,7 @@ public class OrmQueryPropertiesParser { String[] res = inputProperties.split(","); StringBuilder sb = new StringBuilder(70); - LinkedHashSet propertySet = new LinkedHashSet(res.length * 2); + LinkedHashSet propertySet = new LinkedHashSet<>(res.length * 2); int count = 0; String temp; diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java index 85abbb7bc..f423d05bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQuerySecondary.java @@ -7,7 +7,7 @@ import java.util.List; /** * The secondary query paths for 'query joins' and 'lazy loading'. */ -public class OrmQuerySecondary implements SpiQuerySecondary { +class OrmQuerySecondary implements SpiQuerySecondary { private final List queryJoins; @@ -16,7 +16,7 @@ public class OrmQuerySecondary implements SpiQuerySecondary { /** * Construct with the 'query join' and 'lazy join' path properties. */ - public OrmQuerySecondary(List queryJoins, List lazyJoins) { + OrmQuerySecondary(List queryJoins, List lazyJoins) { this.queryJoins = queryJoins; this.lazyJoins = lazyJoins; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java index d3ed01562..cb5ebaaa8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java @@ -41,7 +41,7 @@ public class OrmUpdateProperties { /** * Set property to null. */ - static class NullValue extends Value { + private static class NullValue extends Value { @Override public String bindClause() { return "=null"; @@ -51,7 +51,7 @@ public class OrmUpdateProperties { /** * Set property to a simple value. */ - static class SimpleValue extends Value { + private static class SimpleValue extends Value { final Object value; @@ -79,7 +79,7 @@ public class OrmUpdateProperties { /** * Set using an expression with no bind value. */ - static class NoneValue extends Value { + private static class NoneValue extends Value { @Override public String bindClause() { return ""; @@ -89,11 +89,11 @@ public class OrmUpdateProperties { /** * Set using an expression with many bind values. */ - static class RawArrayValue extends Value { + private static class RawArrayValue extends Value { final Object[] bindValues; - public RawArrayValue(Object[] bindValues) { + RawArrayValue(Object[] bindValues) { this.bindValues = bindValues; } @@ -114,7 +114,7 @@ public class OrmUpdateProperties { /** * The set properties/expressions and their bind values. */ - private LinkedHashMap values = new LinkedHashMap(); + private LinkedHashMap values = new LinkedHashMap<>(); /** * Normal set property. @@ -138,7 +138,7 @@ public class OrmUpdateProperties { /** * Set a raw expression with many bind values. */ - public void setRaw(String propertyExpression, Object... vals) { + void setRaw(String propertyExpression, Object... vals) { if (vals.length == 0) { setRaw(propertyExpression); } else { @@ -157,7 +157,7 @@ public class OrmUpdateProperties { /** * Build the hash for the query plan caching. */ - public void buildQueryPlanHash(HashQueryPlanBuilder builder) { + void buildQueryPlanHash(HashQueryPlanBuilder builder) { builder.add(OrmUpdateProperties.class); Set> entries = values.entrySet(); for (Map.Entry entry : entries) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java index 345503966..cfae419ca 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/SimpleTextParser.java @@ -24,7 +24,7 @@ public class SimpleTextParser { return pos; } - public String getOql() { + String getOql() { return oql; } @@ -32,7 +32,7 @@ public class SimpleTextParser { return word; } - public String peekNextWord() { + private String peekNextWord() { int origPos = pos; String nw = nextWordInternal(); pos = origPos; From e83556cada5ab2bbd1f35a43131e47a7df713a18 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 22:51:51 +1300 Subject: [PATCH 06/87] Refactor - clean up OrmQueryDetailParser, remove unused sections --- .../querydefn/OrmQueryDetailParser.java | 90 ------------------- 1 file changed, 90 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java index 83e0c04b4..a84cfad46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java @@ -13,14 +13,6 @@ public class OrmQueryDetailParser { private final OrmQueryDetail detail = new OrmQueryDetail(); - private int maxRows; - - private int firstRow; - - private String rawWhereClause; - - private String rawOrderBy; - private final SimpleTextParser parser; public OrmQueryDetailParser(String oql) { @@ -57,94 +49,12 @@ public class OrmQueryDetailParser { private void process() { if (isFetch()) { detail.fetch(readFindFetch()); - - } else if (parser.isMatch("where")) { - readWhere(); - - } else if (parser.isMatch("order", "by")) { - readOrderBy(); - - } else if (parser.isMatch("limit")) { - readLimit(); - } else { throw new PersistenceException("Query expected 'fetch', 'where','order by' or 'limit' keyword but got [" + parser.getWord() + "] \r " + parser.getOql()); } } - private void readLimit() { - try { - String maxLimit = parser.nextWord(); - maxRows = Integer.parseInt(maxLimit); - - String offsetKeyword = parser.nextWord(); - if (offsetKeyword != null) { - if (!parser.isMatch("offset")) { - throw new PersistenceException("expected offset keyword but got " + parser.getWord()); - } - String firstRowLimit = parser.nextWord(); - firstRow = Integer.parseInt(firstRowLimit); - parser.nextWord(); - } - } catch (NumberFormatException e) { - String msg = "Expected an integer for maxRows or firstRows in limit offset clause"; - throw new PersistenceException(msg, e); - } - } - - private void readOrderBy() { - // read the by - parser.nextWord(); - - StringBuilder sb = new StringBuilder(); - while (parser.nextWord() != null) { - if (parser.isMatch("limit")) { - break; - } else { - String w = parser.getWord(); - if (!w.startsWith("(")) { - sb.append(" "); - } - sb.append(w); - } - } - rawOrderBy = sb.toString().trim(); - - if (!parser.isFinished()) { - readLimit(); - } - } - - private void readWhere() { - - int nextMode = 0; - StringBuilder sb = new StringBuilder(); - while ((parser.nextWord()) != null) { - if (parser.isMatch("order", "by")) { - nextMode = 1; - break; - - } else if (parser.isMatch("limit")) { - nextMode = 2; - break; - - } else { - sb.append(" ").append(parser.getWord()); - } - } - String whereClause = sb.toString().trim(); - if (!whereClause.isEmpty()) { - rawWhereClause = whereClause; - } - - if (nextMode == 1) { - readOrderBy(); - } else if (nextMode == 2) { - readLimit(); - } - } - private void readSelect() { String props = parser.nextWord(); if (props.startsWith("(")) { From e5356e711868c72ca6f463de47f01eb5ff194e29 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 23:01:03 +1300 Subject: [PATCH 07/87] Refactor - tidy up in com.avaje.ebeaninternal util, no effective change --- .../server/util/BeanCollectionFactory.java | 43 ------------------- .../server/util/BindParamsParser.java | 22 +--------- .../ebeaninternal/util/SortByClause.java | 10 ++--- .../util/SortByClauseParser.java | 2 +- 4 files changed, 8 insertions(+), 69 deletions(-) delete mode 100644 src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java b/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java deleted file mode 100644 index 0bb17902e..000000000 --- a/src/main/java/com/avaje/ebeaninternal/server/util/BeanCollectionFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.avaje.ebeaninternal.server.util; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; - -import com.avaje.ebean.bean.BeanCollection; -import com.avaje.ebean.common.BeanList; -import com.avaje.ebean.common.BeanMap; -import com.avaje.ebean.common.BeanSet; -import com.avaje.ebeaninternal.api.SpiQuery; - -/** - * Creates the BeanCollections. - *

- * Creates the BeanSet BeanMap and BeanList objects. - *

- */ -public class BeanCollectionFactory { - - private static final int defaultListInitialCapacity = 20; - private static final int defaultSetInitialCapacity = 32; - private static final int defaultMapInitialCapacity = 32; - - /** - * Create a BeanCollection for the given parameters. - */ - public static BeanCollection create(SpiQuery.Type manyType) { - - switch (manyType) { - case MAP: - return new BeanMap<>(new LinkedHashMap<>(defaultMapInitialCapacity)); - case LIST: - return new BeanList<>(new ArrayList<>(defaultListInitialCapacity)); - case SET: - return new BeanSet<>(new LinkedHashSet<>(defaultSetInitialCapacity)); - - default: - throw new RuntimeException("Invalid Arg " + manyType); - } - } - -} diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java b/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java index 644181e38..6c7113605 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java @@ -18,8 +18,8 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; */ public class BindParamsParser { - public static final String ENCRYPTKEY_PREFIX = "encryptkey_"; - public static final String ENCRYPTKEY_GAP = "___"; + private static final String ENCRYPTKEY_PREFIX = "encryptkey_"; + private static final String ENCRYPTKEY_GAP = "___"; private static final int ENCRYPTKEY_PREFIX_LEN = ENCRYPTKEY_PREFIX.length(); private static final int ENCRYPTKEY_GAP_LEN = ENCRYPTKEY_GAP.length(); @@ -47,30 +47,12 @@ public class BindParamsParser { return new BindParamsParser(params, sql, beanDescriptor).parseSql(); } - public static OrderedList parseNamedParams(BindParams params, String sql) { - return new BindParamsParser(params, sql, null).parseSqlNamedParams(); - } - private BindParamsParser(BindParams params, String sql, BeanDescriptor beanDescriptor) { this.params = params; this.sql = sql; this.beanDescriptor = beanDescriptor; } - /** - * Used for parsing having clauses with named parameters. - *

- * The issue here is that BindParams contains named parameters for - * both where and having clauses. BindParams.positionedParameters is - * used for the where and the OrderedList for the having. - *

- */ - private OrderedList parseSqlNamedParams() { - OrderedList orderedList = new OrderedList(); - parseNamedParams(orderedList); - return orderedList; - } - /** * Parse the sql changed named parameters to positioned parameters if required. *

diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java index c0b2806ac..dde8dd930 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClause.java @@ -12,22 +12,22 @@ import java.util.List; */ public class SortByClause { - public static final String NULLSHIGH = "nullshigh"; + static final String NULLSHIGH = "nullshigh"; - public static final String NULLSLOW = "nullslow"; + static final String NULLSLOW = "nullslow"; /** * The ascending keyword. */ - public static final String ASC = "asc"; + static final String ASC = "asc"; /** * The descending keyword. */ - public static final String DESC = "desc"; + static final String DESC = "desc"; - private final List properties = new ArrayList(); + private final List properties = new ArrayList<>(); /** * Return the number of properties in the clause. diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java index 18ce90867..b40a596a1 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java @@ -83,7 +83,7 @@ public final class SortByClauseParser { if (SortByClause.DESC.equalsIgnoreCase(word)) { return false; } - String m = "Expection ASC or DESC but got [" + word + "] in [" + rawSortBy + "]"; + String m = "Expect ASC or DESC but got [" + word + "] in [" + rawSortBy + "]"; throw new RuntimeException(m); } From 54d7a6fb42b4fbd3f4fe909bb47d1ea94d55d65b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 5 Nov 2016 23:04:33 +1300 Subject: [PATCH 08/87] Refactor - clean up docstore api mapping, diamond operator only --- .../docstore/api/mapping/DocMappingBuilder.java | 6 +++--- .../docstore/api/mapping/DocPropertyMapping.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java index 9f3ab7d23..434f7cc3f 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java @@ -18,9 +18,9 @@ public class DocMappingBuilder { private final DocStore docStore; - private final Stack properties = new Stack(); + private final Stack properties = new Stack<>(); - private final Map map = new LinkedHashMap(); + private final Map map = new LinkedHashMap<>(); /** * Create with the document structure paths and docStore deployment annotation. @@ -124,7 +124,7 @@ public class DocMappingBuilder { */ private static class SortableVisitor extends DocPropertyAdapter { - private Map sortableMap = new LinkedHashMap(); + private Map sortableMap = new LinkedHashMap<>(); @Override public void visitProperty(DocPropertyMapping property) { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java index 24681d85e..515aeb601 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java @@ -16,7 +16,7 @@ public class DocPropertyMapping { private DocPropertyOptions options; - private List children = new ArrayList(); + private List children = new ArrayList<>(); /** * Construct ROOT. From d84080fb76bb30c75ec95a6064dfb8ea880434f9 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 6 Nov 2016 19:45:46 +1300 Subject: [PATCH 09/87] Refactor - clean up DefaultTypeManager, diamond operator and access modifiers only --- .../server/type/DefaultTypeManager.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 6ef22fba2..ef34b6fec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -145,7 +145,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { private final ScalarType classType = new ScalarTypeClass(); - private final List> customScalarTypes = new ArrayList>(); + private final List> customScalarTypes = new ArrayList<>(); private final CheckImmutable checkImmutable; @@ -198,9 +198,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { this.checkImmutable = new CheckImmutable(this); this.reflectScalarBuilder = new ReflectionBasedTypeBuilder(this); - this.compoundTypeMap = new ConcurrentHashMap, CtCompoundType>(); - this.typeMap = new ConcurrentHashMap, ScalarType>(); - this.nativeMap = new ConcurrentHashMap>(); + this.compoundTypeMap = new ConcurrentHashMap<>(); + this.typeMap = new ConcurrentHashMap<>(); + this.nativeMap = new ConcurrentHashMap<>(); boolean objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent(); this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null; @@ -330,7 +330,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { logAdd(scalarType); } - protected void logAdd(ScalarType scalarType) { + private void logAdd(ScalarType scalarType) { if (logger.isDebugEnabled()) { String msg = "ScalarType register [" + scalarType.getClass().getName() + "]"; msg += " for [" + scalarType.getType().getName() + "]"; @@ -379,7 +379,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return null; } - public ScalarDataReader getScalarDataReader(Class propertyType, int sqlType) { + private ScalarDataReader getScalarDataReader(Class propertyType, int sqlType) { if (sqlType == 0) { return recursiveCreateScalarDataReader(propertyType); @@ -398,7 +398,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { throw new RuntimeException(msg); } - public ScalarDataReader getScalarDataReader(Class type) { + private ScalarDataReader getScalarDataReader(Class type) { ScalarDataReader reader = typeMap.get(type); if (reader == null) { reader = compoundTypeMap.get(type); @@ -585,7 +585,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return value; } - protected boolean isIntegerType(String s) { + boolean isIntegerType(String s) { if (isLeadingZeros(s)) { return false; } @@ -614,7 +614,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { boolean integerType = true; - Map nameValueMap = new HashMap(); + Map nameValueMap = new HashMap<>(); Field[] fields = enumType.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { @@ -668,7 +668,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { */ private ScalarType createEnumScalarTypeDbValue(Class> enumType, Method method, boolean integerType) { - Map nameValueMap = new HashMap(); + Map nameValueMap = new HashMap<>(); Enum[] enumConstants = enumType.getEnumConstants(); for (int i = 0; i < enumConstants.length; i++) { @@ -723,7 +723,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * interface and register it with this TypeManager. *

*/ - protected void initialiseCustomScalarTypes(JsonConfig.DateTime mode, BootupClasses bootupClasses) { + private void initialiseCustomScalarTypes(JsonConfig.DateTime mode, BootupClasses bootupClasses) { ScalarTypeLongToTimestamp longToTimestamp = new ScalarTypeLongToTimestamp(mode); @@ -773,7 +773,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } @SuppressWarnings({"unchecked", "rawtypes"}) - protected void initialiseScalarConverters(BootupClasses bootupClasses) { + private void initialiseScalarConverters(BootupClasses bootupClasses) { List>> foundTypes = bootupClasses.getScalarConverters(); @@ -809,7 +809,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } - protected void initialiseCompoundTypes(BootupClasses bootupClasses) { + private void initialiseCompoundTypes(BootupClasses bootupClasses) { List>> compoundTypes = bootupClasses.getCompoundTypes(); for (int j = 0; j < compoundTypes.size(); j++) { @@ -835,7 +835,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } @SuppressWarnings({"unchecked", "rawtypes"}) - protected CtCompoundType createCompoundScalarDataReader(Class compoundTypeClass, CompoundType compoundType, String info) { + private CtCompoundType createCompoundScalarDataReader(Class compoundTypeClass, CompoundType compoundType, String info) { CtCompoundType ctCompoundType = compoundTypeMap.get(compoundTypeClass); if (ctCompoundType != null) { @@ -890,7 +890,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { /** * Add support for Jackson's JsonNode mapping to Clob, Blob, Varchar, JSON and JSONB. */ - protected void initialiseJacksonTypes(ServerConfig config) { + private void initialiseJacksonTypes(ServerConfig config) { if (objectMapper != null) { @@ -913,7 +913,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } } - protected void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { if (java7Present) { typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); @@ -950,7 +950,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * Detect if Joda classes are in the classpath and if so register the Joda * data types. */ - protected void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { // detect if Joda classes are in the classpath if (config.getClassLoadConfig().isJodaTimePresent()) { @@ -978,7 +978,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { * Register all the standard types supported. This is the standard JDBC types * plus some other common types such as java.util.Date and java.util.Calendar. */ - protected void initialiseStandard(JsonConfig.DateTime mode, ServerConfig config) { + private void initialiseStandard(JsonConfig.DateTime mode, ServerConfig config) { DatabasePlatform databasePlatform = config.getDatabasePlatform(); int platformClobType = databasePlatform.getClobDbType(); @@ -1043,7 +1043,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.CLOB, clobType); } else { // for Postgres Clobs handled by Varchar ScalarType... - ScalarType platClobScalarType = nativeMap.get(Integer.valueOf(platformClobType)); + ScalarType platClobScalarType = nativeMap.get(platformClobType); if (platClobScalarType == null) { throw new IllegalArgumentException("Type for dbPlatform clobType [" + clobType + "] not found."); } @@ -1060,7 +1060,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.BLOB, blobType); } else { // for Postgres Blobs handled by LongVarbinary ScalarType... - ScalarType platBlobScalarType = nativeMap.get(Integer.valueOf(platformBlobType)); + ScalarType platBlobScalarType = nativeMap.get(platformBlobType); if (platBlobScalarType == null) { throw new IllegalArgumentException("Type for dbPlatform blobType [" + blobType + "] not found."); } From 2a6d38eef2cf683aa5a42e4194d05f1abfd0c80a Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 6 Nov 2016 20:33:56 +1300 Subject: [PATCH 10/87] #852 - javax.persistence.PersistenceException: No ScalarType registered for class Foo$1 ... where Foo is an Enum where individual instances override a method (example below). --- .../server/deploy/parse/DeployUtil.java | 5 +-- .../server/type/DefaultTypeManager.java | 32 +++++++++++-------- .../server/type/TypeManager.java | 5 +++ .../com/avaje/ebean/server/type/MyEnum.java | 28 ++++++++++++++++ .../ebean/server/type/TestTypeManager.java | 27 +++++++++++++++- src/test/resources/logback-test.xml | 8 ++--- 6 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 src/test/java/com/avaje/ebean/server/type/MyEnum.java diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java index 6ac806c88..8fc97f4a2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -119,14 +119,15 @@ public class DeployUtil { ScalarType scalarType = typeManager.getScalarType(enumType); if (scalarType == null) { // look for @DbEnumValue or @EnumValue annotations etc - scalarType = typeManager.createEnumScalarType((Class>)enumType); + Class> enumClass = (Class>)enumType; + scalarType = typeManager.createEnumScalarType(enumClass); if (scalarType == null) { // use JPA normal Enum type (without mapping) EnumType type = enumerated != null ? enumerated.value() : null; scalarType = createEnumScalarTypePerSpec(enumType, type); } - typeManager.add(scalarType); + typeManager.addEnumType(scalarType, enumClass); } prop.setScalarType(scalarType); prop.setDbType(scalarType.getJdbcType()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index ef34b6fec..67fb843e3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -62,19 +62,7 @@ import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Currency; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.TimeZone; -import java.util.UUID; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** @@ -330,6 +318,24 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { logAdd(scalarType); } + /** + * Register the ScalarType for an enum. This is special in the sense that an Enum + * can have many classes if it uses method overrides and we need to register all + * the variations/classes for the enum. + */ + @Override + public void addEnumType(ScalarType scalarType, Class enumClass) { + + Set> mappedClasses = new HashSet<>(); + for (Object value : EnumSet.allOf(enumClass).toArray()) { + mappedClasses.add(value.getClass()); + } + for (Class cls: mappedClasses) { + typeMap.put(cls, scalarType); + } + logAdd(scalarType); + } + private void logAdd(ScalarType scalarType) { if (logger.isDebugEnabled()) { String msg = "ScalarType register [" + scalarType.getClass().getName() + "]"; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/TypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/TypeManager.java index 7b880cd9a..358ab024f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/TypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/TypeManager.java @@ -30,6 +30,11 @@ public interface TypeManager { */ void add(ScalarType scalarType); + /** + * Register a ScalarType for an Enum with can have multiple classes. + */ + void addEnumType(ScalarType type, Class myEnumClass); + /** * Return the Internal CompoundType handler for a given compound type. */ diff --git a/src/test/java/com/avaje/ebean/server/type/MyEnum.java b/src/test/java/com/avaje/ebean/server/type/MyEnum.java new file mode 100644 index 000000000..50579a7cf --- /dev/null +++ b/src/test/java/com/avaje/ebean/server/type/MyEnum.java @@ -0,0 +1,28 @@ +package com.avaje.ebean.server.type; + +import com.avaje.ebean.annotation.EnumValue; + +/** + * Enum with method overrides (and hence multiple actual classes). + */ +public enum MyEnum { + + @EnumValue("A")Aval { + @Override + public String doSomething() { + return "bar"; + } + }, + @EnumValue("B")Bval, + + @EnumValue("C")Cval { + @Override + public String doSomething() { + return "baz"; + } + }; + + public String doSomething() { + return "foo"; + } +} diff --git a/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java b/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java index 5d7516ec2..6f3ce1442 100644 --- a/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java +++ b/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java @@ -23,6 +23,31 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestTypeManager extends BaseTestCase { + @Test + public void testEnumWithSubclasses() throws SQLException { + + DefaultTypeManager typeManager = createTypeManager(); + + ScalarType type = typeManager.createEnumScalarType(MyEnum.class); + typeManager.addEnumType(type, MyEnum.class); + + Object val = type.read(new DummyDataReader("A")); + assertThat(val).isEqualTo(MyEnum.Aval); + val = type.read(new DummyDataReader("B")); + assertThat(val).isEqualTo(MyEnum.Bval); + val = type.read(new DummyDataReader("C")); + assertThat(val).isEqualTo(MyEnum.Cval); + + ScalarType typeGeneral = typeManager.getScalarType(MyEnum.class); + assertThat(typeGeneral).isNotNull(); + ScalarType typeB = typeManager.getScalarType(MyEnum.Bval.getClass()); + assertThat(typeB).isNotNull(); + ScalarType typeA = typeManager.getScalarType(MyEnum.Aval.getClass()); + assertThat(typeA).isNotNull(); + ScalarType typeC = typeManager.getScalarType(MyEnum.Cval.getClass()); + assertThat(typeC).isNotNull(); + } + @Test public void testEnumWithChar() throws SQLException { @@ -88,7 +113,7 @@ public class TestTypeManager extends BaseTestCase { String val; - public DummyDataReader(String val) { + DummyDataReader(String val) { super(null, null); this.val = val; } diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index ecacef46d..44bfd40d3 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -78,10 +78,10 @@ - - - - + + + + From 969a3c8b8d23c135c968b4d853c8023fd025ff36 Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 10:00:02 +0100 Subject: [PATCH 11/87] Replace explicit type with <> --- .../com/avaje/ebean/DRawSqlColumnsParser.java | 4 +- src/main/java/com/avaje/ebean/Ebean.java | 4 +- src/main/java/com/avaje/ebean/Model.java | 2 +- src/main/java/com/avaje/ebean/OrderBy.java | 12 +++--- src/main/java/com/avaje/ebean/RawSql.java | 10 ++--- src/main/java/com/avaje/ebean/TxScope.java | 8 ++-- .../avaje/ebean/bean/EntityBeanIntercept.java | 6 +-- .../avaje/ebean/bean/NodeUsageCollector.java | 2 +- .../ebean/common/AbstractBeanCollection.java | 2 +- .../java/com/avaje/ebean/common/BeanList.java | 26 ++++++------ .../java/com/avaje/ebean/common/BeanMap.java | 12 +++--- .../java/com/avaje/ebean/common/BeanSet.java | 14 +++---- .../avaje/ebean/common/ModifyCollection.java | 2 +- .../com/avaje/ebean/common/ModifyHolder.java | 8 ++-- .../com/avaje/ebean/common/ModifyList.java | 6 +-- .../com/avaje/ebean/config/PropertyMap.java | 2 +- .../com/avaje/ebean/config/ServerConfig.java | 34 +++++++-------- .../config/dbplatform/DbDefaultValue.java | 2 +- .../dbplatform/DbPlatformTypeLookup.java | 4 +- .../dbplatform/DbPlatformTypeMapping.java | 2 +- .../dbplatform/SequenceIdGenerator.java | 4 +- .../avaje/ebean/dbmigration/DbMigration.java | 2 +- .../ddlgeneration/platform/BaseTableDdl.java | 6 +-- .../platform/HistoryTableUpdate.java | 2 +- .../platform/util/IndexColumns.java | 2 +- .../ddlgeneration/platform/util/IndexSet.java | 2 +- .../dbmigration/migration/AddColumn.java | 2 +- .../dbmigration/migration/Applications.java | 2 +- .../dbmigration/migration/ChangeSet.java | 2 +- .../dbmigration/migration/CreateTable.java | 6 +-- .../dbmigration/migration/Migration.java | 2 +- .../model/MCompoundForeignKey.java | 4 +- .../avaje/ebean/dbmigration/model/MIndex.java | 4 +- .../avaje/ebean/dbmigration/model/MTable.java | 14 +++---- .../dbmigration/model/MigrationModel.java | 2 +- .../dbmigration/model/ModelContainer.java | 4 +- .../ebean/dbmigration/model/ModelDiff.java | 4 +- .../ebean/dbmigration/model/PendingDrops.java | 6 +-- .../build/ModelBuildPropertyVisitor.java | 2 +- .../ebean/event/changelog/ChangeSet.java | 4 +- .../ebean/event/readaudit/ReadEvent.java | 2 +- .../com/avaje/ebean/text/PathProperties.java | 4 +- .../avaje/ebean/text/json/EJsonReader.java | 8 ++-- .../ebean/text/json/JsonReadOptions.java | 2 +- .../ebean/text/json/JsonWriteOptions.java | 2 +- .../com/avaje/ebean/util/StringHelper.java | 6 +-- .../avaje/ebeaninternal/api/BindParams.java | 6 +-- .../ebeaninternal/api/LoadBeanRequest.java | 4 +- .../ebeaninternal/api/LoadManyRequest.java | 2 +- .../ebeaninternal/api/ManyWhereJoins.java | 4 +- .../api/SpiExpressionValidation.java | 2 +- .../api/TransactionEventBeans.java | 2 +- .../api/TransactionEventTable.java | 2 +- .../extraddl/model/ExtraDdl.java | 2 +- .../server/autotune/AutoTuneCollection.java | 4 +- .../server/autotune/model/Autotune.java | 2 +- .../server/autotune/model/ProfileDiff.java | 2 +- .../server/autotune/model/ProfileEmpty.java | 2 +- .../server/autotune/model/ProfileNew.java | 2 +- .../autotune/service/BaseQueryTuner.java | 2 +- .../autotune/service/ProfileManager.java | 2 +- .../autotune/service/ProfileOrigin.java | 4 +- .../service/ProfileOriginNodeUsage.java | 2 +- .../server/cache/CacheChangeSet.java | 10 ++--- .../server/cache/CachedBeanData.java | 4 +- .../server/cache/CachedBeanDataFromBean.java | 2 +- .../server/cache/CachedManyIds.java | 2 +- .../server/cache/DefaultCacheHolder.java | 4 +- .../server/cache/DefaultServerCache.java | 4 +- .../changelog/DefaultChangeLogRegister.java | 2 +- .../server/cluster/BinaryMessageList.java | 2 +- .../server/cluster/ClusterManager.java | 2 +- .../server/core/ClassPathScanners.java | 2 +- .../server/core/DefaultMetaInfoManager.java | 6 +-- .../server/core/DefaultServer.java | 28 ++++++------- .../ebeaninternal/server/core/DiffHelp.java | 2 +- .../server/core/InternString.java | 2 +- .../server/core/InternalConfiguration.java | 2 +- .../server/core/OrmQueryRequest.java | 2 +- .../server/core/PersistRequestBean.java | 2 +- .../server/core/RelationalQueryRequest.java | 2 +- .../server/core/bootup/BootupClasses.java | 42 +++++++++---------- .../server/core/bootup/DistillPackages.java | 4 +- .../server/core/bootup/ManifestReader.java | 2 +- .../deploy/BeanCollectionHelpFactory.java | 8 ++-- .../server/deploy/BeanDescriptor.java | 26 ++++++------ .../deploy/BeanDescriptorCacheHelp.java | 4 +- .../deploy/BeanDescriptorDraftHelp.java | 2 +- .../server/deploy/BeanDescriptorJsonHelp.java | 2 +- .../server/deploy/BeanDescriptorManager.java | 34 +++++++-------- .../deploy/BeanLifecycleAdapterFactory.java | 16 +++---- .../server/deploy/BeanListHelp.java | 8 ++-- .../server/deploy/BeanManagerFactory.java | 2 +- .../server/deploy/BeanMapHelp.java | 2 +- .../server/deploy/BeanPropertyAssoc.java | 2 +- .../server/deploy/BeanPropertyAssocMany.java | 10 ++--- .../server/deploy/BeanPropertyAssocOne.java | 8 ++-- .../server/deploy/BeanPropertyCompound.java | 4 +- .../deploy/BeanPropertyCompoundRoot.java | 2 +- .../server/deploy/BeanSetHelp.java | 6 +-- .../deploy/ChainedBeanPersistController.java | 6 +-- .../deploy/ChainedBeanPersistListener.java | 6 +-- .../ChainedBeanPostConstructListener.java | 4 +- .../server/deploy/ChainedBeanPostLoad.java | 4 +- .../deploy/ChainedBeanQueryAdapter.java | 4 +- .../server/deploy/DeployPropertyParser.java | 2 +- .../server/deploy/InheritInfo.java | 6 +-- .../server/deploy/IntersectionRow.java | 2 +- .../GeneratedPropertyFactory.java | 4 +- .../InsertTimestampFactory.java | 2 +- .../UpdateTimestampFactory.java | 2 +- .../server/deploy/id/IdBinderEmbedded.java | 2 +- .../deploy/meta/DeployBeanDescriptor.java | 36 ++++++++-------- .../deploy/meta/DeployBeanEmbedded.java | 2 +- .../deploy/meta/DeployBeanPropertyLists.java | 32 +++++++------- .../server/deploy/meta/DeployTableJoin.java | 4 +- .../server/deploy/parse/AnnotationBase.java | 4 +- .../server/deploy/parse/AnnotationParser.java | 2 +- .../server/deploy/parse/DeployBeanInfo.java | 2 +- .../server/deploy/parse/DeployInherit.java | 4 +- .../deploy/parse/DeployInheritInfo.java | 4 +- .../server/deploy/parse/SqlReservedWords.java | 2 +- .../ebeaninternal/server/el/ElFilter.java | 42 +++++++++---------- .../server/el/ElPropertyChainBuilder.java | 2 +- .../expression/DefaultExampleExpression.java | 4 +- .../expression/DefaultExpressionFactory.java | 12 +++--- .../expression/DefaultExpressionList.java | 14 +++---- .../expression/DefaultExpressionRequest.java | 2 +- .../expression/FilterExpressionList.java | 2 +- .../server/expression/InExpression.java | 2 +- .../server/expression/JunctionExpression.java | 4 +- .../server/expression/PrepareDocNested.java | 6 +-- .../server/grammer/EqlAdapter.java | 6 +-- .../server/grammer/EqlParser.java | 2 +- .../server/grammer/OperatorMapping.java | 2 +- .../server/lib/ShutdownManager.java | 2 +- .../server/lib/util/StringHelper.java | 2 +- .../server/loadcontext/DLoadBeanContext.java | 4 +- .../server/loadcontext/DLoadContext.java | 6 +-- .../server/loadcontext/DLoadManyContext.java | 4 +- .../server/persist/BatchControl.java | 2 +- .../server/persist/BatchedBeanHolder.java | 8 ++-- .../server/persist/BatchedPstmt.java | 2 +- .../server/persist/BatchedPstmtHolder.java | 2 +- .../server/persist/BindValues.java | 2 +- .../server/persist/DefaultPersister.java | 16 +++---- .../persist/DeleteUnloadedForeignKeys.java | 2 +- .../server/persist/dml/MetaFactory.java | 4 +- .../server/persist/dml/UpdateMeta.java | 2 +- .../server/persist/dmlbind/BindableList.java | 2 +- .../dmlbind/FactoryBaseProperties.java | 2 +- .../persist/dmlbind/FactoryEmbedded.java | 2 +- .../properties/BeanPropertiesReader.java | 2 +- .../ebeaninternal/server/query/CQuery.java | 2 +- .../server/query/SqlTreeBuilder.java | 2 +- .../server/querydefn/DefaultOrmQuery.java | 2 +- .../server/text/csv/CsvUtilReader.java | 4 +- .../server/text/csv/TCsvReader.java | 4 +- .../server/text/json/DJsonContext.java | 6 +-- .../server/text/json/WriteJson.java | 2 +- .../server/transaction/BeanPersistIdMap.java | 2 +- .../server/transaction/BeanPersistIds.java | 8 ++-- .../transaction/BulkEventListenerMap.java | 4 +- .../DefaultPersistenceContext.java | 6 +-- .../server/transaction/DeleteByIdMap.java | 2 +- .../server/transaction/JdbcTransaction.java | 12 +++--- .../transaction/RemoteTransactionEvent.java | 4 +- .../server/transaction/TransactionMap.java | 2 +- .../server/type/CtCompoundTypeScalarList.java | 6 +-- .../server/type/EnumToDbValueMap.java | 6 +-- .../type/ImmutableCompoundTypeBuilder.java | 4 +- .../server/type/ModifyAwareCollection.java | 2 +- .../server/type/ModifyAwareList.java | 12 +++--- .../server/type/ModifyAwareMap.java | 6 +-- .../server/type/ScalarTypeEnumStandard.java | 4 +- .../type/reflect/ImmutableMetaFactory.java | 6 +-- .../ebeaninternal/server/util/ArrayStack.java | 4 +- .../xmlmapping/model/XmEbean.java | 2 +- .../xmlmapping/model/XmEntity.java | 4 +- .../xmlmapping/model/XmRawSql.java | 4 +- .../docstore/api/DocStoreUpdates.java | 8 ++-- .../api/support/DocStoreBeanBaseAdapter.java | 4 +- .../docstore/api/support/DocStructure.java | 4 +- .../docstore/none/NoneDocStoreFactory.java | 2 +- .../ebean/EbeanServer_deleteAllByIdTest.java | 10 ++--- .../com/avaje/ebean/EbeanServer_refresh.java | 2 +- .../avaje/ebean/EbeanServer_saveAllTest.java | 2 +- .../ebean/TestPropertyChangeListener.java | 2 +- .../ebean/bean/EntityBeanInterceptTest.java | 2 +- .../com/avaje/ebean/common/BeanListTest.java | 30 ++++++------- .../com/avaje/ebean/common/BeanMapTest.java | 24 +++++------ .../com/avaje/ebean/common/BeanSetTest.java | 30 ++++++------- .../model/MigrationVersionTest.java | 2 +- .../dbmigration/model/PendingDropsTest.java | 2 +- .../ebean/event/BeanFindControllerTest.java | 2 +- .../event/BeanPersistControllerTest.java | 2 +- .../avaje/ebean/event/BeanPostLoadTest.java | 2 +- .../cache/CachedBeanDataSerializeTest.java | 2 +- .../server/changelog/Helper.java | 6 +-- .../deploy/BeanPropertyAssocManyTest.java | 4 +- .../deploy/DeployPropertyParserMapTests.java | 2 +- .../expression/AllEqualsExpressionTest.java | 6 +-- .../DefaultExampleExpressionTest.java | 2 +- .../expression/DefaultExpressionListTest.java | 2 +- .../expression/JunctionExpressionTest.java | 6 +-- .../expression/TDSpiExpressionRequest.java | 2 +- .../query/LimitOffsetPagedListTest.java | 2 +- .../server/query/OrderVersionDescTest.java | 2 +- .../server/querydefn/OrmQueryPlanKeyTest.java | 6 +-- .../querydefn/OrmQueryPropertiesTest.java | 6 +-- .../server/type/ModifyAwareListTest.java | 4 +- .../server/type/ModifyAwareMapTest.java | 12 +++--- .../server/type/ScalarTypeMonthDayTest.java | 2 +- .../type/ScalarTypePostgresHstoreTest.java | 6 +-- .../server/util/ArrayStackTest.java | 18 ++++---- .../support/DocStoreBeanBaseAdapterTest.java | 2 +- .../api/support/DocStoreIndexEventTest.java | 4 +- .../tests/basic/TestDeleteByIdCollection.java | 4 +- .../com/avaje/tests/basic/TestM2MVanilla.java | 2 +- .../basic/TestUuidInsertMasterDetail.java | 2 +- .../batchinsert/TestBatchInsertSimple.java | 6 +-- .../batchload/TestBatchLazyWithCacheHits.java | 2 +- .../tests/cache/TestCacheCollectionIds.java | 2 +- .../compositekeys/TestCKeyIdInExpression.java | 2 +- .../tests/compositekeys/TestCKeyLazyLoad.java | 2 +- ...ascadeDeleteChildrenWithCompositeKeys.java | 4 +- .../tests/draftable/LinkQueryPublishTest.java | 2 +- .../TestConstructorManyAddAll.java | 2 +- .../idkeys/TestPropertyChangeSupport.java | 2 +- .../tests/insert/TestInsertCollection.java | 6 +-- .../tests/insert/TestInsertOnStringKey.java | 2 +- .../com/avaje/tests/iud/TestCarWheelIud.java | 2 +- .../com/avaje/tests/json/TestDbJson_List.java | 4 +- .../include/TestJsonExcludeEmptyList.java | 4 +- .../json/include/TestJsonExcludeEmptyMap.java | 4 +- .../json/include/TestJsonExcludeEmptySet.java | 4 +- .../TestJsonExcludeTransientEmptyList.java | 4 +- .../transientproperties/TestModelAJson.java | 2 +- .../TestM2MDeleteObjectWithCascadeToM2m.java | 2 +- .../tests/m2m/TestM2MDeleteWithCascade.java | 2 +- .../avaje/tests/m2m/TestM2mDeleteObject.java | 4 +- .../avaje/tests/model/array/EArrayBean.java | 6 +-- .../tests/model/array/TestDbArray_basic.java | 4 +- .../com/avaje/tests/model/basic/Article.java | 2 +- .../avaje/tests/model/basic/CKeyParent.java | 2 +- .../java/com/avaje/tests/model/basic/Car.java | 2 +- .../com/avaje/tests/model/basic/Customer.java | 2 +- .../tests/model/basic/EVanillaCollection.java | 2 +- .../com/avaje/tests/model/basic/MUser.java | 2 +- .../com/avaje/tests/model/basic/MnocUser.java | 2 +- .../model/basic/MyEBasicConfigStartup.java | 2 +- .../avaje/tests/model/basic/OCachedBean.java | 4 +- .../com/avaje/tests/model/basic/Order.java | 4 +- .../tests/model/basic/ResetBasicData.java | 6 +-- .../com/avaje/tests/model/basic/Section.java | 2 +- .../com/avaje/tests/model/basic/TSMaster.java | 2 +- .../avaje/tests/model/basic/TSMasterTwo.java | 2 +- .../com/avaje/tests/model/basic/UTMaster.java | 2 +- .../xtra/TestDeleteUnloadedChildren.java | 4 +- .../TestInsertBatchThenFlushThenUpdate.java | 2 +- .../basic/xtra/TestInsertBatchThenUpdate.java | 2 +- ...TestInsertBatchWithDifferentRootTypes.java | 4 +- .../avaje/tests/model/info/InfoCompany.java | 4 +- .../avaje/tests/model/info/InfoCustomer.java | 2 +- .../java/com/avaje/tests/model/ivo/Oid.java | 6 +-- .../model/ivo/converter/OidTypeConverter.java | 2 +- .../avaje/tests/model/json/EBasicHstore.java | 2 +- .../tests/model/json/EBasicJsonList.java | 6 +-- .../com/avaje/tests/model/map/MpUser.java | 2 +- .../tests/model/onetoone/album/Album.java | 2 +- .../tests/model/onetoone/album/Cover.java | 2 +- .../album/DeleteById_SoftDelete_Tests.java | 4 +- .../tests/model/selfref/ResourceFile.java | 2 +- .../com/avaje/tests/model/survey/Group.java | 2 +- .../tests/model/survey/TestOrderByFetch.java | 8 ++-- ...estPersistenceContextScopeUsingOrders.java | 4 +- .../com/avaje/tests/query/TestSubQuery.java | 2 +- .../query/other/TestManyLazyLoadingQuery.java | 2 +- .../softdelete/TestSoftDeletePagingList.java | 2 +- .../tests/rawsql/inherit/ParentQueryTest.java | 2 +- .../rawsql/inherit/ParentRawSqlTest.java | 10 ++--- .../avaje/tests/readaudit/TestReadAudit.java | 6 +-- .../tests/softdelete/TestSoftDeleteTop.java | 4 +- .../tests/sp/TestManyToManySaveTwice.java | 2 +- .../avaje/tests/text/json/TestJsonSimple.java | 2 +- .../transaction/TestInsertManyAndRef.java | 2 +- .../tests/unitinternal/TestOrderByParse.java | 26 ++++++------ .../tests/update/TestStatelessUpdate.java | 14 +++---- .../avaje/ebeantest/LoggedSqlCollector.java | 6 +-- .../avaje/test/model/rawsql/inherit/Data.java | 2 +- .../test/model/rawsql/inherit/Parent.java | 2 +- 291 files changed, 743 insertions(+), 743 deletions(-) diff --git a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java index dab7d91ad..1c4e0e623 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java @@ -30,7 +30,7 @@ final class DRawSqlColumnsParser { private ColumnMapping parse() { - ArrayList columns = new ArrayList(); + ArrayList columns = new ArrayList<>(); while (pos <= end) { ColumnMapping.Column c = nextColumnInfo(); columns.add(c); @@ -47,7 +47,7 @@ final class DRawSqlColumnsParser { String[] split = colInfo.split("\\s(?=[^\\)]*(?:\\(|$))"); if (split.length > 1) { - ArrayList tmp = new ArrayList(split.length); + ArrayList tmp = new ArrayList<>(split.length); for (int i = 0; i < split.length; i++) { if (!split[i].trim().isEmpty()) { tmp.add(split[i].trim()); diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java index ffd330b1a..33020f033 100644 --- a/src/main/java/com/avaje/ebean/Ebean.java +++ b/src/main/java/com/avaje/ebean/Ebean.java @@ -132,13 +132,13 @@ public final class Ebean { /** * Cache for fast concurrent read access. */ - private final ConcurrentHashMap concMap = new ConcurrentHashMap(); + private final ConcurrentHashMap concMap = new ConcurrentHashMap<>(); /** * Cache for synchronized read, creation and put. Protected by the monitor * object. */ - private final HashMap syncMap = new HashMap(); + private final HashMap syncMap = new HashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebean/Model.java b/src/main/java/com/avaje/ebean/Model.java index f03e52706..d4553a528 100644 --- a/src/main/java/com/avaje/ebean/Model.java +++ b/src/main/java/com/avaje/ebean/Model.java @@ -512,7 +512,7 @@ public abstract class Model { * Create and return a new Finder for a different server. */ public Finder on(String server) { - return new Finder(server, type); + return new Finder<>(server, type); } /** diff --git a/src/main/java/com/avaje/ebean/OrderBy.java b/src/main/java/com/avaje/ebean/OrderBy.java index ff1b8cc1c..5ccd42bf8 100644 --- a/src/main/java/com/avaje/ebean/OrderBy.java +++ b/src/main/java/com/avaje/ebean/OrderBy.java @@ -28,7 +28,7 @@ public final class OrderBy implements Serializable { * Create an empty OrderBy with no associated query. */ public OrderBy() { - this.list = new ArrayList(3); + this.list = new ArrayList<>(3); } private OrderBy(List list) { @@ -52,7 +52,7 @@ public final class OrderBy implements Serializable { */ public OrderBy(Query query, String orderByClause) { this.query = query; - this.list = new ArrayList(3); + this.list = new ArrayList<>(3); parse(orderByClause); } @@ -100,11 +100,11 @@ public final class OrderBy implements Serializable { * Return a copy of this OrderBy with the path trimmed. */ public OrderBy copyWithTrim(String path) { - List newList = new ArrayList(list.size()); + List newList = new ArrayList<>(list.size()); for (int i = 0; i < list.size(); i++) { newList.add(list.get(i).copyWithTrim(path)); } - return new OrderBy(newList); + return new OrderBy<>(newList); } /** @@ -141,7 +141,7 @@ public final class OrderBy implements Serializable { */ public OrderBy copy() { - OrderBy copy = new OrderBy(); + OrderBy copy = new OrderBy<>(); for (int i = 0; i < list.size(); i++) { copy.add(list.get(i).copy()); } @@ -370,7 +370,7 @@ public final class OrderBy implements Serializable { return null; } - ArrayList wordList = new ArrayList(pairs.length); + ArrayList wordList = new ArrayList<>(pairs.length); for (int i = 0; i < pairs.length; i++) { if (!isEmptyString(pairs[i])) { wordList.add(pairs[i]); diff --git a/src/main/java/com/avaje/ebean/RawSql.java b/src/main/java/com/avaje/ebean/RawSql.java index a5488de72..54cf268f5 100644 --- a/src/main/java/com/avaje/ebean/RawSql.java +++ b/src/main/java/com/avaje/ebean/RawSql.java @@ -401,7 +401,7 @@ public final class RawSql implements Serializable { this.parsed = true; this.propertyMap = null; this.propertyColumnMap = null; - this.dbColumnMap = new LinkedHashMap(); + this.dbColumnMap = new LinkedHashMap<>(); for (int i = 0; i < columns.size(); i++) { Column c = columns.get(i); dbColumnMap.put(c.getDbColumnKey(), c); @@ -416,7 +416,7 @@ public final class RawSql implements Serializable { this.parsed = false; this.propertyMap = null; this.propertyColumnMap = null; - this.dbColumnMap = new LinkedHashMap(); + this.dbColumnMap = new LinkedHashMap<>(); } /** @@ -426,7 +426,7 @@ public final class RawSql implements Serializable { this.immutable = false; this.parsed = false; this.propertyMap = null; - this.dbColumnMap = new LinkedHashMap(); + this.dbColumnMap = new LinkedHashMap<>(); int pos = 0; for (String prop : propertyNames) { @@ -443,8 +443,8 @@ public final class RawSql implements Serializable { this.parsed = parsed; this.dbColumnMap = dbColumnMap; - HashMap pcMap = new HashMap(); - HashMap pMap = new HashMap(); + HashMap pcMap = new HashMap<>(); + HashMap pMap = new HashMap<>(); for (Column c : dbColumnMap.values()) { pMap.put(c.getPropertyName(), c.getDbColumn()); diff --git a/src/main/java/com/avaje/ebean/TxScope.java b/src/main/java/com/avaje/ebean/TxScope.java index 0811f63b5..36c6f0633 100644 --- a/src/main/java/com/avaje/ebean/TxScope.java +++ b/src/main/java/com/avaje/ebean/TxScope.java @@ -282,7 +282,7 @@ public final class TxScope { */ public TxScope setRollbackFor(Class rollbackThrowable) { if (rollbackFor == null) { - rollbackFor = new ArrayList>(2); + rollbackFor = new ArrayList<>(2); } rollbackFor.add(rollbackThrowable); return this; @@ -294,7 +294,7 @@ public final class TxScope { @SuppressWarnings("unchecked") public TxScope setRollbackFor(Class[] rollbackThrowables) { if (rollbackFor == null) { - rollbackFor = new ArrayList>(rollbackThrowables.length); + rollbackFor = new ArrayList<>(rollbackThrowables.length); } for (int i = 0; i < rollbackThrowables.length; i++) { rollbackFor.add((Class) rollbackThrowables[i]); @@ -316,7 +316,7 @@ public final class TxScope { */ public TxScope setNoRollbackFor(Class noRollback) { if (noRollbackFor == null) { - noRollbackFor = new ArrayList>(2); + noRollbackFor = new ArrayList<>(2); } this.noRollbackFor.add(noRollback); return this; @@ -328,7 +328,7 @@ public final class TxScope { @SuppressWarnings("unchecked") public TxScope setNoRollbackFor(Class[] noRollbacks) { if (noRollbackFor == null) { - noRollbackFor = new ArrayList>(noRollbacks.length); + noRollbackFor = new ArrayList<>(noRollbacks.length); } for (int i = 0; i < noRollbacks.length; i++) { noRollbackFor.add((Class) noRollbacks[i]); diff --git a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java index 22d68e0e4..3cef1e723 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java @@ -587,7 +587,7 @@ public final class EntityBeanIntercept implements Serializable { if (fullyLoadedBean) { return null; } - Set props = new LinkedHashSet(); + Set props = new LinkedHashSet<>(); for (int i=0; i getDirtyPropertyNames() { - Set props = new LinkedHashSet(); + Set props = new LinkedHashSet<>(); addDirtyPropertyNames(props, null); return props; } @@ -666,7 +666,7 @@ public final class EntityBeanIntercept implements Serializable { * Return a map of dirty properties with their new and old values. */ public Map getDirtyValues() { - Map dirtyValues = new LinkedHashMap(); + Map dirtyValues = new LinkedHashMap<>(); addDirtyPropertyValues(dirtyValues, null); return dirtyValues; } diff --git a/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java b/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java index 405b36e9f..6eb6333ac 100644 --- a/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java +++ b/src/main/java/com/avaje/ebean/bean/NodeUsageCollector.java @@ -29,7 +29,7 @@ public final class NodeUsageCollector { /** * The properties used at this profile point. */ - private final Set used = new LinkedHashSet(); + private final Set used = new LinkedHashSet<>(); /** * set to true if the bean is modified (setter called) diff --git a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java index d7270fcbf..acd15d700 100644 --- a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java +++ b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java @@ -159,7 +159,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { protected ModifyHolder getModifyHolder() { if (modifyHolder == null) { - modifyHolder = new ModifyHolder(); + modifyHolder = new ModifyHolder<>(); } return modifyHolder; } diff --git a/src/main/java/com/avaje/ebean/common/BeanList.java b/src/main/java/com/avaje/ebean/common/BeanList.java index 2b01cd367..663154fd1 100644 --- a/src/main/java/com/avaje/ebean/common/BeanList.java +++ b/src/main/java/com/avaje/ebean/common/BeanList.java @@ -37,7 +37,7 @@ public final class BeanList extends AbstractBeanCollection implements List * Uses an ArrayList as the underlying List implementation. */ public BeanList() { - this(new ArrayList()); + this(new ArrayList<>()); } /** @@ -68,7 +68,7 @@ public final class BeanList extends AbstractBeanCollection implements List @SuppressWarnings("unchecked") public void loadFrom(BeanCollection other) { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); } list.addAll((Collection) other.getActualDetails()); } @@ -76,7 +76,7 @@ public final class BeanList extends AbstractBeanCollection implements List @SuppressWarnings("unchecked") public void internalAdd(Object bean) { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); } if (bean != null) { list.add((E) bean); @@ -92,7 +92,7 @@ public final class BeanList extends AbstractBeanCollection implements List public boolean checkEmptyLazyLoad() { if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); return true; } else { return false; @@ -105,7 +105,7 @@ public final class BeanList extends AbstractBeanCollection implements List if (!disableLazyLoad && modifyListening) { lazyLoadCollection(true); } else { - list = new ArrayList(); + list = new ArrayList<>(); } } } @@ -115,7 +115,7 @@ public final class BeanList extends AbstractBeanCollection implements List synchronized (this) { if (list == null) { if (disableLazyLoad) { - list = new ArrayList(); + list = new ArrayList<>(); } else { lazyLoadCollection(false); } @@ -296,11 +296,11 @@ public final class BeanList extends AbstractBeanCollection implements List public Iterator iterator() { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator()); + return new ReadOnlyListIterator<>(list.listIterator()); } if (modifyListening) { Iterator it = list.iterator(); - return new ModifyIterator(this, it); + return new ModifyIterator<>(this, it); } return list.iterator(); } @@ -313,11 +313,11 @@ public final class BeanList extends AbstractBeanCollection implements List public ListIterator listIterator() { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator()); + return new ReadOnlyListIterator<>(list.listIterator()); } if (modifyListening) { ListIterator it = list.listIterator(); - return new ModifyListIterator(this, it); + return new ModifyListIterator<>(this, it); } return list.listIterator(); } @@ -325,11 +325,11 @@ public final class BeanList extends AbstractBeanCollection implements List public ListIterator listIterator(int index) { init(); if (isReadOnly()) { - return new ReadOnlyListIterator(list.listIterator(index)); + return new ReadOnlyListIterator<>(list.listIterator(index)); } if (modifyListening) { ListIterator it = list.listIterator(index); - return new ModifyListIterator(this, it); + return new ModifyListIterator<>(this, it); } return list.listIterator(index); } @@ -425,7 +425,7 @@ public final class BeanList extends AbstractBeanCollection implements List return Collections.unmodifiableList(list.subList(fromIndex, toIndex)); } if (modifyListening) { - return new ModifyList(this, list.subList(fromIndex, toIndex)); + return new ModifyList<>(this, list.subList(fromIndex, toIndex)); } return list.subList(fromIndex, toIndex); } diff --git a/src/main/java/com/avaje/ebean/common/BeanMap.java b/src/main/java/com/avaje/ebean/common/BeanMap.java index 2ad9feadf..54d5cd4d2 100644 --- a/src/main/java/com/avaje/ebean/common/BeanMap.java +++ b/src/main/java/com/avaje/ebean/common/BeanMap.java @@ -33,7 +33,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma * Create using a underlying LinkedHashMap. */ public BeanMap() { - this(new LinkedHashMap()); + this(new LinkedHashMap<>()); } public BeanMap(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName) { @@ -61,14 +61,14 @@ public final class BeanMap extends AbstractBeanCollection implements Ma public void internalPutNull() { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } } @SuppressWarnings("unchecked") public void internalPut(Object key, Object bean) { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } if (key != null) { map.put((K) key, (E) bean); @@ -108,7 +108,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma public boolean checkEmptyLazyLoad() { if (map == null) { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); return true; } else { return false; @@ -121,7 +121,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma if (modifyListening) { lazyLoadCollection(true); } else { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } } } @@ -313,7 +313,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma } if (modifyListening) { Collection c = map.values(); - return new ModifyCollection(this, c); + return new ModifyCollection<>(this, c); } return map.values(); } diff --git a/src/main/java/com/avaje/ebean/common/BeanSet.java b/src/main/java/com/avaje/ebean/common/BeanSet.java index 67df7ddb2..f7b780681 100644 --- a/src/main/java/com/avaje/ebean/common/BeanSet.java +++ b/src/main/java/com/avaje/ebean/common/BeanSet.java @@ -34,7 +34,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set()); + this(new LinkedHashSet<>()); } public BeanSet(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { @@ -61,7 +61,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set other) { if (set == null) { - set = new LinkedHashSet(); + set = new LinkedHashSet<>(); } set.addAll((Collection) other.getActualDetails()); } @@ -76,7 +76,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); } if (bean != null) { set.add((E) bean); @@ -100,7 +100,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); return true; } else { return false; @@ -113,7 +113,7 @@ public final class BeanSet extends AbstractBeanCollection implements Set(); + set = new LinkedHashSet<>(); } } } @@ -256,10 +256,10 @@ public final class BeanSet extends AbstractBeanCollection implements Set iterator() { init(); if (isReadOnly()) { - return new ReadOnlyIterator(set.iterator()); + return new ReadOnlyIterator<>(set.iterator()); } if (modifyListening) { - return new ModifyIterator(this, set.iterator()); + return new ModifyIterator<>(this, set.iterator()); } return set.iterator(); } diff --git a/src/main/java/com/avaje/ebean/common/ModifyCollection.java b/src/main/java/com/avaje/ebean/common/ModifyCollection.java index e2aa5eff4..cd71bc42c 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyCollection.java +++ b/src/main/java/com/avaje/ebean/common/ModifyCollection.java @@ -72,7 +72,7 @@ class ModifyCollection implements Collection { @Override public Iterator iterator() { Iterator it = c.iterator(); - return new ModifyIterator(owner, it); + return new ModifyIterator<>(owner, it); } @Override diff --git a/src/main/java/com/avaje/ebean/common/ModifyHolder.java b/src/main/java/com/avaje/ebean/common/ModifyHolder.java index b11f0d39d..9a9180810 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyHolder.java +++ b/src/main/java/com/avaje/ebean/common/ModifyHolder.java @@ -21,16 +21,16 @@ class ModifyHolder implements Serializable { /** * Deletions list for manyToMany persistence. */ - private Set modifyDeletions = new LinkedHashSet(); + private Set modifyDeletions = new LinkedHashSet<>(); /** * Additions list for manyToMany persistence. */ - private Set modifyAdditions = new LinkedHashSet(); + private Set modifyAdditions = new LinkedHashSet<>(); void reset() { - modifyDeletions = new LinkedHashSet(); - modifyAdditions = new LinkedHashSet(); + modifyDeletions = new LinkedHashSet<>(); + modifyAdditions = new LinkedHashSet<>(); } /** diff --git a/src/main/java/com/avaje/ebean/common/ModifyList.java b/src/main/java/com/avaje/ebean/common/ModifyList.java index bb2e3afa1..b0ee8e971 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyList.java +++ b/src/main/java/com/avaje/ebean/common/ModifyList.java @@ -61,11 +61,11 @@ class ModifyList extends ModifyCollection implements List { } public ListIterator listIterator() { - return new ModifyListIterator(owner, list.listIterator()); + return new ModifyListIterator<>(owner, list.listIterator()); } public ListIterator listIterator(int index) { - return new ModifyListIterator(owner, list.listIterator(index)); + return new ModifyListIterator<>(owner, list.listIterator(index)); } public E remove(int index) { @@ -82,7 +82,7 @@ class ModifyList extends ModifyCollection implements List { } public List subList(int fromIndex, int toIndex) { - return new ModifyList(owner, list.subList(fromIndex, toIndex)); + return new ModifyList<>(owner, list.subList(fromIndex, toIndex)); } } diff --git a/src/main/java/com/avaje/ebean/config/PropertyMap.java b/src/main/java/com/avaje/ebean/config/PropertyMap.java index 8e2f8db70..3c9482953 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyMap.java +++ b/src/main/java/com/avaje/ebean/config/PropertyMap.java @@ -16,7 +16,7 @@ public final class PropertyMap implements Serializable { private static final long serialVersionUID = 1L; - private final LinkedHashMap map = new LinkedHashMap(); + private final LinkedHashMap map = new LinkedHashMap<>(); /** * Return properties loaded from test-ebean.properties. diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 5a16413b2..14e2e6085 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -81,11 +81,11 @@ public class ServerConfig { * Typically configuration type objects that are passed by this ServerConfig * to plugins. For example - IgniteConfiguration passed to Ignite plugin. */ - private Map serviceObject = new HashMap(); + private Map serviceObject = new HashMap<>(); private ContainerConfig containerConfig; - private List customDbTypeMappings = new ArrayList(); + private List customDbTypeMappings = new ArrayList<>(); /** * The underlying properties that were used during configuration. @@ -121,13 +121,13 @@ public class ServerConfig { * List of interesting classes such as entities, embedded, ScalarTypes, * Listeners, Finders, Controllers etc. */ - private List> classes = new ArrayList>(); + private List> classes = new ArrayList<>(); /** * The packages that are searched for interesting classes. Only used when * classes is empty/not explicitly specified. */ - private List packages = new ArrayList(); + private List packages = new ArrayList<>(); /** * Configuration for the ElasticSearch integration. @@ -331,15 +331,15 @@ public class ServerConfig { private DbUuid dbUuid = DbUuid.AUTO_VARCHAR; - private List idGenerators = new ArrayList(); - private List findControllers = new ArrayList(); - private List persistControllers = new ArrayList(); - private List postLoaders = new ArrayList(); - private List postConstructListeners = new ArrayList(); - private List persistListeners = new ArrayList(); - private List queryAdapters = new ArrayList(); - private List bulkTableEventListeners = new ArrayList(); - private List configStartupListeners = new ArrayList(); + private List idGenerators = new ArrayList<>(); + private List findControllers = new ArrayList<>(); + private List persistControllers = new ArrayList<>(); + private List postLoaders = new ArrayList<>(); + private List postConstructListeners = new ArrayList<>(); + private List persistListeners = new ArrayList<>(); + private List queryAdapters = new ArrayList<>(); + private List bulkTableEventListeners = new ArrayList<>(); + private List configStartupListeners = new ArrayList<>(); /** * By default inserts are included in the change log. @@ -1726,7 +1726,7 @@ public class ServerConfig { */ public void addClass(Class cls) { if (classes == null) { - classes = new ArrayList>(); + classes = new ArrayList<>(); } classes.add(cls); } @@ -1739,7 +1739,7 @@ public class ServerConfig { */ public void addPackage(String packageName) { if (packages == null) { - packages = new ArrayList(); + packages = new ArrayList<>(); } packages.add(packageName); } @@ -2488,7 +2488,7 @@ public class ServerConfig { return classes; } - List> classes = new ArrayList>(); + List> classes = new ArrayList<>(); String[] split = classNames.split("[ ,;]"); for (int i = 0; i < split.length; i++) { @@ -2507,7 +2507,7 @@ public class ServerConfig { private List getSearchJarsPackages(String searchPackages) { - List hitList = new ArrayList(); + List hitList = new ArrayList<>(); if (searchPackages != null) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java index 0a0776318..2a5aa82d2 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java @@ -23,7 +23,7 @@ public class DbDefaultValue { */ public static final String NOW = "now"; - protected Map map = new LinkedHashMap(); + protected Map map = new LinkedHashMap<>(); /** * Set the DB now function. diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java index 57a0b1083..ca9c39341 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookup.java @@ -11,12 +11,12 @@ class DbPlatformTypeLookup { /** * A map to lookup the type by name. */ - private Map nameLookup = new HashMap(); + private Map nameLookup = new HashMap<>(); /** * A map to lookup the type by JDBC int value. */ - private Map idLookup = new HashMap(); + private Map idLookup = new HashMap<>(); DbPlatformTypeLookup() { addAll(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java index 94c3f3a8a..c2c2d791c 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java @@ -25,7 +25,7 @@ public class DbPlatformTypeMapping { private static final DbPlatformType MULTILINESTRING = new DbPlatformType("multilinestring"); private static final DbPlatformType MULTIPOLYGON = new DbPlatformType("multipolygon"); - private final Map typeMap = new HashMap(); + private final Map typeMap = new HashMap<>(); /** * Return the DbTypeMap with standard (not platform specific) types. diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index e0ce358ec..d996938fc 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -40,7 +40,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { protected final BackgroundExecutor backgroundExecutor; - protected final ArrayList idList = new ArrayList(50); + protected final ArrayList idList = new ArrayList<>(50); protected final int batchSize; @@ -178,7 +178,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { String sql = getSql(loadSize); - ArrayList newIds = new ArrayList(loadSize); + ArrayList newIds = new ArrayList<>(loadSize); boolean useTxnConnection = t != null; diff --git a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java index 06692d82c..20d112b57 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java @@ -79,7 +79,7 @@ public class DbMigration { protected DatabasePlatform databasePlatform; - protected List platforms = new ArrayList(); + protected List platforms = new ArrayList<>(); protected ServerConfig serverConfig; diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java index 94deb10d1..1cb4a9818 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -53,7 +53,7 @@ public class BaseTableDdl implements TableDdl { /** * Used when unique constraints specifically for OneToOne can't be created normally (MsSqlServer). */ - protected List externalUnique = new ArrayList(); + protected List externalUnique = new ArrayList<>(); // counters used when constraint names are truncated due to maximum length // and these counters are used to keep the constraint name unique @@ -66,7 +66,7 @@ public class BaseTableDdl implements TableDdl { * Base tables that have associated history tables that need their triggers/functions regenerated as * columns have been added, removed, included or excluded. */ - protected Map regenerateHistoryTriggers = new LinkedHashMap(); + protected Map regenerateHistoryTriggers = new LinkedHashMap<>(); /** * Construct with a naming convention and platform specific DDL. @@ -499,7 +499,7 @@ public class BaseTableDdl implements TableDdl { * Return the list of columns that make the primary key. */ protected List determinePrimaryKeyColumns(List columns) { - List pk = new ArrayList(3); + List pk = new ArrayList<>(3); for (Column column : columns) { if (isTrue(column.isPrimaryKey())) { pk.add(column); diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java index 8f743fc91..dc3505f4b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java @@ -43,7 +43,7 @@ public class HistoryTableUpdate { private final String baseTable; - private final List columnChanges = new ArrayList(); + private final List columnChanges = new ArrayList<>(); /** * Construct with a given base table name. diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java index f0475f468..309a44ebe 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java @@ -8,7 +8,7 @@ import java.util.List; */ public class IndexColumns { - List columns = new ArrayList(4); + List columns = new ArrayList<>(4); /** * Construct representing as a single column index. diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java index d4421524e..3e8148542 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java @@ -11,7 +11,7 @@ import java.util.List; */ public class IndexSet { - private List indexes = new ArrayList(); + private List indexes = new ArrayList<>(); /** * Clear the indexes (for each table). diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java index 58de889a3..16c01d2af 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddColumn.java @@ -70,7 +70,7 @@ public class AddColumn { */ public List getColumn() { if (column == null) { - column = new ArrayList(); + column = new ArrayList<>(); } return this.column; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java index 3c6b52774..262bd6ecc 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java @@ -61,7 +61,7 @@ public class Applications { */ public List getApplication() { if (application == null) { - application = new ArrayList(); + application = new ArrayList<>(); } return this.application; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java index 8341525c5..df76e2d0a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java @@ -113,7 +113,7 @@ public class ChangeSet { */ public List getChangeSetChildren() { if (changeSetChildren == null) { - changeSetChildren = new ArrayList(); + changeSetChildren = new ArrayList<>(); } return this.changeSetChildren; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java index dac8198b0..f5a470a89 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java @@ -105,7 +105,7 @@ public class CreateTable { */ public List getColumn() { if (column == null) { - column = new ArrayList(); + column = new ArrayList<>(); } return this.column; } @@ -134,7 +134,7 @@ public class CreateTable { */ public List getUniqueConstraint() { if (uniqueConstraint == null) { - uniqueConstraint = new ArrayList(); + uniqueConstraint = new ArrayList<>(); } return this.uniqueConstraint; } @@ -163,7 +163,7 @@ public class CreateTable { */ public List getForeignKey() { if (foreignKey == null) { - foreignKey = new ArrayList(); + foreignKey = new ArrayList<>(); } return this.foreignKey; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java index 54f97dcb7..611987e0d 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java @@ -63,7 +63,7 @@ public class Migration { */ public List getChangeSet() { if (changeSet == null) { - changeSet = new ArrayList(); + changeSet = new ArrayList<>(); } return this.changeSet; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java index 2d4803603..b528544cc 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundForeignKey.java @@ -16,8 +16,8 @@ public class MCompoundForeignKey { private String name; private final String referenceTable; - private final List columns = new ArrayList(); - private final List referenceColumns = new ArrayList(); + private final List columns = new ArrayList<>(); + private final List referenceColumns = new ArrayList<>(); private String indexName; public MCompoundForeignKey(String name, String referenceTable, String indexName) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java index 5b3e4a112..0c2f9e1cf 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java @@ -15,7 +15,7 @@ public class MIndex { private String indexName; - private List columns = new ArrayList(); + private List columns = new ArrayList<>(); /** * Create a single column non unique index. @@ -120,7 +120,7 @@ public class MIndex { private List split(String columns) { - List colList = new ArrayList(); + List colList = new ArrayList<>(); String[] cols = columns.split(","); for (int i = 0; i columns = new LinkedHashMap(); + private Map columns = new LinkedHashMap<>(); /** * Compound unique constraints. */ - private List uniqueConstraints = new ArrayList(); + private List uniqueConstraints = new ArrayList<>(); /** * Compound foreign keys. */ - private List compoundKeys = new ArrayList(); + private List compoundKeys = new ArrayList<>(); /** * Column name for the 'When created' column. This can be used for the initial effective start date when adding @@ -122,7 +122,7 @@ public class MTable { */ private AddColumn addColumn; - private List droppedColumns = new ArrayList(); + private List droppedColumns = new ArrayList<>(); /** * Create a copy of this table structure as a 'draft' table. @@ -369,7 +369,7 @@ public class MTable { public List allHistoryColumns(boolean includeDropped) { - List columnNames = new ArrayList(columns.size()); + List columnNames = new ArrayList<>(columns.size()); for (MColumn column : columns.values()) { if (column.isIncludeInHistory()) { columnNames.add(column.getName()); @@ -444,7 +444,7 @@ public class MTable { * Return the list of columns that make the primary key. */ public List primaryKeyColumns() { - List pk = new ArrayList(3); + List pk = new ArrayList<>(3); for (MColumn column : allColumns()) { if (column.isPrimaryKey()) { pk.add(column); @@ -590,7 +590,7 @@ public class MTable { * Return true if the foreign key names are not unique. */ private boolean hasDuplicateForeignKeys() { - Set fkNames = new HashSet(); + Set fkNames = new HashSet<>(); for (MCompoundForeignKey fk : compoundKeys) { if (!fkNames.add(fk.getName())) { return true; diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java index b621bb6ce..3237ce697 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java @@ -49,7 +49,7 @@ public class MigrationModel { } }); - List resources = new ArrayList(); + List resources = new ArrayList<>(); for (File xmlFile: xmlFiles) { resources.add(new MigrationResource(xmlFile, createVersion(xmlFile))); diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java index e3a41fdc2..1870ff332 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java @@ -28,12 +28,12 @@ public class ModelContainer { /** * All the tables in the model. */ - private final Map tables = new LinkedHashMap(); + private final Map tables = new LinkedHashMap<>(); /** * All the non unique non foreign key indexes. */ - private final Map indexes = new LinkedHashMap(); + private final Map indexes = new LinkedHashMap<>(); private final PendingDrops pendingDrops = new PendingDrops(); diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java index da50becb7..b0c7ae749 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelDiff.java @@ -30,12 +30,12 @@ public class ModelDiff { /** * List of 'create' type changes. */ - private final List applyChanges = new ArrayList(); + private final List applyChanges = new ArrayList<>(); /** * List of 'drop' type changes. Expected to be placed into a separate DDL script. */ - private final List dropChanges = new ArrayList(); + private final List dropChanges = new ArrayList<>(); /** * Construct with a base model. diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java index cb4235f92..5a2875487 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java @@ -16,7 +16,7 @@ import java.util.List; */ public class PendingDrops { - private final LinkedHashMap map = new LinkedHashMap(); + private final LinkedHashMap map = new LinkedHashMap<>(); /** * Add a 'pending drops' changeSet for the given version. @@ -36,7 +36,7 @@ public class PendingDrops { */ public List pendingDrops() { - List versions = new ArrayList(); + List versions = new ArrayList<>(); for (Entry value : map.values()) { if (value.hasPendingDrops()) { versions.add(value.version.asString()); @@ -143,7 +143,7 @@ public class PendingDrops { final MigrationVersion version; - final List list = new ArrayList(); + final List list = new ArrayList<>(); Entry(MigrationVersion version) { this.version = version; diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index 2ad3925e2..7e66c16ed 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -166,7 +166,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { ImportedId importedId = p.getImportedId(); - List modelColumns = new ArrayList(columns.length); + List modelColumns = new ArrayList<>(columns.length); MCompoundForeignKey compoundKey = null; if (columns.length > 1) { diff --git a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java index 5e229acf8..0285e83cf 100644 --- a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java @@ -49,7 +49,7 @@ public class ChangeSet { /** * The bean changes. */ - List changes = new ArrayList(); + List changes = new ArrayList<>(); /** * Construct with a txnId. @@ -182,7 +182,7 @@ public class ChangeSet { */ public Map getUserContext() { if (userContext == null) { - userContext = new LinkedHashMap(); + userContext = new LinkedHashMap<>(); } return userContext; } diff --git a/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java b/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java index 904742c95..5a95494af 100644 --- a/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java +++ b/src/main/java/com/avaje/ebean/event/readaudit/ReadEvent.java @@ -159,7 +159,7 @@ public class ReadEvent { */ public Map getUserContext() { if (userContext == null) { - userContext = new LinkedHashMap(); + userContext = new LinkedHashMap<>(); } return userContext; } diff --git a/src/main/java/com/avaje/ebean/text/PathProperties.java b/src/main/java/com/avaje/ebean/text/PathProperties.java index 6eeb0b4dd..9944f2a8b 100644 --- a/src/main/java/com/avaje/ebean/text/PathProperties.java +++ b/src/main/java/com/avaje/ebean/text/PathProperties.java @@ -42,7 +42,7 @@ public class PathProperties implements FetchPath { */ public PathProperties() { this.rootProps = new Props(this, null, null); - this.pathMap = new LinkedHashMap(); + this.pathMap = new LinkedHashMap<>(); this.pathMap.put(null, rootProps); } @@ -172,7 +172,7 @@ public class PathProperties implements FetchPath { } private Props(PathProperties owner, String parentPath, String path) { - this(owner, parentPath, path, new LinkedHashSet()); + this(owner, parentPath, path, new LinkedHashSet<>()); } public String getPath() { diff --git a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java index dba25227c..a6ee75616 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java +++ b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java @@ -286,11 +286,11 @@ class EJsonReader { private String key; ObjectContext() { - map = new LinkedHashMap(); + map = new LinkedHashMap<>(); } ObjectContext(ModifyAwareOwner owner) { - map = new ModifyAwareMap(owner, new LinkedHashMap()); + map = new ModifyAwareMap<>(owner, new LinkedHashMap<>()); } public void popContext(Context temp) { @@ -319,11 +319,11 @@ class EJsonReader { private final List values; ArrayContext() { - values = new ArrayList(); + values = new ArrayList<>(); } ArrayContext(ModifyAwareOwner owner) { - values = new ModifyAwareList(owner, new ArrayList()); + values = new ModifyAwareList<>(owner, new ArrayList<>()); } public void popContext(Context temp) { diff --git a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java index a8569d078..d348a3875 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java @@ -29,7 +29,7 @@ public class JsonReadOptions { * Default constructor. */ public JsonReadOptions() { - this.visitorMap = new LinkedHashMap>(); + this.visitorMap = new LinkedHashMap<>(); } /** diff --git a/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java b/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java index c610d926e..5c80e0c43 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonWriteOptions.java @@ -85,7 +85,7 @@ public class JsonWriteOptions { */ public JsonWriteOptions setPathVisitor(String path, JsonWriteBeanVisitor visitor) { if (visitorMap == null) { - visitorMap = new HashMap>(); + visitorMap = new HashMap<>(); } visitorMap.put(path, visitor); return this; diff --git a/src/main/java/com/avaje/ebean/util/StringHelper.java b/src/main/java/com/avaje/ebean/util/StringHelper.java index 24fcabbfc..3eed6135c 100644 --- a/src/main/java/com/avaje/ebean/util/StringHelper.java +++ b/src/main/java/com/avaje/ebean/util/StringHelper.java @@ -37,7 +37,7 @@ public class StringHelper { throw new RuntimeException("missing quoted value at the end of " + tag); } - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); // recursively parse out the name value pairs... return parseNameQuotedValue(map, tag, 0); } @@ -122,7 +122,7 @@ public class StringHelper { public static Map delimitedToMap(String allNameValuePairs, String listDelimiter, String nameValueSeparator) { - HashMap params = new HashMap(); + HashMap params = new HashMap<>(); if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { return params; } @@ -237,7 +237,7 @@ public class StringHelper { */ public static String[] delimitedToArray(String str, String delimiter, boolean keepEmpties) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); int startPos = 0; delimiter(str, delimiter, keepEmpties, startPos, list); String[] result = new String[list.size()]; diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java index c0dc62556..8a049de7f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java @@ -20,9 +20,9 @@ public class BindParams implements Serializable { private static final long serialVersionUID = 4541081933302086285L; - private final List positionedParameters = new ArrayList(); + private final List positionedParameters = new ArrayList<>(); - private final Map namedParameters = new LinkedHashMap(); + private final Map namedParameters = new LinkedHashMap<>(); /** * This is the sql. For named parameters this is the sql after the named @@ -308,7 +308,7 @@ public class BindParams implements Serializable { private final StringBuilder preparedSql; public OrderedList() { - this(new ArrayList()); + this(new ArrayList<>()); } public OrderedList(List paramList) { diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java index 2a66310de..48499ee40 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java @@ -95,7 +95,7 @@ public class LoadBeanRequest extends LoadRequest { */ public List getIdList(int batchSize) { - List idList = new ArrayList(batchSize); + List idList = new ArrayList<>(batchSize); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); for (int i = 0; i < batch.size(); i++) { @@ -150,7 +150,7 @@ public class LoadBeanRequest extends LoadRequest { */ public void postLoad(List list) { - Set loadedIds = new HashSet(); + Set loadedIds = new HashSet<>(); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); // collect Ids and maybe load bean cache diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 9c845714d..20de44756 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -101,7 +101,7 @@ public class LoadManyRequest extends LoadRequest { private List getParentIdList(int batchSize) { - ArrayList idList = new ArrayList(batchSize); + ArrayList idList = new ArrayList<>(batchSize); BeanPropertyAssocMany many = getMany(); for (int i = 0; i < batch.size(); i++) { diff --git a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java index 1a1519b4c..41b9f9540 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java @@ -19,7 +19,7 @@ public class ManyWhereJoins implements Serializable { private static final long serialVersionUID = -6490181101871795417L; - private final TreeMap joins = new TreeMap(); + private final TreeMap joins = new TreeMap<>(); private StringBuilder formulaProperties = new StringBuilder(); @@ -113,7 +113,7 @@ public class ManyWhereJoins implements Serializable { */ public TreeSet getPropertyNames() { - TreeSet propertyNames = new TreeSet(); + TreeSet propertyNames = new TreeSet<>(); for (PropertyJoin join : joins.values()) { propertyNames.add(join.getProperty()); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java index 3e0b4e0da..1b0cdb24e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionValidation.java @@ -12,7 +12,7 @@ public class SpiExpressionValidation { private final BeanType desc; - private final LinkedHashSet unknown = new LinkedHashSet(); + private final LinkedHashSet unknown = new LinkedHashSet<>(); public SpiExpressionValidation(BeanType desc) { this.desc = desc; diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 4bfd565ae..1fd704b14 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -15,7 +15,7 @@ import com.avaje.ebeaninternal.server.core.PersistRequestBean; */ public class TransactionEventBeans { - final ArrayList> requests = new ArrayList>(); + final ArrayList> requests = new ArrayList<>(); /** * Return the list of PersistRequests that BeanListeners are interested in. diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java index 08d50ee82..1922b6bee 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java @@ -16,7 +16,7 @@ public final class TransactionEventTable implements Serializable { private static final long serialVersionUID = 2236555729767483264L; - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); public String toString() { return "TransactionEventTable " + map.values(); diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java index 23a9c4b9f..79d532c70 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java @@ -63,7 +63,7 @@ public class ExtraDdl { */ public List getDdlScript() { if (ddlScript == null) { - ddlScript = new ArrayList(); + ddlScript = new ArrayList<>(); } return this.ddlScript; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java index 0f90d116b..61658145f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/AutoTuneCollection.java @@ -11,7 +11,7 @@ import java.util.List; */ public class AutoTuneCollection { - List entries = new ArrayList(); + List entries = new ArrayList<>(); public Entry add(ObjectGraphOrigin origin, OrmQueryDetail detail, String sourceQuery) { Entry entry = new Entry(origin, detail, sourceQuery); @@ -46,7 +46,7 @@ public class AutoTuneCollection { /** * Summary execution statistics for queries related to this origin point. */ - private final List queries = new ArrayList(); + private final List queries = new ArrayList<>(); public Entry(ObjectGraphOrigin origin, OrmQueryDetail detail, String originalQuery) { this.origin = origin; diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java index 68bd3c7fd..6de29008b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java @@ -70,7 +70,7 @@ public class Autotune { */ public List getOrigin() { if (origin == null) { - origin = new ArrayList(); + origin = new ArrayList<>(); } return this.origin; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java index 4bdf73c57..c8357a41e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java @@ -61,7 +61,7 @@ public class ProfileDiff { */ public List getOrigin() { if (origin == null) { - origin = new ArrayList(); + origin = new ArrayList<>(); } return this.origin; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java index 0b0dc7eb1..317d7d431 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java @@ -61,7 +61,7 @@ public class ProfileEmpty { */ public List getOrigin() { if (origin == null) { - origin = new ArrayList(); + origin = new ArrayList<>(); } return this.origin; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java index 80fdf48ae..416b3e8c4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java @@ -61,7 +61,7 @@ public class ProfileNew { */ public List getOrigin() { if (origin == null) { - origin = new ArrayList(); + origin = new ArrayList<>(); } return this.origin; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java index 03366ecbf..6d2dcf043 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/BaseQueryTuner.java @@ -30,7 +30,7 @@ public class BaseQueryTuner { /** * Map of the tuned query details per profile query point. */ - private final Map tunedQueryInfoMap = new ConcurrentHashMap(); + private final Map tunedQueryInfoMap = new ConcurrentHashMap<>(); private final SpiEbeanServer server; diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java index ff4cca43a..fdf3d702f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileManager.java @@ -31,7 +31,7 @@ public class ProfileManager implements ProfilingListener { /** * Map of the usage and query statistics gathered. */ - private final Map profileMap = new ConcurrentHashMap(); + private final Map profileMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java index c89a9db87..7f9391abe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOrigin.java @@ -26,9 +26,9 @@ public class ProfileOrigin { private final double profilingRate; - private final Map queryStatsMap = new ConcurrentHashMap(); + private final Map queryStatsMap = new ConcurrentHashMap<>(); - private final Map nodeUsageMap = new ConcurrentHashMap(); + private final Map nodeUsageMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java index b61372bee..561e1ce46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginNodeUsage.java @@ -30,7 +30,7 @@ public class ProfileOriginNodeUsage { private boolean modified; - private final Set aggregateUsed = new LinkedHashSet(); + private final Set aggregateUsed = new LinkedHashSet<>(); public ProfileOriginNodeUsage(String path) { // handle null paths as using ConcurrentHashMap diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java index 7b5a06946..3be305558 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java @@ -15,16 +15,16 @@ import java.util.Set; */ public class CacheChangeSet { - private final List entries = new ArrayList(); + private final List entries = new ArrayList<>(); private final Set> queryCaches = new HashSet<>(); - private final Map manyChangeMap = new HashMap(); + private final Map manyChangeMap = new HashMap<>(); /** * Set of "base tables" modified used to invalidate entities based on views. */ - private final Set viewInvalidation = new HashSet(); + private final Set viewInvalidation = new HashSet<>(); private final boolean viewEntityInvalidation; @@ -137,9 +137,9 @@ public class CacheChangeSet { final ManyKey key; - final List removes = new ArrayList(); + final List removes = new ArrayList<>(); - final Map puts = new LinkedHashMap(); + final Map puts = new LinkedHashMap<>(); boolean clear; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java index 16f1d3d78..b82a4c361 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java @@ -63,7 +63,7 @@ public class CachedBeanData implements Externalizable { if (in.readBoolean()) { discValue = in.readUTF(); } - data = new LinkedHashMap(); + data = new LinkedHashMap<>(); int count = in.readInt(); for (int i = 0; i < count; i++) { String key = in.readUTF(); @@ -82,7 +82,7 @@ public class CachedBeanData implements Externalizable { */ public CachedBeanData update(Map changes, long version) { - Map copy = new HashMap(); + Map copy = new HashMap<>(); copy.putAll(data); copy.putAll(changes); return new CachedBeanData(null, discValue, copy, version); diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java index 387552f37..46b19524b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java @@ -15,7 +15,7 @@ public class CachedBeanDataFromBean { EntityBeanIntercept ebi = bean._ebean_getIntercept(); - Map data = new LinkedHashMap(); + Map data = new LinkedHashMap<>(); BeanProperty idProperty = desc.getIdProperty(); if (idProperty != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java index b84c91194..dcc5b2f96 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedManyIds.java @@ -38,7 +38,7 @@ public class CachedManyIds implements Externalizable { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); - idList = new ArrayList(size); + idList = new ArrayList<>(size); for (int i = 0; i < size; i++) { idList.add(in.readObject()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java index 5834986d2..82c58da0b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java @@ -15,9 +15,9 @@ import java.util.concurrent.ConcurrentHashMap; */ public class DefaultCacheHolder { - private final ConcurrentHashMap concMap = new ConcurrentHashMap(); + private final ConcurrentHashMap concMap = new ConcurrentHashMap<>(); - private final HashMap synchMap = new HashMap(); + private final HashMap synchMap = new HashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java index 8a5dc8a32..da247e70c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java @@ -68,7 +68,7 @@ public class DefaultServerCache implements ServerCache { * Construct using a ConcurrentHashMap and cache options. */ public DefaultServerCache(String name, ServerCacheOptions options) { - this(name, new ConcurrentHashMap(), options); + this(name, new ConcurrentHashMap<>(), options); } /** @@ -277,7 +277,7 @@ public class DefaultServerCache implements ServerCache { long trimmedByTTL = 0; long trimmedByLRU = 0; - ArrayList activeList = new ArrayList(); + ArrayList activeList = new ArrayList<>(); long idleExpire = System.currentTimeMillis() - (maxIdleSecs * 1000); long ttlExpire = System.currentTimeMillis() - (maxSecsToLive * 1000); diff --git a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java index f26cf8543..3a6c2068f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegister.java @@ -41,7 +41,7 @@ public class DefaultChangeLogRegister implements ChangeLogRegister { return insertModeInclude(changeLog.inserts()) ? INCLUDE_INSERTS : EXCLUDE_INSERTS; } - Set updateProps = new HashSet(); + Set updateProps = new HashSet<>(); for (int i = 0; i < updatesThatInclude.length; i++) { updateProps.add(updatesThatInclude[i]); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java b/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java index 17d7e6b33..d46111512 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cluster/BinaryMessageList.java @@ -10,7 +10,7 @@ import java.util.List; */ public class BinaryMessageList { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); public void add(BinaryMessage msg) { list.add(msg); diff --git a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java index 30af29e53..f339968da 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java @@ -19,7 +19,7 @@ public class ClusterManager { private static final Logger logger = LoggerFactory.getLogger(ClusterManager.class); - private final ConcurrentHashMap serverMap = new ConcurrentHashMap(); + private final ConcurrentHashMap serverMap = new ConcurrentHashMap<>(); private final Object monitor = new Object(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java b/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java index 6464fe709..e08b28eef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/ClassPathScanners.java @@ -18,7 +18,7 @@ public class ClassPathScanners { */ public static List find(ServerConfig serverConfig) { - List scanners = new ArrayList(); + List scanners = new ArrayList<>(); ServiceLoader scannerLoader = serverConfig.serviceLoad(ClassPathScannerFactory.class); for (ClassPathScannerFactory factory : scannerLoader) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java index d0fd38992..1e4200c7e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java @@ -27,13 +27,13 @@ public class DefaultMetaInfoManager implements MetaInfoManager { @Override public List getMetaBeanInfoList() { - return new ArrayList(server.getBeanDescriptors()); + return new ArrayList<>(server.getBeanDescriptors()); } @Override public List collectQueryPlanStatistics(boolean reset) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (MetaBeanInfo metaBeanInfo : getMetaBeanInfoList()) { list.addAll(metaBeanInfo.collectQueryPlanStatistics(reset)); @@ -44,7 +44,7 @@ public class DefaultMetaInfoManager implements MetaInfoManager { public List collectNodeStatistics(boolean reset) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (CObjectGraphNodeStatistics nodeStatistics : server.objectGraphStats.values()) { MetaObjectGraphNodeStats nodeStats = nodeStatistics.get(reset); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 437aa4c88..fc963cc88 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -190,7 +190,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public DefaultServer(InternalConfiguration config, ServerCacheManager cache) { this.serverConfig = config.getServerConfig(); - this.objectGraphStats = new ConcurrentHashMap(); + this.objectGraphStats = new ConcurrentHashMap<>(); this.metaInfoManager = new DefaultMetaInfoManager(this); this.serverCacheManager = cache; this.databasePlatform = config.getDatabasePlatform(); @@ -871,7 +871,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { String m = beanType.getName() + " is NOT an Entity Bean registered with this server?"; throw new PersistenceException(m); } - return new ElFilter(desc); + return new ElFilter<>(desc); } public CsvReader createCsvReader(Class beanType) { @@ -879,11 +879,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (descriptor == null) { throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found"); } - return new TCsvReader(this, descriptor); + return new TCsvReader<>(this, descriptor); } public UpdateQuery update(Class beanType) { - return new DefaultUpdateQuery(createQuery(beanType)); + return new DefaultUpdateQuery<>(createQuery(beanType)); } public Query find(Class beanType) { @@ -921,7 +921,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (desc == null) { throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?"); } - return new DefaultOrmQuery(desc, this, expressionFactory); + return new DefaultOrmQuery<>(desc, this, expressionFactory); } public Update createUpdate(Class beanType, String ormUpdate) { @@ -931,7 +931,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new PersistenceException(m); } - return new DefaultOrmUpdate(beanType, this, desc.getBaseTable(), ormUpdate); + return new DefaultOrmUpdate<>(beanType, this, desc.getBaseTable(), ormUpdate); } public SqlQuery createSqlQuery(String sql) { @@ -989,7 +989,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { query.setOrigin(createCallStack()); } - OrmQueryRequest request = new OrmQueryRequest(this, queryEngine, query, (SpiTransaction) t); + OrmQueryRequest request = new OrmQueryRequest<>(this, queryEngine, query, (SpiTransaction) t); request.prepareQuery(); return request; @@ -1242,9 +1242,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { Transaction newTxn = createTransaction(); - CallableQueryRowCount call = new CallableQueryRowCount(this, copy, newTxn); + CallableQueryRowCount call = new CallableQueryRowCount<>(this, copy, newTxn); - QueryFutureRowCount queryFuture = new QueryFutureRowCount(call); + QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; @@ -1261,8 +1261,8 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { Transaction newTxn = createTransaction(); - CallableQueryIds call = new CallableQueryIds(this, copy, newTxn); - QueryFutureIds queryFuture = new QueryFutureIds(call); + CallableQueryIds call = new CallableQueryIds<>(this, copy, newTxn); + QueryFutureIds queryFuture = new QueryFutureIds<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); @@ -1284,8 +1284,8 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Create a new transaction solely to execute the findList() at some future time Transaction newTxn = createTransaction(); - CallableQueryList call = new CallableQueryList(this, spiQuery, newTxn); - QueryFutureList queryFuture = new QueryFutureList(call); + CallableQueryList call = new CallableQueryList<>(this, spiQuery, newTxn); + QueryFutureList queryFuture = new QueryFutureList<>(call); backgroundExecutor.execute(queryFuture.getFutureTask()); return queryFuture; } @@ -1303,7 +1303,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { return docStore().findPagedList(createQueryRequest(Type.LIST, query, transaction)); } - return new LimitOffsetPagedList(this, spiQuery); + return new LimitOffsetPagedList<>(this, spiQuery); } public QueryIterator findIterate(Query query, Transaction t) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java index 0f6c5d0ea..6a237d323 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java @@ -75,7 +75,7 @@ public class DiffHelp { if (!assoc.isEmbedded()) { // flatten for assoc one beans if (flattened == null) { - flattened = new LinkedHashMap(); + flattened = new LinkedHashMap<>(); } flattenToId(flattened, entry, beanProperty, assoc); iterator.remove(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java index a9ee3282e..f8d6b332a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java @@ -11,7 +11,7 @@ import java.util.HashMap; */ public final class InternString { - private static final HashMap map = new HashMap(); + private static final HashMap map = new HashMap<>(); /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java index caf82e185..25665cfd4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternalConfiguration.java @@ -108,7 +108,7 @@ public class InternalConfiguration { /** * List of plugins (that ultimately the DefaultServer configures late in construction). */ - private final List plugins = new ArrayList(); + private final List plugins = new ArrayList<>(); public InternalConfiguration(ClusterManager clusterManager, ServerCacheManager cacheManager, SpiBackgroundExecutor backgroundExecutor, diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java index 5b1a74340..a0d98ec3e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/OrmQueryRequest.java @@ -449,7 +449,7 @@ public final class OrmQueryRequest extends BeanRequest implements BeanQueryRe if (cached != null && isAuditReads() && readAuditQueryType()) { // raw sql can't use L2 cache so normal queries only in here Collection actualDetails = cached.getActualDetails(); - List ids = new ArrayList(actualDetails.size()); + List ids = new ArrayList<>(actualDetails.size()); for (T bean : actualDetails) { ids.add(beanDescriptor.getIdForJson(bean)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index c4fd5a141..5fe67d8db 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -911,7 +911,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP */ public void addUpdatedManyProperty(BeanPropertyAssocMany updatedAssocMany) { if (updatedManys == null) { - updatedManys = new ArrayList>(5); + updatedManys = new ArrayList<>(5); } updatedManys.add(updatedAssocMany); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java index a43845e0a..901603485 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java @@ -138,7 +138,7 @@ public final class RelationalQueryRequest { */ private String[] getPropertyNames() throws SQLException { - ArrayList propNames = new ArrayList(); + ArrayList propNames = new ArrayList<>(); ResultSetMetaData metaData = resultSet.getMetaData(); int columnsPlusOne = metaData.getColumnCount() + 1; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java index 3df277068..6fb8d9602 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClasses.java @@ -38,45 +38,45 @@ public class BootupClasses implements ClassFilter { private static final Logger logger = LoggerFactory.getLogger(BootupClasses.class); - private final List> embeddableList = new ArrayList>(); + private final List> embeddableList = new ArrayList<>(); - private final List> entityList = new ArrayList>(); + private final List> entityList = new ArrayList<>(); - private final List>> scalarTypeList = new ArrayList>>(); + private final List>> scalarTypeList = new ArrayList<>(); - private final List>> scalarConverterList = new ArrayList>>(); + private final List>> scalarConverterList = new ArrayList<>(); - private final List>> compoundTypeList = new ArrayList>>(); + private final List>> compoundTypeList = new ArrayList<>(); // The following objects are instantiiated on first request // there is always a candidate list, that holds the class and an // instance list, that holds the instance. Once a class is instantiiated // (or added) it will get removed from the candidate list - private final List> idGeneratorCandidates = new ArrayList>(); + private final List> idGeneratorCandidates = new ArrayList<>(); - private final List> beanPersistControllerCandidates = new ArrayList>(); + private final List> beanPersistControllerCandidates = new ArrayList<>(); - private final List> beanPostLoadCandidates = new ArrayList>(); + private final List> beanPostLoadCandidates = new ArrayList<>(); - private final List> beanPostConstructListenerCandidates = new ArrayList>(); + private final List> beanPostConstructListenerCandidates = new ArrayList<>(); - private final List> beanFindControllerCandidates = new ArrayList>(); + private final List> beanFindControllerCandidates = new ArrayList<>(); - private final List> beanPersistListenerCandidates = new ArrayList>(); + private final List> beanPersistListenerCandidates = new ArrayList<>(); - private final List> beanQueryAdapterCandidates = new ArrayList>(); + private final List> beanQueryAdapterCandidates = new ArrayList<>(); - private final List> serverConfigStartupCandidates = new ArrayList>(); + private final List> serverConfigStartupCandidates = new ArrayList<>(); - private final List idGeneratorInstances = new ArrayList(); - private final List beanPersistControllerInstances = new ArrayList(); - private final List beanPostLoadInstances = new ArrayList(); - private final List beanPostConstructListenerInstances = new ArrayList(); - private final List beanFindControllerInstances = new ArrayList(); - private final List beanPersistListenerInstances = new ArrayList(); - private final List beanQueryAdapterInstances = new ArrayList(); - private final List serverConfigStartupInstances = new ArrayList(); + private final List idGeneratorInstances = new ArrayList<>(); + private final List beanPersistControllerInstances = new ArrayList<>(); + private final List beanPostLoadInstances = new ArrayList<>(); + private final List beanPostConstructListenerInstances = new ArrayList<>(); + private final List beanFindControllerInstances = new ArrayList<>(); + private final List beanPersistListenerInstances = new ArrayList<>(); + private final List beanQueryAdapterInstances = new ArrayList<>(); + private final List serverConfigStartupInstances = new ArrayList<>(); // single objects private Class changeLogPrepareClass; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java index a1b978d21..1bb50c71d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java @@ -17,11 +17,11 @@ class DistillPackages { static List distill(Collection packages, Collection mfPackages) { // sort into natural order - TreeSet treeSet = new TreeSet(); + TreeSet treeSet = new TreeSet<>(); treeSet.addAll(packages); treeSet.addAll(mfPackages); - List distilled = new ArrayList(); + List distilled = new ArrayList<>(); // build the distilled list for (String pack : treeSet) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java index 37b734bd9..7098786f7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java @@ -19,7 +19,7 @@ class ManifestReader { private static final Logger logger = LoggerFactory.getLogger(ManifestReader.class); - private final Set packageSet = new HashSet(); + private final Set packageSet = new HashSet<>(); /** * Read the packages from ebean.mf manifest files found as resources. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java index 827be9818..fcf14366a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanCollectionHelpFactory.java @@ -21,11 +21,11 @@ public class BeanCollectionHelpFactory { ManyType manyType = manyProperty.getManyType(); switch (manyType) { case LIST: - return new BeanListHelp(manyProperty); + return new BeanListHelp<>(manyProperty); case SET: - return new BeanSetHelp(manyProperty); + return new BeanSetHelp<>(manyProperty); case MAP: - return new BeanMapHelp(manyProperty); + return new BeanMapHelp<>(manyProperty); default: throw new RuntimeException("Invalid type " + manyType); } @@ -46,7 +46,7 @@ public class BeanCollectionHelpFactory { } else { BeanDescriptor target = request.getBeanDescriptor(); String mapKey = request.getQuery().getMapKey(); - return new BeanMapHelp(target, mapKey); + return new BeanMapHelp<>(target, mapKey); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java index b04cd4218..6843bc098 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java @@ -101,15 +101,15 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { private static final Logger logger = LoggerFactory.getLogger(BeanDescriptor.class); - private final ConcurrentHashMap updatePlanCache = new ConcurrentHashMap(); + private final ConcurrentHashMap updatePlanCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap queryPlanCache = new ConcurrentHashMap(); + private final ConcurrentHashMap queryPlanCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap elCache = new ConcurrentHashMap(); + private final ConcurrentHashMap elCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap elDeployCache = new ConcurrentHashMap(); + private final ConcurrentHashMap elDeployCache = new ConcurrentHashMap<>(); - private final ConcurrentHashMap> comparatorCache = new ConcurrentHashMap>(); + private final ConcurrentHashMap> comparatorCache = new ConcurrentHashMap<>(); private final Map namedRawSql; @@ -492,9 +492,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { boolean noRelationships = propertiesOne.length + propertiesMany.length == 0; this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly(); - this.cacheHelp = new BeanDescriptorCacheHelp(this, owner.getCacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported); - this.jsonHelp = new BeanDescriptorJsonHelp(this); - this.draftHelp = new BeanDescriptorDraftHelp(this); + this.cacheHelp = new BeanDescriptorCacheHelp<>(this, owner.getCacheManager(), deploy.getCacheOptions(), cacheSharableBeans, propertiesOneImported); + this.jsonHelp = new BeanDescriptorJsonHelp<>(this); + this.draftHelp = new BeanDescriptorDraftHelp<>(this); this.docStoreAdapter = owner.createDocStoreBeanAdapter(this, deploy); this.docStoreQueueId = docStoreAdapter.getQueueId(); @@ -1362,7 +1362,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public List collectQueryPlanStatisticsInternal(boolean reset, boolean collectAll) { - List list = new ArrayList(queryPlanCache.size()); + List list = new ArrayList<>(queryPlanCache.size()); for (CQueryPlan queryPlan : queryPlanCache.values()) { Snapshot snapshot = queryPlan.getSnapshot(reset); if (collectAll || snapshot.getExecutionCount() > 0) { @@ -2014,7 +2014,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { comparators[i] = createPropertyComparator(sortProperty); } - return new ElComparatorCompound(comparators); + return new ElComparatorCompound<>(comparators); } private ElComparator createPropertyComparator(SortByClause.Property sortProp) { @@ -2025,7 +2025,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { if (nullsHigh == null) { nullsHigh = Boolean.TRUE; } - return new ElComparatorProperty(elGetValue, sortProp.isAscending(), nullsHigh); + return new ElComparatorProperty<>(elGetValue, sortProp.isAscending(), nullsHigh); } @Override @@ -2719,7 +2719,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public Map diffForInsert(EntityBean newBean) { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); diffForInsert(null, map, newBean); return map; } @@ -2743,7 +2743,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Return the diff comparing the bean values. */ public Map diff(EntityBean newBean, EntityBean oldBean) { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); diff(null, map, newBean, oldBean); return map; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 3b9e066ed..9cba445a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -296,7 +296,7 @@ final class BeanDescriptorCacheHelp { BeanDescriptor targetDescriptor = many.getTargetDescriptor(); - List idList = new ArrayList(); + List idList = new ArrayList<>(); Collection actualDetails = BeanCollectionUtil.getActualEntries(details); if (actualDetails == null) { return null; @@ -642,7 +642,7 @@ final class BeanDescriptorCacheHelp { boolean updateNaturalKey = false; - Map changes = new LinkedHashMap(); + Map changes = new LinkedHashMap<>(); EntityBean bean = updateRequest.getEntityBean(); boolean[] dirtyProperties = updateRequest.getDirtyProperties(); for (int i = 0; i < dirtyProperties.length; i++) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java index a4589ec53..a3e26d057 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java @@ -30,7 +30,7 @@ public final class BeanDescriptorDraftHelp { */ private BeanProperty[] resetProperties() { - List list = new ArrayList(); + List list = new ArrayList<>(); BeanProperty[] props = desc.propertiesNonMany(); for (BeanProperty prop : props) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java index cf220a3c8..7046cee77 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java @@ -145,7 +145,7 @@ public class BeanDescriptorJsonHelp { } else { // read an unmapped property if (unmappedProperties == null) { - unmappedProperties = new LinkedHashMap(); + unmappedProperties = new LinkedHashMap<>(); } unmappedProperties.put(key, EJson.parse(parser)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index 4f7e79b1e..478dd2cc8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -138,19 +138,19 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private final String serverName; - private Map, DeployBeanInfo> deployInfoMap = new HashMap, DeployBeanInfo>(); + private Map, DeployBeanInfo> deployInfoMap = new HashMap<>(); - private final Map, BeanTable> beanTableMap = new HashMap, BeanTable>(); + private final Map, BeanTable> beanTableMap = new HashMap<>(); - private final Map> descMap = new HashMap>(); + private final Map> descMap = new HashMap<>(); - private final Map> descQueueMap = new HashMap>(); + private final Map> descQueueMap = new HashMap<>(); - private final Map> beanManagerMap = new HashMap>(); + private final Map> beanManagerMap = new HashMap<>(); - private final Map>> tableToDescMap = new HashMap>>(); + private final Map>> tableToDescMap = new HashMap<>(); - private final Map>> tableToViewDescMap = new HashMap>>(); + private final Map>> tableToViewDescMap = new HashMap<>(); private List> immutableDescriptorList; @@ -179,12 +179,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap { /** * Map of base tables to 'with history views' used to support 'as of' queries. */ - private final Map asOfTableMap = new HashMap(); + private final Map asOfTableMap = new HashMap<>(); /** * Map of base tables to 'draft' tables. */ - private final Map draftTableMap = new HashMap(); + private final Map draftTableMap = new HashMap<>(); /** * Create for a given database dbConfig. @@ -324,7 +324,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { // creates the BeanDescriptors readEntityRelationships(); - List> list = new ArrayList>(descMap.values()); + List> list = new ArrayList<>(descMap.values()); Collections.sort(list, beanDescComparator); immutableDescriptorList = Collections.unmodifiableList(list); @@ -353,7 +353,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { Enumeration resources = classLoader.getResources("ebean.xml"); - List mappings = new ArrayList(); + List mappings = new ArrayList<>(); while (resources.hasMoreElements()) { URL url = resources.nextElement(); InputStream is = url.openStream(); @@ -479,7 +479,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { baseTable = baseTable.toLowerCase(); List> list = tableToDescMap.get(baseTable); if (list == null) { - list = new ArrayList>(1); + list = new ArrayList<>(1); tableToDescMap.put(baseTable, list); } list.add(desc); @@ -493,7 +493,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { depTable = depTable.toLowerCase(); List> list = tableToViewDescMap.get(depTable); if (list == null) { - list = new ArrayList>(1); + list = new ArrayList<>(1); tableToViewDescMap.put(depTable, list); } list.add(desc); @@ -639,7 +639,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private BeanDescriptor createEmbedded(Class beanClass) { DeployBeanInfo info = getDeploy(beanClass); - return new BeanDescriptor(this, info.getDescriptor()); + return new BeanDescriptor<>(this, info.getDescriptor()); } /** @@ -859,7 +859,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { // this is the entity bean type - that owns this property Class owningType = prop.getOwningType(); - Set matchSet = new HashSet(); + Set matchSet = new HashSet<>(); // get the bean descriptor that holds the mappedBy property DeployBeanDescriptor targetDesc = getTargetDescriptor(prop); @@ -1166,7 +1166,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { */ private DeployBeanInfo createDeployBeanInfo(Class beanClass) { - DeployBeanDescriptor desc = new DeployBeanDescriptor(this, beanClass, serverConfig); + DeployBeanDescriptor desc = new DeployBeanDescriptor<>(this, beanClass, serverConfig); desc.setUpdateChangesOnly(updateChangesOnly); @@ -1179,7 +1179,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { createProperties.createProperties(desc); - DeployBeanInfo info = new DeployBeanInfo(deployUtil, desc); + DeployBeanInfo info = new DeployBeanInfo<>(deployUtil, desc); readAnnotations.readInitial(info, eagerFetchLobs); return info; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 19e782aab..89d19d3c5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -64,14 +64,14 @@ public class BeanLifecycleAdapterFactory { private static class MethodsHolder { private boolean hasPersistMethods; - private final List preInserts = new ArrayList(); - private final List postInserts = new ArrayList(); - private final List preUpdates = new ArrayList(); - private final List postUpdates = new ArrayList(); - private final List preDeletes = new ArrayList(); - private final List postDeletes = new ArrayList(); - private final List postLoads = new ArrayList(); - private final List postConstructs = new ArrayList(); + private final List preInserts = new ArrayList<>(); + private final List postInserts = new ArrayList<>(); + private final List preUpdates = new ArrayList<>(); + private final List postUpdates = new ArrayList<>(); + private final List preDeletes = new ArrayList<>(); + private final List postDeletes = new ArrayList<>(); + private final List postLoads = new ArrayList<>(); + private final List postConstructs = new ArrayList<>(); /** * Has one of the pre or post insert update delete annotated methods. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java index c44ee4e56..6cd4cd0f0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java @@ -61,7 +61,7 @@ public final class BeanListHelp implements BeanCollectionHelp { BeanList bl = (BeanList) bc; if (bl.getActualList() == null) { - bl.setActualList(new ArrayList()); + bl.setActualList(new ArrayList<>()); } return bl; @@ -72,12 +72,12 @@ public final class BeanListHelp implements BeanCollectionHelp { @Override public BeanCollection createEmptyNoParent() { - return new BeanList(); + return new BeanList<>(); } @Override public BeanCollection createEmpty(EntityBean parentBean) { - BeanList beanList = new BeanList(loader, parentBean, propertyName); + BeanList beanList = new BeanList<>(loader, parentBean, propertyName); if (many != null) { beanList.setModifyListening(many.getModifyListenMode()); } @@ -87,7 +87,7 @@ public final class BeanListHelp implements BeanCollectionHelp { @Override public BeanCollection createReference(EntityBean parentBean) { - BeanList beanList = new BeanList(loader, parentBean, propertyName); + BeanList beanList = new BeanList<>(loader, parentBean, propertyName); beanList.setModifyListening(many.getModifyListenMode()); return beanList; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java index ff9bb39bb..70723d72d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanManagerFactory.java @@ -17,7 +17,7 @@ public class BeanManagerFactory { public BeanManager create(BeanDescriptor desc) { - return new BeanManager(desc, persisterFactory.create(desc)); + return new BeanManager<>(desc, persisterFactory.create(desc)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java index 6340c9fb0..8e7971647 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanMapHelp.java @@ -64,7 +64,7 @@ public final class BeanMapHelp implements BeanCollectionHelp { BeanMap bm = (BeanMap) bc; Map actualMap = bm.getActualMap(); if (actualMap == null) { - actualMap = new LinkedHashMap(); + actualMap = new LinkedHashMap<>(); bm.setActualMap(actualMap); } return new Adder(beanProp, actualMap); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java index b9bc0bd92..24cfb38eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -360,7 +360,7 @@ public abstract class BeanPropertyAssoc extends BeanProperty { private ImportedIdSimple[] createImportedList(BeanPropertyAssoc owner, TableJoinColumn[] cols, BeanProperty[] props, BeanProperty[] others) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (int i = 0; i < cols.length; i++) { list.add(createImportedScalar(owner, cols[i], props, others)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index 5c68c35b5..79a5eec7c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -305,7 +305,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { private List findIdsByParentId(Object parentId, Transaction t, ArrayList excludeDetailIds) { String rawWhere = deriveWhereParentIdSql(false, ""); - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); bindWhereParentId(bindValues, parentId); EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -375,7 +375,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { String expr = rawWhere + inClause; - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); for (int i = 0; i < parentIdList.size(); i++) { bindWhereParentId(bindValues, parentIdList.get(i)); } @@ -667,7 +667,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (exportedProperties.length == 1) { return parentIds; } - List expandedList = new ArrayList(parentIds.size() * exportedProperties.length); + List expandedList = new ArrayList<>(parentIds.size() * exportedProperties.length); for (int i = 0; i < parentIds.size(); i++) { for (int y = 0; y < exportedProperties.length; y++) { Object compId = parentIds.get(i); @@ -771,7 +771,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); if (idProp != null && idProp.isEmbedded()) { @@ -1037,7 +1037,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { liveVal.size(); Collection liveBeans = liveVal.getActualDetails(); - Map liveMap = new LinkedHashMap(); + Map liveMap = new LinkedHashMap<>(); for (Object liveBean : liveBeans) { Object id = targetDescriptor.getId((EntityBean) liveBean); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 20b2f56b2..51f606895 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -78,7 +78,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { // Overriding of the columns and use table alias of owning BeanDescriptor BeanEmbeddedMeta overrideMeta = BeanEmbeddedMetaFactory.create(owner, deploy); embeddedProps = overrideMeta.getProperties(); - embeddedPropsMap = new HashMap(); + embeddedPropsMap = new HashMap<>(); for (int i = 0; i < embeddedProps.length; i++) { embeddedPropsMap.put(embeddedProps[i].getName(), embeddedProps[i]); } @@ -238,7 +238,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String rawWhere = deriveWhereParentIdSql(false); - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); bindWhereParentId(bindValues, parentId); EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -257,7 +257,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String expr = rawWhere + inClause; - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); for (int i = 0; i < parentIdList.size(); i++) { bindWhereParentId(bindValues, parentIdList.get(i)); } @@ -506,7 +506,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); if (idProp != null && idProp.isEmbedded()) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java index 1b0b384c0..8127ce025 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java @@ -31,9 +31,9 @@ public class BeanPropertyCompound extends BeanProperty { private final BeanProperty[] scalarProperties; - private final LinkedHashMap propertyMap = new LinkedHashMap(); + private final LinkedHashMap propertyMap = new LinkedHashMap<>(); - private final LinkedHashMap nonScalarMap = new LinkedHashMap(); + private final LinkedHashMap nonScalarMap = new LinkedHashMap<>(); /** * Create the property. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java index e4e692ce4..8e9f9969e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompoundRoot.java @@ -31,7 +31,7 @@ public class BeanPropertyCompoundRoot { this.fullBeanName = deploy.getFullBeanName(); this.name = deploy.getName(); this.setter = deploy.getSetter(); - this.propList = new ArrayList(); + this.propList = new ArrayList<>(); } public BeanProperty[] getScalarProperties() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java index 1990c30ed..487d89f7e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanSetHelp.java @@ -52,7 +52,7 @@ public final class BeanSetHelp implements BeanCollectionHelp { if (bc instanceof BeanSet) { BeanSet beanSet = (BeanSet) bc; if (beanSet.getActualSet() == null) { - beanSet.setActualSet(new LinkedHashSet()); + beanSet.setActualSet(new LinkedHashSet<>()); } return beanSet; @@ -76,7 +76,7 @@ public final class BeanSetHelp implements BeanCollectionHelp { @Override public BeanCollection createEmpty(EntityBean ownerBean) { - BeanSet beanSet = new BeanSet(loader, ownerBean, propertyName); + BeanSet beanSet = new BeanSet<>(loader, ownerBean, propertyName); if (many != null) { beanSet.setModifyListening(many.getModifyListenMode()); } @@ -86,7 +86,7 @@ public final class BeanSetHelp implements BeanCollectionHelp { @Override public BeanCollection createReference(EntityBean parentBean) { - BeanSet beanSet = new BeanSet(loader, parentBean, propertyName); + BeanSet beanSet = new BeanSet<>(loader, parentBean, propertyName); beanSet.setModifyListening(many.getModifyListenMode()); return beanSet; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java index 06f3218fa..cf565d1a5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java @@ -32,7 +32,7 @@ public class ChainedBeanPersistController implements BeanPersistController { * Helper method used to create a list from 2 BeanPersistController's. */ private static List addList(BeanPersistController c1, BeanPersistController c2) { - ArrayList addList = new ArrayList(2); + ArrayList addList = new ArrayList<>(2); addList.add(c1); addList.add(c2); return addList; @@ -62,7 +62,7 @@ public class ChainedBeanPersistController implements BeanPersistController { if (list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -77,7 +77,7 @@ public class ChainedBeanPersistController implements BeanPersistController { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistListener.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistListener.java index 813caf459..71a82892e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistListener.java @@ -39,7 +39,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { * Helper method used to create a list from 2 BeanPersistListener. */ private static List addList(BeanPersistListener c1, BeanPersistListener c2) { - ArrayList addList = new ArrayList(2); + ArrayList addList = new ArrayList<>(2); addList.add(c1); addList.add(c2); return addList; @@ -60,7 +60,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -75,7 +75,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java index 4ec842e07..58bdb5f1f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java @@ -29,7 +29,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen if (list.contains(c)) { return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -44,7 +44,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen if (!list.contains(c)) { return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java index ab31a33a7..9558d86dc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java @@ -29,7 +29,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -44,7 +44,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java index 4745e7f6b..3987ca537 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java @@ -36,7 +36,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { if (list.contains(c)){ return this; } else { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); @@ -51,7 +51,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { if (!list.contains(c)){ return this; } else { - ArrayList newList = new ArrayList(); + ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParser.java index 6b5b603d5..276ca89cb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParser.java @@ -17,7 +17,7 @@ public final class DeployPropertyParser extends DeployParser { private final BeanDescriptor beanDescriptor; - private final Set includes = new HashSet(); + private final Set includes = new HashSet<>(); public DeployPropertyParser(BeanDescriptor beanDescriptor) { this.beanDescriptor = beanDescriptor; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java index 2ad49241b..3821f2ba0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java @@ -31,7 +31,7 @@ public class InheritInfo { private final Class type; - private final ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList<>(); /** * Map of discriminator values to InheritInfo. @@ -64,8 +64,8 @@ public class InheritInfo { if (r == null) { // this is a root node root = this; - discMap = new HashMap(); - typeMap = new HashMap(); + discMap = new HashMap<>(); + typeMap = new HashMap<>(); registerWithRoot(this); } else { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java index 3d0a48a65..367675c1b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/IntersectionRow.java @@ -18,7 +18,7 @@ public class IntersectionRow { private final BeanDescriptor targetDescriptor; - private final LinkedHashMap values = new LinkedHashMap(); + private final LinkedHashMap values = new LinkedHashMap<>(); private ArrayList excludeIds; private BeanDescriptor excludeDescriptor; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java index 890b6581f..a9e0bd32d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java @@ -25,7 +25,7 @@ public class GeneratedPropertyFactory { private final UpdateTimestampFactory updateFactory; - private final HashSet numberTypes = new HashSet(); + private final HashSet numberTypes = new HashSet<>(); private final GeneratedWhoModified generatedWhoModified; @@ -33,7 +33,7 @@ public class GeneratedPropertyFactory { private final ClassLoadConfig classLoadConfig; - private final Map idGeneratorMap = new HashMap(); + private final Map idGeneratorMap = new HashMap<>(); public GeneratedPropertyFactory(ServerConfig serverConfig, List idGenerators) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java index c07426bbe..b1a510507 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/InsertTimestampFactory.java @@ -19,7 +19,7 @@ public class InsertTimestampFactory { final GeneratedInsertLong longTime = new GeneratedInsertLong(); - final Map, GeneratedProperty> map = new HashMap, GeneratedProperty>(); + final Map, GeneratedProperty> map = new HashMap<>(); public InsertTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedInsertTimestamp()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java index dd7c1653a..1e9f005e6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactory.java @@ -19,7 +19,7 @@ public class UpdateTimestampFactory { final GeneratedUpdateLong longTime = new GeneratedUpdateLong(); - final Map, GeneratedProperty> map = new HashMap, GeneratedProperty>(); + final Map, GeneratedProperty> map = new HashMap<>(); public UpdateTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedUpdateTimestamp()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index 43579af80..9c421b652 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -234,7 +234,7 @@ public final class IdBinderEmbedded implements IdBinder { public Object getIdForJson(EntityBean bean) { EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean); - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); for (int i = 0; i < props.length; i++) { map.put(props[i].getName(), props[i].getValue(ebValue)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index c382068c4..37041ab4b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -48,9 +48,9 @@ import java.util.Map; */ public class DeployBeanDescriptor { - private static final Map EMPTY_NAMED_QUERY = new HashMap(); + private static final Map EMPTY_NAMED_QUERY = new HashMap<>(); - private static final Map EMPTY_RAW_MAP = new HashMap(); + private static final Map EMPTY_RAW_MAP = new HashMap<>(); private static class PropOrder implements Comparator { @@ -73,7 +73,7 @@ public class DeployBeanDescriptor { /** * Map of BeanProperty Linked so as to preserve order. */ - private LinkedHashMap propMap = new LinkedHashMap(); + private LinkedHashMap propMap = new LinkedHashMap<>(); private Map namedRawSql; @@ -153,11 +153,11 @@ public class DeployBeanDescriptor { */ private final Class beanType; - private final List persistControllers = new ArrayList(); - private final List persistListeners = new ArrayList(); - private final List queryAdapters = new ArrayList(); - private final List postLoaders = new ArrayList(); - private final List postConstructListeners = new ArrayList(); + private final List persistControllers = new ArrayList<>(); + private final List persistListeners = new ArrayList<>(); + private final List queryAdapters = new ArrayList<>(); + private final List postLoaders = new ArrayList<>(); + private final List postConstructListeners = new ArrayList<>(); private CacheOptions cacheOptions = CacheOptions.NO_CACHING; @@ -169,7 +169,7 @@ public class DeployBeanDescriptor { /** * The table joins for this bean. Server side only. */ - private final ArrayList tableJoinList = new ArrayList(2); + private final ArrayList tableJoinList = new ArrayList<>(2); /** * Inheritance information. Server side only. @@ -454,7 +454,7 @@ public class DeployBeanDescriptor { */ public void addIndex(IndexDefinition c) { if (indexDefinitions == null) { - indexDefinitions = new ArrayList(); + indexDefinitions = new ArrayList<>(); } indexDefinitions.add(c); } @@ -629,12 +629,12 @@ public class DeployBeanDescriptor { public void sortProperties() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(propMap.values()); Collections.sort(list, PROP_ORDER); - propMap = new LinkedHashMap(list.size()); + propMap = new LinkedHashMap<>(list.size()); for (int i = 0; i < list.size(); i++) { addBeanProperty(list.get(i)); } @@ -917,7 +917,7 @@ public class DeployBeanDescriptor { public List propertiesId() { if (idProperties == null) { - idProperties = new ArrayList(2); + idProperties = new ArrayList<>(2); for (DeployBeanProperty prop : propMap.values()) { if (prop.isId()) { idProperties.add(prop); @@ -945,7 +945,7 @@ public class DeployBeanDescriptor { */ public List> propertiesAssocOne() { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (prop instanceof DeployBeanPropertyAssocOne) { @@ -964,7 +964,7 @@ public class DeployBeanDescriptor { */ public List> propertiesAssocMany() { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (prop instanceof DeployBeanPropertyAssocMany) { @@ -980,7 +980,7 @@ public class DeployBeanDescriptor { */ public List propertiesBase() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (DeployBeanProperty prop : propMap.values()) { if (!(prop instanceof DeployBeanPropertyAssoc) && !prop.isId()) { @@ -1089,7 +1089,7 @@ public class DeployBeanDescriptor { */ public void addNamedQuery(String name, String query) { if (namedQuery == null) { - namedQuery = new LinkedHashMap(); + namedQuery = new LinkedHashMap<>(); } namedQuery.put(name, query); } @@ -1106,7 +1106,7 @@ public class DeployBeanDescriptor { */ public void addRawSql(String name, RawSql rawSql) { if (namedRawSql == null) { - namedRawSql = new HashMap(); + namedRawSql = new HashMap<>(); } namedRawSql.put(name, rawSql); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java index a85e63200..48f1db521 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanEmbedded.java @@ -15,7 +15,7 @@ public class DeployBeanEmbedded { /** * A map of property names to dbColumns. */ - private final Map propMap = new HashMap(); + private final Map propMap = new HashMap<>(); /** * Set a Map of property names to dbColumns. diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index b0666e501..9d707fdd9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -35,29 +35,29 @@ public class DeployBeanPropertyLists { private final LinkedHashMap propertyMap; - private final List ids = new ArrayList(); + private final List ids = new ArrayList<>(); - private final List local = new ArrayList(); + private final List local = new ArrayList<>(); - private final List mutable = new ArrayList(); + private final List mutable = new ArrayList<>(); - private final List> manys = new ArrayList>(); + private final List> manys = new ArrayList<>(); - private final List nonManys = new ArrayList(); + private final List nonManys = new ArrayList<>(); - private final List> ones = new ArrayList>(); + private final List> ones = new ArrayList<>(); - private final List> onesImported = new ArrayList>(); + private final List> onesImported = new ArrayList<>(); - private final List> embedded = new ArrayList>(); + private final List> embedded = new ArrayList<>(); - private final List baseScalar = new ArrayList(); + private final List baseScalar = new ArrayList<>(); - private final List baseCompound = new ArrayList(); + private final List baseCompound = new ArrayList<>(); - private final List transients = new ArrayList(); + private final List transients = new ArrayList<>(); - private final List nonTransients = new ArrayList(); + private final List nonTransients = new ArrayList<>(); private final TableJoin[] tableJoins; @@ -76,7 +76,7 @@ public class DeployBeanPropertyLists { unidirectional = new BeanPropertyAssocOne(owner, desc, deployUnidirectional); } - this.propertyMap = new LinkedHashMap(); + this.propertyMap = new LinkedHashMap<>(); // see if there is a discriminator property we should add String discriminatorColumn = null; @@ -346,7 +346,7 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocOne[] getOne(boolean imported, Mode mode) { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (int i = 0; i < ones.size(); i++) { BeanPropertyAssocOne prop = ones.get(i); if (imported != prop.isOneToOneExported()) { @@ -371,7 +371,7 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocMany[] getMany2Many() { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (int i = 0; i < manys.size(); i++) { BeanPropertyAssocMany prop = manys.get(i); if (prop.isManyToMany()) { @@ -383,7 +383,7 @@ public class DeployBeanPropertyLists { } private BeanPropertyAssocMany[] getMany(Mode mode) { - ArrayList> list = new ArrayList>(); + ArrayList> list = new ArrayList<>(); for (int i = 0; i < manys.size(); i++) { BeanPropertyAssocMany prop = manys.get(i); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java index fad7550a0..5296fff32 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java @@ -28,7 +28,7 @@ public class DeployTableJoin { /** * The list of join column pairs. Used to generate the on clause. */ - private ArrayList columns = new ArrayList(4); + private ArrayList columns = new ArrayList<>(4); private InheritInfo inheritInfo; @@ -53,7 +53,7 @@ public class DeployTableJoin { * Copy all the columns to this join potentially reversing the columns. */ public void setColumns(DeployTableJoinColumn[] cols, boolean reverse) { - columns = new ArrayList(); + columns = new ArrayList<>(); for (int i = 0; i < cols.length; i++) { addJoinColumn(cols[i].copy(reverse)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java index d6fc3b540..1b3d8acd5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationBase.java @@ -101,7 +101,7 @@ public abstract class AnnotationBase { if (ann != null) { return ann; } else { - return findAnnotation(annotatedElement, annotationType, new HashSet()); + return findAnnotation(annotatedElement, annotationType, new HashSet<>()); } } @@ -121,7 +121,7 @@ public abstract class AnnotationBase { return ann; } else { while (clazz != null && clazz != Object.class) { - ann = findAnnotation(clazz, annotationType, new HashSet()); + ann = findAnnotation(clazz, annotationType, new HashSet<>()); if (ann != null) { return ann; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java index 031681a5b..e2457ba77 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -54,7 +54,7 @@ public abstract class AnnotationParser extends AnnotationBase { AttributeOverrides attrOverrides = get(prop, AttributeOverrides.class); if (attrOverrides != null) { - HashMap propMap = new HashMap(); + HashMap propMap = new HashMap<>(); AttributeOverride[] aoArray = attrOverrides.value(); for (int i = 0; i < aoArray.length; i++) { String propName = aoArray[i].name(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java index 63ffc3801..ac7543d1b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployBeanInfo.java @@ -16,7 +16,7 @@ public class DeployBeanInfo { /** * Holds TableJoins for secondary table properties. */ - private final HashMap tableJoinMap = new HashMap(); + private final HashMap tableJoinMap = new HashMap<>(); private final DeployUtil util; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java index b110798f9..a1eec01bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInherit.java @@ -19,9 +19,9 @@ import java.util.Map; */ public class DeployInherit { - private final Map, DeployInheritInfo> deployMap = new LinkedHashMap, DeployInheritInfo>(); + private final Map, DeployInheritInfo> deployMap = new LinkedHashMap<>(); - private final Map, InheritInfo> finalMap = new LinkedHashMap, InheritInfo>(); + private final Map, InheritInfo> finalMap = new LinkedHashMap<>(); private final BootupClasses bootupClasses; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java index 6c45bdd52..3964c5d23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployInheritInfo.java @@ -32,7 +32,7 @@ public class DeployInheritInfo { private Class parent; - private final ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList<>(); /** * Create for a given type. @@ -202,7 +202,7 @@ public class DeployInheritInfo { public String getWhere() { - List discList = new ArrayList(); + List discList = new ArrayList<>(); appendDiscriminator(discList); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java index 96beb0fdc..329307b5b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java @@ -45,7 +45,7 @@ public class SqlReservedWords { +",WHERE,WITH"; - private static final HashSet keywords = new HashSet(); + private static final HashSet keywords = new HashSet<>(); static { String[] initialKeywords = baseKeyWords.split(","); diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java index 9ef9a520c..c8650d0d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java @@ -15,7 +15,7 @@ public final class ElFilter implements Filter { private final BeanDescriptor beanDescriptor; - private final ArrayList> matches = new ArrayList>(); + private final ArrayList> matches = new ArrayList<>(); private int maxRows; @@ -61,7 +61,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.InSet(matchingValues, elGetValue)); + matches.add(new ElMatchBuilder.InSet<>(matchingValues, elGetValue)); return this; } @@ -70,7 +70,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Eq(value, comparator)); + matches.add(new ElMatchBuilder.Eq<>(value, comparator)); return this; } @@ -80,7 +80,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Ne(value, comparator)); + matches.add(new ElMatchBuilder.Ne<>(value, comparator)); return this; } @@ -92,7 +92,7 @@ public final class ElFilter implements Filter { ElComparator elComparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Between(min, max, elComparator)); + matches.add(new ElMatchBuilder.Between<>(min, max, elComparator)); return this; } @@ -102,7 +102,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Gt(value, comparator)); + matches.add(new ElMatchBuilder.Gt<>(value, comparator)); return this; } @@ -111,7 +111,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Ge(value, comparator)); + matches.add(new ElMatchBuilder.Ge<>(value, comparator)); return this; } @@ -119,7 +119,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.Ieq(elGetValue, value)); + matches.add(new ElMatchBuilder.Ieq<>(elGetValue, value)); return this; } @@ -128,7 +128,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IsNotNull(elGetValue)); + matches.add(new ElMatchBuilder.IsNotNull<>(elGetValue)); return this; } @@ -137,7 +137,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IsNull(elGetValue)); + matches.add(new ElMatchBuilder.IsNull<>(elGetValue)); return this; } @@ -147,7 +147,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Le(value, comparator)); + matches.add(new ElMatchBuilder.Le<>(value, comparator)); return this; } @@ -157,7 +157,7 @@ public final class ElFilter implements Filter { value = convertValue(propertyName, value); ElComparator comparator = getElComparator(propertyName); - matches.add(new ElMatchBuilder.Lt(value, comparator)); + matches.add(new ElMatchBuilder.Lt<>(value, comparator)); return this; } @@ -169,7 +169,7 @@ public final class ElFilter implements Filter { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, regEx, options)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, regEx, options)); return this; } @@ -178,7 +178,7 @@ public final class ElFilter implements Filter { String quote = ".*" + Pattern.quote(value) + ".*"; ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, quote, 0)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, quote, 0)); return this; } @@ -187,7 +187,7 @@ public final class ElFilter implements Filter { String quote = ".*" + Pattern.quote(value) + ".*"; ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.RegularExpr(elGetValue, quote, Pattern.CASE_INSENSITIVE)); + matches.add(new ElMatchBuilder.RegularExpr<>(elGetValue, quote, Pattern.CASE_INSENSITIVE)); return this; } @@ -195,28 +195,28 @@ public final class ElFilter implements Filter { public Filter endsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.EndsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.EndsWith<>(elGetValue, value)); return this; } public Filter startsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.StartsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.StartsWith<>(elGetValue, value)); return this; } public Filter iendsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IEndsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.IEndsWith<>(elGetValue, value)); return this; } public Filter istartsWith(String propertyName, String value) { ElPropertyValue elGetValue = getElGetValue(propertyName); - matches.add(new ElMatchBuilder.IStartsWith(elGetValue, value)); + matches.add(new ElMatchBuilder.IStartsWith<>(elGetValue, value)); return this; } @@ -229,11 +229,11 @@ public final class ElFilter implements Filter { if (sortByClause != null) { // create shallow copy and sort - list = new ArrayList(list); + list = new ArrayList<>(list); beanDescriptor.sort(list, sortByClause); } - ArrayList filterList = new ArrayList(); + ArrayList filterList = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { T t = list.get(i); diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java index 946e8d1fc..d8b681858 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChainBuilder.java @@ -17,7 +17,7 @@ public class ElPropertyChainBuilder { private final String expression; - private final List chain = new ArrayList(); + private final List chain = new ArrayList<>(); private final boolean embedded; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index a979879a2..63ce7c23c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -82,7 +82,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio DefaultExampleExpression(ArrayList source) { this.entity = null; - this.list = new ArrayList(source.size()); + this.list = new ArrayList<>(source.size()); for (SpiExpression expression : source) { list.add(expression.copyForPlanKey()); } @@ -273,7 +273,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio */ private ArrayList buildExpressions(BeanDescriptor beanDescriptor) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); addExpressions(list, beanDescriptor, entity, null); return list; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java index 5115a8ae3..2e0a7c1f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java @@ -492,35 +492,35 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { * Return a list of expressions that will be joined by AND's. */ public Junction conjunction(Query query) { - return new JunctionExpression(Junction.Type.AND, query, query.where()); + return new JunctionExpression<>(Junction.Type.AND, query, query.where()); } /** * Return a list of expressions that will be joined by OR's. */ public Junction disjunction(Query query) { - return new JunctionExpression(Junction.Type.OR, query, query.where()); + return new JunctionExpression<>(Junction.Type.OR, query, query.where()); } /** * Return a list of expressions that will be joined by AND's. */ public Junction conjunction(Query query, ExpressionList parent) { - return new JunctionExpression(Junction.Type.AND, query, parent); + return new JunctionExpression<>(Junction.Type.AND, query, parent); } /** * Return a list of expressions that will be joined by OR's. */ public Junction disjunction(Query query, ExpressionList parent) { - return new JunctionExpression(Junction.Type.OR, query, parent); + return new JunctionExpression<>(Junction.Type.OR, query, parent); } /** * Return a list of expressions that are wrapped by NOT. */ public Junction junction(Junction.Type type, Query query) { - return new JunctionExpression(type, query, query.where()); + return new JunctionExpression<>(type, query, query.where()); } /** @@ -528,6 +528,6 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { */ @Override public Junction junction(Junction.Type type, Query query, ExpressionList parent) { - return new JunctionExpression(type, query, parent); + return new JunctionExpression<>(type, query, parent); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index 497317fcf..e1e289523 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -50,7 +50,7 @@ public class DefaultExpressionList implements SpiExpressionList { * Construct for Text root expression list - this handles implicit Bool Should, Must etc. */ public DefaultExpressionList(Query query) { - this(query, query.getExpressionFactory(), null, new ArrayList(), true); + this(query, query.getExpressionFactory(), null, new ArrayList<>(), true); } public DefaultExpressionList(Query query, ExpressionList parentExprList) { @@ -58,7 +58,7 @@ public class DefaultExpressionList implements SpiExpressionList { } DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList) { - this(query, expr, parentExprList, new ArrayList()); + this(query, expr, parentExprList, new ArrayList<>()); } DefaultExpressionList(Query query, ExpressionFactory expr, ExpressionList parentExprList, List list) { @@ -74,7 +74,7 @@ public class DefaultExpressionList implements SpiExpressionList { } private DefaultExpressionList() { - this(null, null, null, new ArrayList()); + this(null, null, null, new ArrayList<>()); } /** @@ -87,11 +87,11 @@ public class DefaultExpressionList implements SpiExpressionList { */ SpiExpression wrap(List list, String nestedPath, Junction.Type type) { - DefaultExpressionList wrapper = new DefaultExpressionList(query, expr, null, list, false); + DefaultExpressionList wrapper = new DefaultExpressionList<>(query, expr, null, list, false); wrapper.setAllDocNested(nestedPath); if (type != null) { - return new JunctionExpression(type, wrapper); + return new JunctionExpression<>(type, wrapper); } else { return wrapper; } @@ -201,13 +201,13 @@ public class DefaultExpressionList implements SpiExpressionList { *

*/ public DefaultExpressionList copy(Query query) { - DefaultExpressionList copy = new DefaultExpressionList(query, expr, null); + DefaultExpressionList copy = new DefaultExpressionList<>(query, expr, null); copy.list.addAll(list); return copy; } public DefaultExpressionList copyForPlanKey() { - DefaultExpressionList copy = new DefaultExpressionList(); + DefaultExpressionList copy = new DefaultExpressionList<>(); for (int i = 0; i < list.size(); i++) { copy.list.add(list.get(i).copyForPlanKey()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java index 76f157b43..3c983bc6d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java @@ -21,7 +21,7 @@ public class DefaultExpressionRequest implements SpiExpressionRequest { private final StringBuilder sql = new StringBuilder(); - private final List bindValues = new ArrayList(); + private final List bindValues = new ArrayList<>(); private final DeployParser deployParser; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java index dc3852ef6..a852d3593 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java @@ -30,7 +30,7 @@ public class FilterExpressionList extends DefaultExpressionList { @Override public SpiExpressionList trimPath(int prefixTrim) { - return new FilterExpressionList(pathPrefix.trimPath(prefixTrim), this); + return new FilterExpressionList<>(pathPrefix.trimPath(prefixTrim), this); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 89ad86c40..3352850da 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -34,7 +34,7 @@ class InExpression extends AbstractExpression { } private Object[] values() { - List vals = new ArrayList(); + List vals = new ArrayList<>(); for (Object sourceValue : sourceValues) { NamedParamHelp.valueAdd(vals, sourceValue); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index 6a3351d66..2b852a1dc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -46,7 +46,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression JunctionExpression(Junction.Type type, Query query, ExpressionList parent) { this.type = type; - this.exprList = new DefaultExpressionList(query, parent); + this.exprList = new DefaultExpressionList<>(query, parent); } /** @@ -84,7 +84,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression } public SpiExpression copyForPlanKey() { - return new JunctionExpression(type, exprList.copyForPlanKey()); + return new JunctionExpression<>(type, exprList.copyForPlanKey()); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java index ee917f830..2c05609b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java @@ -73,7 +73,7 @@ class PrepareDocNested { */ private List group() { - Map groups = new LinkedHashMap(); + Map groups = new LinkedHashMap<>(); // organise expressions by nestedPath for (int i = 0; i < origSize; i++) { @@ -87,7 +87,7 @@ class PrepareDocNested { group.list.add(expr); } - List newList = new ArrayList(); + List newList = new ArrayList<>(); Collection values = groups.values(); for (Group group : values) { group.addTo(newList); @@ -145,7 +145,7 @@ class PrepareDocNested { final String nestedPath; - final List list = new ArrayList(); + final List list = new ArrayList<>(); Group(String nestedPath) { this.nestedPath = nestedPath; diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java index 1eceaf120..762ec25b5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java @@ -57,7 +57,7 @@ class EqlAdapter extends EQLBaseListener { } if (whereStack == null) { - whereStack = new ArrayStack>(); + whereStack = new ArrayStack<>(); whereStack.push(query.where()); } // return the current expression list @@ -66,7 +66,7 @@ class EqlAdapter extends EQLBaseListener { private ExpressionList _peekText() { if (textStack == null) { - textStack = new ArrayStack>(); + textStack = new ArrayStack<>(); // empty so push on the queries base expression list textStack.push(query.text()); } @@ -216,7 +216,7 @@ class EqlAdapter extends EQLBaseListener { @Override public void enterIn_expression(EQLParser.In_expressionContext ctx) { - this.inValues = new ArrayList(); + this.inValues = new ArrayList<>(); this.inPropertyName = getLeftHandSidePath(ctx); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java index 12b5e7a41..44e06bff3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlParser.java @@ -28,7 +28,7 @@ public class EqlParser { parser.addErrorListener(errorListener); EQLParser.Select_statementContext context = parser.select_statement(); - EqlAdapter adapter = new EqlAdapter(query); + EqlAdapter adapter = new EqlAdapter<>(query); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(adapter, context); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java index 2e19dd512..94d300e66 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java @@ -5,7 +5,7 @@ import java.util.Map; class OperatorMapping { - Map map = new HashMap(); + Map map = new HashMap<>(); public OperatorMapping() { map.put("eq", EqlOperator.EQ); diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java index 8100e6816..33f298554 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java @@ -23,7 +23,7 @@ public final class ShutdownManager { private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); - static final List servers = new ArrayList(); + static final List servers = new ArrayList<>(); static final ShutdownHook shutdownHook = new ShutdownHook(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java index b3bb630e2..4e5b7667c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java @@ -23,7 +23,7 @@ public class StringHelper { public static Map delimitedToMap(String allNameValuePairs, String listDelimiter, String nameValueSeparator) { - HashMap params = new HashMap(); + HashMap params = new HashMap<>(); if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { return params; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java index 3a73be4e3..c1f374bb1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadBeanContext.java @@ -27,7 +27,7 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex public DLoadBeanContext(DLoadContext parent, BeanDescriptor desc, String path, int defaultBatchSize, OrmQueryProperties queryProps) { super(parent, desc, path, defaultBatchSize, queryProps); // bufferList only required when using query joins (queryFetch) - this.bufferList = (!queryFetch) ? null : new ArrayList(); + this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(firstBatchSize); } @@ -109,7 +109,7 @@ public class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContex public LoadBuffer(DLoadBeanContext context, int batchSize) { this.context = context; this.batchSize = batchSize; - this.list = new ArrayList(batchSize); + this.list = new ArrayList<>(batchSize); } public int getBatchSize() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java index 2088e5b05..eb5e6707b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java @@ -33,8 +33,8 @@ public class DLoadContext implements LoadContext { private final BeanDescriptor rootDescriptor; - private final Map beanMap = new HashMap(); - private final Map manyMap = new HashMap(); + private final Map beanMap = new HashMap<>(); + private final Map manyMap = new HashMap<>(); private final DLoadBeanContext rootBeanContext; @@ -55,7 +55,7 @@ public class DLoadContext implements LoadContext { private final ObjectGraphOrigin origin; private final boolean useProfiling; - private final Map nodePathMap = new HashMap(); + private final Map nodePathMap = new HashMap<>(); private PersistenceContext persistenceContext; diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java index 979244593..b55b1efe4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadManyContext.java @@ -35,7 +35,7 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex this.property = property; this.docStoreMapped = property.getTargetDescriptor().isDocStoreMapped(); // bufferList only required when using query joins (queryFetch) - this.bufferList = (!queryFetch) ? null : new ArrayList(); + this.bufferList = (!queryFetch) ? null : new ArrayList<>(); this.currentBuffer = createBuffer(firstBatchSize); } @@ -133,7 +133,7 @@ public class DLoadManyContext extends DLoadBaseContext implements LoadManyContex // case it changes as part of a findIterate etc this.persistenceContext = context.getPersistenceContext(); this.batchSize = batchSize; - this.list = new ArrayList>(batchSize); + this.list = new ArrayList<>(batchSize); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index 846ed3dd2..e4efe2cb7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -42,7 +42,7 @@ public final class BatchControl { * Map of the BatchedBeanHolder objects. They each have a depth and are later * sorted by their depth to get the execution order. */ - private final HashMap beanHoldMap = new HashMap(); + private final HashMap beanHoldMap = new HashMap<>(); private final SpiTransaction transaction; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java index df18d3a93..e842c52eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedBeanHolder.java @@ -54,7 +54,7 @@ public class BatchedBeanHolder { * Set of beans in this batch. This is used to ensure that a single bean instance is not included * in the batch twice (two separate insert requests etc). */ - private final IdentityHashMap persistedBeans = new IdentityHashMap(); + private final IdentityHashMap persistedBeans = new IdentityHashMap<>(); /** * Create a new entry with a given type and depth. @@ -132,7 +132,7 @@ public class BatchedBeanHolder { switch (request.getType()) { case INSERT: if (inserts == null) { - inserts = new ArrayList(); + inserts = new ArrayList<>(); } inserts.add(request); return inserts.size(); @@ -140,14 +140,14 @@ public class BatchedBeanHolder { case UPDATE: case SOFT_DELETE: if (updates == null) { - updates = new ArrayList(); + updates = new ArrayList<>(); } updates.add(request); return updates.size(); case DELETE: if (deletes == null) { - deletes = new ArrayList(); + deletes = new ArrayList<>(); } deletes.add(request); return deletes.size(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java index c2c808ea7..ed5be8019 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java @@ -27,7 +27,7 @@ public class BatchedPstmt { /** * The list of BatchPostExecute used to perform post processing. */ - private final ArrayList list = new ArrayList(); + private final ArrayList list = new ArrayList<>(); private final String sql; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java index 2f682e215..c726b7a8f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java @@ -25,7 +25,7 @@ public class BatchedPstmtHolder { * A Map of the statements using a String key. This is used so that the same * Statement,Prepared,Callable is reused. */ - private final LinkedHashMap stmtMap = new LinkedHashMap(); + private final LinkedHashMap stmtMap = new LinkedHashMap<>(); /** * The Max size across all the BatchedPstmt. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java index bb41fd74b..8bf946244 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BindValues.java @@ -7,7 +7,7 @@ import java.util.ArrayList; */ public class BindValues { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); /** * Create with a Binder. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 7883d169e..4c035aa9c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -136,7 +136,7 @@ public final class DefaultPersister implements Persister { Class beanType = query.getBeanType(); BeanDescriptor desc = server.getBeanDescriptor(beanType); - DraftHandler draftHandler = new DraftHandler(desc, transaction); + DraftHandler draftHandler = new DraftHandler<>(desc, transaction); List liveBeans = draftHandler.fetchSourceBeans(query, false); PUB.debug("draftRestore [{}] count[{}]", desc.getName(), liveBeans.size()); @@ -165,7 +165,7 @@ public final class DefaultPersister implements Persister { * Helper method to return the list of Id values for the list of beans. */ private List getBeanIds(BeanDescriptor desc, List beans) { - List idList = new ArrayList(); + List idList = new ArrayList<>(); for (T liveBean: beans) { idList.add(desc.getBeanId(liveBean)); } @@ -181,7 +181,7 @@ public final class DefaultPersister implements Persister { Class beanType = query.getBeanType(); BeanDescriptor desc = server.getBeanDescriptor(beanType); - DraftHandler draftHandler = new DraftHandler(desc, transaction); + DraftHandler draftHandler = new DraftHandler<>(desc, transaction); List draftBeans = draftHandler.fetchSourceBeans(query, true); PUB.debug("publish [{}] count[{}]", desc.getName(), draftBeans.size()); @@ -193,7 +193,7 @@ public final class DefaultPersister implements Persister { BeanManager mgr = beanDescriptorManager.getBeanManager(beanType); - List livePublish = new ArrayList(draftBeans.size()); + List livePublish = new ArrayList<>(draftBeans.size()); for (T draftBean: draftBeans) { T liveBean = draftHandler.publishToDestinationBean(draftBean); livePublish.add(liveBean); @@ -226,7 +226,7 @@ public final class DefaultPersister implements Persister { final BeanDescriptor desc; final Transaction transaction; final BeanProperty draftDirty; - final List draftUpdates = new ArrayList(); + final List draftUpdates = new ArrayList<>(); /** * Id value of the last published bean. @@ -573,7 +573,7 @@ public final class DefaultPersister implements Persister { BeanDescriptor descriptor = beanDescriptorManager.getBeanDescriptor(beanType); - ArrayList idList = new ArrayList(ids.size()); + ArrayList idList = new ArrayList<>(ids.size()); for (Object id : ids) { // convert to appropriate type if required idList.add(descriptor.convertId(id)); @@ -985,7 +985,7 @@ public final class DefaultPersister implements Persister { ArrayList detailIds = null; if (deleteMissingChildren) { // collect the Id's (to exclude from deleteManyDetails) - detailIds = new ArrayList(); + detailIds = new ArrayList<>(); } // increase depth for batching order @@ -1292,7 +1292,7 @@ public final class DefaultPersister implements Persister { if (targetDesc.propertiesManyToMany().length > 0) { // convert into a list of reference objects and perform delete by object - List refList = new ArrayList(childIds.size()); + List refList = new ArrayList<>(childIds.size()); for (Object id : childIds) { refList.add(targetDesc.createReference(null, false, id, null)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java index 9a8488231..175695a21 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java @@ -23,7 +23,7 @@ import java.util.List; */ class DeleteUnloadedForeignKeys { - private final List> propList = new ArrayList>(4); + private final List> propList = new ArrayList<>(4); private final SpiEbeanServer server; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java index 1ad53e203..374500421 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/MetaFactory.java @@ -56,7 +56,7 @@ public class MetaFactory { */ public UpdateMeta createUpdate(BeanDescriptor desc) { - List setList = new ArrayList(); + List setList = new ArrayList<>(); baseFact.create(setList, desc, DmlMode.UPDATE, includeLobs); embeddedFact.create(setList, desc, DmlMode.UPDATE, includeLobs); @@ -90,7 +90,7 @@ public class MetaFactory { BindableId id = idFact.createId(desc); - List allList = new ArrayList(); + List allList = new ArrayList<>(); baseFact.create(allList, desc, DmlMode.INSERT, includeLobs); embeddedFact.create(allList, desc, DmlMode.INSERT, includeLobs); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java index 073e23d71..32bc1f022 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java @@ -116,7 +116,7 @@ public final class UpdateMeta { // build a new UpdatePlan and cache it // build a bindableList that only contains the changed properties - List list = new ArrayList(); + List list = new ArrayList<>(); set.addToUpdate(persistRequest, list); BindableList bindableList = new BindableList(list); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index cf46cd141..f8f231b29 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -23,7 +23,7 @@ public class BindableList implements Bindable { * Return a bindable list that excludes @DraftOnly properties. */ public BindableList excludeDraftOnly() { - List copy = new ArrayList(items.length); + List copy = new ArrayList<>(items.length); for (Bindable b : items) { if (!b.isDraftOnly()) { copy.add(b); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index 9ce0717fb..e1378423b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -34,7 +34,7 @@ public class FactoryBaseProperties { for (int i = 0; i < compoundProps.length; i++) { BeanProperty[] props = compoundProps[i].getScalarProperties(); - List newList = new ArrayList(props.length); + List newList = new ArrayList<>(props.length); addCompound(props, newList, mode, withLobs); BindableCompound compoundBindable = new BindableCompound(compoundProps[i], newList); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java index 7cedbbaa2..45d1e165e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java @@ -30,7 +30,7 @@ public class FactoryEmbedded { BeanProperty[] props = embedded[j].getProperties(); - List bindList = new ArrayList(props.length); + List bindList = new ArrayList<>(props.length); for (int i = 0; i < props.length; i++) { Bindable item = factoryProperty.create(props[i], mode, withLobs); diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java index 39c78781d..d466fb7cb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java @@ -10,7 +10,7 @@ import java.util.Map; */ public class BeanPropertiesReader { - private final Map propertyIndexMap = new HashMap(); + private final Map propertyIndexMap = new HashMap<>(); private final String[] props; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java index 0dee1d36a..8a6663b36 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQuery.java @@ -737,7 +737,7 @@ public class CQuery implements DbReadContext, CancelableQuery { if (!collection.isEmpty()) { // get the id values of the underlying collection - List ids = new ArrayList(collection.size()); + List ids = new ArrayList<>(collection.size()); Collection underlyingBeans = collection.getActualDetails(); for (T underlyingBean : underlyingBeans) { ids.add(desc.getIdForJson(underlyingBean)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index 519b6d88c..e53bfc904 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -666,7 +666,7 @@ public class SqlTreeBuilder { */ private String[] findExtras() { - List extras = new ArrayList(); + List extras = new ArrayList<>(); for (String predProp : predicateIncludes) { if (!selectIncludes.contains(predProp)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 240cf50c7..7a5ee3e1a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1418,7 +1418,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override public ExpressionList having() { if (havingExpressions == null) { - havingExpressions = new DefaultExpressionList(this, null); + havingExpressions = new DefaultExpressionList<>(this, null); } return havingExpressions; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java index 650c94f5e..4a7fc27e1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java @@ -128,7 +128,7 @@ public class CsvUtilReader { */ public List readAll() throws IOException { - List allElements = new ArrayList(); + List allElements = new ArrayList<>(); while (hasNext) { String[] nextLineAsTokens = readNext(); if (nextLineAsTokens != null) @@ -188,7 +188,7 @@ public class CsvUtilReader { return null; } - List tokensOnThisLine = new ArrayList(); + List tokensOnThisLine = new ArrayList<>(); StringBuilder sb = new StringBuilder(); boolean inQuotes = false; diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java index e185d3fe4..3fe34fe90 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java @@ -35,7 +35,7 @@ public class TCsvReader implements CsvReader { private final BeanDescriptor descriptor; - private final List columnList = new ArrayList(); + private final List columnList = new ArrayList<>(); private final CsvColumn ignoreColumn = new CsvColumn(); @@ -155,7 +155,7 @@ public class TCsvReader implements CsvReader { } public void process(Reader reader) throws Exception { - DefaultCsvCallback callback = new DefaultCsvCallback(persistBatchSize, logInfoFrequency); + DefaultCsvCallback callback = new DefaultCsvCallback<>(persistBatchSize, logInfoFrequency); process(reader, callback); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java index 21d6ffd6f..92a4603ae 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java @@ -123,7 +123,7 @@ public class DJsonContext implements JsonContext { BeanDescriptor desc = getDescriptor(cls); ReadJson readJson = new ReadJson(desc, parser, options, determineObjectMapper(options)); - return new DJsonBeanReader(desc, readJson); + return new DJsonBeanReader<>(desc, readJson); } @Override @@ -131,7 +131,7 @@ public class DJsonContext implements JsonContext { BeanDescriptor desc = (BeanDescriptor)beanType; ReadJson readJson = new ReadJson(desc, parser, options, determineObjectMapper(options)); - return new DJsonBeanReader(desc, readJson); + return new DJsonBeanReader<>(desc, readJson); } public List toList(Class cls, String json) throws JsonIOException { @@ -161,7 +161,7 @@ public class DJsonContext implements JsonContext { ReadJson readJson = new ReadJson(desc, src, options, determineObjectMapper(options)); try { - List list = new ArrayList(); + List list = new ArrayList<>(); JsonToken currentToken = src.getCurrentToken(); if (currentToken != JsonToken.START_ARRAY) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java index 11af1a92f..aa01245af 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java @@ -50,7 +50,7 @@ public class WriteJson implements JsonWriter { this.visitors = visitors; this.objectMapper = objectMapper; this.include = include; - this.parentBeans = new ArrayStack(); + this.parentBeans = new ArrayStack<>(); this.pathStack = new PathStack(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java index adc4180d2..dbe4c0f68 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIdMap.java @@ -13,7 +13,7 @@ import java.util.Map; */ public final class BeanPersistIdMap { - private final Map beanMap = new LinkedHashMap(); + private final Map beanMap = new LinkedHashMap<>(); public String toString() { return beanMap.toString(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java index 9c888394b..03c6c344b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java @@ -98,7 +98,7 @@ public class BeanPersistIds { if (count < 1) { return null; } - List idList = new ArrayList(count); + List idList = new ArrayList<>(count); for (int i = 0; i < count; i++) { idList.add(idBinder.readData(dataInput)); } @@ -186,21 +186,21 @@ public class BeanPersistIds { private void addInsertId(Serializable id) { if (insertIds == null) { - insertIds = new ArrayList(); + insertIds = new ArrayList<>(); } insertIds.add(id); } private void addUpdateId(Serializable id) { if (updateIds == null) { - updateIds = new ArrayList(); + updateIds = new ArrayList<>(); } updateIds.add(id); } private void addDeleteId(Serializable id) { if (deleteIds == null) { - deleteIds = new ArrayList(); + deleteIds = new ArrayList<>(); } deleteIds.add(id); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java index c82d8aac6..ed56e9946 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java @@ -10,7 +10,7 @@ import java.util.Set; public class BulkEventListenerMap { - private final HashMap map = new HashMap(); + private final HashMap map = new HashMap<>(); public BulkEventListenerMap(List listeners) { @@ -48,7 +48,7 @@ public class BulkEventListenerMap { private static class Entry { - final List listeners = new ArrayList(); + final List listeners = new ArrayList<>(); private void add(BulkTableEventListener l) { listeners.add(l); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java index fa7970edf..41a4dc6ad 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DefaultPersistenceContext.java @@ -30,7 +30,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { /** * Map used hold caches. One cache per bean type. */ - private final HashMap, ClassContext> typeCache = new HashMap, ClassContext>(); + private final HashMap, ClassContext> typeCache = new HashMap<>(); private final Monitor monitor = new Monitor(); @@ -134,7 +134,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { private static class ClassContext { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); private Set deleteSet; @@ -187,7 +187,7 @@ public final class DefaultPersistenceContext implements PersistenceContext { private void deleted(Object id) { if (deleteSet == null) { - deleteSet = new HashSet(); + deleteSet = new HashSet<>(); } deleteSet.add(id); map.remove(id); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java index 55b47ff76..3f00a02f0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -19,7 +19,7 @@ import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; */ public final class DeleteByIdMap { - private final Map beanMap = new LinkedHashMap(); + private final Map beanMap = new LinkedHashMap<>(); public String toString() { return beanMap.toString(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java index 4478d10a2..759fccc9b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java @@ -255,7 +255,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void register(TransactionCallback callback) { if (callbackList == null) { - callbackList = new ArrayList(4); + callbackList = new ArrayList<>(4); } callbackList.add(callback); } @@ -336,7 +336,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void registerDeferred(PersistDeferredRelationship derived) { if (deferredList == null) { - deferredList = new ArrayList(); + deferredList = new ArrayList<>(); } deferredList.add(derived); } @@ -350,7 +350,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void registerDeleteBean(Integer persistingBean) { if (deletingBeansHash == null) { - deletingBeansHash = new HashSet(); + deletingBeansHash = new HashSet<>(); } deletingBeansHash.add(persistingBean); } @@ -388,7 +388,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public boolean isRegisteredBean(Object bean) { if (persistingBeans == null) { - persistingBeans = new IdentityHashMap(); + persistingBeans = new IdentityHashMap<>(); } return (persistingBeans.put(bean, PLACEHOLDER) != null); } @@ -401,7 +401,7 @@ public class JdbcTransaction implements SpiTransaction { public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName) { if (m2mIntersectionSave == null) { // first attempt so yes allow this m2m intersection direction - m2mIntersectionSave = new HashMap(); + m2mIntersectionSave = new HashMap<>(); m2mIntersectionSave.put(intersectionTable, beanName); return true; } @@ -1064,7 +1064,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public void putUserObject(String name, Object value) { if (userObjects == null) { - userObjects = new HashMap(); + userObjects = new HashMap<>(); } userObjects.put(name, value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java index 42b79bd3f..77e72c59b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java @@ -10,7 +10,7 @@ import java.util.List; public class RemoteTransactionEvent implements Runnable { - private final List beanPersistList = new ArrayList(); + private final List beanPersistList = new ArrayList<>(); private List tableList; @@ -77,7 +77,7 @@ public class RemoteTransactionEvent implements Runnable { public void addTableIUD(TableIUD tableIud) { if (tableList == null) { - tableList = new ArrayList(4); + tableList = new ArrayList<>(4); } tableList.add(tableIud); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java index d02a84915..e4f43fcde 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionMap.java @@ -14,7 +14,7 @@ public class TransactionMap { /** * Map of State by serverName. */ - private final HashMap map = new HashMap(); + private final HashMap map = new HashMap<>(); public String toString() { return map.toString(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java index 79fe9f2e4..fdfea3f00 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java @@ -14,16 +14,16 @@ import java.util.Set; */ public final class CtCompoundTypeScalarList { - private final LinkedHashMap> scalarProps = new LinkedHashMap>(); + private final LinkedHashMap> scalarProps = new LinkedHashMap<>(); - private final LinkedHashMap compoundProperties = new LinkedHashMap(); + private final LinkedHashMap compoundProperties = new LinkedHashMap<>(); /** * Return the list of non-scalar properties. These occur when compound types are nested. */ public List getNonScalarProperties() { - List nonScalarProps = new ArrayList(); + List nonScalarProps = new ArrayList<>(); for (String propKey : compoundProperties.keySet()) { if (!scalarProps.containsKey(propKey)) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java index 742aa864a..53c56172e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbValueMap.java @@ -46,9 +46,9 @@ public abstract class EnumToDbValueMap { public EnumToDbValueMap(boolean allowNulls, boolean isIntegerType) { this.allowNulls = allowNulls; this.isIntegerType = isIntegerType; - this.keyMap = new LinkedHashMap(); - this.valueMap = new LinkedHashMap(); - this.nameMap = new HashMap(); + this.keyMap = new LinkedHashMap<>(); + this.valueMap = new LinkedHashMap<>(); + this.nameMap = new HashMap<>(); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java index e00afac15..26b4e726a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java @@ -19,7 +19,7 @@ public final class ImmutableCompoundTypeBuilder { } }; - private final Map, Entry> entryMap = new HashMap, Entry>(); + private final Map, Entry> entryMap = new HashMap<>(); /** * Clear the cache of partial compound objects. @@ -80,7 +80,7 @@ public final class ImmutableCompoundTypeBuilder { private Entry(CtCompoundType ct) { this.ct = ct; - this.valueMap = new HashMap(); + this.valueMap = new HashMap<>(); } private Object set(String propName, Object value) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareCollection.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareCollection.java index 1455815bf..308e6118b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareCollection.java @@ -66,7 +66,7 @@ public class ModifyAwareCollection implements Collection { } public Iterator iterator() { - return new ModifyAwareIterator(owner, c.iterator()); + return new ModifyAwareIterator<>(owner, c.iterator()); } public boolean remove(Object o) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java index 2e17c0c66..7dd01366f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java @@ -61,7 +61,7 @@ public class ModifyAwareList implements List, ModifyAwareOwner { @Override public Iterator iterator() { - return new ModifyAwareIterator(owner, list.iterator()); + return new ModifyAwareIterator<>(owner, list.iterator()); } @Override @@ -157,17 +157,17 @@ public class ModifyAwareList implements List, ModifyAwareOwner { @Override public ListIterator listIterator() { - return new ModifyAwareListIterator(owner, list.listIterator()); + return new ModifyAwareListIterator<>(owner, list.listIterator()); } @Override public ListIterator listIterator(int index) { - return new ModifyAwareListIterator(owner, list.listIterator(index)); + return new ModifyAwareListIterator<>(owner, list.listIterator(index)); } @Override public List subList(int fromIndex, int toIndex) { - return new ModifyAwareList(owner, list.subList(fromIndex, toIndex)); + return new ModifyAwareList<>(owner, list.subList(fromIndex, toIndex)); } /** @@ -175,8 +175,8 @@ public class ModifyAwareList implements List, ModifyAwareOwner { */ public ModifyAwareSet asSet() { - LinkedHashSet set = new LinkedHashSet(); + LinkedHashSet set = new LinkedHashSet<>(); set.addAll(list); - return new ModifyAwareSet(owner, set); + return new ModifyAwareSet<>(owner, set); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java index 724dde7e7..36693628a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareMap.java @@ -102,17 +102,17 @@ public class ModifyAwareMap implements Map, ModifyAwareOwner { @Override public Set keySet() { - return new ModifyAwareSet(this, map.keySet()); + return new ModifyAwareSet<>(this, map.keySet()); } @Override public Collection values() { - return new ModifyAwareCollection(this, map.values()); + return new ModifyAwareCollection<>(this, map.values()); } @Override public Set> entrySet() { - return new ModifyAwareSet>(this, map.entrySet()); + return new ModifyAwareSet<>(this, map.entrySet()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java index ca232e718..1712c6dfe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java @@ -46,7 +46,7 @@ public class ScalarTypeEnumStandard { @Override public Set getDbCheckConstraintValues() { - LinkedHashSet values = new LinkedHashSet(); + LinkedHashSet values = new LinkedHashSet<>(); Object[] ea = enumType.getEnumConstants(); for (int i = 0; i < ea.length; i++) { @@ -129,7 +129,7 @@ public class ScalarTypeEnumStandard { @Override public Set getDbCheckConstraintValues() { - LinkedHashSet values = new LinkedHashSet(); + LinkedHashSet values = new LinkedHashSet<>(); for (int i = 0; i < enumArray.length; i++) { Enum e = (Enum) enumArray[i]; values.add(Integer.toString(e.ordinal())); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java index 096e5341f..738a8dd19 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java @@ -20,7 +20,7 @@ public class ImmutableMetaFactory { ScoreConstructor[] scoreConstructors = scoreConstructors(cls); - ArrayList errors = new ArrayList(); + ArrayList errors = new ArrayList<>(); // search the constructors in score order ... // ... we need to find a set of readers for each @@ -111,7 +111,7 @@ public class ImmutableMetaFactory { } // filter out any constructors with less parameters than the max - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (int i = 0; i < score.length; i++) { if (score[i].getParamCount() == maxParamCount) { list.add(score[i]); @@ -207,7 +207,7 @@ public class ImmutableMetaFactory { if (parameterTypes.length < 2) { return false; } - HashSet> set = new HashSet>(); + HashSet> set = new HashSet<>(); for (int i = 0; i < parameterTypes.length; i++) { if (!set.add(parameterTypes[i])) { return true; diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/ArrayStack.java b/src/main/java/com/avaje/ebeaninternal/server/util/ArrayStack.java index 42761dabf..0be14e20d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/ArrayStack.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/ArrayStack.java @@ -16,14 +16,14 @@ public class ArrayStack { * Creates an empty Stack with an initial size. */ public ArrayStack(int size) { - this.list = new ArrayList(size); + this.list = new ArrayList<>(size); } /** * Creates an empty Stack. */ public ArrayStack() { - this.list = new ArrayList(); + this.list = new ArrayList<>(); } public String toString() { diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java index b0fb313b2..6ec91de9a 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java @@ -63,7 +63,7 @@ public class XmEbean { */ public List getEntity() { if (entity == null) { - entity = new ArrayList(); + entity = new ArrayList<>(); } return this.entity; } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java index 6d2a26f54..5092f3cc4 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java @@ -71,7 +71,7 @@ public class XmEntity { */ public List getNamedQuery() { if (namedQuery == null) { - namedQuery = new ArrayList(); + namedQuery = new ArrayList<>(); } return this.namedQuery; } @@ -100,7 +100,7 @@ public class XmEntity { */ public List getRawSql() { if (rawSql == null) { - rawSql = new ArrayList(); + rawSql = new ArrayList<>(); } return this.rawSql; } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java index ec79bdb66..e042d0965 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java @@ -75,7 +75,7 @@ public class XmRawSql { */ public List getAliasMapping() { if (aliasMapping == null) { - aliasMapping = new ArrayList(); + aliasMapping = new ArrayList<>(); } return this.aliasMapping; } @@ -104,7 +104,7 @@ public class XmRawSql { */ public List getColumnMapping() { if (columnMapping == null) { - columnMapping = new ArrayList(); + columnMapping = new ArrayList<>(); } return this.columnMapping; } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdates.java b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdates.java index cf64d524e..9c5668ce6 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdates.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdates.java @@ -15,22 +15,22 @@ public class DocStoreUpdates { /** * Persist inserts and updates. */ - private final List persistEvents = new ArrayList(); + private final List persistEvents = new ArrayList<>(); /** * Delete by Id. */ - private final List deleteEvents = new ArrayList(); + private final List deleteEvents = new ArrayList<>(); /** * Nested updates. */ - private final List nestedEvents = new ArrayList(); + private final List nestedEvents = new ArrayList<>(); /** * Entries sent to the queue for later processing. */ - private final List queueEntries = new ArrayList(); + private final List queueEntries = new ArrayList<>(); public DocStoreUpdates() { } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java index 0407befec..3b17dc39b 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java @@ -83,7 +83,7 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< * List of embedded paths from other documents that include this document type. * As such an update to this doc type means that those embedded documents need to be updated. */ - protected final List embeddedInvalidation = new ArrayList(); + protected final List embeddedInvalidation = new ArrayList<>(); protected final PathProperties pathProps; @@ -216,7 +216,7 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< * Return the property names as property index positions. */ protected int[] getPropertyPositions(Set properties) { - List posList = new ArrayList(); + List posList = new ArrayList<>(); for (String property : properties) { BeanProperty prop = desc.getBeanProperty(property); if (prop != null) { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java index eb4866bb9..4903c50a4 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java @@ -22,9 +22,9 @@ public class DocStructure { /** * The embedded document structures by path. */ - private final Map embedded = new HashMap(); + private final Map embedded = new HashMap<>(); - private final Map manyRoot = new HashMap(); + private final Map manyRoot = new HashMap<>(); /** * Create given an initial deployment doc mapping. diff --git a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java index 41547ff11..963ef0642 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java @@ -21,7 +21,7 @@ public class NoneDocStoreFactory implements DocStoreFactory { @Override public DocStoreBeanAdapter createAdapter(BeanDescriptor desc, DeployBeanDescriptor deploy) { - return new NoneDocStoreBeanAdapter(desc, deploy); + return new NoneDocStoreBeanAdapter<>(desc, deploy); } static class NoneIntegration implements DocStoreIntegration { diff --git a/src/test/java/com/avaje/ebean/EbeanServer_deleteAllByIdTest.java b/src/test/java/com/avaje/ebean/EbeanServer_deleteAllByIdTest.java index 0e3f48ebd..ef83795cc 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_deleteAllByIdTest.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_deleteAllByIdTest.java @@ -18,7 +18,7 @@ public class EbeanServer_deleteAllByIdTest { List someBeans = beans(3); Ebean.saveAll(someBeans); - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (EBasicVer someBean : someBeans) { ids.add(someBean.getId()); } @@ -38,7 +38,7 @@ public class EbeanServer_deleteAllByIdTest { List someBeans = beans(3); Ebean.saveAll(someBeans); - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (EBasicVer someBean : someBeans) { ids.add(someBean.getId()); } @@ -64,7 +64,7 @@ public class EbeanServer_deleteAllByIdTest { List someBeans = beans(3); Ebean.saveAll(someBeans); - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (EBasicVer someBean : someBeans) { ids.add(someBean.getId()); } @@ -85,7 +85,7 @@ public class EbeanServer_deleteAllByIdTest { List someBeans = beans(3); Ebean.saveAll(someBeans); - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (EBasicVer someBean : someBeans) { ids.add(someBean.getId()); } @@ -106,7 +106,7 @@ public class EbeanServer_deleteAllByIdTest { } private List beans(int count) { - List beans = new ArrayList(); + List beans = new ArrayList<>(); for (int i = 0; i < count; i++) { beans.add(bean("foo" + i)); } diff --git a/src/test/java/com/avaje/ebean/EbeanServer_refresh.java b/src/test/java/com/avaje/ebean/EbeanServer_refresh.java index 35f9deb1d..19306f73d 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_refresh.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_refresh.java @@ -52,7 +52,7 @@ public class EbeanServer_refresh { Order order = Ebean.find(Order.class, 1); order.getCustomer().getName(); - order.setDetails(new ArrayList()); + order.setDetails(new ArrayList<>()); Ebean.refresh(order); } diff --git a/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java b/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java index 4cdedd009..4bf49df0a 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java @@ -115,7 +115,7 @@ public class EbeanServer_saveAllTest extends BaseTestCase { private List beans(int count) { - List beans = new ArrayList(); + List beans = new ArrayList<>(); for (int i = 0; i events = new ArrayList(); + List events = new ArrayList<>(); @Override public void propertyChange(PropertyChangeEvent evt) { diff --git a/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java b/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java index 9a813451c..c4db21e0b 100644 --- a/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java +++ b/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java @@ -26,7 +26,7 @@ public class EntityBeanInterceptTest extends BaseTestCase { List list = Ebean.find(Customer.class).findList(); - Set propertyNames = new HashSet(); + Set propertyNames = new HashSet<>(); propertyNames.add("name"); propertyNames.add("status"); diff --git a/src/test/java/com/avaje/ebean/common/BeanListTest.java b/src/test/java/com/avaje/ebean/common/BeanListTest.java index a9c036322..712c5b7ad 100644 --- a/src/test/java/com/avaje/ebean/common/BeanListTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanListTest.java @@ -18,7 +18,7 @@ public class BeanListTest { @NotNull private List all() { - List all = new ArrayList(); + List all = new ArrayList<>(); all.add(object1); all.add(object2); all.add(object3); @@ -27,7 +27,7 @@ public class BeanListTest { @NotNull private List some() { - List some = new ArrayList(); + List some = new ArrayList<>(); some.add(object2); some.add(object3); return some; @@ -36,7 +36,7 @@ public class BeanListTest { @Test public void testAdd() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); list.add(object1); @@ -57,7 +57,7 @@ public class BeanListTest { @Test public void testAddAll_given_emptyStart() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -70,7 +70,7 @@ public class BeanListTest { @Test public void testAdd_given_someAlreadyIn() throws Exception { - BeanList list = new BeanList(some()); + BeanList list = new BeanList<>(some()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -86,7 +86,7 @@ public class BeanListTest { @Test public void testAddSome_given_someAlreadyIn() throws Exception { - BeanList list = new BeanList(some()); + BeanList list = new BeanList<>(some()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -99,7 +99,7 @@ public class BeanListTest { @Test public void testRemove_given_beansInAdditions() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); list.addAll(all()); assertThat(list.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -115,7 +115,7 @@ public class BeanListTest { @Test public void testRemoveAll_given_beansInAdditions() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); list.addAll(all()); assertThat(list.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -130,7 +130,7 @@ public class BeanListTest { @Test public void testRemove_given_beansNotInAdditions() throws Exception { - BeanList list = new BeanList(all()); + BeanList list = new BeanList<>(all()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -145,7 +145,7 @@ public class BeanListTest { @Test public void testRemoveAll_given_beansNotInAdditions() throws Exception { - BeanList list = new BeanList(all()); + BeanList list = new BeanList<>(all()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -159,7 +159,7 @@ public class BeanListTest { @Test public void testClear() throws Exception { - BeanList list = new BeanList(all()); + BeanList list = new BeanList<>(all()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -173,7 +173,7 @@ public class BeanListTest { @Test public void testClear_given_someBeansInAdditions() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.add(object1); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); list.add(object2); @@ -190,7 +190,7 @@ public class BeanListTest { @Test public void testRetainAll_given_beansInAdditions() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); list.addAll(all()); assertThat(list.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -205,7 +205,7 @@ public class BeanListTest { @Test public void testRetainAll_given_someBeansInAdditions() throws Exception { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.add(object1); list.add(object2); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); @@ -221,7 +221,7 @@ public class BeanListTest { @Test public void testRetainAll_given_noBeansInAdditions() throws Exception { - BeanList list = new BeanList(all()); + BeanList list = new BeanList<>(all()); list.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act diff --git a/src/test/java/com/avaje/ebean/common/BeanMapTest.java b/src/test/java/com/avaje/ebean/common/BeanMapTest.java index b611887e7..a5683bab8 100644 --- a/src/test/java/com/avaje/ebean/common/BeanMapTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanMapTest.java @@ -18,7 +18,7 @@ public class BeanMapTest { @NotNull private Map all() { - Map all = new LinkedHashMap(); + Map all = new LinkedHashMap<>(); all.put("1", object1); all.put("2", object2); all.put("3", object3); @@ -27,7 +27,7 @@ public class BeanMapTest { @NotNull private Map some() { - Map all = new LinkedHashMap(); + Map all = new LinkedHashMap<>(); all.put("2", object2); all.put("3", object3); return all; @@ -36,7 +36,7 @@ public class BeanMapTest { @Test public void testAdd() throws Exception { - BeanMap map = new BeanMap(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.put("1", object1); map.put("4", null); @@ -59,7 +59,7 @@ public class BeanMapTest { @Test public void testAddAll_given_emptyStart() throws Exception { - BeanMap set = new BeanMap(); + BeanMap set = new BeanMap<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -72,7 +72,7 @@ public class BeanMapTest { @Test public void testAdd_given_someAlreadyIn() throws Exception { - BeanMap map = new BeanMap(some()); + BeanMap map = new BeanMap<>(some()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -88,7 +88,7 @@ public class BeanMapTest { @Test public void testAddSome_given_someAlreadyIn() throws Exception { - BeanMap map = new BeanMap(some()); + BeanMap map = new BeanMap<>(some()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -101,7 +101,7 @@ public class BeanMapTest { @Test public void testRemove_given_beansInAdditions() throws Exception { - BeanMap map = new BeanMap(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.putAll(all()); assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -117,7 +117,7 @@ public class BeanMapTest { @Test public void testRemoveAll_given_beansInAdditions() throws Exception { - BeanMap map = new BeanMap(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.putAll(all()); assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -133,7 +133,7 @@ public class BeanMapTest { @Test public void testRemove_given_beansNotInAdditions() throws Exception { - BeanMap map = new BeanMap(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -148,7 +148,7 @@ public class BeanMapTest { @Test public void testRemoveAll_given_beansNotInAdditions() throws Exception { - BeanMap map = new BeanMap(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -163,7 +163,7 @@ public class BeanMapTest { @Test public void testClear() throws Exception { - BeanMap map = new BeanMap(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -177,7 +177,7 @@ public class BeanMapTest { @Test public void testClear_given_someBeansInAdditions() throws Exception { - BeanMap map = new BeanMap(); + BeanMap map = new BeanMap<>(); map.put("1",object1); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.put("2", object2); diff --git a/src/test/java/com/avaje/ebean/common/BeanSetTest.java b/src/test/java/com/avaje/ebean/common/BeanSetTest.java index 9eddbde9a..3f6432c8a 100644 --- a/src/test/java/com/avaje/ebean/common/BeanSetTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanSetTest.java @@ -18,7 +18,7 @@ public class BeanSetTest { @NotNull private Set all() { - Set all = new LinkedHashSet(); + Set all = new LinkedHashSet<>(); all.add(object1); all.add(object2); all.add(object3); @@ -27,7 +27,7 @@ public class BeanSetTest { @NotNull private Set some() { - Set some = new LinkedHashSet(); + Set some = new LinkedHashSet<>(); some.add(object2); some.add(object3); return some; @@ -36,7 +36,7 @@ public class BeanSetTest { @Test public void testAdd() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); set.add(object1); @@ -57,7 +57,7 @@ public class BeanSetTest { @Test public void testAddAll_given_emptyStart() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -70,7 +70,7 @@ public class BeanSetTest { @Test public void testAdd_given_someAlreadyIn() throws Exception { - BeanSet set = new BeanSet(some()); + BeanSet set = new BeanSet<>(some()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -86,7 +86,7 @@ public class BeanSetTest { @Test public void testAddSome_given_someAlreadyIn() throws Exception { - BeanSet set = new BeanSet(some()); + BeanSet set = new BeanSet<>(some()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -99,7 +99,7 @@ public class BeanSetTest { @Test public void testRemove_given_beansInAdditions() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); set.addAll(all()); assertThat(set.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -115,7 +115,7 @@ public class BeanSetTest { @Test public void testRemoveAll_given_beansInAdditions() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); set.addAll(all()); assertThat(set.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -130,7 +130,7 @@ public class BeanSetTest { @Test public void testRemove_given_beansNotInAdditions() throws Exception { - BeanSet set = new BeanSet(all()); + BeanSet set = new BeanSet<>(all()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -145,7 +145,7 @@ public class BeanSetTest { @Test public void testRemoveAll_given_beansNotInAdditions() throws Exception { - BeanSet set = new BeanSet(all()); + BeanSet set = new BeanSet<>(all()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -159,7 +159,7 @@ public class BeanSetTest { @Test public void testClear() throws Exception { - BeanSet set = new BeanSet(all()); + BeanSet set = new BeanSet<>(all()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -173,7 +173,7 @@ public class BeanSetTest { @Test public void testClear_given_someBeansInAdditions() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.add(object1); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); set.add(object2); @@ -190,7 +190,7 @@ public class BeanSetTest { @Test public void testRetainAll_given_beansInAdditions() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); set.addAll(all()); assertThat(set.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -205,7 +205,7 @@ public class BeanSetTest { @Test public void testRetainAll_given_someBeansInAdditions() throws Exception { - BeanSet set = new BeanSet(); + BeanSet set = new BeanSet<>(); set.add(object1); set.add(object2); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); @@ -221,7 +221,7 @@ public class BeanSetTest { @Test public void testRetainAll_given_noBeansInAdditions() throws Exception { - BeanSet set = new BeanSet(all()); + BeanSet set = new BeanSet<>(all()); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java index 6d02dfe57..1ce65cd6e 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java @@ -14,7 +14,7 @@ public class MigrationVersionTest { @Test public void sort() { - List list= new ArrayList(); + List list= new ArrayList<>(); list.add(MigrationVersion.parse("1.1__point")); list.add(MigrationVersion.parse("3.0__three")); list.add(MigrationVersion.parse("1.0__init")); diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java index 3411fcc86..f0762a9fe 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java @@ -211,7 +211,7 @@ public class PendingDropsTest { class TDModelContainer extends ModelContainer { - List drops = new ArrayList(); + List drops = new ArrayList<>(); @Override public void registerPendingHistoryDropColumns(ChangeSet changeSet) { diff --git a/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java b/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java index 7476b7c22..2128c8b2a 100644 --- a/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java @@ -106,7 +106,7 @@ public class BeanFindControllerTest extends BaseTestCase { @Override public BeanCollection findMany(BeanQueryRequest request) { - BeanList list = new BeanList(); + BeanList list = new BeanList<>(); list.add((T)createBean()); return list; } diff --git a/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java b/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java index 5aba15b8a..761634eb5 100644 --- a/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java @@ -90,7 +90,7 @@ public class BeanPersistControllerTest { boolean continueDefaultPersisting; - List methodsCalled = new ArrayList(); + List methodsCalled = new ArrayList<>(); /** * No default constructor so only registered manually. diff --git a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java index 1e782cc67..1dabfa7d1 100644 --- a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java @@ -69,7 +69,7 @@ public class BeanPostLoadTest extends BaseTestCase { boolean dummy; - List methodsCalled = new ArrayList(); + List methodsCalled = new ArrayList<>(); Object bean; diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java index dc7eec116..8d48f7f84 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java @@ -29,7 +29,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { @Test public void write() throws IOException, ClassNotFoundException { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); map.put("name", "rob"); map.put("some", "thing"); map.put("whenCreated", ""+System.currentTimeMillis()); diff --git a/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java b/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java index 25d7196c1..bad5f5920 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java +++ b/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java @@ -37,7 +37,7 @@ public class Helper { @NotNull private BeanChange createInsert(long startId) { - Map values = new LinkedHashMap(); + Map values = new LinkedHashMap<>(); values.put("name", new ValuePair("rob", null)); values.put("modified", new ValuePair(new Timestamp(System.currentTimeMillis()), null)); @@ -48,7 +48,7 @@ public class Helper { @NotNull private BeanChange createUpdate(long startId) { - Map values = new LinkedHashMap(); + Map values = new LinkedHashMap<>(); values.put("name", new ValuePair("jim", "steve")); values.put("nowHasVal", new ValuePair("wasNull", null)); values.put("nowNull", new ValuePair(null, "hadVal")); @@ -62,7 +62,7 @@ public class Helper { @NotNull private BeanChange createDelete(long startId) { - return new BeanChange("mytable", startId+3, ChangeType.DELETE, new HashMap()); + return new BeanChange("mytable", startId+3, ChangeType.DELETE, new HashMap<>()); } } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java index 3846b23e9..faf9f50ac 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java @@ -29,7 +29,7 @@ public class BeanPropertyAssocManyTest extends BaseTestCase { public void createReferenceIfNull_when_notBeanCollection_expect_null() { Customer customer = new Customer(); - customer.setContacts(new ArrayList()); + customer.setContacts(new ArrayList<>()); BeanCollection ref = contacts().createReferenceIfNull((EntityBean) customer); assertNull(ref); @@ -52,7 +52,7 @@ public class BeanPropertyAssocManyTest extends BaseTestCase { ResetBasicData.reset(); - List customerIds = new ArrayList(); + List customerIds = new ArrayList<>(); customerIds.add(1L); customerIds.add(2L); diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java index 6539d0aae..c2a2dfa7a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java @@ -12,7 +12,7 @@ public class DeployPropertyParserMapTests { public void test_like_escape() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("customer.name", "t1.name"); map.put("id", "t0.id"); diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java index 619519225..9321e9811 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java @@ -95,21 +95,21 @@ public class AllEqualsExpressionTest { } AllEqualsExpression exp(String key0, Object val1) { - LinkedHashMap map = new LinkedHashMap(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); return exp(map); } AllEqualsExpression exp(String key0, Object val1, String key2, Object val2) { - LinkedHashMap map = new LinkedHashMap(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); map.put(key2, val2); return exp(map); } AllEqualsExpression exp(String key0, Object val1, String key2, Object val2, String key3, Object val3) { - LinkedHashMap map = new LinkedHashMap(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); map.put(key2, val2); map.put(key3, val3); diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java index a0f637028..934dfb00a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java @@ -94,7 +94,7 @@ public class DefaultExampleExpressionTest extends BaseTestCase { } private OrmQueryRequest create(SpiQuery query) { - return new OrmQueryRequest(null, null, query, null); + return new OrmQueryRequest<>(null, null, query, null); } @Test diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java index 14e095c6c..eb848e91f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java @@ -10,7 +10,7 @@ public class DefaultExpressionListTest { DefaultExpressionList exp() { - return new DefaultExpressionList(null, new DefaultExpressionFactory(true, true), null); + return new DefaultExpressionList<>(null, new DefaultExpressionFactory(true, true), null); } DefaultExpressionList spi(ExpressionList list) { diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java index fcd789555..d9d2052ea 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java @@ -16,7 +16,7 @@ public class JunctionExpressionTest { DefaultExpressionList exp(Expression... expressions) { - DefaultExpressionList list = new DefaultExpressionList(null, new DefaultExpressionFactory(true, false), null); + DefaultExpressionList list = new DefaultExpressionList<>(null, new DefaultExpressionFactory(true, false), null); for (Expression ex : expressions) { list.add(ex); } @@ -24,11 +24,11 @@ public class JunctionExpressionTest { } JunctionExpression and(DefaultExpressionList list) { - return new JunctionExpression(Junction.Type.AND, list); + return new JunctionExpression<>(Junction.Type.AND, list); } JunctionExpression or(DefaultExpressionList list) { - return new JunctionExpression(Junction.Type.OR, list); + return new JunctionExpression<>(Junction.Type.OR, list); } @Test diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/TDSpiExpressionRequest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/TDSpiExpressionRequest.java index 33f1f207d..52aa9c185 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/TDSpiExpressionRequest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/TDSpiExpressionRequest.java @@ -13,7 +13,7 @@ import java.util.List; */ public class TDSpiExpressionRequest implements SpiExpressionRequest { - List bindValues = new ArrayList(); + List bindValues = new ArrayList<>(); final BeanDescriptor descriptor; diff --git a/src/test/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedListTest.java b/src/test/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedListTest.java index 47ebf44b7..23165829e 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedListTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedListTest.java @@ -88,7 +88,7 @@ public class LimitOffsetPagedListTest { } private LimitOffsetPagedList limitQuery(SpiQuery query) { - return new LimitOffsetPagedList(server, query); + return new LimitOffsetPagedList<>(server, query); } private SpiQuery queryWith(int first, int max) { diff --git a/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java b/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java index b13e255b9..6eeae26ba 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java @@ -23,7 +23,7 @@ public class OrderVersionDescTest { Version at200 = at(200); Version at300 = at(300); - List> versions = new ArrayList>(); + List> versions = new ArrayList<>(); versions.add(at200); versions.add(atNull); versions.add(at300); diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java index 7af9dfd88..9f8676f3a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java @@ -118,7 +118,7 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_diffOrderByNull() { - OrderBy o1 = new OrderBy("id"); + OrderBy o1 = new OrderBy<>("id"); OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null); OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null); @@ -128,8 +128,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { @Test public void equals_when_orderBySame() { - OrderBy o1 = new OrderBy("id, name"); - OrderBy o2 = new OrderBy("id, name"); + OrderBy o1 = new OrderBy<>("id, name"); + OrderBy o2 = new OrderBy<>("id, name"); OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null); OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o2, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null); diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java index 8e50cc033..d1233fe6f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java @@ -22,7 +22,7 @@ public class OrmQueryPropertiesTest { @Test public void construct_with_propertySet_when_empty() { - OrmQueryProperties p1 = new OrmQueryProperties(null, new LinkedHashSet()); + OrmQueryProperties p1 = new OrmQueryProperties(null, new LinkedHashSet<>()); assertThat(p1.getProperties()).isEqualTo(""); assertThat(p1.allProperties()).isFalse(); } @@ -30,7 +30,7 @@ public class OrmQueryPropertiesTest { @Test public void construct_with_propertySet_when_one() { - LinkedHashSet set = new LinkedHashSet(); + LinkedHashSet set = new LinkedHashSet<>(); set.add("name"); OrmQueryProperties p1 = new OrmQueryProperties(null, set); @@ -41,7 +41,7 @@ public class OrmQueryPropertiesTest { @Test public void construct_with_propertySet_when_some() { - LinkedHashSet set = new LinkedHashSet(); + LinkedHashSet set = new LinkedHashSet<>(); set.add("id"); set.add("name"); set.add("startDate"); diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java index 6dd619067..dea108068 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java @@ -12,10 +12,10 @@ public class ModifyAwareListTest { private ModifyAwareList createList() { ArrayList list = new ArrayList(); list.addAll(Arrays.asList("A","B","C","D","E")); - return new ModifyAwareList(list); + return new ModifyAwareList<>(list); } private ModifyAwareList createEmptyList() { - return new ModifyAwareList(new ArrayList()); + return new ModifyAwareList<>(new ArrayList<>()); } @Test diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java index 1f9a09b12..a50997680 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java @@ -9,18 +9,18 @@ import static org.junit.Assert.*; public class ModifyAwareMapTest { private ModifyAwareMap createMap() { - LinkedHashMap map = new LinkedHashMap(); + LinkedHashMap map = new LinkedHashMap<>(); map.put("A", "one"); map.put("B", "two"); map.put("C", "three"); map.put("D", "four"); map.put("E", "five"); - return new ModifyAwareMap(map); + return new ModifyAwareMap<>(map); } private ModifyAwareMap createEmptyMap() { - LinkedHashMap map = new LinkedHashMap(); - return new ModifyAwareMap(map); + LinkedHashMap map = new LinkedHashMap<>(); + return new ModifyAwareMap<>(map); } @Test @@ -115,7 +115,7 @@ public class ModifyAwareMapTest { ModifyAwareMap map = createMap(); assertFalse(map.isMarkedDirty()); - Map other = new HashMap(); + Map other = new HashMap<>(); map.putAll(other); assertTrue(map.isMarkedDirty()); } @@ -126,7 +126,7 @@ public class ModifyAwareMapTest { ModifyAwareMap map = createMap(); assertFalse(map.isMarkedDirty()); - Map other = new HashMap(); + Map other = new HashMap<>(); other.put("A", "one"); map.putAll(other); assertTrue(map.isMarkedDirty()); diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java index 8f69584e3..1b3c05fc8 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java @@ -64,7 +64,7 @@ public class ScalarTypeMonthDayTest { public void testJson() throws Exception { MonthDay value = MonthDay.of(4, 29); - JsonTester jsonTester = new JsonTester(type); + JsonTester jsonTester = new JsonTester<>(type); jsonTester.test(value); } diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java index 1cc7fdefc..9a52898aa 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java @@ -34,10 +34,10 @@ public class ScalarTypePostgresHstoreTest { @Test public void testIsDirty() throws Exception { - Map emptyMap = new HashMap(); + Map emptyMap = new HashMap<>(); assertTrue(hstore.isDirty(emptyMap)); - ModifyAwareMap modAware = new ModifyAwareMap(emptyMap); + ModifyAwareMap modAware = new ModifyAwareMap<>(emptyMap); assertFalse(hstore.isDirty(modAware)); modAware.put("foo", "Rob"); assertTrue(hstore.isDirty(emptyMap)); @@ -62,7 +62,7 @@ public class ScalarTypePostgresHstoreTest { @Test public void testJsonWrite() throws Exception { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); assertEquals("{\"key\":{}}", generateJson(map)); diff --git a/src/test/java/com/avaje/ebeaninternal/server/util/ArrayStackTest.java b/src/test/java/com/avaje/ebeaninternal/server/util/ArrayStackTest.java index e794b72b2..9ca1e943a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/util/ArrayStackTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/util/ArrayStackTest.java @@ -12,7 +12,7 @@ public class ArrayStackTest { @Test public void testPushPop() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); stack.push("1"); stack.push("2"); stack.push("3"); @@ -25,7 +25,7 @@ public class ArrayStackTest { @Test public void testPushPop_given_stackInitialSizeExceeded() throws Exception { - ArrayStack stack = new ArrayStack(2); + ArrayStack stack = new ArrayStack<>(2); stack.push("1"); stack.push("2"); stack.push("3"); @@ -38,14 +38,14 @@ public class ArrayStackTest { @Test(expected = EmptyStackException.class) public void testPop_given_emptyStack_throws() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); stack.pop(); } @Test(expected = EmptyStackException.class) public void testPeek_given_empty_throws() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); assertThat(stack.peek()); } @@ -53,7 +53,7 @@ public class ArrayStackTest { @Test public void testPeek_given_notEmpty() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); stack.push("1"); assertThat(stack.peek()).isEqualTo("1"); } @@ -61,7 +61,7 @@ public class ArrayStackTest { @Test public void testPeekWithNull() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); assertThat(stack.peekWithNull()).isNull(); @@ -72,7 +72,7 @@ public class ArrayStackTest { @Test public void testIsEmpty() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); assertThat(stack.isEmpty()).isTrue(); stack.push("1"); @@ -82,7 +82,7 @@ public class ArrayStackTest { @Test public void testSize() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); assertThat(stack.size()).isEqualTo(0); stack.push("1"); @@ -94,7 +94,7 @@ public class ArrayStackTest { @Test public void testContains() throws Exception { - ArrayStack stack = new ArrayStack(); + ArrayStack stack = new ArrayStack<>(); stack.push("1"); assertThat(stack.contains("1")).isTrue(); diff --git a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java index 6c7a61d99..090e9b932 100644 --- a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java +++ b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java @@ -28,7 +28,7 @@ public class DocStoreBeanBaseAdapterTest extends BaseTestCase { DeployBeanDescriptor deployDesc = (DeployBeanDescriptor)mock(DeployBeanDescriptor.class); - TDAdapter adapter = new TDAdapter(orderDesc, deployDesc); + TDAdapter adapter = new TDAdapter<>(orderDesc, deployDesc); assertThat(adapter.getIndexName()).isEqualTo("order"); assertThat(adapter.getIndexType()).isEqualTo("order"); diff --git a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java index 915556868..67128499a 100644 --- a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java +++ b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java @@ -38,7 +38,7 @@ public class DocStoreIndexEventTest { when(mock.docStore()).thenReturn(mockDocType); Order bean = new Order(); - DocStoreIndexEvent event = new DocStoreIndexEvent(mock, 42, bean); + DocStoreIndexEvent event = new DocStoreIndexEvent<>(mock, 42, bean); event.docStoreUpdate(null); @@ -51,7 +51,7 @@ public class DocStoreIndexEventTest { Order bean = new Order(); - DocStoreIndexEvent event = new DocStoreIndexEvent(orderType(), 42, bean); + DocStoreIndexEvent event = new DocStoreIndexEvent<>(orderType(), 42, bean); DocStoreUpdates updates = new DocStoreUpdates(); event.addToQueue(updates); diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java b/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java index a2e46d313..f2e22e346 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java @@ -31,7 +31,7 @@ public class TestDeleteByIdCollection extends BaseTestCase { Assert.assertNotNull(c0Back); Assert.assertNotNull(c1Back); - List ids = new ArrayList(); + List ids = new ArrayList<>(); // also test id type conversion ids.add("" + c0.getId()); ids.add("" + c1.getId()); @@ -62,7 +62,7 @@ public class TestDeleteByIdCollection extends BaseTestCase { Assert.assertNotNull(o1Back); - List ids = new ArrayList(); + List ids = new ArrayList<>(); // also test id type conversion ids.add(order0.getId()); ids.add(order1.getId()); diff --git a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java index ac56a3e6d..c82aa67ef 100644 --- a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java +++ b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java @@ -45,7 +45,7 @@ public class TestM2MVanilla extends BaseTestCase { MUser user = Ebean.find(MUser.class, u0.getUserid()); - List roleList = new ArrayList(); + List roleList = new ArrayList<>(); roleList.add(r1); roleList.add(r2); diff --git a/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java b/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java index 99069115b..1d11001be 100644 --- a/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java +++ b/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java @@ -17,7 +17,7 @@ public class TestUuidInsertMasterDetail extends BaseTestCase { UUTwo two = new UUTwo(); two.setName("something"); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.add(two); UUOne one = new UUOne(); diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java index 20aec87a8..784958b30 100644 --- a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java @@ -128,7 +128,7 @@ public class TestBatchInsertSimple extends BaseTestCase { int numOfMasters = 3; - List masters = new ArrayList(); + List masters = new ArrayList<>(); for (int i = 0; i < numOfMasters; i++) { masters.add(createMasterAndDetails(i, 7)); } @@ -154,7 +154,7 @@ public class TestBatchInsertSimple extends BaseTestCase { int numOfMasters = 3; - List masters = new ArrayList(); + List masters = new ArrayList<>(); for (int i = 0; i < numOfMasters; i++) { masters.add(createMasterAndDetails(i, 5)); } @@ -177,7 +177,7 @@ public class TestBatchInsertSimple extends BaseTestCase { private UTMaster createMasterAndDetails(int masterPos, int size) { UTMaster master = createMaster(masterPos); - List details = new ArrayList(); + List details = new ArrayList<>(); int count = 2 + random.nextInt(size); diff --git a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java index c7cf264d3..5ccb67a97 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java +++ b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java @@ -28,7 +28,7 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase { @Test public void testOnCacheHit() { - ArrayList inserted = new ArrayList(); + ArrayList inserted = new ArrayList<>(); String[] names = "A,B,C,D,E,F,G,H,I,J".split(","); for (int i = 0; i < names.length; i++) { inserted.add(insert(names[i])); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java b/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java index 6836cdfb4..f02b97796 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java @@ -257,7 +257,7 @@ public class TestCacheCollectionIds extends BaseTestCase { cachedBean = Ebean.find(OCachedBean.class, cachedBean.getId()); cachedBean.setName("mod"); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.add(Ebean.find(Country.class, "NZ")); cachedBean.setCountries(list); Ebean.save(cachedBean); diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCKeyIdInExpression.java b/src/test/java/com/avaje/tests/compositekeys/TestCKeyIdInExpression.java index d4f032370..0032314cd 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCKeyIdInExpression.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCKeyIdInExpression.java @@ -51,7 +51,7 @@ public class TestCKeyIdInExpression extends BaseTestCase { ROrderPK k2 = new ROrderPK("b", 105); ROrderPK k3 = new ROrderPK("c", 106); - List keys = new ArrayList(); + List keys = new ArrayList<>(); keys.add(k0); keys.add(k1); keys.add(k2); diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java b/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java index d07567931..818f9372c 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java @@ -71,7 +71,7 @@ public class TestCKeyLazyLoad extends BaseTestCase { int size = details.size(); Assert.assertTrue(size > 0); - List idList = new ArrayList(); + List idList = new ArrayList<>(); idList.add(id); idList.add(id2); diff --git a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java index b3d7c718f..5c6b6868d 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java @@ -67,7 +67,7 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { if (isMsSqlServer()) return; assertEquals(2, Ebean.find(User.class).findList().size()); - List ids = new ArrayList(); + List ids = new ArrayList<>(); ids.add(1L); ids.add(2L); @@ -89,7 +89,7 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany)beanDescriptor.getBeanProperty("userRoles"); - List ids = new ArrayList(); + List ids = new ArrayList<>(); ids.add(1L); ids.add(2L); diff --git a/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java b/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java index 762068b91..65574a832 100644 --- a/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java +++ b/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java @@ -28,7 +28,7 @@ public class LinkQueryPublishTest { EbeanServer server = Ebean.getDefaultServer(); - List ids = new ArrayList(); + List ids = new ArrayList<>(); ids.add(link1.getId()); ids.add(link2.getId()); ids.add(link3.getId()); diff --git a/src/test/java/com/avaje/tests/enhancement/TestConstructorManyAddAll.java b/src/test/java/com/avaje/tests/enhancement/TestConstructorManyAddAll.java index 8eeea9139..d3288bf67 100644 --- a/src/test/java/com/avaje/tests/enhancement/TestConstructorManyAddAll.java +++ b/src/test/java/com/avaje/tests/enhancement/TestConstructorManyAddAll.java @@ -13,7 +13,7 @@ public class TestConstructorManyAddAll extends BaseTestCase { @Test public void test() { - List startRoles = new ArrayList(); + List startRoles = new ArrayList<>(); MUser mUser = new MUser(startRoles); mUser.getRoles(); } diff --git a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java index 9b5b7911e..eb41bc679 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java +++ b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java @@ -19,7 +19,7 @@ import java.util.List; */ public class TestPropertyChangeSupport extends EbeanTestCase implements PropertyChangeListener { private int nuofEvents = 0; - private List pces = new ArrayList(); + private List pces = new ArrayList<>(); private PropertyChangeEvent lastPce; public void propertyChange(PropertyChangeEvent evt) { diff --git a/src/test/java/com/avaje/tests/insert/TestInsertCollection.java b/src/test/java/com/avaje/tests/insert/TestInsertCollection.java index 40b2fcc61..6ff223931 100644 --- a/src/test/java/com/avaje/tests/insert/TestInsertCollection.java +++ b/src/test/java/com/avaje/tests/insert/TestInsertCollection.java @@ -21,7 +21,7 @@ public class TestInsertCollection extends BaseTestCase { Customer cust2 = new Customer(); cust2.setName("bob"); - List customers = new ArrayList(); + List customers = new ArrayList<>(); customers.add(cust1); customers.add(cust2); @@ -51,7 +51,7 @@ public class TestInsertCollection extends BaseTestCase { Customer cust3 = new Customer(); cust3.setName("mac"); - List saveList = new ArrayList(); + List saveList = new ArrayList<>(); saveList.add(cust1Check2); saveList.add(cust3); @@ -64,7 +64,7 @@ public class TestInsertCollection extends BaseTestCase { Customer cust3Check = Ebean.find(Customer.class, cust3.getId()); Assert.assertEquals("mac", cust3Check.getName()); - List deleteList = new ArrayList(); + List deleteList = new ArrayList<>(); deleteList.add(cust1Check3); deleteList.add(cust3); deleteList.add(cust2Check2); diff --git a/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java b/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java index 4de60d3dc..16f83ee1b 100644 --- a/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java +++ b/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java @@ -33,7 +33,7 @@ public class TestInsertOnStringKey extends BaseTestCase { } private List toList(OrderItemEntity orderItemEntity) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(orderItemEntity); return list; } diff --git a/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java b/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java index 392a411a6..69bb66d88 100644 --- a/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java +++ b/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java @@ -37,7 +37,7 @@ public class TestCarWheelIud extends BaseTestCase { w4.setCar(car); w4.setTire(t4); - List wheels = new ArrayList(); + List wheels = new ArrayList<>(); wheels.add(w1); wheels.add(w2); wheels.add(w3); diff --git a/src/test/java/com/avaje/tests/json/TestDbJson_List.java b/src/test/java/com/avaje/tests/json/TestDbJson_List.java index fc96b7f3f..c1496d339 100644 --- a/src/test/java/com/avaje/tests/json/TestDbJson_List.java +++ b/src/test/java/com/avaje/tests/json/TestDbJson_List.java @@ -38,13 +38,13 @@ public class TestDbJson_List extends BaseTestCase { bean.setPlainBean(new PlainBean("plain", 52)); - List beanList = new ArrayList(); + List beanList = new ArrayList<>(); beanList.add(new PlainBean("one", 1)); beanList.add(new PlainBean("two", 2)); bean.setBeanList(beanList); - Set beanSet = new LinkedHashSet(); + Set beanSet = new LinkedHashSet<>(); beanSet.add(new PlainBean("A", 1)); beanSet.add(new PlainBean("B", 2)); bean.setBeanSet(beanSet); diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java index 7ea433058..2e6901c58 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java @@ -20,7 +20,7 @@ public class TestJsonExcludeEmptyList { bean.setId(99); bean.setStatus(null); bean.setOrderDate(null); - bean.setDetails(new ArrayList()); + bean.setDetails(new ArrayList<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_NULL); @@ -39,7 +39,7 @@ public class TestJsonExcludeEmptyList { bean.setId(99); bean.setStatus(null); bean.setOrderDate(null); - bean.setDetails(new ArrayList()); + bean.setDetails(new ArrayList<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_EMPTY); diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyMap.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyMap.java index 1332ffa7a..105d493c8 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyMap.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyMap.java @@ -17,7 +17,7 @@ public class TestJsonExcludeEmptyMap { EBasicJsonMap bean = new EBasicJsonMap(); bean.setId(99L); - bean.setContent(new LinkedHashMap()); + bean.setContent(new LinkedHashMap<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_NULL); @@ -34,7 +34,7 @@ public class TestJsonExcludeEmptyMap { EBasicJsonMap bean = new EBasicJsonMap(); bean.setId(99L); - bean.setContent(new LinkedHashMap()); + bean.setContent(new LinkedHashMap<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_EMPTY); diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java index 2b065a516..bdf677d1f 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java @@ -18,7 +18,7 @@ public class TestJsonExcludeEmptySet { AttributeHolder bean = new AttributeHolder(); bean.setId(99); - bean.setAttributes(new LinkedHashSet()); + bean.setAttributes(new LinkedHashSet<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_NULL); @@ -35,7 +35,7 @@ public class TestJsonExcludeEmptySet { AttributeHolder bean = new AttributeHolder(); bean.setId(99); - bean.setAttributes(new LinkedHashSet()); + bean.setAttributes(new LinkedHashSet<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_EMPTY); diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeTransientEmptyList.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeTransientEmptyList.java index 13a8fdc2c..dd3d4713e 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeTransientEmptyList.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeTransientEmptyList.java @@ -20,7 +20,7 @@ public class TestJsonExcludeTransientEmptyList { EJsonTransientList bean = new EJsonTransientList(); bean.setId(99L); - bean.setFileNames(new ArrayList()); + bean.setFileNames(new ArrayList<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_NULL); @@ -37,7 +37,7 @@ public class TestJsonExcludeTransientEmptyList { EJsonTransientList bean = new EJsonTransientList(); bean.setId(99L); - bean.setFileNames(new ArrayList()); + bean.setFileNames(new ArrayList<>()); JsonWriteOptions options = new JsonWriteOptions(); options.setInclude(JsonConfig.Include.NON_EMPTY); diff --git a/src/test/java/com/avaje/tests/json/transientproperties/TestModelAJson.java b/src/test/java/com/avaje/tests/json/transientproperties/TestModelAJson.java index c6dc250af..decf2fba6 100644 --- a/src/test/java/com/avaje/tests/json/transientproperties/TestModelAJson.java +++ b/src/test/java/com/avaje/tests/json/transientproperties/TestModelAJson.java @@ -21,7 +21,7 @@ public class TestModelAJson { b.setOneField(1); b.setTwoField(1); - a.setList(new ArrayList()); + a.setList(new ArrayList<>()); a.getList().add(b); PathProperties pathProperties = PathProperties.parse("(a,list(oneField))"); diff --git a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteObjectWithCascadeToM2m.java b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteObjectWithCascadeToM2m.java index 6a74b17ab..ed08702fa 100644 --- a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteObjectWithCascadeToM2m.java +++ b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteObjectWithCascadeToM2m.java @@ -32,7 +32,7 @@ public class TestM2MDeleteObjectWithCascadeToM2m extends BaseTestCase { Role role1 = new Role("RoleOne"); role1.setTenant(tenant1); - Set permissions = new HashSet(); + Set permissions = new HashSet<>(); List permsList = Ebean.find(Permission.class).findList(); permissions.addAll(permsList); diff --git a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteWithCascade.java b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteWithCascade.java index 6525886ba..0a5043617 100644 --- a/src/test/java/com/avaje/tests/m2m/TestM2MDeleteWithCascade.java +++ b/src/test/java/com/avaje/tests/m2m/TestM2MDeleteWithCascade.java @@ -36,7 +36,7 @@ public class TestM2MDeleteWithCascade extends BaseTestCase { MUser notThere = Ebean.find(MUser.class, u0.getUserid()); Assert.assertNull("been deleted", notThere); - List roleIds = new ArrayList(); + List roleIds = new ArrayList<>(); Collections.addAll(roleIds, r0.getRoleid(), r1.getRoleid()); int rc = Ebean.find(MRole.class).where().idIn(roleIds).findCount(); diff --git a/src/test/java/com/avaje/tests/m2m/TestM2mDeleteObject.java b/src/test/java/com/avaje/tests/m2m/TestM2mDeleteObject.java index a8cc9179b..eda5da6db 100644 --- a/src/test/java/com/avaje/tests/m2m/TestM2mDeleteObject.java +++ b/src/test/java/com/avaje/tests/m2m/TestM2mDeleteObject.java @@ -34,7 +34,7 @@ public class TestM2mDeleteObject extends BaseTestCase { Role role1 = new Role("role"); role1.setTenant(t); - Set permissions = new HashSet(); + Set permissions = new HashSet<>(); List permsList = Ebean.find(Permission.class).findList(); permissions.addAll(permsList); @@ -72,7 +72,7 @@ public class TestM2mDeleteObject extends BaseTestCase { Role role1 = new Role("role"); - Set permissions = new HashSet(); + Set permissions = new HashSet<>(); permissions.add(p2); role1.setPermissions(permissions); Ebean.save(role1); diff --git a/src/test/java/com/avaje/tests/model/array/EArrayBean.java b/src/test/java/com/avaje/tests/model/array/EArrayBean.java index c16960592..678354139 100644 --- a/src/test/java/com/avaje/tests/model/array/EArrayBean.java +++ b/src/test/java/com/avaje/tests/model/array/EArrayBean.java @@ -19,13 +19,13 @@ public class EArrayBean { String name; @DbArray(length = 300) - List phoneNumbers = new ArrayList(); + List phoneNumbers = new ArrayList<>(); @DbArray - List uids = new ArrayList(); + List uids = new ArrayList<>(); @DbArray - List otherIds = new ArrayList(); + List otherIds = new ArrayList<>(); @DbArray List doubs; diff --git a/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java b/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java index 405cbdfa7..d93bd9e1b 100644 --- a/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java +++ b/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java @@ -29,7 +29,7 @@ public class TestDbArray_basic extends BaseTestCase { phNumbers.add("9823"); - List doubles = new ArrayList(); + List doubles = new ArrayList<>(); doubles.add(1.3); doubles.add(2.4); @@ -140,7 +140,7 @@ public class TestDbArray_basic extends BaseTestCase { bean.setOtherIds(null); bean.setUids(null); - List all = new ArrayList(); + List all = new ArrayList<>(); all.add(bean); Ebean.saveAll(all); diff --git a/src/test/java/com/avaje/tests/model/basic/Article.java b/src/test/java/com/avaje/tests/model/basic/Article.java index fb70b9e86..4427c6aea 100644 --- a/src/test/java/com/avaje/tests/model/basic/Article.java +++ b/src/test/java/com/avaje/tests/model/basic/Article.java @@ -56,7 +56,7 @@ public class Article extends BasicDomain { public void addSection(Section s) { if (sections == null) { - sections = new ArrayList
(); + sections = new ArrayList<>(); } sections.add(s); } diff --git a/src/test/java/com/avaje/tests/model/basic/CKeyParent.java b/src/test/java/com/avaje/tests/model/basic/CKeyParent.java index dc58b6ba6..1b75efc86 100644 --- a/src/test/java/com/avaje/tests/model/basic/CKeyParent.java +++ b/src/test/java/com/avaje/tests/model/basic/CKeyParent.java @@ -68,7 +68,7 @@ public class CKeyParent { public void add(CKeyDetail detail) { if (details == null) { - details = new ArrayList(); + details = new ArrayList<>(); } details.add(detail); } diff --git a/src/test/java/com/avaje/tests/model/basic/Car.java b/src/test/java/com/avaje/tests/model/basic/Car.java index d389618a6..55a28ff99 100644 --- a/src/test/java/com/avaje/tests/model/basic/Car.java +++ b/src/test/java/com/avaje/tests/model/basic/Car.java @@ -42,7 +42,7 @@ public class Car extends Vehicle { @OneToMany(mappedBy = "car") @OrderBy("fuse.locationCode") - private Set accessories = new HashSet(); + private Set accessories = new HashSet<>(); private String notes; diff --git a/src/test/java/com/avaje/tests/model/basic/Customer.java b/src/test/java/com/avaje/tests/model/basic/Customer.java index 5a4732498..2163bb330 100644 --- a/src/test/java/com/avaje/tests/model/basic/Customer.java +++ b/src/test/java/com/avaje/tests/model/basic/Customer.java @@ -219,7 +219,7 @@ public class Customer extends BasicDomain { public void addContact(Contact contact) { if (contacts == null) { - contacts = new ArrayList(); + contacts = new ArrayList<>(); } contacts.add(contact); } diff --git a/src/test/java/com/avaje/tests/model/basic/EVanillaCollection.java b/src/test/java/com/avaje/tests/model/basic/EVanillaCollection.java index 97ecea714..614a2bd1c 100644 --- a/src/test/java/com/avaje/tests/model/basic/EVanillaCollection.java +++ b/src/test/java/com/avaje/tests/model/basic/EVanillaCollection.java @@ -19,7 +19,7 @@ public class EVanillaCollection { List details; public EVanillaCollection() { - details = new ArrayList(); + details = new ArrayList<>(); } public Integer getId() { diff --git a/src/test/java/com/avaje/tests/model/basic/MUser.java b/src/test/java/com/avaje/tests/model/basic/MUser.java index 558b590d7..21b22b2e5 100644 --- a/src/test/java/com/avaje/tests/model/basic/MUser.java +++ b/src/test/java/com/avaje/tests/model/basic/MUser.java @@ -64,7 +64,7 @@ public class MUser { public void addRole(MRole role) { if (roles == null) { - roles = new ArrayList(); + roles = new ArrayList<>(); } roles.add(role); } diff --git a/src/test/java/com/avaje/tests/model/basic/MnocUser.java b/src/test/java/com/avaje/tests/model/basic/MnocUser.java index 7cfbd7265..d746716e8 100644 --- a/src/test/java/com/avaje/tests/model/basic/MnocUser.java +++ b/src/test/java/com/avaje/tests/model/basic/MnocUser.java @@ -67,7 +67,7 @@ public class MnocUser { public void addValidRole(MnocRole role) { if (validRoles == null) { - validRoles = new ArrayList(); + validRoles = new ArrayList<>(); } validRoles.add(role); } diff --git a/src/test/java/com/avaje/tests/model/basic/MyEBasicConfigStartup.java b/src/test/java/com/avaje/tests/model/basic/MyEBasicConfigStartup.java index 3941e5c77..e2e19b863 100644 --- a/src/test/java/com/avaje/tests/model/basic/MyEBasicConfigStartup.java +++ b/src/test/java/com/avaje/tests/model/basic/MyEBasicConfigStartup.java @@ -30,7 +30,7 @@ public class MyEBasicConfigStartup implements ServerConfigStartup { public static class EbasicBulkListener implements BulkTableEventListener { - final Set s = new HashSet(); + final Set s = new HashSet<>(); EbasicBulkListener() { s.add("e_basic"); diff --git a/src/test/java/com/avaje/tests/model/basic/OCachedBean.java b/src/test/java/com/avaje/tests/model/basic/OCachedBean.java index cc7be91b2..4d2636696 100644 --- a/src/test/java/com/avaje/tests/model/basic/OCachedBean.java +++ b/src/test/java/com/avaje/tests/model/basic/OCachedBean.java @@ -25,10 +25,10 @@ public class OCachedBean { String name; @ManyToMany(cascade = CascadeType.ALL) - List countries = new ArrayList(); + List countries = new ArrayList<>(); @OneToMany(mappedBy = "cachedBean", cascade = CascadeType.ALL) - List children = new ArrayList(); + List children = new ArrayList<>(); public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/basic/Order.java b/src/test/java/com/avaje/tests/model/basic/Order.java index 98e7cb722..13b91815f 100644 --- a/src/test/java/com/avaje/tests/model/basic/Order.java +++ b/src/test/java/com/avaje/tests/model/basic/Order.java @@ -252,7 +252,7 @@ public class Order implements Serializable { public void addDetail(OrderDetail detail) { if (details == null) { - details = new ArrayList(); + details = new ArrayList<>(); } details.add(detail); } @@ -268,7 +268,7 @@ public class Order implements Serializable { public void addShipment(OrderShipment shipment) { if (shipments == null) { - shipments = new ArrayList(); + shipments = new ArrayList<>(); } shipments.add(shipment); } diff --git a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java index b4d3bd35d..4280fe31a 100644 --- a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java +++ b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java @@ -257,7 +257,7 @@ public class ResetBasicData { Order order = new Order(); order.setCustomer(customer); - List details = new ArrayList(); + List details = new ArrayList<>(); details.add(new OrderDetail(product1, 5, 10.50)); details.add(new OrderDetail(product2, 3, 1.10)); details.add(new OrderDetail(product3, 1, 2.00)); @@ -278,7 +278,7 @@ public class ResetBasicData { order.setStatus(Status.SHIPPED); order.setCustomer(customer); - List details = new ArrayList(); + List details = new ArrayList<>(); details.add(new OrderDetail(product1, 4, 10.50)); order.setDetails(details); @@ -296,7 +296,7 @@ public class ResetBasicData { order.setStatus(Status.COMPLETE); order.setCustomer(customer); - List details = new ArrayList(); + List details = new ArrayList<>(); details.add(new OrderDetail(product1, 3, 10.50)); details.add(new OrderDetail(product3, 40, 2.10)); details.add(new OrderDetail(product1, 5, 10.00)); diff --git a/src/test/java/com/avaje/tests/model/basic/Section.java b/src/test/java/com/avaje/tests/model/basic/Section.java index 429732c86..016433f03 100644 --- a/src/test/java/com/avaje/tests/model/basic/Section.java +++ b/src/test/java/com/avaje/tests/model/basic/Section.java @@ -73,7 +73,7 @@ public class Section extends BasicDomain { public void addSubSection(SubSection s) { if (subSections == null) { - subSections = new ArrayList(); + subSections = new ArrayList<>(); } subSections.add(s); } diff --git a/src/test/java/com/avaje/tests/model/basic/TSMaster.java b/src/test/java/com/avaje/tests/model/basic/TSMaster.java index ff1306887..9de0b7b0d 100644 --- a/src/test/java/com/avaje/tests/model/basic/TSMaster.java +++ b/src/test/java/com/avaje/tests/model/basic/TSMaster.java @@ -75,7 +75,7 @@ public class TSMaster { public void addDetail(TSDetail detail) { if (details == null) { - details = new ArrayList(); + details = new ArrayList<>(); } details.add(detail); } diff --git a/src/test/java/com/avaje/tests/model/basic/TSMasterTwo.java b/src/test/java/com/avaje/tests/model/basic/TSMasterTwo.java index ebb860ae5..f78aa69ec 100644 --- a/src/test/java/com/avaje/tests/model/basic/TSMasterTwo.java +++ b/src/test/java/com/avaje/tests/model/basic/TSMasterTwo.java @@ -72,7 +72,7 @@ public class TSMasterTwo { public void addDetail(TSDetailTwo detail) { if (details == null) { - details = new ArrayList(); + details = new ArrayList<>(); } details.add(detail); } diff --git a/src/test/java/com/avaje/tests/model/basic/UTMaster.java b/src/test/java/com/avaje/tests/model/basic/UTMaster.java index fe2d38d7d..6a31d0bc3 100644 --- a/src/test/java/com/avaje/tests/model/basic/UTMaster.java +++ b/src/test/java/com/avaje/tests/model/basic/UTMaster.java @@ -78,7 +78,7 @@ public class UTMaster extends Model { public void addDetail(UTDetail detail) { if (details == null) { - details = new ArrayList(); + details = new ArrayList<>(); } details.add(detail); } diff --git a/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java b/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java index 0df57a452..a3223937b 100644 --- a/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java +++ b/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java @@ -30,7 +30,7 @@ public class TestDeleteUnloadedChildren extends BaseTestCase { EdChild child = new EdChild(); child.setName("Harddisk 123"); child.setParent(parent); - ArrayList children = new ArrayList(); + ArrayList children = new ArrayList<>(); children.add(child); parent.setChildren(children); @@ -42,7 +42,7 @@ public class TestDeleteUnloadedChildren extends BaseTestCase { child = new EdChild(); child.setName("DVBS Card"); - children = new ArrayList(); + children = new ArrayList<>(); children.add(child); extendedParent.setChildren(children); diff --git a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java index c0334d51c..ba2951f55 100644 --- a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java +++ b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenFlushThenUpdate.java @@ -31,7 +31,7 @@ public class TestInsertBatchThenFlushThenUpdate extends BaseTestCase { EdChild child = new EdChild(); child.setName("Harddisk 123"); child.setParent(parent); - ArrayList children = new ArrayList(); + ArrayList children = new ArrayList<>(); children.add(child); parent.setChildren(children); diff --git a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenUpdate.java b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenUpdate.java index a9c22e64c..ca0912c49 100644 --- a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenUpdate.java +++ b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchThenUpdate.java @@ -33,7 +33,7 @@ public class TestInsertBatchThenUpdate extends BaseTestCase { EdChild child = new EdChild(); child.setName("Harddisk 123"); child.setParent(parent); - ArrayList children = new ArrayList(); + ArrayList children = new ArrayList<>(); children.add(child); parent.setChildren(children); diff --git a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchWithDifferentRootTypes.java b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchWithDifferentRootTypes.java index 56042653d..ae6d10a04 100644 --- a/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchWithDifferentRootTypes.java +++ b/src/test/java/com/avaje/tests/model/basic/xtra/TestInsertBatchWithDifferentRootTypes.java @@ -30,7 +30,7 @@ public class TestInsertBatchWithDifferentRootTypes extends BaseTestCase { EdChild child = new EdChild(); child.setName("Harddisk 123"); child.setParent(parent); - ArrayList children = new ArrayList(); + ArrayList children = new ArrayList<>(); children.add(child); parent.setChildren(children); @@ -42,7 +42,7 @@ public class TestInsertBatchWithDifferentRootTypes extends BaseTestCase { child = new EdChild(); child.setName("DVBS Card"); - children = new ArrayList(); + children = new ArrayList<>(); children.add(child); extendedParent.setChildren(children); diff --git a/src/test/java/com/avaje/tests/model/info/InfoCompany.java b/src/test/java/com/avaje/tests/model/info/InfoCompany.java index 7d8e698f0..67448e4cf 100644 --- a/src/test/java/com/avaje/tests/model/info/InfoCompany.java +++ b/src/test/java/com/avaje/tests/model/info/InfoCompany.java @@ -10,7 +10,7 @@ import java.util.List; @Entity public class InfoCompany extends Model { - public static final Finder find = new Finder(InfoCompany.class); + public static final Finder find = new Finder<>(InfoCompany.class); @Id Long id; @@ -22,7 +22,7 @@ public class InfoCompany extends Model { @JsonIgnore @OneToMany(mappedBy = "company", cascade = CascadeType.ALL) - List contacts = new ArrayList(); + List contacts = new ArrayList<>(); public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/info/InfoCustomer.java b/src/test/java/com/avaje/tests/model/info/InfoCustomer.java index eea7e2154..ed422e2fe 100644 --- a/src/test/java/com/avaje/tests/model/info/InfoCustomer.java +++ b/src/test/java/com/avaje/tests/model/info/InfoCustomer.java @@ -11,7 +11,7 @@ import javax.persistence.Version; @Entity public class InfoCustomer extends Model { - public static final Finder find = new Finder(InfoCustomer.class); + public static final Finder find = new Finder<>(InfoCustomer.class); @Id Long id; diff --git a/src/test/java/com/avaje/tests/model/ivo/Oid.java b/src/test/java/com/avaje/tests/model/ivo/Oid.java index 6d8ebf808..7629c33a3 100644 --- a/src/test/java/com/avaje/tests/model/ivo/Oid.java +++ b/src/test/java/com/avaje/tests/model/ivo/Oid.java @@ -31,15 +31,15 @@ public class Oid { } public static Oid valueOf(String s) { - return new Oid(Integer.valueOf(s)); + return new Oid<>(Integer.valueOf(s)); } public static Oid valueOf(long i) { - return new Oid(i); + return new Oid<>(i); } public static Oid valueOf(Class cls, String s) { Integer v = Integer.valueOf(s); - return new Oid(v); + return new Oid<>(v); } } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java b/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java index 689cc59a6..cb5abdb42 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java @@ -9,7 +9,7 @@ public class OidTypeConverter {//implements ScalarTypeConverter,Long> { if (scalarType == null){ return null; } - return new Oid(scalarType); + return new Oid<>(scalarType); } public Long unwrapValue(Oid beanType) { diff --git a/src/test/java/com/avaje/tests/model/json/EBasicHstore.java b/src/test/java/com/avaje/tests/model/json/EBasicHstore.java index 0c6ccfea9..775559a44 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicHstore.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicHstore.java @@ -25,7 +25,7 @@ public class EBasicHstore { public EBasicHstore(String name) { this.name = name; - this.map = new LinkedHashMap(); + this.map = new LinkedHashMap<>(); } public Long getId() { diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java index 800c8b427..ab841aebe 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java @@ -29,16 +29,16 @@ public class EBasicJsonList { List beanList; @DbJson(length = 700) - Map beanMap = new LinkedHashMap(); + Map beanMap = new LinkedHashMap<>(); @DbJson(length = 500) PlainBean plainBean; @DbJson(length = 50) - Set flags = new LinkedHashSet(); + Set flags = new LinkedHashSet<>(); @DbJson(length = 100, storage = DbJsonType.VARCHAR) - List tags = new ArrayList(); + List tags = new ArrayList<>(); @Version Long version; diff --git a/src/test/java/com/avaje/tests/model/map/MpUser.java b/src/test/java/com/avaje/tests/model/map/MpUser.java index c7efaf6e9..6801b6486 100644 --- a/src/test/java/com/avaje/tests/model/map/MpUser.java +++ b/src/test/java/com/avaje/tests/model/map/MpUser.java @@ -18,7 +18,7 @@ public class MpUser { @OneToMany(cascade = CascadeType.ALL) @MapKey(name = "code") - public Map roles = new HashMap(); + public Map roles = new HashMap<>(); public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/onetoone/album/Album.java b/src/test/java/com/avaje/tests/model/onetoone/album/Album.java index 3bc4f4056..faf16d6a2 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/album/Album.java +++ b/src/test/java/com/avaje/tests/model/onetoone/album/Album.java @@ -10,7 +10,7 @@ import javax.persistence.OneToOne; @Entity public class Album extends BaseModel { - public static final Model.Finder find = new Model.Finder(Album.class); + public static final Model.Finder find = new Model.Finder<>(Album.class); private String name; diff --git a/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java b/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java index da792d368..c274dfb4b 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java +++ b/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java @@ -15,7 +15,7 @@ public class Cover extends Model { private static final Logger logger = LoggerFactory.getLogger(Cover.class); - public static final Finder find = new Finder(Cover.class); + public static final Finder find = new Finder<>(Cover.class); @Id protected Long id; diff --git a/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java b/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java index 3ce7c919e..adde5f4fe 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java +++ b/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java @@ -296,7 +296,7 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase { } private List ids(List beans) { - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (Cover someBean : beans) { ids.add(someBean.getId()); } @@ -304,7 +304,7 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase { } private List beans(int count) { - List beans = new ArrayList(); + List beans = new ArrayList<>(); for (int i = 0; i < count; i++) { beans.add(new Cover("delById " + i)); } diff --git a/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java b/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java index d244b5d0e..5a328da44 100644 --- a/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java +++ b/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java @@ -26,7 +26,7 @@ public class ResourceFile extends BaseResourceFile { @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, mappedBy = "parent") @PrivateOwned - private Set alternatives = new HashSet(); + private Set alternatives = new HashSet<>(); @Column(name = "name", length = 128, nullable = false) private String name; diff --git a/src/test/java/com/avaje/tests/model/survey/Group.java b/src/test/java/com/avaje/tests/model/survey/Group.java index 52ec98da3..d9a92394e 100644 --- a/src/test/java/com/avaje/tests/model/survey/Group.java +++ b/src/test/java/com/avaje/tests/model/survey/Group.java @@ -29,7 +29,7 @@ public class Group { @OneToMany(mappedBy = "group", cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @OrderBy("sequenceNumber") - private List questions = new ArrayList(); + private List questions = new ArrayList<>(); private int sequenceNumber; diff --git a/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java b/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java index 6af87160f..5f4c1cbec 100644 --- a/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java +++ b/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java @@ -16,25 +16,25 @@ public class TestOrderByFetch extends BaseTestCase { public void test() { Survey survey = new Survey("s1"); - List categories = new ArrayList(); + List categories = new ArrayList<>(); Category category = new Category("c1"); category.setSequenceNumber(1); categories.add(category); survey.setCategories(categories); - List groups = new ArrayList(); + List groups = new ArrayList<>(); Group group1 = group(1); Group group2 = group(2); groups.add(group1); groups.add(group2); category.setGroups(groups); - List questionListGroup1 = new ArrayList(); + List questionListGroup1 = new ArrayList<>(); questionListGroup1.add(question(1)); questionListGroup1.add(question(2)); questionListGroup1.add(question(3)); group1.setQuestions(questionListGroup1); - List questionListGroup2 = new ArrayList(); + List questionListGroup2 = new ArrayList<>(); questionListGroup2.add(question(1)); questionListGroup2.add(question(2)); group2.setQuestions(questionListGroup2); diff --git a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java index b08030538..09d15e5fd 100644 --- a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java +++ b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java @@ -34,8 +34,8 @@ public class TestPersistenceContextScopeUsingOrders extends BaseTestCase { assertTrue(!orders.isEmpty()); // collect the customer instances - List customers = new ArrayList(); - Set identities = new HashSet(); + List customers = new ArrayList<>(); + Set identities = new HashSet<>(); for (Order order : orders) { Customer customer = order.getCustomer(); diff --git a/src/test/java/com/avaje/tests/query/TestSubQuery.java b/src/test/java/com/avaje/tests/query/TestSubQuery.java index ccb7dfff5..e7d26851d 100644 --- a/src/test/java/com/avaje/tests/query/TestSubQuery.java +++ b/src/test/java/com/avaje/tests/query/TestSubQuery.java @@ -24,7 +24,7 @@ public class TestSubQuery extends BaseTestCase { ResetBasicData.reset(); - List productIds = new ArrayList(); + List productIds = new ArrayList<>(); productIds.add(3); Query sq = Ebean.createQuery(Order.class).select("id").where() diff --git a/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java b/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java index 0a9aa9b49..b1b1cfe5f 100644 --- a/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java +++ b/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java @@ -29,7 +29,7 @@ public class TestManyLazyLoadingQuery extends BaseTestCase { BeanDescriptor descOrder = server.getBeanDescriptor(Order.class); BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany)descOrder.getBeanProperty("details"); - List parentIds = new ArrayList(); + List parentIds = new ArrayList<>(); parentIds.add(1); diff --git a/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java b/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java index d3dee624a..a0ba745c8 100644 --- a/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java +++ b/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java @@ -17,7 +17,7 @@ public class TestSoftDeletePagingList extends BaseTestCase { @Test public void test() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new Cover("SoftDelPaged-1")); list.add(new Cover("SoftDelPaged-2")); list.add(new Cover("SoftDelPaged-3")); diff --git a/src/test/java/com/avaje/tests/rawsql/inherit/ParentQueryTest.java b/src/test/java/com/avaje/tests/rawsql/inherit/ParentQueryTest.java index af5061306..e6b7d057b 100644 --- a/src/test/java/com/avaje/tests/rawsql/inherit/ParentQueryTest.java +++ b/src/test/java/com/avaje/tests/rawsql/inherit/ParentQueryTest.java @@ -19,7 +19,7 @@ public class ParentQueryTest extends BaseTestCase { @Test public void QueryParentCollectionFetch() { - List exampleData = new ArrayList(); + List exampleData = new ArrayList<>(); exampleData.add(new Data(0)); exampleData.add(new Data(1)); exampleData.add(new Data(2)); diff --git a/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java b/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java index 15109274d..6a867ac26 100644 --- a/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java +++ b/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java @@ -25,7 +25,7 @@ public class ParentRawSqlTest extends BaseTestCase { @Test public void RawSqlParentLoad() { - List exampleData = new ArrayList(); + List exampleData = new ArrayList<>(); exampleData.add(new Data(0)); exampleData.add(new Data(1)); exampleData.add(new Data(2)); @@ -57,7 +57,7 @@ public class ParentRawSqlTest extends BaseTestCase { @Test public void RawSqlParentFetch() { - List exampleData = new ArrayList(); + List exampleData = new ArrayList<>(); exampleData.add(new Data(0)); exampleData.add(new Data(1)); exampleData.add(new Data(2)); @@ -178,7 +178,7 @@ public class ParentRawSqlTest extends BaseTestCase { .fetch("parent", new FetchConfig().query()) .findList(); - List partial = new ArrayList(); + List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { partial.add(aggregate.parent); } @@ -202,7 +202,7 @@ public class ParentRawSqlTest extends BaseTestCase { .fetch("parent", new FetchConfig().query()) .findList(); - List partial = new ArrayList(); + List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { partial.add(aggregate.parent); } @@ -228,7 +228,7 @@ public class ParentRawSqlTest extends BaseTestCase { .fetch("parent", new FetchConfig().query()) .findList(); - List partial = new ArrayList(); + List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { partial.add(aggregate.parent); } diff --git a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java index 927e75bba..43fa894db 100644 --- a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java +++ b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java @@ -359,9 +359,9 @@ public class TestReadAudit extends BaseTestCase { class TDReadAuditLogger implements ReadAuditLogger { - Set plans = new HashSet(); - List beans = new ArrayList(); - List many = new ArrayList(); + Set plans = new HashSet<>(); + List beans = new ArrayList<>(); + List many = new ArrayList<>(); TDReadAuditLogger(boolean dummy) { } diff --git a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteTop.java b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteTop.java index 2f7af21ab..89feea799 100644 --- a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteTop.java +++ b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteTop.java @@ -43,7 +43,7 @@ public class TestSoftDeleteTop extends BaseTestCase { transaction.end(); } - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(up1); list.add(up2); @@ -56,7 +56,7 @@ public class TestSoftDeleteTop extends BaseTestCase { ESoftDelUp up1 = new ESoftDelUp("upBatchX"); ESoftDelUp up2 = new ESoftDelUp("upBatchY"); - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(up1); list.add(up2); diff --git a/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java b/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java index a641f2d5c..b700e3a93 100644 --- a/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java +++ b/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java @@ -20,7 +20,7 @@ public class TestManyToManySaveTwice extends BaseTestCase { Ebean.createSqlUpdate("delete from sp_car_wheel").execute(); Ebean.createSqlUpdate("delete from sp_car_car").execute(); - List wheels = new LinkedList(); + List wheels = new LinkedList<>(); wheels.add(new Wheel()); wheels.add(new Wheel()); wheels.add(new Wheel()); diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java b/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java index 8e588564a..5ccf92d73 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java @@ -44,7 +44,7 @@ public class TestJsonSimple extends BaseTestCase { Assert.assertEquals(12L, e2.get("a")); Assert.assertEquals("rob", ((Map)e2.get("name")).get("first")); - Map m = new LinkedHashMap(); + Map m = new LinkedHashMap<>(); m.put("hello", "rob"); m.put("test", "me"); diff --git a/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java b/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java index 3726099f8..e83c9b328 100644 --- a/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java +++ b/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java @@ -39,7 +39,7 @@ public class TestInsertManyAndRef extends BaseTestCase { u.setName("Mr Test"); u.setPassword("password"); - final List bookmarks = new ArrayList(); + final List bookmarks = new ArrayList<>(); final BBookmark b1 = new BBookmark(); b1.setBookmarkReference("Acts 2:7-20"); b1.setUser(u); diff --git a/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java b/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java index 11267f790..940b352e8 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java @@ -16,25 +16,25 @@ public class TestOrderByParse extends BaseTestCase { @Test public void testParsingOne() { - OrderBy o1 = new OrderBy("id"); + OrderBy o1 = new OrderBy<>("id"); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); assertTrue(o1.toStringFormat().equals("id")); - o1 = new OrderBy("id asc"); + o1 = new OrderBy<>("id asc"); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); assertTrue(o1.toStringFormat().equals("id")); - o1 = new OrderBy("id desc"); + o1 = new OrderBy<>("id desc"); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(!o1.getProperties().get(0).isAscending()); assertTrue(o1.toStringFormat().equals("id desc")); - o1 = new OrderBy(" id asc "); + o1 = new OrderBy<>(" id asc "); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); @@ -47,7 +47,7 @@ public class TestOrderByParse extends BaseTestCase { @Test public void parseNullsHigh() { - OrderBy o1 = new OrderBy("id desc nulls high"); + OrderBy o1 = new OrderBy<>("id desc nulls high"); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(!o1.getProperties().get(0).isAscending()); @@ -57,7 +57,7 @@ public class TestOrderByParse extends BaseTestCase { @Test public void add_parse() { - OrderBy o1 = new OrderBy(); + OrderBy o1 = new OrderBy<>(); o1.add("id desc nulls high"); assertTrue(o1.getProperties().size() == 1); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); @@ -68,7 +68,7 @@ public class TestOrderByParse extends BaseTestCase { @Test public void parseNullsHigh_with_second() { - OrderBy o1 = new OrderBy("id desc nulls high, name"); + OrderBy o1 = new OrderBy<>("id desc nulls high, name"); assertTrue(o1.getProperties().size() == 2); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(!o1.getProperties().get(0).isAscending()); @@ -80,7 +80,7 @@ public class TestOrderByParse extends BaseTestCase { @Test public void testParsingTwo() { - OrderBy o1 = new OrderBy("id,name"); + OrderBy o1 = new OrderBy<>("id,name"); assertTrue(o1.getProperties().size() == 2); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); @@ -88,7 +88,7 @@ public class TestOrderByParse extends BaseTestCase { assertTrue(o1.getProperties().get(1).isAscending()); assertEquals("id, name", o1.toStringFormat()); - o1 = new OrderBy(" id , name "); + o1 = new OrderBy<>(" id , name "); assertTrue(o1.getProperties().size() == 2); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); @@ -96,7 +96,7 @@ public class TestOrderByParse extends BaseTestCase { assertTrue(o1.getProperties().get(1).isAscending()); assertEquals("id, name", o1.toStringFormat()); - o1 = new OrderBy(" id desc , name desc "); + o1 = new OrderBy<>(" id desc , name desc "); assertTrue(o1.getProperties().size() == 2); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(!o1.getProperties().get(0).isAscending()); @@ -104,7 +104,7 @@ public class TestOrderByParse extends BaseTestCase { assertTrue(!o1.getProperties().get(1).isAscending()); assertEquals("id desc, name desc", o1.toStringFormat()); - o1 = new OrderBy(" id ascending, name asc"); + o1 = new OrderBy<>(" id ascending, name asc"); assertTrue(o1.getProperties().size() == 2); assertTrue(o1.getProperties().get(0).getProperty().equals("id")); assertTrue(o1.getProperties().get(0).isAscending()); @@ -117,7 +117,7 @@ public class TestOrderByParse extends BaseTestCase { @Test public void testAddMethods() { - OrderBy o1 = new OrderBy(); + OrderBy o1 = new OrderBy<>(); o1.asc("id"); o1.asc("name"); assertTrue(o1.getProperties().size() == 2); @@ -127,7 +127,7 @@ public class TestOrderByParse extends BaseTestCase { assertTrue(o1.getProperties().get(1).isAscending()); assertEquals("id, name", o1.toStringFormat()); - o1 = new OrderBy(); + o1 = new OrderBy<>(); o1.desc("id"); o1.desc("name"); assertTrue(o1.getProperties().size() == 2); diff --git a/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java b/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java index 9c832c6cc..a5d832825 100644 --- a/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java +++ b/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java @@ -136,7 +136,7 @@ public class TestStatelessUpdate extends BaseTestCase { Customer customer = new Customer(); customer.setName("something"); - customer.setContacts(new ArrayList()); + customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); server.save(customer); @@ -171,7 +171,7 @@ public class TestStatelessUpdate extends BaseTestCase { Customer customer = new Customer(); customer.setName("something"); - customer.setContacts(new ArrayList()); + customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); server.save(customer); @@ -204,7 +204,7 @@ public class TestStatelessUpdate extends BaseTestCase { Customer customer = new Customer(); customer.setName("something"); - customer.setContacts(new ArrayList()); + customer.setContacts(new ArrayList<>()); customer.getContacts().add(contact); server.save(customer); @@ -314,8 +314,8 @@ public class TestStatelessUpdate extends BaseTestCase { Customer assCustomer = server.find(Customer.class, customer.getId()); List assContacts = assCustomer.getContacts(); assertEquals(2, assContacts.size()); - Set ids = new LinkedHashSet(); - Set names = new LinkedHashSet(); + Set ids = new LinkedHashSet<>(); + Set names = new LinkedHashSet<>(); for (Contact contact : assContacts) { ids.add(contact.getId()); names.add(contact.getLastName()); @@ -372,8 +372,8 @@ public class TestStatelessUpdate extends BaseTestCase { // contact 2 was not deleted this time assertEquals(3, assContacts.size()); - Set ids = new LinkedHashSet(); - Set names = new LinkedHashSet(); + Set ids = new LinkedHashSet<>(); + Set names = new LinkedHashSet<>(); for (Contact contact : assContacts) { ids.add(contact.getId()); names.add(contact.getLastName()); diff --git a/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java b/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java index e0399cad5..c6b273502 100644 --- a/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java +++ b/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java @@ -55,7 +55,7 @@ public class LoggedSqlCollector { private static class BasicAppender extends UnsynchronizedAppenderBase { - List messages = new ArrayList(); + List messages = new ArrayList<>(); @Override protected void append(ILoggingEvent eventObject) { @@ -69,7 +69,7 @@ public class LoggedSqlCollector { */ List collectStart() { List tempMessages = messages; - messages = new ArrayList(); + messages = new ArrayList<>(); // set started flag start(); return tempMessages; @@ -82,7 +82,7 @@ public class LoggedSqlCollector { // set stopped state stop(); List tempMessages = messages; - messages = new ArrayList(); + messages = new ArrayList<>(); return tempMessages; } diff --git a/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java b/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java index 4665a14c9..0858128b7 100644 --- a/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java +++ b/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java @@ -17,7 +17,7 @@ public class Data { private Integer val; @ManyToMany(mappedBy = "data") - public List parents = new ArrayList(); + public List parents = new ArrayList<>(); public Data(int number) { this.val = number; diff --git a/src/test/java/org/avaje/test/model/rawsql/inherit/Parent.java b/src/test/java/org/avaje/test/model/rawsql/inherit/Parent.java index 2a5376be4..fbc9cd5f8 100644 --- a/src/test/java/org/avaje/test/model/rawsql/inherit/Parent.java +++ b/src/test/java/org/avaje/test/model/rawsql/inherit/Parent.java @@ -25,7 +25,7 @@ public abstract class Parent { private String more; @ManyToMany(cascade = CascadeType.PERSIST) - private List data = new ArrayList(); + private List data = new ArrayList<>(); protected Parent(Integer val, String more) { this.val = val; From abb25d397a1d6d2e9e5606db7e0ebe30fa9e0d54 Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 10:03:33 +0100 Subject: [PATCH 12/87] Fix comments --- src/main/java/com/avaje/ebean/PagedList.java | 2 +- ...ascadeDeleteChildrenWithCompositeKeys.java | 32 +++++++------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/avaje/ebean/PagedList.java b/src/main/java/com/avaje/ebean/PagedList.java index 3bd67beae..2b93872cc 100644 --- a/src/main/java/com/avaje/ebean/PagedList.java +++ b/src/main/java/com/avaje/ebean/PagedList.java @@ -8,7 +8,7 @@ import java.util.concurrent.Future; *

* The benefit of using PagedList over just using the normal Query with * {@link Query#setFirstRow(int)} and {@link Query#setMaxRows(int)} is that it additionally wraps - * functionality that can call {@link Query#findFutureRowCount()} to determine total row count, + * functionality that can call {@link Query#findFutureCount()} to determine total row count, * total page count etc. *

*

diff --git a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java index b3d7c718f..ae6268e3a 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java @@ -1,33 +1,23 @@ package com.avaje.tests.compositekeys; -import static org.junit.Assert.assertEquals; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Embeddable; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -import org.junit.Before; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import org.junit.Before; +import org.junit.Test; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.junit.Assert.assertEquals; /** - * @see https://groups.google.com/forum/#!topic/ebean/VD1MV2-LrOc + * Read more at https://groups.google.com/forum/#!topic/ebean/VD1MV2-LrOc */ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { From cbfce0d14dba28e1c3f00dd803d10579d1964d4e Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 6 Nov 2016 22:18:23 +1300 Subject: [PATCH 13/87] #855 - Fix @Aggregation lazy loading and base select issue --- .../deploy/meta/DeployBeanPropertyLists.java | 4 +- .../aggregation/TestAggregationCount.java | 45 +++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index b0666e501..e263a5510 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -214,7 +214,9 @@ public class DeployBeanPropertyLists { if (prop instanceof BeanPropertyCompound) { baseCompound.add((BeanPropertyCompound) prop); } else { - baseScalar.add(prop); + if (!prop.isAggregation()) { + baseScalar.add(prop); + } } } } diff --git a/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java b/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java index 525dcb169..d633d1f78 100644 --- a/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java +++ b/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java @@ -5,6 +5,7 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.tevent.TEventMany; import com.avaje.tests.model.tevent.TEventOne; +import org.junit.BeforeClass; import org.junit.Test; import java.util.List; @@ -13,9 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestAggregationCount extends BaseTestCase { - @Test - public void testFull() { - + @BeforeClass + public static void setup() { TEventOne one = new TEventOne("first"); one.getLogs().add(new TEventMany("all", 1, 10)); one.getLogs().add(new TEventMany("be", 2, 12.2)); @@ -27,6 +27,42 @@ public class TestAggregationCount extends BaseTestCase { two.getLogs().add(new TEventMany("add", 30, 13)); two.getLogs().add(new TEventMany("alf", 30, 13)); Ebean.save(two); + } + + @Test + public void testBaseSelect() { + + Query query = Ebean.find(TEventOne.class); + List list = query.findList(); + + String sql = sqlOf(query, 5); + assertThat(sql).contains("select t0.id, t0.name, t0.version, t0.event_id from tevent_one t0"); + + for (TEventOne eventOne : list) { + // lazy loading on Aggregation properties + // is not expected to work at this stage + Double totalAmount = eventOne.getTotalAmount(); + assertThat(totalAmount).isNull(); + } + } + + @Test + public void testNonAggregationLazyLoading() { + + Query query = Ebean.find(TEventOne.class).select("id"); + List list = query.findList(); + + String sql = sqlOf(query, 5); + assertThat(sql).contains("select t0.id from tevent_one t0"); + + for (TEventOne eventOne : list) { + String name = eventOne.getName(); + assertThat(name).isNotNull(); + } + } + + @Test + public void testFull() { Query query2 = Ebean.find(TEventOne.class) .select("name, count, totalUnits, totalAmount") @@ -49,6 +85,9 @@ public class TestAggregationCount extends BaseTestCase { assertThat(sql).contains("where u1.description like ? "); assertThat(sql).contains(" group by t0.id, t0.name having count(u1.*) >= ? order by t0.name"); + // invoke lazy loading + Long version = list.get(0).getVersion(); + assertThat(version).isNotNull(); } @Test From a8778ef14ce44d990434976c439c09fab4b4169e Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 10:26:13 +0100 Subject: [PATCH 14/87] Change identical 'catch' statements --- .../migrationreader/MigrationXmlWriter.java | 5 +---- .../server/deploy/BeanLifecycleAdapterFactory.java | 12 +++--------- .../tests/idkeys/TestPropertyChangeSupport.java | 6 +----- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java index 9c19f0382..5fb293a37 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriter.java @@ -45,10 +45,7 @@ public class MigrationXmlWriter { writer.close(); - } catch (IOException e) { - throw new RuntimeException(e); - - } catch (JAXBException e) { + } catch (IOException | JAXBException e) { throw new RuntimeException(e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 19e782aab..029f83fb6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -170,9 +170,7 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } @@ -237,9 +235,7 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } @@ -272,9 +268,7 @@ public class BeanLifecycleAdapterFactory { private void invoke(Method method, Object bean) { try { method.invoke(bean); - } catch (InvocationTargetException e) { - throw new PersistenceException("Error invoking lifecycle method", e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new PersistenceException("Error invoking lifecycle method", e); } } diff --git a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java index 9b5b7911e..b604d74d5 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java +++ b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java @@ -163,11 +163,7 @@ public class TestPropertyChangeSupport extends EbeanTestCase implements Property Method apcs = al.getClass().getMethod("addPropertyChangeListener", PropertyChangeListener.class); apcs.invoke(al, listener); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); } } From b94f852b6787dc74f97df83edc5d7802a2bd2bac Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 10:29:42 +0100 Subject: [PATCH 15/87] Remove unnecessary boxing and unboxing --- .../server/type/LongToTimestampConverter.java | 2 +- .../com/avaje/tests/compositekeys/TestCore.java | 15 ++++----------- .../avaje/tests/query/sqlquery/SqlQueryTests.java | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java index 6f308c516..b553d550c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java @@ -12,7 +12,7 @@ public class LongToTimestampConverter implements ScalarTypeConverter @@ -113,7 +106,7 @@ public class TestCore extends EbeanTestCase { // qItems.where(Expr.eq("key.customer", Integer.valueOf(1))); // I want to discourage the direct use of Expr - qItems.where().eq("key.customer", Integer.valueOf(1)); + qItems.where().eq("key.customer", 1); items = qItems.findList(); assertNotNull(items); diff --git a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java index 4e7cefb0c..00955ed89 100644 --- a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java +++ b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java @@ -139,7 +139,7 @@ public class SqlQueryTests extends BaseTestCase { public boolean accept(SqlRow bean) { count.incrementAndGet(); Integer id = bean.getInteger("id"); - return id.intValue() < 3; + return id < 3; } }); From e0931e41e566371c74c37dfbb8306a4134e0658f Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 10:50:31 +0100 Subject: [PATCH 16/87] Remove deprecated API usage --- .../ebeaninternal/server/type/ScalarTypeJodaLocalTime.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java index eeb8ad79c..02dc9bae8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java @@ -29,7 +29,7 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { if (value == null) { b.setNull(Types.TIME); } else { - b.setTime(new Time(value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute())); + b.setTime(new Time(value.toDateTimeToday().getMillis())); } } @@ -48,7 +48,7 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { public Object toJdbcType(Object value) { if (value instanceof LocalTime) { LocalTime lt = (LocalTime) value; - return new Time(lt.getHourOfDay(), lt.getMinuteOfHour(), lt.getSecondOfMinute()); + return new Time(lt.toDateTimeToday().getMillis()); } return BasicTypeConverter.toTime(value); } From 6680e2ea75b74641a2bfabd7050513b954cc7d3e Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 11:17:53 +0100 Subject: [PATCH 17/87] Replace anonymous classes with lambda expressions --- .../dbplatform/SequenceIdGenerator.java | 16 +-- .../dbmigration/model/MigrationModel.java | 7 +- .../server/deploy/BeanDescriptor.java | 9 +- .../server/deploy/InheritInfo.java | 15 +- .../transaction/PostCommitProcessing.java | 12 +- .../transaction/TransactionManager.java | 7 +- .../api/support/DocStoreBeanBaseAdapter.java | 9 +- .../inheritance/TestDuplcateKeyException.java | 20 ++- .../tests/model/basic/ResetBasicData.java | 128 ++++++++---------- .../model/selfref/TestTextJsonSelfRef.java | 30 ++-- .../query/TestOneToManyCorrectGrouping.java | 11 +- .../avaje/tests/query/TestQueryFindEach.java | 20 +-- .../tests/query/TestQueryFindEachWhile.java | 24 ++-- .../tests/query/TestQueryFindIterate.java | 66 ++++----- .../avaje/tests/query/TestQueryFindVisit.java | 17 +-- .../query/lazy/TestQueryDefaultBatchSize.java | 14 +- .../query/other/TestFindIterateHeapDump.java | 11 +- .../tests/query/sqlquery/SqlQueryTests.java | 25 +--- .../avaje/tests/readaudit/TestReadAudit.java | 14 +- .../avaje/tests/transaction/TestNested.java | 7 +- .../tests/update/TestSqlUpdateInTxn.java | 18 ++- 21 files changed, 177 insertions(+), 303 deletions(-) diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index d996938fc..cc74d7478 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -98,11 +98,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { protected void loadLargeAllocation(final int allocateSize) { // preAllocateIds was called with a relatively large batchSize // so we will just go ahead and load those anyway in background - backgroundExecutor.execute(new Runnable() { - public void run() { - loadMoreIds(allocateSize, null); - } - }); + backgroundExecutor.execute(() -> loadMoreIds(allocateSize, null)); } /** @@ -145,12 +141,10 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { currentlyBackgroundLoading = batchSize; - backgroundExecutor.execute(new Runnable() { - public void run() { - loadMoreIds(batchSize, null); - synchronized (backgroundLoadMonitor) { - currentlyBackgroundLoading = 0; - } + backgroundExecutor.execute(() -> { + loadMoreIds(batchSize, null); + synchronized (backgroundLoadMonitor) { + currentlyBackgroundLoading = 0; } }); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java index 3237ce697..17b27e751 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java @@ -42,12 +42,7 @@ public class MigrationModel { private void readMigrations() { // find all the migration xml files - File[] xmlFiles = modelDirectory.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().toLowerCase().endsWith(modelSuffix); - } - }); + File[] xmlFiles = modelDirectory.listFiles(pathname -> pathname.getName().toLowerCase().endsWith(modelSuffix)); List resources = new ArrayList<>(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java index 6843bc098..b47881684 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java @@ -974,12 +974,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { prop.docStoreMapping(mapping, prefix); } if (inheritInfo != null) { - inheritInfo.visitChildren(new InheritInfoVisitor() { - @Override - public void visit(InheritInfo inheritInfo) { - for (BeanProperty localProperty : inheritInfo.localProperties()) { - localProperty.docStoreMapping(mapping, prefix); - } + inheritInfo.visitChildren(inheritInfo1 -> { + for (BeanProperty localProperty : inheritInfo1.localProperties()) { + localProperty.docStoreMapping(mapping, prefix); } }); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java index 3821f2ba0..a5586d87f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/InheritInfo.java @@ -94,15 +94,12 @@ public class InheritInfo { */ public void appendCheckConstraintValues(final String propertyName, final Set checkConstraintValues) { - visitChildren(new InheritInfoVisitor() { - @Override - public void visit(InheritInfo inheritInfo) { - BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName); - if (prop != null) { - Set values = prop.getDbCheckConstraintValues(); - if (values != null) { - checkConstraintValues.addAll(values); - } + visitChildren(inheritInfo -> { + BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName); + if (prop != null) { + Set values = prop.getDbCheckConstraintValues(); + if (values != null) { + checkConstraintValues.addAll(values); } } }); diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java index f47dcb04e..cc4b2c0e6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -152,13 +152,11 @@ public final class PostCommitProcessing { * In background notify persist listeners, cluster and document store. */ Runnable backgroundNotify() { - return new Runnable() { - public void run() { - processCacheChanges(cacheChanges); - localPersistListenersNotify(); - notifyCluster(); - processDocStoreUpdates(); - } + return () -> { + processCacheChanges(cacheChanges); + localPersistListenersNotify(); + notifyCluster(); + processDocStoreUpdates(); }; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java index 4d42916e4..68e477df7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java @@ -422,12 +422,7 @@ public class TransactionManager { if (changeLogPrepare.prepare(changeSet)) { // call the log method in background - backgroundExecutor.execute(new Runnable() { - @Override - public void run() { - changeLogListener.log(changeSet); - } - }); + backgroundExecutor.execute(() -> changeLogListener.log(changeSet)); } } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java index 3b17dc39b..942094df6 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java @@ -262,12 +262,9 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { - inheritInfo.visitChildren(new InheritInfoVisitor() { - @Override - public void visit(InheritInfo inheritInfo) { - for (BeanProperty localProperty : inheritInfo.localProperties()) { - localProperty.docStoreInclude(includeByDefault, docStructure); - } + inheritInfo.visitChildren(inheritInfo1 -> { + for (BeanProperty localProperty : inheritInfo1.localProperties()) { + localProperty.docStoreInclude(includeByDefault, docStructure); } }); } diff --git a/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java b/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java index 09e6a61a4..480c6d4f2 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java +++ b/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java @@ -37,17 +37,15 @@ public class TestDuplcateKeyException extends BaseTestCase { holder.add(listAttribute); try { - Ebean.execute(new TxRunnable() { - public void run() { - //Ebean.currentTransaction().log("-- saving holder first time"); - // Alternatively turn off cascade Persist for this transaction - //Ebean.currentTransaction().setPersistCascade(false); - Ebean.save(holder); - //Ebean.currentTransaction().log("-- saving holder second time"); - // we don't get this far before failing - //Ebean.save(holder); - } - }); + Ebean.execute(() -> { + //Ebean.currentTransaction().log("-- saving holder first time"); + // Alternatively turn off cascade Persist for this transaction + //Ebean.currentTransaction().setPersistCascade(false); + Ebean.save(holder); +//Ebean.currentTransaction().log("-- saving holder second time"); + // we don't get this far before failing + //Ebean.save(holder); + }); } catch (Exception e){ Assert.assertEquals(e.getMessage(), "test rollback"); } diff --git a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java index 4280fe31a..5d441ee0a 100644 --- a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java +++ b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java @@ -23,49 +23,45 @@ public class ResetBasicData { final ResetBasicData me = new ResetBasicData(); - server.execute(new TxRunnable() { - public void run() { - if (server.find(Product.class).findCount() > 0) { - // we can't really delete this base data as - // the test rely on the products being in there - return; - } - //me.deleteAll(); - me.insertCountries(); - me.insertProducts(); - me.insertTestCustAndOrders(); + server.execute(() -> { + if (server.find(Product.class).findCount() > 0) { + // we can't really delete this base data as + // the test rely on the products being in there + return; } + //me.deleteAll(); + me.insertCountries(); + me.insertProducts(); + me.insertTestCustAndOrders(); }); runOnce = true; } public void deleteAll() { - Ebean.execute(new TxRunnable() { - public void run() { + Ebean.execute(() -> { - // orm update use bean name and bean properties - server.createSqlUpdate("delete from o_cached_bean_child").execute(); - server.createSqlUpdate("delete from o_cached_bean_country").execute(); - server.createSqlUpdate("delete from o_cached_bean").execute(); + // orm update use bean name and bean properties + server.createSqlUpdate("delete from o_cached_bean_child").execute(); + server.createSqlUpdate("delete from o_cached_bean_country").execute(); + server.createSqlUpdate("delete from o_cached_bean").execute(); - server.createUpdate(OrderShipment.class, "delete from orderShipment").execute(); + server.createUpdate(OrderShipment.class, "delete from orderShipment").execute(); - server.createUpdate(OrderDetail.class, "delete from orderDetail").execute(); + server.createUpdate(OrderDetail.class, "delete from orderDetail").execute(); - server.createUpdate(Order.class, "delete from order").execute(); + server.createUpdate(Order.class, "delete from order").execute(); - server.createUpdate(Contact.class, "delete from contact").execute(); + server.createUpdate(Contact.class, "delete from contact").execute(); - server.createUpdate(Customer.class, "delete from Customer").execute(); + server.createUpdate(Customer.class, "delete from Customer").execute(); - server.createUpdate(Address.class, "delete from address").execute(); + server.createUpdate(Address.class, "delete from address").execute(); - // sql update uses table and column names - server.createSqlUpdate("delete from o_country").execute(); - server.createSqlUpdate("delete from o_product").execute(); + // sql update uses table and column names + server.createSqlUpdate("delete from o_country").execute(); + server.createSqlUpdate("delete from o_product").execute(); - } }); } @@ -76,18 +72,16 @@ public class ResetBasicData { return; } - server.execute(new TxRunnable() { - public void run() { - Country c = new Country(); - c.setCode("NZ"); - c.setName("New Zealand"); - server.save(c); + server.execute(() -> { + Country c = new Country(); + c.setCode("NZ"); + c.setName("New Zealand"); + server.save(c); - Country au = new Country(); - au.setCode("AU"); - au.setName("Australia"); - server.save(au); - } + Country au = new Country(); + au.setCode("AU"); + au.setName("Australia"); + server.save(au); }); } @@ -97,46 +91,42 @@ public class ResetBasicData { if (server.find(Product.class).findCount() > 0) { return; } - server.execute(new TxRunnable() { - public void run() { - Product p = new Product(); - p.setName("Chair"); - p.setSku("C001"); - server.save(p); + server.execute(() -> { + Product p = new Product(); + p.setName("Chair"); + p.setSku("C001"); + server.save(p); - p = new Product(); - p.setName("Desk"); - p.setSku("DSK1"); - server.save(p); + p = new Product(); + p.setName("Desk"); + p.setSku("DSK1"); + server.save(p); - p = new Product(); - p.setName("Computer"); - p.setSku("C002"); - server.save(p); + p = new Product(); + p.setName("Computer"); + p.setSku("C002"); + server.save(p); - p = new Product(); - p.setName("Printer"); - p.setSku("C003"); - server.save(p); - } + p = new Product(); + p.setName("Printer"); + p.setSku("C003"); + server.save(p); }); } public void insertTestCustAndOrders() { - Ebean.execute(new TxRunnable() { - public void run() { - Customer cust1 = insertCustomer("Rob"); - Customer cust2 = insertCustomerNoAddress(); - insertCustomerFiona(); - insertCustomerNoContacts("NocCust"); + Ebean.execute(() -> { + Customer cust1 = insertCustomer("Rob"); + Customer cust2 = insertCustomerNoAddress(); + insertCustomerFiona(); + insertCustomerNoContacts("NocCust"); - createOrder1(cust1); - createOrder2(cust2); - createOrder3(cust1); - createOrder4(cust1); - createOrder5(cust2); - } + createOrder1(cust1); + createOrder2(cust2); + createOrder3(cust1); + createOrder4(cust1); + createOrder5(cust2); }); } diff --git a/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java b/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java index 4c928bbf7..9da8647eb 100644 --- a/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java +++ b/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java @@ -15,26 +15,24 @@ public class TestTextJsonSelfRef extends BaseTestCase { @Test public void test() { - Ebean.execute(new TxRunnable() { - public void run() { + Ebean.execute(() -> { - if (Ebean.find(SelfRefCustomer.class).findCount() == 0) { - SelfRefCustomer c1 = new SelfRefCustomer(); - c1.setName("Foo"); - c1.setReferredBy(c1); + if (Ebean.find(SelfRefCustomer.class).findCount() == 0) { + SelfRefCustomer c1 = new SelfRefCustomer(); + c1.setName("Foo"); + c1.setReferredBy(c1); - SelfRefCustomer c2 = new SelfRefCustomer(); - c2.setName("Bar"); - c2.setReferredBy(c1); + SelfRefCustomer c2 = new SelfRefCustomer(); + c2.setName("Bar"); + c2.setReferredBy(c1); - SelfRefCustomer c3 = new SelfRefCustomer(); - c3.setName("baz"); - c3.setReferredBy(c1); + SelfRefCustomer c3 = new SelfRefCustomer(); + c3.setName("baz"); + c3.setReferredBy(c1); - Ebean.save(c1); - Ebean.save(c2); - Ebean.save(c3); - } + Ebean.save(c1); + Ebean.save(c2); + Ebean.save(c3); } }); diff --git a/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java b/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java index f639ee2da..59858862e 100644 --- a/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java +++ b/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java @@ -28,14 +28,11 @@ public class TestOneToManyCorrectGrouping extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); - customerQuery.findEach(new QueryEachConsumer() { - @Override - public void accept(Customer customer) { - for (Order order : customer.getOrders()) { - order.getId(); - } - count.incrementAndGet(); + customerQuery.findEach(customer -> { + for (Order order : customer.getOrders()) { + order.getId(); } + count.incrementAndGet(); }); assertEquals(EXPECTED_ITERATIONS, count.get()); } diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindEach.java b/src/test/java/com/avaje/tests/query/TestQueryFindEach.java index 08ed70f21..1db5af130 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindEach.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindEach.java @@ -25,12 +25,9 @@ public class TestQueryFindEach extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEach(new QueryEachConsumer() { - - public void accept(Customer customer) { - counter.incrementAndGet(); - customer.getName(); - } + query.findEach(customer -> { + counter.incrementAndGet(); + customer.getName(); }); Assert.assertEquals(2, counter.get()); @@ -52,13 +49,10 @@ public class TestQueryFindEach extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEach(new QueryEachConsumer() { - - public void accept(Customer customer) { - counter.incrementAndGet(); - if (counter.intValue() > 0) { - throw new IllegalStateException("cause a failure"); - } + query.findEach(customer -> { + counter.incrementAndGet(); + if (counter.intValue() > 0) { + throw new IllegalStateException("cause a failure"); } }); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java b/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java index dddff3155..943d1b1a5 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java @@ -25,13 +25,10 @@ public class TestQueryFindEachWhile extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEachWhile(new QueryEachWhileConsumer< Customer > () { - - public boolean accept(Customer customer) { - counter.incrementAndGet(); - customer.getName(); - return true; - } + query.findEachWhile(customer -> { + counter.incrementAndGet(); + customer.getName(); + return true; }); Assert.assertEquals(2, counter.get()); @@ -53,15 +50,12 @@ public class TestQueryFindEachWhile extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEachWhile(new QueryEachWhileConsumer() { - - public boolean accept(Customer customer) { - counter.incrementAndGet(); - if (counter.intValue() > 0) { - throw new IllegalStateException("cause a failure"); - } - return true; + query.findEachWhile(customer -> { + counter.incrementAndGet(); + if (counter.intValue() > 0) { + throw new IllegalStateException("cause a failure"); } + return true; }); Assert.assertFalse("Never get here - exception thrown", true); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java b/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java index 2c50253a6..1d219807e 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java @@ -94,12 +94,7 @@ public class TestQueryFindIterate extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); - query.findEach(new QueryEachConsumer() { - @Override - public void accept(Customer bean) { - count.incrementAndGet(); - } - }); + query.findEach(bean -> count.incrementAndGet()); assertEquals(2, count.get()); } @@ -112,16 +107,13 @@ public class TestQueryFindIterate extends BaseTestCase { Ebean.find(Order.class) //.select("orderDate") .where().gt("id",0).le("id",10) - .findEach(new QueryEachConsumer() { - @Override - public void accept(Order order) { - Customer customer = order.getCustomer(); - // invoke lazy loading on customer, order details and order shipments - order.getId(); - customer.getName(); - order.getDetails().size(); - order.getShipments().size(); - } + .findEach(order -> { + Customer customer = order.getCustomer(); + // invoke lazy loading on customer, order details and order shipments + order.getId(); + customer.getName(); + order.getDetails().size(); + order.getShipments().size(); }); } @@ -139,14 +131,11 @@ public class TestQueryFindIterate extends BaseTestCase { .fetch("customer", "name") .where().gt("id",0).le("id",10) .setUseCache(false) - .findEach(new QueryEachConsumer() { - @Override - public void accept(Order order) { - Customer customer = order.getCustomer(); - customer.getName(); - order.getDetails().size(); - order.getShipments().size(); - } + .findEach(order -> { + Customer customer = order.getCustomer(); + customer.getName(); + order.getDetails().size(); + order.getShipments().size(); }); @@ -179,15 +168,12 @@ public class TestQueryFindIterate extends BaseTestCase { .fetch("details") .where().gt("id",0).le("id",10) .order().asc("id") - .findEach(new QueryEachConsumer() { - @Override - public void accept(Order order) { - Customer customer = order.getCustomer(); - order.getId(); - customer.getName(); - order.getDetails().size(); - order.getShipments().size(); - } + .findEach(order -> { + Customer customer = order.getCustomer(); + order.getId(); + customer.getName(); + order.getDetails().size(); + order.getShipments().size(); }); List loggedSql = LoggedSqlCollector.stop(); @@ -211,11 +197,8 @@ public class TestQueryFindIterate extends BaseTestCase { .setMaxRows(2); // this throws an exception immediately - query.findEach(new QueryEachConsumer() { - @Override - public void accept(Customer bean) { + query.findEach(bean -> { - } }); if (!server.getName().equals("h2")) { @@ -238,12 +221,9 @@ public class TestQueryFindIterate extends BaseTestCase { .where().gt("id", 0) .setMaxRows(2); - query.findEach(new QueryEachConsumer() { - @Override - public void accept(Customer customer) { - if (customer != null) { - throw new IllegalStateException("cause an exception"); - } + query.findEach(customer -> { + if (customer != null) { + throw new IllegalStateException("cause an exception"); } }); } diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java b/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java index 238e48427..e863e8598 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java @@ -28,11 +28,7 @@ public class TestQueryFindVisit extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEach(new QueryEachConsumer() { - public void accept(Customer bean) { - counter.incrementAndGet(); - } - }); + query.findEach(bean -> counter.incrementAndGet()); Assert.assertEquals(2, counter.get()); } @@ -53,13 +49,10 @@ public class TestQueryFindVisit extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(0); - query.findEach(new QueryEachConsumer() { - - public void accept(Customer bean) { - counter.incrementAndGet(); - if (counter.intValue() > 0) { - throw new IllegalStateException("cause a failure"); - } + query.findEach(bean -> { + counter.incrementAndGet(); + if (counter.intValue() > 0) { + throw new IllegalStateException("cause a failure"); } }); diff --git a/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java b/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java index 3d0b2167d..92a93822c 100644 --- a/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java +++ b/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java @@ -21,12 +21,7 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { Ebean.find(Order.class) .setLazyLoadBatchSize(2) - .findEach(new QueryEachConsumer() { - @Override - public void accept(Order bean) { - doStuff(bean); - } - }); + .findEach(bean -> doStuff(bean)); } @Test @@ -40,12 +35,7 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { .fetch("customer") .fetch("customer.contacts") .setLazyLoadBatchSize(2) - .findEach(new QueryEachConsumer() { - @Override - public void accept(Order bean) { - doStuff(bean); - } - }); + .findEach(bean -> doStuff(bean)); } @Test diff --git a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java index 652e6257e..08df73b74 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java @@ -59,14 +59,11 @@ public class TestFindIterateHeapDump extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(); server.find(EBasic.class) - .findEach(new QueryEachConsumer() { - @Override - public void accept(EBasic bean) { + .findEach(bean -> { - int count = counter.incrementAndGet(); - if (count == 1) { - dumpHeap("heap-dump13-initial.snapshot", true); - } + int count = counter.incrementAndGet(); + if (count == 1) { + dumpHeap("heap-dump13-initial.snapshot", true); } }); diff --git a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java index 00955ed89..83c0db136 100644 --- a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java +++ b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java @@ -95,12 +95,7 @@ public class SqlQueryTests extends BaseTestCase { sqlQuery.setMaxRows(10); LoggedSqlCollector.start(); - sqlQuery.findEach(new QueryEachConsumer() { - @Override - public void accept(SqlRow bean) { - bean.get("id"); - } - }); + sqlQuery.findEach(bean -> bean.get("id")); List sql = LoggedSqlCollector.stop(); assertThat(sql.get(0)).contains("limit 10"); @@ -116,12 +111,7 @@ public class SqlQueryTests extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); SqlQuery sqlQuery = Ebean.createSqlQuery("select * from o_order"); - sqlQuery.findEach(new QueryEachConsumer() { - @Override - public void accept(SqlRow bean) { - count.incrementAndGet(); - } - }); + sqlQuery.findEach(bean -> count.incrementAndGet()); assertEquals(expectedRows, count.get()); } @@ -134,13 +124,10 @@ public class SqlQueryTests extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); SqlQuery sqlQuery = Ebean.createSqlQuery("select * from o_order order by id"); - sqlQuery.findEachWhile(new QueryEachWhileConsumer() { - @Override - public boolean accept(SqlRow bean) { - count.incrementAndGet(); - Integer id = bean.getInteger("id"); - return id < 3; - } + sqlQuery.findEachWhile(bean -> { + count.incrementAndGet(); + Integer id = bean.getInteger("id"); + return id < 3; }); assertEquals(3, count.get()); diff --git a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java index 43fa894db..59657d078 100644 --- a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java +++ b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java @@ -284,12 +284,7 @@ public class TestReadAudit extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); server.find(EBasicChangeLog.class) .where().startsWith("shortDescription", "readAudit") - .findEach(new QueryEachConsumer() { - @Override - public void accept(EBasicChangeLog bean) { - count.incrementAndGet(); - } - }); + .findEach(bean -> count.incrementAndGet()); assertThat(count.get()).isEqualTo(2); assertThat(readAuditPrepare.count).isEqualTo(1); @@ -299,12 +294,7 @@ public class TestReadAudit extends BaseTestCase { server.find(EBasicChangeLog.class) .where().startsWith("shortDescription", "readAudit") - .findEach(new QueryEachConsumer() { - @Override - public void accept(EBasicChangeLog bean) { - count.incrementAndGet(); - } - }); + .findEach(bean -> count.incrementAndGet()); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); diff --git a/src/test/java/com/avaje/tests/transaction/TestNested.java b/src/test/java/com/avaje/tests/transaction/TestNested.java index 7b9ca74c6..7d0519c77 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNested.java +++ b/src/test/java/com/avaje/tests/transaction/TestNested.java @@ -13,12 +13,7 @@ public class TestNested extends BaseTestCase { public void test() { try { - Ebean.execute(new TxRunnable() { - public void run() { - - willFail(); - } - }); + Ebean.execute(() -> willFail()); } catch (RuntimeException e) { Assert.assertEquals(e.getMessage(), "test rollback"); } diff --git a/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java b/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java index e5e5508fc..f8eff5f18 100644 --- a/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java +++ b/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java @@ -43,17 +43,15 @@ public class TestSqlUpdateInTxn extends BaseTestCase { Assert.assertEquals("foo2", log3.getDescription()); Assert.assertEquals("mod0", log3.getModifiedDescription()); - Ebean.execute(new TxRunnable() { - public void run() { - SqlUpdate update = Ebean.createSqlUpdate( updateDml ) ; - update.setParameter("desc", "foo3"); - update.setParameter("id", id); - update.execute(); + Ebean.execute(() -> { + SqlUpdate update = Ebean.createSqlUpdate( updateDml ) ; + update.setParameter("desc", "foo3"); + update.setParameter("id", id); + update.execute(); - SqlUpdate updateMod = Ebean.createSqlUpdate( updateModDml ) ; - updateMod.setParameter("desc", "mod1"); - updateMod.execute(); - } + SqlUpdate updateMod1 = Ebean.createSqlUpdate( updateModDml ) ; + updateMod1.setParameter("desc", "mod1"); + updateMod1.execute(); }); AuditLog log4 = Ebean.find(AuditLog.class, log.getId()); From 8dc521ca8b420599e57724f972fbeca6802b2bc1 Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Sun, 6 Nov 2016 11:48:59 +0100 Subject: [PATCH 18/87] Remove redundant "public" modifier for interface methods --- .../java/com/avaje/tests/idkeys/TestGeneratedKeys.java | 9 ++++----- .../java/com/avaje/tests/model/interfaces/IAddress.java | 4 ++-- .../java/com/avaje/tests/model/interfaces/IPerson.java | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java b/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java index f9f83605e..f90f1957b 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java +++ b/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java @@ -1,9 +1,5 @@ package com.avaje.tests.idkeys; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - import com.avaje.ebean.Transaction; import com.avaje.ebean.config.dbplatform.IdType; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -11,6 +7,10 @@ import com.avaje.tests.idkeys.db.GenKeyIdentity; import com.avaje.tests.idkeys.db.GenKeySequence; import com.avaje.tests.lib.EbeanTestCase; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + /** * Test various key generation strategies. * @@ -78,7 +78,6 @@ public class TestGeneratedKeys extends EbeanTestCase } catch (SQLException e) { - ; } } } diff --git a/src/test/java/com/avaje/tests/model/interfaces/IAddress.java b/src/test/java/com/avaje/tests/model/interfaces/IAddress.java index b1f0be99e..401209567 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/IAddress.java +++ b/src/test/java/com/avaje/tests/model/interfaces/IAddress.java @@ -1,6 +1,6 @@ package com.avaje.tests.model.interfaces; public interface IAddress { - public String getStreet(); - public void setStreet(String s); + String getStreet(); + void setStreet(String s); } diff --git a/src/test/java/com/avaje/tests/model/interfaces/IPerson.java b/src/test/java/com/avaje/tests/model/interfaces/IPerson.java index c8c636e74..b8bc2f9f1 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/IPerson.java +++ b/src/test/java/com/avaje/tests/model/interfaces/IPerson.java @@ -1,6 +1,6 @@ package com.avaje.tests.model.interfaces; public interface IPerson { - public IAddress getDefaultAddress(); - public void setDefaultAddress(IAddress address); + IAddress getDefaultAddress(); + void setDefaultAddress(IAddress address); } From 63f852475ddfbd7d624ecbb4d81d7bb0541e5e20 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 17:15:47 +1300 Subject: [PATCH 19/87] #863 - @Enumerated(EnumType.STRING) DayOfWeek day; ... incorrectly maps to SQL Integer type --- .../server/deploy/parse/DeployUtil.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java index 8fc97f4a2..736ee30af 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -117,6 +117,10 @@ public class DeployUtil { throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?"); } ScalarType scalarType = typeManager.getScalarType(enumType); + if (enumOverrideDefaultMapping(enumerated, scalarType)) { + logger.debug("override default enum mapping for type {}", enumType); + scalarType = null; + } if (scalarType == null) { // look for @DbEnumValue or @EnumValue annotations etc Class> enumClass = (Class>)enumType; @@ -133,6 +137,17 @@ public class DeployUtil { prop.setDbType(scalarType.getJdbcType()); } + /** + * Return true if there is an existing default mapping for the enum that needs + * to be overridden (for example, DayOfWeek defaults to Integer mapping 1 to 7 + * and some might want this mapped to 'MONDAY' etc). + */ + private boolean enumOverrideDefaultMapping(Enumerated enumerated, ScalarType scalarType) { + return enumerated != null && scalarType != null + && enumerated.value() == EnumType.STRING + && scalarType.getJdbcType() != Types.VARCHAR; + } + private ScalarType createEnumScalarTypePerSpec(Class enumType, EnumType type) { if (type == null) { From b581c893ecc595283bde87bb3d96d1ba6b0ea3ff Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 19:47:34 +1300 Subject: [PATCH 20/87] No effective change - tidy up test conversation User entity bean --- .../avaje/tests/model/converstation/User.java | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/test/java/com/avaje/tests/model/converstation/User.java b/src/test/java/com/avaje/tests/model/converstation/User.java index 350fa74bc..d0c99f028 100644 --- a/src/test/java/com/avaje/tests/model/converstation/User.java +++ b/src/test/java/com/avaje/tests/model/converstation/User.java @@ -1,25 +1,22 @@ package com.avaje.tests.model.converstation; +import com.avaje.ebean.annotation.History; +import com.avaje.ebean.annotation.HistoryExclude; +import com.avaje.tests.model.BaseModel; + import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.Table; -import com.avaje.ebean.annotation.History; -import com.avaje.ebean.annotation.HistoryExclude; -import com.avaje.ebean.annotation.WhenModified; -import com.avaje.tests.model.BaseModel; - -import java.sql.Timestamp; - @History @Entity -@Table(name="c_user") +@Table(name = "c_user") public class User extends BaseModel { boolean inactive; - + String name; - + String email; @HistoryExclude @@ -28,12 +25,9 @@ public class User extends BaseModel { @ManyToOne Group group; - @WhenModified - Timestamp whenModified; - public User() { } - + public boolean isInactive() { return inactive; } @@ -74,13 +68,4 @@ public class User extends BaseModel { this.passwordHash = passwordHash; } - @Override - public Timestamp getWhenModified() { - return whenModified; - } - - @Override - public void setWhenModified(Timestamp whenModified) { - this.whenModified = whenModified; - } } From d05b59343235c419785e5c8f9ae76d65a55e2f4f Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 19:50:05 +1300 Subject: [PATCH 21/87] #862 - ENH: Change ServerConfig such that if H2 is the DataSource/DatabasePlatform then automatically it sets up for testing (ddl generation) --- .../com/avaje/ebean/config/ServerConfig.java | 34 +++++++++++++++++++ .../server/core/DefaultContainer.java | 2 +- ...nServerFactory_ServerConfigStart_Test.java | 1 + .../avaje/ebean/config/ServerConfigTest.java | 2 ++ .../build/ModelBuild_compoundKeyTest.java | 1 + .../ModelBuild_explicitSequencesTest.java | 1 + .../event/BeanPersistControllerTest.java | 1 + .../avaje/ebean/event/BeanPostLoadTest.java | 1 + .../transaction/TestAutoCommitDataSource.java | 1 + src/test/resources/ebean.properties | 4 +-- src/test/resources/logback-test.xml | 8 ++--- 11 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 14e2e6085..d750c654b 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -77,6 +77,12 @@ public class ServerConfig { */ private String name = "db"; + /** + * When false (default) H2 automatically uses DDL generate and run + * (i.e. assumes we are running tests using in memory h2). + */ + private boolean h2ProductionMode; + /** * Typically configuration type objects that are passed by this ServerConfig * to plugins. For example - IgniteConfiguration passed to Ignite plugin. @@ -509,6 +515,27 @@ public class ServerConfig { this.name = name; } + /** + * Return true if H2 should be used in production mode. + *

+ * Otherwise it is assumed we are using H2 for testing and DDL generate and run is turned on. + *

+ */ + public boolean isH2ProductionMode() { + return h2ProductionMode; + } + + /** + * Set to true for H2 to be used in production mode. + *

+ * Do this when we want to use H2 and not have the DDL generation and run automatically turned on. + * Otherwise it is assumed we are using H2 for testing purposes. + *

+ */ + public void setH2ProductionMode(boolean h2ProductionMode) { + this.h2ProductionMode = h2ProductionMode; + } + /** * Return the container / clustering configuration. *

@@ -1444,6 +1471,12 @@ public class ServerConfig { */ public void setDatabasePlatform(DatabasePlatform databasePlatform) { this.databasePlatform = databasePlatform; + if (!h2ProductionMode && databasePlatform != null && databasePlatform.isPlatform(Platform.H2)) { + // we are using H2 to run tests so turn on DDL generation and run + this.ddlGenerate = true; + this.ddlRun = true; + this.ddlCreateOnly = true; + } } /** @@ -2460,6 +2493,7 @@ public class ServerConfig { jsonDateTime = JsonConfig.DateTime.MILLIS; } + h2ProductionMode = p.getBoolean("h2ProductionMode", h2ProductionMode); ddlGenerate = p.getBoolean("ddl.generate", ddlGenerate); ddlRun = p.getBoolean("ddl.run", ddlRun); ddlCreateOnly = p.getBoolean("ddl.createOnly", ddlCreateOnly); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java index 009513583..38e781d70 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java @@ -240,7 +240,7 @@ public class DefaultContainer implements SpiContainer { DatabasePlatform db = factory.create(config); db.configure(config); config.setDatabasePlatform(db); - logger.info("DatabasePlatform name:" + config.getName() + " platform:" + db.getName()); + logger.info("DatabasePlatform name:{} platform:{}", config.getName(), db.getName()); } } diff --git a/src/test/java/com/avaje/ebean/EbeanServerFactory_ServerConfigStart_Test.java b/src/test/java/com/avaje/ebean/EbeanServerFactory_ServerConfigStart_Test.java index 3f9bdbed5..e30a39682 100644 --- a/src/test/java/com/avaje/ebean/EbeanServerFactory_ServerConfigStart_Test.java +++ b/src/test/java/com/avaje/ebean/EbeanServerFactory_ServerConfigStart_Test.java @@ -18,6 +18,7 @@ public class EbeanServerFactory_ServerConfigStart_Test { config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); + config.setH2ProductionMode(true); config.setDdlGenerate(false); config.setDdlRun(false); config.setDefaultServer(false); diff --git a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java index 202caca0f..01c1b4029 100644 --- a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java +++ b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java @@ -34,9 +34,11 @@ public class ServerConfigTest { props.setProperty("jdbcFetchSizeFindList", "43"); props.setProperty("backgroundExecutorShutdownSecs", "98"); props.setProperty("backgroundExecutorSchedulePoolSize", "4"); + props.setProperty("h2ProductionMode", "true"); serverConfig.loadFromProperties(props); + assertTrue(serverConfig.isH2ProductionMode()); assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch()); assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade()); assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid()); diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_compoundKeyTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_compoundKeyTest.java index 9a08860ef..9e5452c67 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_compoundKeyTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_compoundKeyTest.java @@ -31,6 +31,7 @@ public class ModelBuild_compoundKeyTest extends BaseTestCase { config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); + config.setH2ProductionMode(true); config.setDdlGenerate(false); config.setDdlRun(false); config.setDefaultServer(false); diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_explicitSequencesTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_explicitSequencesTest.java index 49fc3ada9..fa3fe09e7 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_explicitSequencesTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuild_explicitSequencesTest.java @@ -25,6 +25,7 @@ public class ModelBuild_explicitSequencesTest extends BaseTestCase { config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); + config.setH2ProductionMode(true); config.setDdlGenerate(false); config.setDdlRun(false); config.setDefaultServer(false); diff --git a/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java b/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java index 761634eb5..c1a6b02f6 100644 --- a/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanPersistControllerTest.java @@ -73,6 +73,7 @@ public class BeanPersistControllerTest { ServerConfig config = new ServerConfig(); config.setName("h2ebasicver"); + config.setH2ProductionMode(true); config.loadFromProperties(); config.setDdlGenerate(true); config.setDdlRun(true); diff --git a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java index 1dabfa7d1..7cbe11ee0 100644 --- a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java @@ -52,6 +52,7 @@ public class BeanPostLoadTest extends BaseTestCase { config.setName("h2ebasicver"); config.loadFromProperties(); + config.setH2ProductionMode(true); config.setDdlGenerate(true); config.setDdlRun(true); diff --git a/src/test/java/com/avaje/tests/transaction/TestAutoCommitDataSource.java b/src/test/java/com/avaje/tests/transaction/TestAutoCommitDataSource.java index 7365b352a..f03d17d49 100644 --- a/src/test/java/com/avaje/tests/transaction/TestAutoCommitDataSource.java +++ b/src/test/java/com/avaje/tests/transaction/TestAutoCommitDataSource.java @@ -43,6 +43,7 @@ public class TestAutoCommitDataSource extends BaseTestCase { ServerConfig config = new ServerConfig(); config.setName("h2autocommit"); + config.setH2ProductionMode(true); config.loadFromProperties(); config.setDataSource(pool); config.setDefaultServer(false); diff --git a/src/test/resources/ebean.properties b/src/test/resources/ebean.properties index 8eb6e2842..8ca08996f 100644 --- a/src/test/resources/ebean.properties +++ b/src/test/resources/ebean.properties @@ -15,8 +15,8 @@ ebean.encryptKeyManager=com.avaje.tests.basic.encrypt.BasicEncyptKeyManager #ebean.autotune.profiling=true #ebean.autotune.profilingUpdateFrequency=5 -ebean.ddl.generate=true -ebean.ddl.run=true +#ebean.ddl.generate=true +#ebean.ddl.run=true datasource.default=h2 #ebean.persistBatch=NONE diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 44bfd40d3..ecacef46d 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -78,10 +78,10 @@ - - - - + + + + From 686593e9e87e36611ea54cf7c30aed833b1aa3e4 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 21:36:19 +1300 Subject: [PATCH 22/87] No effective change - tidy up test Order entity bean --- src/test/java/com/avaje/tests/model/basic/Order.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/java/com/avaje/tests/model/basic/Order.java b/src/test/java/com/avaje/tests/model/basic/Order.java index 13b91815f..8db2097d4 100644 --- a/src/test/java/com/avaje/tests/model/basic/Order.java +++ b/src/test/java/com/avaje/tests/model/basic/Order.java @@ -47,11 +47,6 @@ public class Order implements Serializable { COMPLETE } - public Order() { - - } - - @Id Integer id; From 7a8d1b85a9b941ae1fbe468caeefa914bed6c8a0 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 21:57:03 +1300 Subject: [PATCH 23/87] #866 - Fix RawSql mapping such that it automatically maps foreign key columns --- .../server/query/CQueryBuilder.java | 16 ++++- .../server/query/CQueryPlanRawSql.java | 16 ++++- .../tests/rawsql/TestRawSqlMasterDetail.java | 69 ++++++++++++++++++- 3 files changed, 98 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java index e83847952..fa039444b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java @@ -363,8 +363,15 @@ class CQueryBuilder { RawSql.ColumnMapping.Column column = it.next(); String propertyName = column.getPropertyName(); if (!RawSqlBuilder.IGNORE_COLUMN.equals(propertyName)) { - ElPropertyValue el = descriptor.getElGetValue(propertyName); + if (el == null && propertyName.endsWith("Id")) { + // try default naming convention for foreign key columns + String foreignIdPath = assocOneIdPath(propertyName); + el = descriptor.getElGetValue(foreignIdPath); + if (el != null) { + propertyName = foreignIdPath; + } + } if (el == null) { throw new PersistenceException("Property [" + propertyName + "] not found on " + descriptor.getFullName()); } else { @@ -404,6 +411,13 @@ class CQueryBuilder { return new SqlTreeBuilder(request, predicates, detail, rawNoId).build(); } + /** + * Return a path for a foreign key property using the default naming convention. + */ + private String assocOneIdPath(String propertyName) { + return propertyName.substring(0, propertyName.length() - 2) + ".id"; + } + /** * Return the SQL response with row limiting (when not an update statement). */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java index 11ce4a076..2f0ec4a51 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanRawSql.java @@ -35,7 +35,13 @@ class CQueryPlanRawSql extends CQueryPlan { // set the resultSet index positions for the property expressions for (int i = 0; i < chain.size(); i++) { - indexPositions[i] = 1 + columnMapping.getIndexPosition(chain.get(i)); + String logicalPropertyPath = chain.get(i); + int mappedPosition = columnMapping.getIndexPosition(logicalPropertyPath); + if (mappedPosition == -1 && logicalPropertyPath.endsWith(".id")) { + // try a automatically mapped foreign key + mappedPosition = columnMapping.getIndexPosition(foreignKeyPath(logicalPropertyPath)); + } + indexPositions[i] = 1 + mappedPosition; } // check and handle the case where a discriminator column for @@ -51,4 +57,12 @@ class CQueryPlanRawSql extends CQueryPlan { return indexPositions; } + + /** + * Return the path for a foreign key column that was automatically mapped. + */ + private String foreignKeyPath(String logicalPropertyPath) { + // trim the .id and replace with Id ... to reverse the auto fk mapping earlier + return logicalPropertyPath.substring(0, logicalPropertyPath.length() - 3) + "Id"; + } } diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java index 801fa3f80..1a1e7639f 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java @@ -4,6 +4,7 @@ import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; +import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; @@ -13,7 +14,7 @@ import org.junit.Test; import java.util.List; import java.util.Random; -import static org.assertj.core.api.StrictAssertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -54,6 +55,72 @@ public class TestRawSqlMasterDetail extends BaseTestCase { } + @Test + public void testForeignKeyColumn() { + + ResetBasicData.reset(); + + // billing_address_id fk column is automatically + // mapped to the logical path: billingAddress.id + + String rs = "select c.id, c.name, c.billing_address_id, c.updtime "+ + "from o_customer c " + + "order by c.id"; + + RawSql rawSql = RawSqlBuilder.parse(rs).create(); + + List customers = Ebean.find(Customer.class) + .setRawSql(rawSql) + .findList(); + + assertThat(customers).isNotEmpty(); + } + + @Test + public void testSimpleNestedColumn() { + + ResetBasicData.reset(); + + + String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime "+ + "from o_customer c " + + " left join o_address ba on ba.id = c.billing_address_id "+ + "order by c.id"; + + RawSql rawSql = RawSqlBuilder.parse(rs) + .tableAliasMapping("ba", "billingAddress") + .create(); + + List customers = Ebean.find(Customer.class) + .setRawSql(rawSql) + .findList(); + + assertThat(customers).isNotEmpty(); + } + + @Test + public void testDoubleJoinColumn() { + + ResetBasicData.reset(); + + String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime, sa.id, sa.line_1, sa.city "+ + "from o_customer c " + + " left join o_address ba on ba.id = c.billing_address_id "+ + " left join o_address sa on sa.id = c.shipping_address_id "+ + "order by c.id"; + + RawSql rawSql = RawSqlBuilder.parse(rs) + .tableAliasMapping("ba", "billingAddress") + .tableAliasMapping("sa", "shippingAddress") + .create(); + + List customers = Ebean.find(Customer.class) + .setRawSql(rawSql) + .findList(); + + assertThat(customers).isNotEmpty(); + } + @Test public void testWithTableAliasMapping() { From 08939721152b7e1701c077797ef9da4c832c88ea Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 22:00:33 +1300 Subject: [PATCH 24/87] Fix for running CI tests as Postgres (where we need to explicitly turn on DDL generation and running for the tests). --- src/test/resources/ebean.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/ebean.properties b/src/test/resources/ebean.properties index 8ca08996f..8eb6e2842 100644 --- a/src/test/resources/ebean.properties +++ b/src/test/resources/ebean.properties @@ -15,8 +15,8 @@ ebean.encryptKeyManager=com.avaje.tests.basic.encrypt.BasicEncyptKeyManager #ebean.autotune.profiling=true #ebean.autotune.profilingUpdateFrequency=5 -#ebean.ddl.generate=true -#ebean.ddl.run=true +ebean.ddl.generate=true +ebean.ddl.run=true datasource.default=h2 #ebean.persistBatch=NONE From 5f35e3c944dde67cb860f9c1bfe0fc34cb0b0d88 Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Mon, 7 Nov 2016 07:46:58 +0100 Subject: [PATCH 25/87] Remove redundant local variables --- .../ebeaninternal/server/grammer/EqlAdapterHelper.java | 4 +--- .../tests/model/ivo/converter/ExhangeCompoundType.java | 4 +--- .../model/ivo/converter/JodaIntervalCompoundType.java | 3 +-- .../avaje/tests/query/other/TestFindIterateHeapDump.java | 7 ++----- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java index 93d84b882..b08e642eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java @@ -132,8 +132,6 @@ class EqlAdapterHelper { } private String unquote(String value) { - String raw = value.substring(1, value.length() - 1); - //raw.replaceAll(); - return raw; + return value.substring(1, value.length() - 1); } } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java b/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java index e7c1db45b..7ccd33f12 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java @@ -14,9 +14,7 @@ public class ExhangeCompoundType implements CompoundType { @SuppressWarnings({ "unchecked", "rawtypes" }) public CompoundTypeProperty[] getProperties() { - - CompoundTypeProperty[] props = {new RateProp(), new CMoneyProp()}; - return props; + return new CompoundTypeProperty[]{new RateProp(), new CMoneyProp()}; } static class RateProp implements CompoundTypeProperty { diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java b/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java index 21d06060e..82780da7d 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java @@ -13,8 +13,7 @@ public class JodaIntervalCompoundType implements CompoundType{ @SuppressWarnings({ "unchecked", "rawtypes" }) public CompoundTypeProperty[] getProperties() { - CompoundTypeProperty[] props = {new Start(), new End()}; - return props; + return new CompoundTypeProperty[]{new Start(), new End()}; } static class Start implements CompoundTypeProperty { diff --git a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java index 08df73b74..f5ae9ad73 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java @@ -3,7 +3,6 @@ package com.avaje.tests.query.other; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.QueryEachConsumer; import com.avaje.tests.model.basic.EBasic; import com.sun.management.HotSpotDiagnosticMXBean; import org.junit.Ignore; @@ -115,10 +114,8 @@ public class TestFindIterateHeapDump extends BaseTestCase { */ private static HotSpotDiagnosticMXBean getHotspotMBean() { try { - MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME, - HotSpotDiagnosticMXBean.class); - return bean; + final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + return ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class); } catch (RuntimeException re) { throw re; } catch (Exception exp) { From 98aa5e9da9e89c2abd67a637aee6f38be1d216fb Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Mon, 7 Nov 2016 11:07:37 +0100 Subject: [PATCH 26/87] Use "Collection.addAll(...)" rather than manually copying arrays --- .../ddlgeneration/platform/util/IndexColumns.java | 5 ++--- .../com/avaje/ebean/dbmigration/model/MIndex.java | 11 +++-------- .../server/changelog/DefaultChangeLogRegister.java | 5 ++--- .../server/persist/dmlbind/BindableList.java | 13 ++++++------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java index 309a44ebe..de9db9012 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java @@ -1,6 +1,7 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform.util; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -21,9 +22,7 @@ public class IndexColumns { * Construct representing index. */ public IndexColumns(String[] columnNames) { - for (int i = 0; i < columnNames.length; i++) { - columns.add(columnNames[i]); - } + Collections.addAll(columns, columnNames); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java index 0c2f9e1cf..dc4e83af8 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MIndex.java @@ -4,6 +4,7 @@ import com.avaje.ebean.dbmigration.migration.CreateIndex; import com.avaje.ebean.dbmigration.migration.DropIndex; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -32,9 +33,7 @@ public class MIndex { public MIndex(String indexName, String tableName, String[] columnNames) { this.tableName = tableName; this.indexName = indexName; - for (int i = 0; i < columnNames.length; i++) { - this.columns.add(columnNames[i]); - } + Collections.addAll(this.columns, columnNames); } public MIndex(CreateIndex createIndex) { @@ -101,7 +100,6 @@ public class MIndex { * Return true if the index has changed. */ private boolean changed(MIndex newIndex) { - if (!tableName.equals(newIndex.getTableName())) { return true; } @@ -119,12 +117,9 @@ public class MIndex { private List split(String columns) { - List colList = new ArrayList<>(); String[] cols = columns.split(","); - for (int i = 0; i updateProps = new HashSet<>(); - for (int i = 0; i < updatesThatInclude.length; i++) { - updateProps.add(updatesThatInclude[i]); - } + Collections.addAll(updateProps, updatesThatInclude); return new UpdateFilter(insertModeInclude(changeLog.inserts()), updateProps); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index f8f231b29..dc7c743e2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -1,13 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * List of Bindable items. */ @@ -38,9 +39,7 @@ public class BindableList implements Bindable { } public void addAll(List list) { - for (int i = 0; i < items.length; i++) { - list.add(items[i]); - } + Collections.addAll(list, items); } public void addToUpdate(PersistRequestBean request, List list) { From 5cf56292323219616c229f4c131fbfb57e7bd0ac Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 23:46:28 +1300 Subject: [PATCH 27/87] #869 - Test for ... Clash on bind hash value for query cache with consecutive values of "01","20" and "02", "10" --- .../com/avaje/tests/cache/TestQueryCache.java | 34 +++++++++++++ .../com/avaje/tests/model/cache/EColAB.java | 50 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/test/java/com/avaje/tests/model/cache/EColAB.java diff --git a/src/test/java/com/avaje/tests/cache/TestQueryCache.java b/src/test/java/com/avaje/tests/cache/TestQueryCache.java index b99568b5d..756295632 100644 --- a/src/test/java/com/avaje/tests/cache/TestQueryCache.java +++ b/src/test/java/com/avaje/tests/cache/TestQueryCache.java @@ -2,6 +2,7 @@ package com.avaje.tests.cache; import java.util.List; +import com.avaje.tests.model.cache.EColAB; import org.junit.Assert; import org.junit.Test; @@ -12,8 +13,41 @@ import com.avaje.ebean.cache.ServerCache; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import static org.assertj.core.api.Assertions.assertThat; + public class TestQueryCache extends BaseTestCase { + @Test + public void clashHashCode() { + + new EColAB("01", "20").save(); + new EColAB("02", "10").save(); + + List list1 = + Ebean.getServer(null) + .find(EColAB.class) + .setUseQueryCache(true) + .where() + .eq("columnA", "01") + .eq("columnB", "20") + .findList(); + + List list2 = + Ebean.getServer(null) + .find(EColAB.class) + .setUseQueryCache(true) + .where() + .eq("columnA", "02") + .eq("columnB", "10") + .findList(); + + assertThat(list1.get(0).getColumnA()).isEqualTo("01"); + assertThat(list1.get(0).getColumnB()).isEqualTo("20"); + + assertThat(list2.get(0).getColumnA()).isEqualTo("02"); + assertThat(list2.get(0).getColumnB()).isEqualTo("10"); + } + @Test @SuppressWarnings("unchecked") public void test() { diff --git a/src/test/java/com/avaje/tests/model/cache/EColAB.java b/src/test/java/com/avaje/tests/model/cache/EColAB.java new file mode 100644 index 000000000..3c6ec3b88 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/cache/EColAB.java @@ -0,0 +1,50 @@ +package com.avaje.tests.model.cache; + +import com.avaje.ebean.Model; +import com.avaje.ebean.annotation.Cache; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Cache(enableQueryCache=true) +@Entity +@Table(name = "e_col_ab") +public class EColAB extends Model { + + @Id + private Long id; + + private String columnA; + + private String columnB; + + public EColAB(String columnA, String columnB) { + this.columnA = columnA; + this.columnB = columnB; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getColumnA() { + return columnA; + } + + public void setColumnA(String columnA) { + this.columnA = columnA; + } + + public String getColumnB() { + return columnB; + } + + public void setColumnB(String columnB) { + this.columnB = columnB; + } +} \ No newline at end of file From 376cb9ebcbf4e0a52b39b11a886ccb8d22b6cd05 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 23:47:29 +1300 Subject: [PATCH 28/87] #869 - Clash on bind hash value for query cache with consecutive values of "01","20" and "02", "10" --- .../ebeaninternal/server/expression/AllEqualsExpression.java | 4 ++-- .../server/expression/ArrayContainsExpression.java | 2 +- .../server/expression/ArrayIsEmptyExpression.java | 2 +- .../ebeaninternal/server/expression/BetweenExpression.java | 2 +- .../server/expression/DefaultExampleExpression.java | 3 +-- .../server/expression/DefaultExpressionList.java | 2 +- .../avaje/ebeaninternal/server/expression/InExpression.java | 4 ++-- .../ebeaninternal/server/expression/JsonPathExpression.java | 2 +- .../ebeaninternal/server/expression/JunctionExpression.java | 2 +- .../ebeaninternal/server/expression/LogicExpression.java | 2 +- 10 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java index bef1ee0bc..75d0504c0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java @@ -120,9 +120,9 @@ class AllEqualsExpression extends NonPrepareExpression { @Override public int queryBindHash() { - int hc = 31; + int hc = 92821; for (Object value : propMap.values()) { - hc = hc * 31 + (value == null ? 0 : value.hashCode()); + hc = hc * 92821 + (value == null ? 0 : value.hashCode()); } return hc; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java index a90c13cf7..a9b419c2c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -52,7 +52,7 @@ public class ArrayContainsExpression extends AbstractExpression { public int queryBindHash() { int hc = values[0].hashCode(); for (int i = 1; i < values.length; i++) { - hc = hc * 31 + values[i].hashCode(); + hc = hc * 92821 + values[i].hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java index 741fcf26f..818ffa57d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java @@ -30,7 +30,7 @@ public class ArrayIsEmptyExpression extends AbstractExpression { @Override public int queryBindHash() { - return empty ? 0 : 31; + return empty ? 0 : 92821; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java index a07970e8d..4d46dbafd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java @@ -54,7 +54,7 @@ class BetweenExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = low().hashCode(); - hc = hc * 31 + high().hashCode(); + hc = hc * 92821 + high().hashCode(); return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index 63ce7c23c..f6060a649 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -230,9 +230,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public int queryBindHash() { int hc = DefaultExampleExpression.class.getName().hashCode(); for (int i = 0; i < list.size(); i++) { - hc = hc * 31 + list.get(i).queryBindHash(); + hc = hc * 92821 + list.get(i).queryBindHash(); } - return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index e1e289523..8b28e2706 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -511,7 +511,7 @@ public class DefaultExpressionList implements SpiExpressionList { public int queryBindHash() { int hash = DefaultExpressionList.class.getName().hashCode(); for (int i = 0, size = list.size(); i < size; i++) { - hash = hash * 31 + list.get(i).queryBindHash(); + hash = hash * 92821 + list.get(i).queryBindHash(); } return hash; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 3352850da..682fdfcc6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -119,9 +119,9 @@ class InExpression extends AbstractExpression { @Override public int queryBindHash() { - int hc = 31; + int hc = 92821; for (int i = 0; i < bindValues.length; i++) { - hc = 31 * hc + bindValues[i].hashCode(); + hc = 92821 * hc + bindValues[i].hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java index 778bbad18..4c0fce9c0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java @@ -79,7 +79,7 @@ class JsonPathExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = (value == null) ? 0 : value.hashCode(); - hc = (upperValue == null) ? hc : hc * 31 + upperValue.hashCode(); + hc = (upperValue == null) ? hc : hc * 92821 + upperValue.hashCode(); return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index 2b852a1dc..b7556fd96 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -204,7 +204,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression int hc = JunctionExpression.class.getName().hashCode(); List list = exprList.internalList(); for (int i = 0; i < list.size(); i++) { - hc = hc * 31 + list.get(i).queryBindHash(); + hc = hc * 92821 + list.get(i).queryBindHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java index 44281d369..b2e0913f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java @@ -146,7 +146,7 @@ abstract class LogicExpression implements SpiExpression { @Override public int queryBindHash() { int hc = expOne.queryBindHash(); - hc = hc * 31 + expTwo.queryBindHash(); + hc = hc * 92821 + expTwo.queryBindHash(); return hc; } From 2986290947606d3239c1be435c00dfe3b43da7b0 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2016 23:57:51 +1300 Subject: [PATCH 29/87] Refactor - change use of 31 prime in various hash to 92821 --- .../ebeaninternal/server/cache/CacheChangeSet.java | 2 +- .../server/core/DefaultCallStackFactory.java | 2 +- .../server/core/PersistRequestBean.java | 6 +++--- .../ebeaninternal/server/deploy/TableJoin.java | 4 ++-- .../server/deploy/TableJoinColumn.java | 6 +++--- .../server/query/RawSqlQueryPlanKey.java | 6 +++--- .../server/querydefn/DefaultOrmQuery.java | 14 +++++++------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java index 3be305558..50fb06f46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java @@ -210,7 +210,7 @@ public class CacheChangeSet { @Override public int hashCode() { - return 31 * desc.hashCode() + manyProperty.hashCode(); + return 92821 * desc.hashCode() + manyProperty.hashCode(); } void cacheClear() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java index 869be6a1f..7a14ceae0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallStackFactory.java @@ -19,7 +19,7 @@ public class DefaultCallStackFactory implements CallStackFactory { int hc = 0; for (int i = 1; i < callStack.length; i++) { - hc = 31 * hc + callStack[i].hashCode(); + hc = 92821 * hc + callStack[i].hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index 5fe67d8db..74520d382 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -458,7 +458,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP private Integer getBeanHash() { if (beanHash == null) { Object id = beanDescriptor.getId(entityBean); - int hc = 31 * bean.getClass().getName().hashCode(); + int hc = 92821 * bean.getClass().getName().hashCode(); if (id != null) { hc += id.hashCode(); } @@ -1015,12 +1015,12 @@ public final class PersistRequestBean extends PersistRequest implements BeanP BeanProperty versionProperty = beanDescriptor.getVersionProperty(); if (versionProperty != null) { if (intercept.isLoadedProperty(versionProperty.getPropertyIndex())) { - hash = hash * 31 + 7; + hash = hash * 92821 + 7; } } if (publish) { - hash = hash * 31; + hash = hash * 92821; } return hash; diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java index 1d1e86ecf..2c18c2a03 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java @@ -56,9 +56,9 @@ public final class TableJoin { */ private int calcQueryHash() { int hc = type.hashCode(); - hc = hc * 31 + (table == null ? 0 : table.hashCode()); + hc = hc * 92821 + (table == null ? 0 : table.hashCode()); for (int i = 0; i < columns.length; i++) { - hc = hc * 31 + columns[i].queryHash(); + hc = hc * 92821 + columns[i].queryHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java index 59a77f77f..d64679402 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java @@ -40,9 +40,9 @@ public class TableJoinColumn { int hash() { int result = localDbColumn != null ? localDbColumn.hashCode() : 0; - result = 31 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0); - result = 31 * result + (insertable ? 1 : 0); - result = 31 * result + (updateable ? 1 : 0); + result = 92821 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0); + result = 92821 * result + (insertable ? 1 : 0); + result = 92821 * result + (updateable ? 1 : 0); return result; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java index 476c3d118..c04b49430 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/RawSqlQueryPlanKey.java @@ -48,9 +48,9 @@ class RawSqlQueryPlanKey implements CQueryPlanKey { @Override public int hashCode() { int result = sql.hashCode(); - result = 31 * result + (rawSql ? 1 : 0); - result = 31 * result + (rowNumberIncluded ? 1 : 0); - result = 31 * result + logWhereSql.hashCode(); + result = 92821 * result + (rawSql ? 1 : 0); + result = 92821 * result + (rowNumberIncluded ? 1 : 0); + result = 92821 * result + logWhereSql.hashCode(); return result; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 7a5ee3e1a..48f39d412 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -866,7 +866,7 @@ public class DefaultOrmQuery implements SpiQuery { */ private int calculateOriginQueryHash() { int hc = beanType.getName().hashCode(); - hc = hc * 31 + (type == null ? 0 : type.ordinal()); + hc = hc * 92821 + (type == null ? 0 : type.ordinal()); return hc; } @@ -916,12 +916,12 @@ public class DefaultOrmQuery implements SpiQuery { @Override public int queryBindHash() { int hc = (id == null ? 0 : id.hashCode()); - hc = hc * 31 + (whereExpressions == null ? 0 : whereExpressions.queryBindHash()); - hc = hc * 31 + (havingExpressions == null ? 0 : havingExpressions.queryBindHash()); - hc = hc * 31 + (bindParams == null ? 0 : bindParams.queryBindHash()); - hc = hc * 31 + (asOf == null ? 0 : asOf.hashCode()); - hc = hc * 31 + (versionsStart == null ? 0 : versionsStart.hashCode()); - hc = hc * 31 + (versionsEnd == null ? 0 : versionsEnd.hashCode()); + hc = hc * 92821 + (whereExpressions == null ? 0 : whereExpressions.queryBindHash()); + hc = hc * 92821 + (havingExpressions == null ? 0 : havingExpressions.queryBindHash()); + hc = hc * 92821 + (bindParams == null ? 0 : bindParams.queryBindHash()); + hc = hc * 92821 + (asOf == null ? 0 : asOf.hashCode()); + hc = hc * 92821 + (versionsStart == null ? 0 : versionsStart.hashCode()); + hc = hc * 92821 + (versionsEnd == null ? 0 : versionsEnd.hashCode()); return hc; } From 6c4c33f1f332f96787ffd0e957cb59a7d58d6acb Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2016 00:03:15 +1300 Subject: [PATCH 30/87] No effective change - reduce logging in test (for CI) --- src/test/resources/logback-test.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index ecacef46d..44bfd40d3 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -78,10 +78,10 @@ - - - - + + + + From ae69fcb80a050d4a921c03deb8d203bc8d1ac938 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2016 00:10:15 +1300 Subject: [PATCH 31/87] #862 - ENH: Change ServerConfig such that if H2 ... no using createOnly = true in case the test EbeanServer instance is created for each test (and hence we need to drop if the same in memory db is used) --- src/main/java/com/avaje/ebean/config/ServerConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index d750c654b..599a2b813 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -1475,7 +1475,6 @@ public class ServerConfig { // we are using H2 to run tests so turn on DDL generation and run this.ddlGenerate = true; this.ddlRun = true; - this.ddlCreateOnly = true; } } From b41238ddbbe66367e44004c14c86b856d647a82b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2016 00:25:13 +1300 Subject: [PATCH 32/87] No effective change - modify TestHistoryInsert for more wait time and logging (PG test failing sometimes in CI) --- .../avaje/tests/history/TestHistoryInsert.java | 15 ++++++++++++--- src/test/resources/logback-test.xml | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/avaje/tests/history/TestHistoryInsert.java b/src/test/java/com/avaje/tests/history/TestHistoryInsert.java index 7c554ab59..3b40c8368 100644 --- a/src/test/java/com/avaje/tests/history/TestHistoryInsert.java +++ b/src/test/java/com/avaje/tests/history/TestHistoryInsert.java @@ -5,9 +5,10 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlQuery; import com.avaje.ebean.SqlRow; import com.avaje.ebean.Version; -import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.tests.model.converstation.User; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Timestamp; import java.util.List; @@ -16,6 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestHistoryInsert extends BaseTestCase { + private final Logger logger = LoggerFactory.getLogger(TestHistoryInsert.class); + @Test public void test() throws InterruptedException { @@ -29,6 +32,7 @@ public class TestHistoryInsert extends BaseTestCase { user.setPasswordHash("someHash"); Ebean.save(user); + logger.info("-- initial save"); Timestamp afterInsert = new Timestamp(System.currentTimeMillis()); @@ -40,7 +44,8 @@ public class TestHistoryInsert extends BaseTestCase { user.setName("Jim v2"); user.setPasswordHash("anotherHash"); - Thread.sleep(10); // wait, to ensure that whenModified differs + Thread.sleep(50); // wait, to ensure that whenModified differs + logger.info("-- update v2"); Ebean.save(user); history = fetchHistory(user); @@ -53,7 +58,9 @@ public class TestHistoryInsert extends BaseTestCase { user.setName("Jim v3"); user.setEmail("three@email.com"); - Thread.sleep(10); // otherwise the timestamp of "whenModified" may not change + Thread.sleep(50); // otherwise the timestamp of "whenModified" may not change + + logger.info("-- update v3"); Ebean.save(user); history = fetchHistory(user); @@ -65,6 +72,7 @@ public class TestHistoryInsert extends BaseTestCase { assertThat(versions).hasSize(3); assertThat(versions.get(0).getDiff()).containsKeys("name", "email", "version", "whenModified"); + logger.info("-- delete"); Ebean.delete(user); User earlyVersion = Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique(); @@ -73,6 +81,7 @@ public class TestHistoryInsert extends BaseTestCase { Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique(); + logger.info("-- last fetchHistory"); history = fetchHistory(user); assertThat(history).hasSize(3); diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 44bfd40d3..35785369c 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -75,6 +75,7 @@ + From 6826fe10152c11776d5dc753a2f39e35761a36e2 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2016 00:32:38 +1300 Subject: [PATCH 33/87] [maven-release-plugin] prepare release ebean-9.1.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 485139656..2cd5bc95f 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.avaje.ebean ebean - 9.1.1-SNAPSHOT + 9.1.1 jar ebean @@ -21,7 +21,7 @@ scm:git:https://github.com/ebean-orm/ebean.git - HEAD + ebean-9.1.1 From d6ba567763014f52b671c30f22ec84320d3d2caa Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2016 00:32:47 +1300 Subject: [PATCH 34/87] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2cd5bc95f..15568eaa7 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.avaje.ebean ebean - 9.1.1 + 9.1.2-SNAPSHOT jar ebean @@ -21,7 +21,7 @@ scm:git:https://github.com/ebean-orm/ebean.git - ebean-9.1.1 + HEAD From ec6a8f5ea2c81a53bf03d37bcb57b5422ba30d35 Mon Sep 17 00:00:00 2001 From: Thibault Meyer Date: Tue, 8 Nov 2016 09:06:13 +0100 Subject: [PATCH 35/87] Replace "for" with "foreach" --- .../com/avaje/ebean/DRawSqlColumnsParser.java | 10 +- src/main/java/com/avaje/ebean/OrderBy.java | 32 ++--- src/main/java/com/avaje/ebean/RawSql.java | 49 ++++---- src/main/java/com/avaje/ebean/TxScope.java | 8 +- .../java/com/avaje/ebean/bean/CallStack.java | 10 +- .../avaje/ebean/bean/EntityBeanIntercept.java | 86 +++++++------- .../java/com/avaje/ebean/common/BeanList.java | 4 +- .../ebean/config/DbConstraintNormalise.java | 8 +- .../com/avaje/ebean/config/ServerConfig.java | 10 +- .../dbplatform/SequenceIdGenerator.java | 4 +- .../platform/MsSqlServerDdl.java | 4 +- .../ddlgeneration/platform/util/IndexSet.java | 4 +- .../build/ModelBuildIntersectionTable.java | 22 ++-- .../build/ModelBuildPropertyVisitor.java | 9 +- .../model/visitor/VisitAllUsing.java | 15 ++- .../com/avaje/ebean/util/StringHelper.java | 18 +-- .../avaje/ebeaninternal/api/BindParams.java | 52 ++++---- .../ebeaninternal/api/LoadBeanRequest.java | 10 +- .../ebeaninternal/api/LoadManyRequest.java | 6 +- .../avaje/ebeaninternal/api/ScopeTrans.java | 8 +- .../ebeaninternal/api/TransactionEvent.java | 4 +- .../api/TransactionEventBeans.java | 6 +- .../server/cache/CachedBeanDataFromBean.java | 11 +- .../server/cache/CachedBeanDataToBean.java | 10 +- .../server/core/DefaultServer.java | 66 +++++------ .../server/core/PersistRequestBean.java | 4 +- .../core/PersistRequestCallableSql.java | 22 ++-- .../server/core/RelationalQueryRequest.java | 4 +- .../server/core/bootup/DistillPackages.java | 4 +- .../server/core/bootup/ManifestReader.java | 4 +- .../server/deploy/BeanCascadeInfo.java | 4 +- .../server/deploy/BeanDescriptor.java | 111 +++++++++--------- .../deploy/BeanDescriptorCacheHelp.java | 20 ++-- .../deploy/BeanDescriptorDraftHelp.java | 22 ++-- .../server/deploy/BeanDescriptorJsonHelp.java | 8 +- .../server/deploy/BeanDescriptorManager.java | 24 ++-- .../server/deploy/BeanFinderManager.java | 3 +- .../deploy/BeanLifecycleAdapterFactory.java | 16 +-- .../server/deploy/BeanListHelp.java | 4 +- .../server/deploy/BeanPropertyAssoc.java | 8 +- .../server/deploy/BeanPropertyAssocMany.java | 43 ++++--- .../server/deploy/BeanPropertyAssocOne.java | 26 ++-- .../server/deploy/BeanPropertyCompound.java | 11 +- .../deploy/BeanQueryAdapterManager.java | 3 +- .../server/deploy/BeanTable.java | 72 ++++++------ .../deploy/ChainedBeanPersistController.java | 84 ++++++------- .../deploy/ChainedBeanPersistListener.java | 38 +++--- .../ChainedBeanPostConstructListener.java | 12 +- .../server/deploy/ChainedBeanPostLoad.java | 14 +-- .../deploy/ChainedBeanQueryAdapter.java | 24 ++-- .../server/deploy/InheritInfo.java | 15 +-- .../server/deploy/IntersectionRow.java | 4 +- .../server/deploy/ParamTypeUtil.java | 24 ++-- .../deploy/PersistControllerManager.java | 3 +- .../server/deploy/PersistListenerManager.java | 11 +- .../server/deploy/PostConstructManager.java | 3 +- .../server/deploy/PostLoadManager.java | 3 +- .../server/deploy/TableJoin.java | 14 +-- .../server/deploy/id/IdBinderEmbedded.java | 58 ++++----- .../server/deploy/id/ImportedIdEmbedded.java | 38 +++--- .../deploy/meta/DeployBeanDescriptor.java | 12 +- .../deploy/meta/DeployBeanPropertyLists.java | 76 ++++++------ .../server/deploy/meta/DeployTableJoin.java | 8 +- .../deploy/parse/AnnotationAssocManys.java | 12 +- .../server/deploy/parse/AnnotationParser.java | 8 +- .../deploy/parse/DeployCreateProperties.java | 13 +- .../server/deploy/parse/SqlReservedWords.java | 18 +-- .../deploy/parse/TransientProperties.java | 43 ++++--- .../server/el/ElComparatorCompound.java | 8 +- .../ebeaninternal/server/el/ElFilter.java | 6 +- .../server/el/ElPropertyChain.java | 8 +- .../expression/ArrayContainsExpression.java | 4 +- .../expression/DefaultExampleExpression.java | 19 ++- .../expression/DefaultExpressionList.java | 33 +++--- .../expression/DefaultExpressionRequest.java | 3 +- .../expression/ExistsQueryExpression.java | 4 +- .../server/expression/IdExpression.java | 4 +- .../server/expression/IdInExpression.java | 4 +- .../server/expression/InExpression.java | 14 +-- .../server/expression/InQueryExpression.java | 4 +- .../server/expression/JunctionExpression.java | 28 ++--- .../server/expression/RawExpression.java | 4 +- .../server/expression/SimpleExpression.java | 4 +- .../ebeaninternal/server/lib/util/Str.java | 18 +-- .../server/loadcontext/DLoadContext.java | 8 +- .../server/persist/BatchControl.java | 4 +- .../server/persist/BatchedPstmt.java | 4 +- .../ebeaninternal/server/persist/Binder.java | 8 +- .../server/persist/DefaultPersister.java | 86 +++++++------- .../persist/DeleteUnloadedForeignKeys.java | 7 +- .../persist/dmlbind/BindableCompound.java | 8 +- .../persist/dmlbind/BindableEmbedded.java | 12 +- .../persist/dmlbind/BindableIdEmbedded.java | 14 +-- .../server/persist/dmlbind/BindableList.java | 12 +- .../persist/dmlbind/FactoryAssocOnes.java | 10 +- .../dmlbind/FactoryBaseProperties.java | 14 +-- .../persist/dmlbind/FactoryEmbedded.java | 10 +- .../dmlbind/MatchedImportedProperty.java | 8 +- .../server/query/CQueryPlan.java | 4 +- .../server/query/SqlTreeBuilder.java | 24 ++-- .../server/query/SqlTreeNodeBean.java | 64 +++++----- .../server/query/SqlTreeNodeExtraJoin.java | 3 +- .../server/query/SqlTreeNodeRoot.java | 4 +- .../server/query/SqlTreeProperties.java | 6 +- .../server/querydefn/DefaultOrmQuery.java | 6 +- .../server/querydefn/OrmQueryDetail.java | 7 +- .../server/querydefn/OrmQueryProperties.java | 3 +- .../querydefn/OrmQueryPropertiesParser.java | 4 +- .../server/text/csv/TCsvReader.java | 36 +++--- .../server/text/json/WriteJson.java | 12 +- .../server/transaction/BeanPersistIds.java | 6 +- .../transaction/BulkEventListenerMap.java | 4 +- .../server/transaction/DeleteByIdMap.java | 14 +-- .../transaction/PostCommitProcessing.java | 8 +- .../transaction/RemoteTransactionEvent.java | 8 +- .../transaction/TransactionManager.java | 7 +- .../server/type/CtCompoundType.java | 4 +- .../server/type/DefaultTypeManager.java | 35 +++--- .../server/type/ScalarTypeEnumStandard.java | 12 +- .../server/type/TypeReflectHelper.java | 3 +- .../server/type/reflect/CheckImmutable.java | 18 +-- .../type/reflect/ImmutableMetaFactory.java | 50 ++++---- .../avaje/ebeaninternal/server/util/Md5.java | 4 +- .../util/SortByClauseParser.java | 4 +- .../api/support/DocStoreBeanBaseAdapter.java | 8 +- .../server/expression/InExpressionTest.java | 6 +- .../batchload/TestBatchLazyWithCacheHits.java | 4 +- .../query/TestAutofetchTuneWithJoin.java | 3 +- 128 files changed, 1047 insertions(+), 1108 deletions(-) diff --git a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java index 1c4e0e623..43a96a191 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java @@ -48,9 +48,9 @@ final class DRawSqlColumnsParser { String[] split = colInfo.split("\\s(?=[^\\)]*(?:\\(|$))"); if (split.length > 1) { ArrayList tmp = new ArrayList<>(split.length); - for (int i = 0; i < split.length; i++) { - if (!split[i].trim().isEmpty()) { - tmp.add(split[i].trim()); + for (String aSplit : split) { + if (!aSplit.trim().isEmpty()) { + tmp.add(aSplit.trim()); } } split = tmp.toArray(new String[tmp.size()]); @@ -66,8 +66,8 @@ final class DRawSqlColumnsParser { if (split.length == 2) { return new ColumnMapping.Column(indexPos++, split[0], split[1]); } - // Ok, we now expect/require the AS keyword and it should be the - // second to last word in the colInfo content + // Ok, we now expect/require the AS keyword and it should be the + // second to last word in the colInfo content if (!split[split.length - 2].equalsIgnoreCase("as")) { throw new PersistenceException("Expecting AS keyword as second to last word when parsing column " + colInfo); } diff --git a/src/main/java/com/avaje/ebean/OrderBy.java b/src/main/java/com/avaje/ebean/OrderBy.java index 5ccd42bf8..b342fb23a 100644 --- a/src/main/java/com/avaje/ebean/OrderBy.java +++ b/src/main/java/com/avaje/ebean/OrderBy.java @@ -30,7 +30,7 @@ public final class OrderBy implements Serializable { public OrderBy() { this.list = new ArrayList<>(3); } - + private OrderBy(List list) { this.list = list; } @@ -60,8 +60,8 @@ public final class OrderBy implements Serializable { * Reverse the ascending/descending order on all the properties. */ public void reverse() { - for (int i = 0; i < list.size(); i++) { - list.get(i).reverse(); + for (Property aList : list) { + aList.reverse(); } } @@ -88,8 +88,8 @@ public final class OrderBy implements Serializable { */ public boolean containsProperty(String propertyName) { - for (int i = 0; i < list.size(); i++) { - if (propertyName.equals(list.get(i).getProperty())) { + for (Property aList : list) { + if (propertyName.equals(aList.getProperty())) { return true; } } @@ -101,12 +101,12 @@ public final class OrderBy implements Serializable { */ public OrderBy copyWithTrim(String path) { List newList = new ArrayList<>(list.size()); - for (int i = 0; i < list.size(); i++) { - newList.add(list.get(i).copyWithTrim(path)); + for (Property aList : list) { + newList.add(aList.copyWithTrim(path)); } return new OrderBy<>(newList); } - + /** * Return the properties for this OrderBy. */ @@ -142,8 +142,8 @@ public final class OrderBy implements Serializable { public OrderBy copy() { OrderBy copy = new OrderBy<>(); - for (int i = 0; i < list.size(); i++) { - copy.add(list.get(i).copy()); + for (Property aList : list) { + copy.add(aList.copy()); } return copy; } @@ -192,7 +192,7 @@ public final class OrderBy implements Serializable { if (!(obj instanceof OrderBy)) { return false; } - + OrderBy e = (OrderBy) obj; return e.list.equals(list); } @@ -356,8 +356,8 @@ public final class OrderBy implements Serializable { } String[] chunks = orderByClause.split(","); - for (int i = 0; i < chunks.length; i++) { - String[] pairs = chunks[i].split(" "); + for (String chunk : chunks) { + String[] pairs = chunk.split(" "); Property p = parseProperty(pairs); if (p != null) { list.add(p); @@ -371,9 +371,9 @@ public final class OrderBy implements Serializable { } ArrayList wordList = new ArrayList<>(pairs.length); - for (int i = 0; i < pairs.length; i++) { - if (!isEmptyString(pairs[i])) { - wordList.add(pairs[i]); + for (String pair : pairs) { + if (!isEmptyString(pair)) { + wordList.add(pair); } } if (wordList.isEmpty()) { diff --git a/src/main/java/com/avaje/ebean/RawSql.java b/src/main/java/com/avaje/ebean/RawSql.java index 54cf268f5..f2727e398 100644 --- a/src/main/java/com/avaje/ebean/RawSql.java +++ b/src/main/java/com/avaje/ebean/RawSql.java @@ -53,37 +53,37 @@ import com.avaje.ebean.util.CamelCaseHelper; *

* *

Example OrderAggregate

- * + * *
{@code
  *  ...
  *  // @Sql indicates to that this bean
  *  // is based on RawSql rather than a table
- * 
+ *
  * @Entity
  * @Sql
  * public class OrderAggregate {
- * 
+ *
  *  @OneToOne
  *  Order order;
- *      
+ *
  *  Double totalAmount;
- *  
+ *
  *  Double totalItems;
- *  
+ *
  *  // getters and setters
  *  ...
  *
  * }
* *

Example 1:

- * + * *
{@code
  *
  *   String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
  *     + " from o_order o"
  *     + " join o_customer c on c.id = o.kcustomer_id "
  *     + " join o_order_detail d on d.order_id = o.id " + " group by order_id, o.status ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     // map the sql result columns to bean properties
  *     .columnMapping("order_id", "order.id")
@@ -93,35 +93,35 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     // we don't need to map this one due to the sql column alias
  *     // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
  *     .create();
- * 
+ *
  *   List list = Ebean.find(OrderAggregate.class)
  *       .setRawSql(rawSql)
  *       .where().gt("order.id", 0)
  *       .having().gt("totalAmount", 20)
  *       .findList();
- * 
+ *
  *
  * }
- * + * *

Example 2:

- * + * *

* The following example uses a FetchConfig().query() so that after the initial * RawSql query is executed Ebean executes a secondary query to fetch the * associated order status, orderDate along with the customer name. *

- * + * *
{@code
  *
  *  String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
  *     + " from o_order_detail d"
  *     + " group by order_id ";
- * 
+ *
  *   RawSql rawSql = RawSqlBuilder.parse(sql)
  *     .columnMapping("order_id", "order.id")
  *     .columnMappingIgnore("'ignoreMe'")
  *     .create();
- * 
+ *
  *   List orders = Ebean.find(OrderAggregate.class)
  *     .setRawSql(rawSql)
  *     .fetch("order", "status,orderDate", new FetchConfig().query())
@@ -131,7 +131,7 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     .order().desc("totalAmount")
  *     .setMaxRows(10)
  *     .findList();
- * 
+ *
  * }
* * @@ -167,14 +167,14 @@ import com.avaje.ebean.util.CamelCaseHelper; *

* Note that lazy loading also works with object graphs built with RawSql. *

- * + * */ public final class RawSql implements Serializable { private static final long serialVersionUID = 1L; private final ResultSet resultSet; - + private final Sql sql; private final ColumnMapping columnMapping; @@ -192,7 +192,7 @@ public final class RawSql implements Serializable { this.sql = null; this.columnMapping = new ColumnMapping(propertyNames); } - + protected RawSql(ResultSet resultSet, Sql sql, ColumnMapping columnMapping) { this.resultSet = resultSet; this.sql = sql; @@ -214,7 +214,7 @@ public final class RawSql implements Serializable { String unParsedSql = (sql == null) ? "" : sql.unparsedSql; return new Key(parsed, unParsedSql, columnMapping); } - + /** * Return the resultSet if this is a ResultSet based RawSql. */ @@ -386,7 +386,7 @@ public final class RawSql implements Serializable { private final LinkedHashMap dbColumnMap; private final Map propertyMap; - + private final Map propertyColumnMap; private final boolean parsed; @@ -402,8 +402,7 @@ public final class RawSql implements Serializable { this.propertyMap = null; this.propertyColumnMap = null; this.dbColumnMap = new LinkedHashMap<>(); - for (int i = 0; i < columns.size(); i++) { - Column c = columns.get(i); + for (Column c : columns) { dbColumnMap.put(c.getDbColumnKey(), c); } } @@ -418,7 +417,7 @@ public final class RawSql implements Serializable { this.propertyColumnMap = null; this.dbColumnMap = new LinkedHashMap<>(); } - + /** * Construct for ResultSet use. */ @@ -476,7 +475,7 @@ public final class RawSql implements Serializable { /** * Creates an immutable copy of this ColumnMapping. - * + * * @throws IllegalStateException * when a propertyName has not been defined for a column. */ diff --git a/src/main/java/com/avaje/ebean/TxScope.java b/src/main/java/com/avaje/ebean/TxScope.java index 36c6f0633..cd8ac0c50 100644 --- a/src/main/java/com/avaje/ebean/TxScope.java +++ b/src/main/java/com/avaje/ebean/TxScope.java @@ -296,8 +296,8 @@ public final class TxScope { if (rollbackFor == null) { rollbackFor = new ArrayList<>(rollbackThrowables.length); } - for (int i = 0; i < rollbackThrowables.length; i++) { - rollbackFor.add((Class) rollbackThrowables[i]); + for (Class rollbackThrowable : rollbackThrowables) { + rollbackFor.add((Class) rollbackThrowable); } return this; } @@ -330,8 +330,8 @@ public final class TxScope { if (noRollbackFor == null) { noRollbackFor = new ArrayList<>(noRollbacks.length); } - for (int i = 0; i < noRollbacks.length; i++) { - noRollbackFor.add((Class) noRollbacks[i]); + for (Class noRollback : noRollbacks) { + noRollbackFor.add((Class) noRollback); } return this; } diff --git a/src/main/java/com/avaje/ebean/bean/CallStack.java b/src/main/java/com/avaje/ebean/bean/CallStack.java index 3d0f61f86..bc93b7206 100644 --- a/src/main/java/com/avaje/ebean/bean/CallStack.java +++ b/src/main/java/com/avaje/ebean/bean/CallStack.java @@ -34,12 +34,12 @@ public final class CallStack implements Serializable { public int hashCode() { int hc = 0; - for (int i = 0; i < callStack.length; i++) { - hc = 31 * hc + callStack[i].hashCode(); + for (StackTraceElement aCallStack : callStack) { + hc = 31 * hc + aCallStack.hashCode(); } return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -88,8 +88,8 @@ public final class CallStack implements Serializable { */ public String description(String newLine) { StringBuilder sb = new StringBuilder(400); - for (int i = 0; i < callStack.length; i++) { - sb.append(callStack[i].toString()).append(newLine); + for (StackTraceElement aCallStack : callStack) { + sb.append(aCallStack.toString()).append(newLine); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java index 3cef1e723..0025abfb1 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java @@ -30,7 +30,7 @@ public final class EntityBeanIntercept implements Serializable { private static final int STATE_NEW = 0; private static final int STATE_REFERENCE = 1; private static final int STATE_LOADED = 2; - + private transient NodeUsageCollector nodeUsageCollector; private transient PropertyChangeSupport pcs; @@ -55,11 +55,11 @@ public final class EntityBeanIntercept implements Serializable { * One of NEW, REF, UPD. */ private int state; - + private boolean readOnly; - + private boolean dirty; - + /** * Flag set to disable lazy loading - typically for SQL "report" type entity beans. */ @@ -74,14 +74,14 @@ public final class EntityBeanIntercept implements Serializable { * Used when a bean is partially filled. */ private final boolean[] loadedProps; - + private boolean fullyLoadedBean; /** * Set of changed properties. */ private boolean[] changedProps; - + /** * Flags indicating if a property is a dirty embedded bean. Used to distingush * between an embedded bean being completely overwritten and one of its @@ -180,7 +180,7 @@ public final class EntityBeanIntercept implements Serializable { public Object getEmbeddedOwner() { return embeddedOwner; } - + /** * Return the property index (for the parent) of this embedded bean. */ @@ -240,8 +240,8 @@ public final class EntityBeanIntercept implements Serializable { * Check each property to see if the bean is partially loaded. */ public boolean isPartial() { - for (int i = 0; i < loadedProps.length; i++) { - if (!loadedProps[i]) { + for (boolean loadedProp : loadedProps) { + if (!loadedProp) { return true; } } @@ -263,7 +263,7 @@ public final class EntityBeanIntercept implements Serializable { this.dirty = true; setEmbeddedPropertyDirty(embeddedProperty); } - + public void setDirty(boolean dirty) { this.dirty = dirty; } @@ -290,12 +290,12 @@ public final class EntityBeanIntercept implements Serializable { if (i == idIndex) { if (!loadedProps[i]) return false; } else if (loadedProps[i]) { - return false; + return false; } } return true; } - + /** * Return true if the entity is a reference. */ @@ -312,7 +312,7 @@ public final class EntityBeanIntercept implements Serializable { // For cases where properties are set on constructor // set every non Id property to unloaded (for lazy loading) for (int i=0; i< loadedProps.length; i++) { - if (i != idPos) { + if (i != idPos) { loadedProps[i] = false; } } @@ -448,7 +448,7 @@ public final class EntityBeanIntercept implements Serializable { } return origValues[propertyIndex]; } - + /** * Finds the index position of a given property. Returns -1 if the property * can not be found. @@ -462,7 +462,7 @@ public final class EntityBeanIntercept implements Serializable { } return -1; } - + /** * Return the property name for the given property. */ @@ -472,7 +472,7 @@ public final class EntityBeanIntercept implements Serializable { } return owner._ebean_getPropertyName(propertyIndex); } - + /** * Return the number of properties.s */ @@ -498,7 +498,7 @@ public final class EntityBeanIntercept implements Serializable { public void setPropertyUnloaded(int propertyIndex) { loadedProps[propertyIndex] = false; } - + /** * Set the property to be loaded. */ @@ -525,7 +525,7 @@ public final class EntityBeanIntercept implements Serializable { * embedded properties is dirty. */ public boolean isDirtyProperty(int propertyIndex) { - return (changedProps != null && changedProps[propertyIndex] + return (changedProps != null && changedProps[propertyIndex] || embeddedDirty != null && embeddedDirty[propertyIndex]); } @@ -536,7 +536,7 @@ public final class EntityBeanIntercept implements Serializable { setChangedProperty(propertyIndex); setDirty(true); } - + public void setChangedProperty(int propertyIndex) { if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; @@ -553,7 +553,7 @@ public final class EntityBeanIntercept implements Serializable { } embeddedDirty[propertyIndex] = true; } - + private void setOriginalValue(int propertyIndex, Object value) { if (origValues == null) { origValues = new Object[owner._ebean_getPropertyNames().length]; @@ -567,19 +567,19 @@ public final class EntityBeanIntercept implements Serializable { * For forced update on a 'New' bean set all the loaded properties to changed. */ public void setNewBeanForUpdate() { - + if (changedProps == null) { changedProps = new boolean[owner._ebean_getPropertyNames().length]; } - + for (int i=0; i< loadedProps.length; i++) { if (loadedProps[i]) { - changedProps[i] = true; + changedProps[i] = true; } } setDirty(true); } - + /** * Return the set of property names for a partially loaded bean. */ @@ -621,7 +621,7 @@ public final class EntityBeanIntercept implements Serializable { addDirtyPropertyNames(props, null); return props; } - + /** * Recursively add dirty properties. */ @@ -670,7 +670,7 @@ public final class EntityBeanIntercept implements Serializable { addDirtyPropertyValues(dirtyValues, null); return dirtyValues; } - + /** * Recursively add dirty properties. */ @@ -684,7 +684,7 @@ public final class EntityBeanIntercept implements Serializable { Object oldVal = getOrigValue(i); dirtyValues.put(propName, new ValuePair(newVal, oldVal)); - + } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); @@ -692,14 +692,14 @@ public final class EntityBeanIntercept implements Serializable { } } } - + /** * Return a dirty property hash taking into account embedded beans. */ public int getDirtyPropertyHash() { return addDirtyPropertyHash(37); } - + /** * Add and return a dirty property hash recursing into embedded beans. */ @@ -749,7 +749,7 @@ public final class EntityBeanIntercept implements Serializable { public int getLazyLoadPropertyIndex() { return lazyLoadProperty; } - + /** * Return the property that triggered the lazy load. */ @@ -849,7 +849,7 @@ public final class EntityBeanIntercept implements Serializable { } return obj1.equals(obj2); } - + /** * Called when a BeanCollection is initialised automatically. */ @@ -920,7 +920,7 @@ public final class EntityBeanIntercept implements Serializable { if (readOnly) { throw new IllegalStateException("This bean is readOnly"); } - + setLoadedProperty(propertyIndex); // Bean itself not considered dirty when many changed @@ -930,7 +930,7 @@ public final class EntityBeanIntercept implements Serializable { return null; } } - + private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) { if (readOnly) { @@ -941,7 +941,7 @@ public final class EntityBeanIntercept implements Serializable { if (setDirtyState) { setOriginalValue(propertyIndex, origValue); if (!dirty) { - dirty = true; + dirty = true; if (embeddedOwner != null) { // Cascade dirty state from Embedded bean to parent bean embeddedOwner._ebean_getIntercept().setEmbeddedDirty(embeddedOwnerIndex); @@ -952,7 +952,7 @@ public final class EntityBeanIntercept implements Serializable { } } } - + /** * Check to see if the values are not equal. If they are not equal then create * the old values for use with ConcurrencyMode.ALL. @@ -962,15 +962,15 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (!areEqual(oldValue, newValue)) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - - return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } - - + + /** * Check for primitive boolean. */ @@ -1007,13 +1007,13 @@ public final class EntityBeanIntercept implements Serializable { public PropertyChangeEvent preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue) { if (state == STATE_NEW) { - setLoadedProperty(propertyIndex); + setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } - + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } @@ -1025,7 +1025,7 @@ public final class EntityBeanIntercept implements Serializable { if (state == STATE_NEW) { setLoadedProperty(propertyIndex); } else if (oldValue != newValue) { - setChangedPropertyValue(propertyIndex, intercept, oldValue); + setChangedPropertyValue(propertyIndex, intercept, oldValue); } else { return null; } diff --git a/src/main/java/com/avaje/ebean/common/BeanList.java b/src/main/java/com/avaje/ebean/common/BeanList.java index 663154fd1..37fd9c309 100644 --- a/src/main/java/com/avaje/ebean/common/BeanList.java +++ b/src/main/java/com/avaje/ebean/common/BeanList.java @@ -261,8 +261,8 @@ public final class BeanList extends AbstractBeanCollection implements List // and fetch just the Id's initClear(); if (modifyRemoveListening) { - for (int i = 0; i < list.size(); i++) { - getModifyHolder().modifyRemoval(list.get(i)); + for (E aList : list) { + getModifyHolder().modifyRemoval(aList); } } list.clear(); diff --git a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java index 8779af15f..7a4ac320c 100644 --- a/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java +++ b/src/main/java/com/avaje/ebean/config/DbConstraintNormalise.java @@ -78,8 +78,8 @@ public class DbConstraintNormalise { public boolean notQuoted(String tableName) { // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - if (tableName.contains(quotedIdentifiers[i])) { + for (String quotedIdentifier : quotedIdentifiers) { + if (tableName.contains(quotedIdentifier)) { return false; } } @@ -95,8 +95,8 @@ public class DbConstraintNormalise { return ""; } // remove quoted identifier characters - for (int i = 0; i < quotedIdentifiers.length; i++) { - tableName = tableName.replace(quotedIdentifiers[i], ""); + for (String quotedIdentifier : quotedIdentifiers) { + tableName = tableName.replace(quotedIdentifier, ""); } return tableName; } diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 599a2b813..7ca2590ea 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -2117,7 +2117,7 @@ public class ServerConfig { */ public void add(BeanPostConstructListener listener) { postConstructListeners.add(listener); - } + } /** * Return the list of BeanFindController instances. */ @@ -2524,8 +2524,8 @@ public class ServerConfig { List> classes = new ArrayList<>(); String[] split = classNames.split("[ ,;]"); - for (int i = 0; i < split.length; i++) { - String cn = split[i].trim(); + for (String aSplit : split) { + String cn = aSplit.trim(); if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) { try { classes.add(Class.forName(cn)); @@ -2545,8 +2545,8 @@ public class ServerConfig { if (searchPackages != null) { String[] entries = searchPackages.split("[ ,;]"); - for (int i = 0; i < entries.length; i++) { - hitList.add(entries[i].trim()); + for (String entry : entries) { + hitList.add(entry.trim()); } } return hitList; diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index cc74d7478..6724d35fd 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -159,8 +159,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { } synchronized (monitor) { - for (int i = 0; i < newIds.size(); i++) { - idList.add(newIds.get(i)); + for (Long newId : newIds) { + idList.add(newId); } } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java index 64902be84..d8cf688d4 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java @@ -47,8 +47,8 @@ public class MsSqlServerDdl extends PlatformDdl { sb.append(columns[i]); } sb.append(") where"); - for (int i = 0; i < columns.length; i++) { - sb.append(" ").append(columns[i]).append(" is not null"); + for (String column : columns) { + sb.append(" ").append(column).append(" is not null"); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java index 3e8148542..42c098b7b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexSet.java @@ -36,8 +36,8 @@ public class IndexSet { */ public boolean add(String[] columns) { IndexColumns newIndex = new IndexColumns(columns); - for (int i = 0; i < indexes.size(); i++) { - if (indexes.get(i).isMatch(newIndex)) { + for (IndexColumns indexe : indexes) { + if (indexe.isMatch(newIndex)) { return false; } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java index f7c122954..27f38d287 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java @@ -60,7 +60,7 @@ public class ModelBuildIntersectionTable { intersectionTable.checkDuplicateForeignKeys(); } - + private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { String tableName = intersectionTableJoin.getTable(); @@ -71,11 +71,11 @@ public class ModelBuildIntersectionTable { MCompoundForeignKey foreignKey = new MCompoundForeignKey(fkName, desc.getBaseTable(), fkIndex); intersectionTable.addForeignKey(foreignKey); - for (int i = 0; i < columns.length; i++) { - String localCol = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); - String refCol = !direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String localCol = direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); + String refCol = !direction ? column.getForeignDbColumn() : column.getLocalDbColumn(); foreignKey.addColumnPair(localCol, refCol); - } + } } private MTable createTable() { @@ -93,14 +93,14 @@ public class ModelBuildIntersectionTable { table.setPkName(ctx.primaryKeyName(tableName)); TableJoinColumn[] columns = intersectionTableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - addColumn(table, localDesc, columns[i].getForeignDbColumn(), columns[i].getLocalDbColumn()); - } + for (TableJoinColumn column : columns) { + addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn()); + } TableJoinColumn[] otherColumns = tableJoin.columns(); - for (int i = 0; i < otherColumns.length; i++) { - addColumn(table, targetDesc, otherColumns[i].getLocalDbColumn(), otherColumns[i].getForeignDbColumn()); - } + for (TableJoinColumn otherColumn : otherColumns) { + addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn()); + } return table; } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index 7e66c16ed..339bec4c5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -54,8 +54,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { private void addIndexes(IndexDefinition[] indexes) { if (indexes != null) { - for (int i = 0; i < indexes.length; i++) { - IndexDefinition index = indexes[i]; + for (IndexDefinition index : indexes) { String[] columns = index.getColumns(); indexSet.add(columns); @@ -178,9 +177,9 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { table.addForeignKey(compoundKey); } - for (int i = 0; i < columns.length; i++) { + for (TableJoinColumn column : columns) { - String dbCol = columns[i].getLocalDbColumn(); + String dbCol = column.getLocalDbColumn(); BeanProperty importedProperty = importedId.findMatchImport(dbCol); if (importedProperty == null) { throw new RuntimeException("Imported BeanProperty not found?"); @@ -369,4 +368,4 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { return val != null && !val.isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java index b25add8e5..2f35f0410 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/VisitAllUsing.java @@ -64,8 +64,7 @@ public class VisitAllUsing { } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - BeanProperty p = propertiesNonTransient[i]; + for (BeanProperty p : propertiesNonTransient) { if (p.isDDLColumn()) { visit(propertyVisitor, p); } @@ -91,8 +90,8 @@ public class VisitAllUsing { // Embedded bean pv.visitEmbedded(assocOne); BeanProperty[] embProps = assocOne.getProperties(); - for (int i = 0; i < embProps.length; i++) { - pv.visitEmbeddedScalar(embProps[i], assocOne); + for (BeanProperty embProp : embProps) { + pv.visitEmbeddedScalar(embProp, assocOne); } } else if (assocOne.isOneToOneExported()) { @@ -110,8 +109,8 @@ public class VisitAllUsing { pv.visitCompound(compound); BeanProperty[] properties = compound.getScalarProperties(); - for (int i = 0; i < properties.length; i++) { - pv.visitCompoundScalar(compound, properties[i]); + for (BeanProperty property : properties) { + pv.visitCompoundScalar(compound, property); } } else { @@ -151,8 +150,8 @@ public class VisitAllUsing { public void visit(InheritInfo inheritInfo) { BeanProperty[] propertiesLocal = inheritInfo.desc().propertiesLocal(); - for (int i = 0; i < propertiesLocal.length; i++) { - owner.visit(pv, propertiesLocal[i]); + for (BeanProperty aPropertiesLocal : propertiesLocal) { + owner.visit(pv, aPropertiesLocal); } } } diff --git a/src/main/java/com/avaje/ebean/util/StringHelper.java b/src/main/java/com/avaje/ebean/util/StringHelper.java index 3eed6135c..947a4bb1d 100644 --- a/src/main/java/com/avaje/ebean/util/StringHelper.java +++ b/src/main/java/com/avaje/ebean/util/StringHelper.java @@ -111,7 +111,7 @@ public class StringHelper { * Parses out a list of Name Value pairs that are delimited together. Will * always return a StringMap. If allNameValuePairs is null, or no name values * can be parsed out an empty StringMap is returned. - * + * * @param allNameValuePairs * the entire string to be parsed. * @param listDelimiter @@ -133,7 +133,7 @@ public class StringHelper { /** * Trims off recurring strings from the front of a string. - * + * * @param source * the source string * @param trim @@ -219,7 +219,7 @@ public class StringHelper { * Convert a string that has delimited values (say comma delimited) in a * String[]. You must explicitly choose whether or not to include empty values * (say two commas that a right beside each other. - * + * *

* e.g. "alpha,beta,,theta"
* With keepEmpties true, this results in a String[] of size 4 with the third @@ -272,7 +272,7 @@ public class StringHelper { * This returns the FIRST string in str that is bounded on the left by * leftBound, and bounded on the right by rightBound. This will return null if * the leftBound is not found within str. - * + * *

* If leftBound can't be found this returns null. *

@@ -280,7 +280,7 @@ public class StringHelper { * This rightBound can't be found then this throws a * StringIndexOutOfBoundsException. *

- * + * * @param str * the base string that we will search for the bounded string. * @param leftBound @@ -364,7 +364,7 @@ public class StringHelper { /** * This method takes a String and will replace all occurrences of the match * String with that of the replace String. - * + * * @param source * the source string * @param match @@ -462,7 +462,7 @@ public class StringHelper { *

* Useful when converting CRNL CR and NL all to a BR tag for example. *

- * + * *
    * 
    * String[] multi = { "\r\n", "\r", "\n" };
@@ -580,8 +580,8 @@ public class StringHelper {
   }
 
   private static boolean charMatch(int iChr, char[] chr) {
-    for (int i = 0; i < chr.length; i++) {
-      if (iChr == chr[i]) {
+    for (char aChr : chr) {
+      if (iChr == aChr) {
         return true;
       }
     }
diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
index 8a049de7f..ecb4c4afe 100644
--- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
+++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java
@@ -23,7 +23,7 @@ public class BindParams implements Serializable {
 	private final List positionedParameters = new ArrayList<>();
 
 	private final Map namedParameters = new LinkedHashMap<>();
-	
+
 	/**
 	 * This is the sql. For named parameters this is the sql after the named
 	 * parameters have been replaced with question mark place holders and the
@@ -37,14 +37,14 @@ public class BindParams implements Serializable {
    */
   private int[] bindHash;
 
-	public BindParams() {  
+	public BindParams() {
 	}
-	
+
   public int queryBindHash() {
      int hc = namedParameters.hashCode();
-     for (int i = 0; i < positionedParameters.size(); i++) {
-       hc = hc * 31 + positionedParameters.get(i).hashCode();
-     }
+    for (Param positionedParameter : positionedParameters) {
+      hc = hc * 31 + positionedParameter.hashCode();
+    }
      return hc;
    }
 
@@ -97,14 +97,14 @@ public class BindParams implements Serializable {
 		}
 		return copy;
 	}
-	
+
 	/**
 	 * Return true if there are no bind parameters.
 	 */
 	public boolean isEmpty() {
 		return positionedParameters.isEmpty() && namedParameters.isEmpty();
 	}
-	
+
 	/**
 	 * Return a Natural Key bind param if supported.
 	 */
@@ -209,7 +209,7 @@ public class BindParams implements Serializable {
 	 * Set a named In parameter that is not null.
 	 */
 	public Param setParameter(String name, Object value) {
-	    
+
 	  Param p = getParam(name);
 		p.setInValue(value);
 		return p;
@@ -302,62 +302,62 @@ public class BindParams implements Serializable {
 	 * 

*/ public static final class OrderedList { - + private final List paramList; - + private final StringBuilder preparedSql; public OrderedList() { this(new ArrayList<>()); } - + public OrderedList(List paramList) { this.paramList = paramList; this.preparedSql = new StringBuilder(); } - + /** * Add a parameter in the correct binding order. */ public void add(Param param) { paramList.add(param); } - + /** * Return the number of bind parameters in this list. */ public int size() { return paramList.size(); } - + /** * Returns the ordered list of bind parameters. */ public List list() { return paramList; } - + /** * Append parsedSql that has named parameters converted into ?. */ public void appendSql(String parsedSql) { preparedSql.append(parsedSql); } - + public String getPreparedSql() { return preparedSql.toString(); } } - + /** * A In Out capable parameter for the CallableStatement. */ public static final class Param implements Serializable { private static final long serialVersionUID = 1L; - + private boolean encryptionKey; - + private boolean isInParam; private boolean isOutParam; @@ -381,9 +381,9 @@ public class BindParams implements Serializable { if (inValue instanceof Collection){ return ((Collection)inValue).size(); } - return 1; + return 1; } - + /** * Create a deep copy of the Param. */ @@ -396,20 +396,20 @@ public class BindParams implements Serializable { copy.outValue = outValue; return copy; } - + public int hashCode() { int hc = getClass().hashCode(); hc = hc * 31 + (isInParam ? 0 : 1); hc = hc * 31 + (isOutParam ? 0 : 1); hc = hc * 31 + (type); - hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); + hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); return hc; } public boolean equals(Object o) { return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); } - + /** * Return true if this is an In parameter that needs to be bound before * execution. @@ -458,7 +458,7 @@ public class BindParams implements Serializable { this.isInParam = true; this.encryptionKey = true; } - + /** * Specify that the In parameter is NULL and the specific type that it * is. diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java index 48499ee40..09e796aac 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java @@ -98,8 +98,7 @@ public class LoadBeanRequest extends LoadRequest { List idList = new ArrayList<>(batchSize); BeanDescriptor desc = loadBuffer.getBeanDescriptor(); - for (int i = 0; i < batch.size(); i++) { - EntityBeanIntercept ebi = batch.get(i); + for (EntityBeanIntercept ebi : batch) { EntityBean bean = ebi.getOwner(); idList.add(desc.getId(bean)); } @@ -154,8 +153,8 @@ public class LoadBeanRequest extends LoadRequest { BeanDescriptor desc = loadBuffer.getBeanDescriptor(); // collect Ids and maybe load bean cache - for (int i = 0; i < list.size(); i++) { - EntityBean loadedBean = (EntityBean) list.get(i); + for (Object aList : list) { + EntityBean loadedBean = (EntityBean) aList; loadedIds.add(desc.getId(loadedBean)); if (isLoadCache()) { desc.cacheBeanPut(loadedBean); @@ -163,10 +162,9 @@ public class LoadBeanRequest extends LoadRequest { } if (lazyLoadProperty != null) { - for (int i = 0; i < batch.size(); i++) { + for (EntityBeanIntercept ebi : batch) { // check if the underlying row in DB was deleted. Mark the bean as 'failed' if // necessary but allow processing to continue until it is accessed by client code - EntityBeanIntercept ebi = batch.get(i); Object id = desc.getId(ebi.getOwner()); if (!loadedIds.contains(id)) { if (desc.isSoftDelete()) { diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 20de44756..3f6172422 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -104,8 +104,7 @@ public class LoadManyRequest extends LoadRequest { ArrayList idList = new ArrayList<>(batchSize); BeanPropertyAssocMany many = getMany(); - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { idList.add(many.getParentId(bc.getOwnerBean())); } int extraIds = batchSize - batch.size(); @@ -177,8 +176,7 @@ public class LoadManyRequest extends LoadRequest { // check for BeanCollection's that where never processed // in the +query or +lazy load due to no rows (predicates) - for (int i = 0; i < batch.size(); i++) { - BeanCollection bc = batch.get(i); + for (BeanCollection bc : batch) { if (bc.checkEmptyLazyLoad()) { if (logger.isDebugEnabled()) { EntityBean ownerBean = bc.getOwnerBean(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java index c2eda8690..734099800 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java @@ -221,8 +221,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (noRollbackFor != null) { - for (int i = 0; i < noRollbackFor.size(); i++) { - if (noRollbackFor.get(i).equals(e.getClass())) { + for (Class aNoRollbackFor : noRollbackFor) { + if (aNoRollbackFor.equals(e.getClass())) { // explicit no rollback for this one return false; @@ -231,8 +231,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { } if (rollbackFor != null) { - for (int i = 0; i < rollbackFor.size(); i++) { - if (rollbackFor.get(i).equals(e.getClass())) { + for (Class aRollbackFor : rollbackFor) { + if (aRollbackFor.equals(e.getClass())) { // explicit rollback for this one return true; } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 845431bb5..6f81f9aa1 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -126,8 +126,8 @@ public class TransactionEvent implements Serializable { List> persistRequestBeans = getPersistRequestBeans(); if (persistRequestBeans != null) { - for (int i=0; i< persistRequestBeans.size(); i++) { - persistRequestBeans.get(i).addDocStoreUpdates(docStoreUpdates); + for (PersistRequestBean persistRequestBean : persistRequestBeans) { + persistRequestBean.addDocStoreUpdates(docStoreUpdates); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 1fd704b14..3b770ce92 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -36,9 +36,9 @@ public class TransactionEventBeans { * Collect the cache changes. */ public void notifyCache(CacheChangeSet changeSet) { - for (int i = 0; i < requests.size(); i++) { - requests.get(i).notifyCache(changeSet); - } + for (PersistRequestBean request : requests) { + request.notifyCache(changeSet); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java index 46b19524b..7927f20bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java @@ -27,8 +27,7 @@ public class CachedBeanDataFromBean { BeanProperty[] props = desc.propertiesNonMany(); // extract all the non-many properties - for (int i = 0; i < props.length; i++) { - BeanProperty prop = props[i]; + for (BeanProperty prop : props) { if (ebi.isLoadedProperty(prop.getPropertyIndex())) { data.put(prop.getName(), prop.getCacheDataValue(bean)); } @@ -56,9 +55,9 @@ public class CachedBeanDataFromBean { idProp.setValue(sharableBean, v); } BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient(); - for (int i = 0; i < propertiesNonTransient.length; i++) { - Object v = propertiesNonTransient[i].getValue(bean); - propertiesNonTransient[i].setValue(sharableBean, v); + for (BeanProperty aPropertiesNonTransient : propertiesNonTransient) { + Object v = aPropertiesNonTransient.getValue(bean); + aPropertiesNonTransient.setValue(sharableBean, v); } EntityBeanIntercept intercept = sharableBean._ebean_intercept(); intercept.setReadOnly(true); @@ -67,4 +66,4 @@ public class CachedBeanDataFromBean { } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java index f324409cc..35e9bf52b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataToBean.java @@ -22,13 +22,13 @@ public class CachedBeanDataToBean { // load the non-many properties BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - loadProperty(bean, cacheBeanData, ebi, props[i], context); + for (BeanProperty prop : props) { + loadProperty(bean, cacheBeanData, ebi, prop, context); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - many[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany aMany : many) { + aMany.createReferenceIfNull(bean); } ebi.setLoadedLazy(); @@ -44,4 +44,4 @@ public class CachedBeanDataToBean { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index fc963cc88..76c3cb0b8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -87,13 +87,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final Logger logger = LoggerFactory.getLogger(DefaultServer.class); private static final int IGNORE_LEADING_ELEMENTS = 5; - + private static final String COM_AVAJE_EBEAN = "com.avaje.ebean"; private static final String ORG_AVAJE_EBEAN = "org.avaje.ebean"; private final ServerConfig serverConfig; - + private final String serverName; private final DatabasePlatform databasePlatform; @@ -113,7 +113,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * false; */ private final boolean rollbackOnChecked; - + /** * Handles the save, delete, updateSql CallableSql. */ @@ -152,7 +152,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private final DocumentStore documentStore; private final MetaInfoManager metaInfoManager; - + /** * The default PersistenceContextScope used if it is not explicitly set on a query. */ @@ -162,21 +162,21 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * Flag set when the server has shutdown. */ private boolean shutdown; - + /** * The default batch size for lazy loading beans or collections. */ private final int lazyLoadBatchSize; - /** - * The query batch size + /** + * The query batch size */ private final int queryBatchSize; private final boolean updateAllPropertiesInBatch; private final boolean collectQueryOrigins; - + private final boolean collectQueryStatsByNode; /** @@ -235,7 +235,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { this.ddlGenerator = new DdlGenerator(this, serverConfig); configureServerPlugins(); - + // Register with the JVM Shutdown hook ShutdownManager.registerEbeanServer(this); } @@ -273,7 +273,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public int getLazyLoadBatchSize() { return lazyLoadBatchSize; } - + public int getQueryBatchSize() { return queryBatchSize; } @@ -798,23 +798,23 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { *

*

* Code example:
- * + * *

    * <code>
    * Ebean.startTransaction();
    * try {
    * 	// do some fetching and or persisting
-   * 
+   *
    * 	// commit at the end
    * 	Ebean.commitTransaction();
-   * 
+   *
    * } finally {
    * 	// if commit didn't occur then rollback the transaction
    * 	Ebean.endTransaction();
    * }
    * </code>
    * 
- * + * *

*/ public void endTransaction() { @@ -1205,7 +1205,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); return request.findIds(); - + } finally { request.endTransIfRequired(); } @@ -1374,7 +1374,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { try { request.initTransIfRequired(); return request.findList(); - + } finally { request.endTransIfRequired(); } @@ -1445,18 +1445,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException("This bean is not an EntityBean?"); } // mark the bean as dirty (so that an update will not get skipped) - ((EntityBean)bean)._ebean_getIntercept().setDirty(true); + ((EntityBean)bean)._ebean_getIntercept().setDirty(true); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean) { update(bean, null); } /** - * Update the bean using the default 'updatesDeleteMissingChildren' setting. + * Update the bean using the default 'updatesDeleteMissingChildren' setting. */ public void update(Object bean, Transaction t) { persister.update(checkEntityBean(bean), t); @@ -1483,7 +1483,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to update? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1491,13 +1491,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { update(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; } } - + /** * Insert the bean. */ @@ -1528,7 +1528,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // Nothing to insert? return; } - + TransWrapper wrap = initTransIfRequired(t); try { SpiTransaction trans = wrap.transaction; @@ -1536,7 +1536,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { persister.insert(checkEntityBean(bean), trans); } wrap.commitIfCreated(); - + } catch (RuntimeException e) { wrap.rollbackIfCreated(); throw e; @@ -1621,7 +1621,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } return (EntityBean)bean; } - + @Override public int saveAll(Collection beans, Transaction transaction) throws OptimisticLockException { return saveAllInternal(beans.iterator(), transaction); @@ -1853,15 +1853,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { public void register(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).register(c); + for (BeanDescriptor aList : list) { + aList.register(c); } } public void deregister(BeanPersistController c) { List> list = beanDescriptorManager.getBeanDescriptorList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).deregister(c); + for (BeanDescriptor aList : list) { + aList.deregister(c); } } @@ -2041,14 +2041,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { // immutable thread safe so return shared instance return jsonContext; } - + @Override public void collectQueryStats(ObjectGraphNode node, long loadedBeanCount, long timeMicros) { - + if (collectQueryStatsByNode) { CObjectGraphNodeStatistics nodeStatistics = objectGraphStats.get(node); if (nodeStatistics == null) { - // race condition here but I actually don't care too much if we miss a + // race condition here but I actually don't care too much if we miss a // few early statistics - especially when the server is warming up etc nodeStatistics = new CObjectGraphNodeStatistics(node); objectGraphStats.put(node, nodeStatistics); @@ -2056,5 +2056,5 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { nodeStatistics.add(loadedBeanCount, timeMicros); } } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index 74520d382..0ba67bfeb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -303,8 +303,8 @@ public final class PersistRequestBean extends PersistRequest implements BeanP */ public boolean hasDirtyProperty(int[] propertyPositions) { - for (int i = 0; i < propertyPositions.length; i++) { - if (dirtyProperties[propertyPositions[i]]) { + for (int propertyPosition : propertyPositions) { + if (dirtyProperties[propertyPosition]) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java index 56ae7e7b3..9028d0949 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java @@ -33,12 +33,12 @@ public final class PersistRequestCallableSql extends PersistRequest { */ public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { - + super(server, t, persistExecute); this.type = PersistRequest.Type.CALLABLESQL; this.callableSql = (SpiCallableSql)cs; } - + @Override public int executeOrQueue() { return executeStatement(); @@ -88,7 +88,7 @@ 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 { @@ -134,14 +134,14 @@ public final class PersistRequestCallableSql extends PersistRequest { List list = bindParam.positionedParameters(); int pos = 0; - for (int i = 0; i < list.size(); i++) { - pos++; - BindParams.Param param = list.get(i); - if (param.isOutParam()) { - Object outValue = cstmt.getObject(pos); - param.setOutValue(outValue); - } - } + for (Param aList : list) { + pos++; + Param param = aList; + if (param.isOutParam()) { + Object outValue = cstmt.getObject(pos); + param.setOutValue(outValue); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java index 901603485..95f9e6e12 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java @@ -191,10 +191,10 @@ public final class RelationalQueryRequest { SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue); int index = 0; - for (int i = 0; i < propertyNames.length; i++) { + for (String propertyName : propertyNames) { index++; Object value = resultSet.getObject(index); - sqlRow.set(propertyNames[i], value); + sqlRow.set(propertyName, value); } return sqlRow; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java index 1bb50c71d..6dbfb865a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackages.java @@ -38,8 +38,8 @@ class DistillPackages { */ private static boolean notAlreadyContained(List distilled, String pack) { - for (int i = 0; i < distilled.size(); i++) { - if (pack.startsWith(distilled.get(i))) { + for (String aDistilled : distilled) { + if (pack.startsWith(aDistilled)) { return false; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java index 7098786f7..a9ce63945 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java @@ -74,8 +74,8 @@ class ManifestReader { */ private void add(String packages) { String[] split = packages.split(",|;| "); - for (int i = 0; i implements MetaBeanInfo, BeanType { this.docStoreQueueId = docStoreAdapter.getQueueId(); // Check if there are no cascade save associated beans ( subject to change - // in initialiseOther()). Note that if we are in an inheritance hierarchy - // then we also need to check every BeanDescriptors in the InheritInfo as + // in initialiseOther()). Note that if we are in an inheritance hierarchy + // then we also need to check every BeanDescriptors in the InheritInfo as // well. We do that later in initialiseOther(). saveRecurseSkippable = (0 == (propertiesOneExportedSave.length + propertiesOneImportedSave.length + propertiesManySave.length)); @@ -588,9 +588,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void setEbeanServer(SpiEbeanServer ebeanServer) { this.ebeanServer = ebeanServer; - for (int i = 0; i < propertiesMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { // used for creating lazy loading lists etc - propertiesMany[i].setLoader(ebeanServer); + aPropertiesMany.setLoader(ebeanServer); } } @@ -661,18 +661,18 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void initialiseOther(Map asOfTableMap, String asOfViewSuffix, Map draftTableMap) { - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany1 : propertiesManyToMany) { // register associated draft table for M2M intersection - propertiesManyToMany[i].registerDraftIntersectionTable(draftTableMap); + aPropertiesManyToMany1.registerDraftIntersectionTable(draftTableMap); } if (historySupport) { // history support on this bean so check all associated intersection tables // and if they are not excluded register the associated 'with history' table - for (int i = 0; i < propertiesManyToMany.length; i++) { + for (BeanPropertyAssocMany aPropertiesManyToMany : propertiesManyToMany) { // register associated history table for M2M intersection - if (!propertiesManyToMany[i].isExcludedFromHistory()) { - TableJoin intersectionTableJoin = propertiesManyToMany[i].getIntersectionTableJoin(); + if (!aPropertiesManyToMany.isExcludedFromHistory()) { + TableJoin intersectionTableJoin = aPropertiesManyToMany.getIntersectionTableJoin(); String intersectionTableName = intersectionTableJoin.getTable(); asOfTableMap.put(intersectionTableName, intersectionTableName + asOfViewSuffix); } @@ -716,8 +716,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ @SuppressWarnings("unchecked") public void initialiseDocMapping() { - for (int i = 0; i < propertiesMany.length; i++) { - propertiesMany[i].initialisePostTarget(); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + aPropertiesMany.initialisePostTarget(); } if (inheritInfo != null && !inheritInfo.isRoot()) { docStoreAdapter = (DocStoreBeanAdapter) inheritInfo.getRoot().desc().docStoreAdapter(); @@ -835,8 +835,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < idList.size(); i++) { - idBinder.bindId(delete, idList.get(i)); + for (Object anIdList : idList) { + idBinder.bindId(delete, anIdList); } return delete; } @@ -851,8 +851,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { DefaultSqlUpdate sqlDelete = new DefaultSqlUpdate(baseSql); Object[] bindValues = idBinder.getBindValues(id); - for (int i = 0; i < bindValues.length; i++) { - sqlDelete.addParameter(bindValues[i]); + for (Object bindValue : bindValues) { + sqlDelete.addParameter(bindValue); } return sqlDelete; @@ -867,8 +867,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public void initialiseFkeys() { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].addFkey(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.addFkey(); } } @@ -1469,9 +1469,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenCreatedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenCreated()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenCreated()) { + return aPropertiesBaseScalar; } } return null; @@ -1482,9 +1482,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ private BeanProperty findWhenModifiedProperty() { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - if (propertiesBaseScalar[i].isGeneratedWhenModified()) { - return propertiesBaseScalar[i]; + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + if (aPropertiesBaseScalar.isGeneratedWhenModified()) { + return aPropertiesBaseScalar; } } return null; @@ -1496,9 +1496,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public BeanPropertyAssocMany getManyProperty(SpiQuery query) { OrmQueryDetail detail = query.getDetail(); - for (int i = 0; i < propertiesMany.length; i++) { - if (detail.includesPath(propertiesMany[i].getName())) { - return propertiesMany[i]; + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (detail.includesPath(aPropertiesMany.getName())) { + return aPropertiesMany; } } @@ -1565,8 +1565,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Creates a new EntityBean. * The parameter isNew controls either this is a new bean (then * {@link BeanPostConstructListener#postCreate(Object)} will be invoked) or - * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked - * on first access (lazy load) or immediately (eager load) + * a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked + * on first access (lazy load) or immediately (eager load) */ @SuppressWarnings("unchecked") public EntityBean createEntityBean(boolean isNew) { @@ -1577,12 +1577,12 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { beanPostConstructListener.autowire(bean); // calls all registered listeners beanPostConstructListener.postConstruct(bean); // calls first the @PostConstruct method and then the listeners } - + if (unloadProperties.length > 0) { // 'unload' any properties initialised in the default constructor EntityBeanIntercept ebi = bean._ebean_getIntercept(); - for (int i = 0; i < unloadProperties.length; i++) { - ebi.setPropertyUnloaded(unloadProperties[i]); + for (int unloadProperty : unloadProperties) { + ebi.setPropertyUnloaded(unloadProperty); } } if (beanPostConstructListener != null && isNew) { @@ -1595,7 +1595,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { throw new PersistenceException(ex); } } - + /** * Creates a new entitybean without invoking {@link BeanPostConstructListener#postCreate(Object)} */ @@ -1938,11 +1938,11 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = propertiesMany(); - for (int i = 0; i < manys.length; i++) { - if (!ebi.isLoadedProperty(manys[i].getPropertyIndex())) { - BeanCollection ref = manys[i].createReferenceIfNull(bean); + for (BeanPropertyAssocMany many : manys) { + if (!ebi.isLoadedProperty(many.getPropertyIndex())) { + BeanCollection ref = many.createReferenceIfNull(bean); if (ref != null && !ref.isRegisteredWithLoadContext()) { - String path = SplitName.add(prefix, manys[i].getName()); + String path = SplitName.add(prefix, many.getName()); loadContext.register(path, ref); } } @@ -2147,9 +2147,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public void resetManyProperties(Object dbBean) { EntityBean bean = (EntityBean) dbBean; - for (int i = 0; i < propertiesMany.length; i++) { - if (propertiesMany[i].isCascadeRefresh()) { - propertiesMany[i].resetMany(bean); + for (BeanPropertyAssocMany aPropertiesMany : propertiesMany) { + if (aPropertiesMany.isCascadeRefresh()) { + aPropertiesMany.resetMany(bean); } } } @@ -2600,8 +2600,8 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Set the embedded owner on any embedded bean properties. */ public void setEmbeddedOwner(EntityBean bean) { - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].setEmbeddedOwner(bean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.setEmbeddedOwner(bean); } } @@ -2624,7 +2624,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } if (idProperty.isEmbedded()) { - // not using Id generator so just base on isLoaded() + // not using Id generator so just base on isLoaded() return !ebi.isLoaded(); } if (!hasIdValue(ebi.getOwner())) { @@ -2674,8 +2674,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Check for mutable scalar types and mark as dirty if necessary. */ public void checkMutableProperties(EntityBeanIntercept ebi) { - for (int i = 0; i < propertiesMutable.length; i++) { - BeanProperty beanProperty = propertiesMutable[i]; + for (BeanProperty beanProperty : propertiesMutable) { int propertyIndex = beanProperty.getPropertyIndex(); if (!ebi.isDirtyProperty(propertyIndex) && ebi.isLoadedProperty(propertyIndex)) { Object value = beanProperty.getValue(ebi.getOwner()); @@ -2725,14 +2724,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { * Populate the diff for inserts with flattened non-null property values. */ public void diffForInsert(String prefix, Map map, EntityBean newBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diffForInsert(prefix, map, newBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diffForInsert(prefix, map, newBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diffForInsert(prefix, map, newBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diffForInsert(prefix, map, newBean); } } @@ -2750,14 +2749,14 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { */ public void diff(String prefix, Map map, EntityBean newBean, EntityBean oldBean) { - for (int i = 0; i < propertiesBaseScalar.length; i++) { - propertiesBaseScalar[i].diff(prefix, map, newBean, oldBean); + for (BeanProperty aPropertiesBaseScalar : propertiesBaseScalar) { + aPropertiesBaseScalar.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesOne.length; i++) { - propertiesOne[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { + aPropertiesOne.diff(prefix, map, newBean, oldBean); } - for (int i = 0; i < propertiesEmbedded.length; i++) { - propertiesEmbedded[i].diff(prefix, map, newBean, oldBean); + for (BeanPropertyAssocOne aPropertiesEmbedded : propertiesEmbedded) { + aPropertiesEmbedded.diff(prefix, map, newBean, oldBean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 9cba445a0..888ad0d71 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -125,8 +125,8 @@ final class BeanDescriptorCacheHelp { * that does have bean caching enabled. */ private boolean isNotifyOnDeletes() { - for (int i = 0; i < propertiesOneImported.length; i++) { - if (propertiesOneImported[i].isCacheNotify()) { + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + if (aPropertiesOneImported.isCacheNotify()) { return true; } } @@ -264,8 +264,7 @@ final class BeanDescriptorCacheHelp { List idList = entry.getIdList(); bc.checkEmptyLazyLoad(); - for (int i = 0; i < idList.size(); i++) { - Object id = idList.get(i); + for (Object id : idList) { Object refBean = targetDescriptor.createReference(readOnly, false, id, persistenceContext); many.add(bc, (EntityBean) refBean); } @@ -320,7 +319,7 @@ final class BeanDescriptorCacheHelp { // check if it is a find by unique id (using the natural key) NaturalKeyBindParam keyBindParam = query.getNaturalKeyBindParam(); if (keyBindParam == null || !isNaturalKey(keyBindParam.getName())) { - // query is not appropriate + // query is not appropriate return null; } @@ -545,8 +544,8 @@ final class BeanDescriptorCacheHelp { } beanCache.remove(id); } - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheClear(); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheClear(); } } @@ -608,8 +607,8 @@ final class BeanDescriptorCacheHelp { } private void cacheDeleteImported(boolean clear, EntityBean entityBean, CacheChangeSet changeSet) { - for (int i = 0; i < propertiesOneImported.length; i++) { - propertiesOneImported[i].cacheDelete(clear, entityBean, changeSet); + for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { + aPropertiesOneImported.cacheDelete(clear, entityBean, changeSet); } } @@ -627,8 +626,7 @@ final class BeanDescriptorCacheHelp { List> manyCollections = updateRequest.getUpdatedManyCollections(); if (manyCollections != null) { - for (int i = 0; i < manyCollections.size(); i++) { - BeanPropertyAssocMany many = manyCollections.get(i); + for (BeanPropertyAssocMany many : manyCollections) { Object details = many.getValue(updateRequest.getEntityBean()); CachedManyIds entry = createManyIds(many, details); if (entry != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java index a3e26d057..70f35ec56 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorDraftHelp.java @@ -85,14 +85,14 @@ public final class BeanDescriptorDraftHelp { } BeanProperty[] props = desc.propertiesNonMany(); - for (int i = 0; i < props.length; i++) { - props[i].publish(draft, live); + for (BeanProperty prop : props) { + prop.publish(draft, live); } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftable()) { - many[i].publishMany(draft, live); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftable()) { + aMany.publishMany(draft, live); } } @@ -105,16 +105,16 @@ public final class BeanDescriptorDraftHelp { public void draftQueryOptimise(Query query) { BeanPropertyAssocOne[] one = desc.propertiesOne(); - for (int i = 0; i < one.length; i++) { - if (one[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(one[i].getName()); + for (BeanPropertyAssocOne anOne : one) { + if (anOne.getTargetDescriptor().isDraftableElement()) { + query.fetch(anOne.getName()); } } BeanPropertyAssocMany[] many = desc.propertiesMany(); - for (int i = 0; i < many.length; i++) { - if (many[i].getTargetDescriptor().isDraftableElement()) { - query.fetch(many[i].getName()); + for (BeanPropertyAssocMany aMany : many) { + if (aMany.getTargetDescriptor().isDraftableElement()) { + query.fetch(aMany.getName()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java index 7046cee77..6dbf2e357 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java @@ -63,9 +63,9 @@ public class BeanDescriptorJsonHelp { writeJson.writeStartObject(null); // render the dirty properties BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (dirtyProps[props[j].getPropertyIndex()]) { - props[j].jsonWrite(writeJson, bean); + for (BeanProperty prop : props) { + if (dirtyProps[prop.getPropertyIndex()]) { + prop.jsonWrite(writeJson, bean); } } writeJson.writeEndObject(); @@ -103,7 +103,7 @@ public class BeanDescriptorJsonHelp { String propName = parser.getCurrentName(); if (!propName.equalsIgnoreCase(discColumn)) { - // just try to assume this is the correct bean type in the inheritance + // just try to assume this is the correct bean type in the inheritance BeanProperty property = desc.getBeanProperty(propName); if (property != null) { EntityBean bean = desc.createEntityBean(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java index 478dd2cc8..a153569ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -423,15 +423,15 @@ public class BeanDescriptorManager implements BeanDescriptorMap { List> normalBeanTypes = tableToDescMap.get(tableName); if (normalBeanTypes != null) { // 'normal' entity beans based on a "base table" - for (int i = 0; i < normalBeanTypes.size(); i++) { - normalBeanTypes.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor normalBeanType : normalBeanTypes) { + normalBeanType.cacheHandleBulkUpdate(tableIUD); } } List> viewBeans = tableToViewDescMap.get(tableName); if (viewBeans != null) { // entity beans based on a "view" - for (int i = 0; i < viewBeans.size(); i++) { - viewBeans.get(i).cacheHandleBulkUpdate(tableIUD); + for (BeanDescriptor viewBean : viewBeans) { + viewBean.cacheHandleBulkUpdate(tableIUD); } } } @@ -458,8 +458,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { for (String depTable : viewInvalidation) { List> list = tableToViewDescMap.get(depTable.toLowerCase()); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).queryCacheClear(); + for (BeanDescriptor aList : list) { + aList.queryCacheClear(); } } } @@ -663,8 +663,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private void readEmbeddedDeployment() { List> embeddedClasses = bootupClasses.getEmbeddables(); - for (int i = 0; i < embeddedClasses.size(); i++) { - registerBeanDescriptor(createEmbedded(embeddedClasses.get(i))); + for (Class embeddedClass : embeddedClasses) { + registerBeanDescriptor(createEmbedded(embeddedClass)); } } @@ -1395,8 +1395,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { boolean hasVersionProperty = false; List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - if (props.get(i).isVersionColumn()) { + for (DeployBeanProperty prop : props) { + if (prop.isVersionColumn()) { hasVersionProperty = true; } } @@ -1407,8 +1407,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { private boolean hasEntityBeanInterface(Class beanClass) { Class[] interfaces = beanClass.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - if (interfaces[i].equals(EntityBean.class)) { + for (Class anInterface : interfaces) { + if (anInterface.equals(EntityBean.class)) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java index a50bd8fe3..c3b65060f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanFinderManager.java @@ -30,8 +30,7 @@ public class BeanFinderManager { */ public void addFindControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanFindController c = list.get(i); + for (BeanFindController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanFindController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.setBeanFinder(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 6b091e0b8..1bc6c474e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -176,8 +176,8 @@ public class BeanLifecycleAdapterFactory { } private void invoke(Method[] methods, BeanPersistRequest request) { - for (int i = 0; i < methods.length; i++) { - invoke(methods[i], request.getBean()); + for (Method method : methods) { + invoke(method, request.getBean()); } } @@ -242,12 +242,12 @@ public class BeanLifecycleAdapterFactory { @Override public void postLoad(Object bean) { - for (int i = 0; i < postLoadMethods.length; i++) { - invoke(postLoadMethods[i], bean); + for (Method postLoadMethod : postLoadMethods) { + invoke(postLoadMethod, bean); } } } - + /** * PostConstructAdapter using reflection to invoke lifecycle methods. */ @@ -275,8 +275,8 @@ public class BeanLifecycleAdapterFactory { @Override public void postConstruct(Object bean) { - for (int i = 0; i < postConstructMethods.length; i++) { - invoke(postConstructMethods[i], bean); + for (Method postConstructMethod : postConstructMethods) { + invoke(postConstructMethod, bean); } } @@ -284,7 +284,7 @@ public class BeanLifecycleAdapterFactory { public void autowire(Object bean) { // autowire is done by global PostConstructListener only } - + @Override public void postCreate(Object bean) { // postCreate is done by global PostConstructListener only diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java index 6cd4cd0f0..8745568f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanListHelp.java @@ -146,8 +146,8 @@ public final class BeanListHelp implements BeanCollectionHelp { if (!list.isEmpty() || ctx.isIncludeEmpty()) { ctx.beginAssocMany(name); - for (int j = 0; j < list.size(); j++) { - targetDescriptor.jsonWrite(ctx, (EntityBean) list.get(j)); + for (Object aList : list) { + targetDescriptor.jsonWrite(ctx, (EntityBean) aList); } ctx.endAssocMany(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java index 24cfb38eb..2e85c8377 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -362,8 +362,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { ArrayList list = new ArrayList<>(); - for (int i = 0; i < cols.length; i++) { - list.add(createImportedScalar(owner, cols[i], props, others)); + for (TableJoinColumn col : cols) { + list.add(createImportedScalar(owner, col, props, others)); } return ImportedIdSimple.sort(list); @@ -399,8 +399,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { } else { EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); bindValues.add(embVal); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index 79a5eec7c..1ef618e42 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -376,8 +376,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { String expr = rawWhere + inClause; List bindValues = new ArrayList<>(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -403,8 +403,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - bindWhereParendId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + bindWhereParendId(delete, aParentIdist); } return delete; @@ -668,10 +668,10 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { return parentIds; } List expandedList = new ArrayList<>(parentIds.size() * exportedProperties.length); - for (int i = 0; i < parentIds.size(); i++) { - for (int y = 0; y < exportedProperties.length; y++) { - Object compId = parentIds.get(i); - expandedList.add(exportedProperties[y].getValue((EntityBean) compId)); + for (Object parentId : parentIds) { + for (ExportedProperty exportedProperty : exportedProperties) { + Object compId = parentId; + expandedList.add(exportedProperty.getValue((EntityBean) compId)); } } return expandedList; @@ -684,8 +684,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { return; } EntityBean parent = (EntityBean) parentId; - for (int i = 0; i < exportedProperties.length; i++) { - Object embVal = exportedProperties[i].getValue(parent); + for (ExportedProperty exportedProperty : exportedProperties) { + Object embVal = exportedProperty.getValue(parent); sqlUpd.addParameter(embVal); } } @@ -696,8 +696,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (alias == null) { alias = "t0"; } - for (int i = 0; i < exportedProperties.length; i++) { - ctx.appendColumn(alias, exportedProperties[i].getForeignDbColumn()); + for (ExportedProperty exportedProperty : exportedProperties) { + ctx.appendColumn(alias, exportedProperty.getForeignDbColumn()); } } @@ -779,8 +779,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -816,11 +816,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { columns = tableJoin.columns(); searchTable = tableJoin.getTable(); } - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embedded, foreignCol, prop); } } @@ -849,8 +849,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanDescriptor targetDesc = getTargetDescriptor(); BeanPropertyAssocOne[] ones = targetDesc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (mappedBy != null) { // match using mappedBy as property name if (mappedBy.equalsIgnoreCase(prop.getName())) { @@ -935,9 +934,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { BeanProperty idProp = descriptor.getIdProperty(); parentBean = (EntityBean) idProp.getValue(parentBean); } - for (int i = 0; i < exportedProperties.length; i++) { - Object val = exportedProperties[i].getValue(parentBean); - String fkColumn = exportedProperties[i].getForeignDbColumn(); + for (ExportedProperty exportedProperty : exportedProperties) { + Object val = exportedProperty.getValue(parentBean); + String fkColumn = exportedProperty.getForeignDbColumn(); row.put(fkColumn, val); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 51f606895..66b57efed 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -79,8 +79,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanEmbeddedMeta overrideMeta = BeanEmbeddedMetaFactory.create(owner, deploy); embeddedProps = overrideMeta.getProperties(); embeddedPropsMap = new HashMap<>(); - for (int i = 0; i < embeddedProps.length; i++) { - embeddedPropsMap.put(embeddedProps[i].getName(), embeddedProps[i]); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedPropsMap.put(embeddedProp.getName(), embeddedProp); } } else { @@ -208,8 +208,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { sb.append(inClause); DefaultSqlUpdate delete = new DefaultSqlUpdate(sb.toString()); - for (int i = 0; i < parentIdist.size(); i++) { - targetIdBinder.bindId(delete, parentIdist.get(i)); + for (Object aParentIdist : parentIdist) { + targetIdBinder.bindId(delete, aParentIdist); } return delete; @@ -258,8 +258,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String expr = rawWhere + inClause; List bindValues = new ArrayList<>(); - for (int i = 0; i < parentIdList.size(); i++) { - bindWhereParentId(bindValues, parentIdList.get(i)); + for (Object aParentIdList : parentIdList) { + bindWhereParentId(bindValues, aParentIdList); } EbeanServer server = getBeanDescriptor().getEbeanServer(); @@ -301,8 +301,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { targetIdBinder.buildRawSqlSelectChain(prefix, selectChain); } else { - for (int i = 0; i < embeddedProps.length; i++) { - embeddedProps[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty embeddedProp : embeddedProps) { + embeddedProp.buildRawSqlSelectChain(prefix, selectChain); } } } @@ -514,8 +514,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { BeanDescriptor targetDesc = one.getTargetDescriptor(); BeanProperty[] emIds = targetDesc.propertiesBaseScalar(); try { - for (int i = 0; i < emIds.length; i++) { - ExportedProperty expProp = findMatch(true, emIds[i]); + for (BeanProperty emId : emIds) { + ExportedProperty expProp = findMatch(true, emId); list.add(expProp); } } catch (PersistenceException e) { @@ -543,11 +543,11 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String searchTable = tableJoin.getTable(); TableJoinColumn[] columns = tableJoin.columns(); - for (int i = 0; i < columns.length; i++) { - String matchTo = columns[i].getLocalDbColumn(); + for (TableJoinColumn column : columns) { + String matchTo = column.getLocalDbColumn(); if (matchColumn.equalsIgnoreCase(matchTo)) { - String foreignCol = columns[i].getForeignDbColumn(); + String foreignCol = column.getForeignDbColumn(); return new ExportedProperty(embeddedProp, foreignCol, prop); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java index 8127ce025..57ff681c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyCompound.java @@ -46,14 +46,13 @@ public class BeanPropertyCompound extends BeanProperty { BeanPropertyCompoundRoot root = deploy.getFlatProperties(); this.scalarProperties = root.getScalarProperties(); - for (int i = 0; i < scalarProperties.length; i++) { - propertyMap.put(scalarProperties[i].getName(), scalarProperties[i]); + for (BeanProperty scalarProperty : scalarProperties) { + propertyMap.put(scalarProperty.getName(), scalarProperty); } List nonScalarPropsList = root.getNonScalarProperties(); - for (int i = 0; i < nonScalarPropsList.size(); i++) { - CtCompoundProperty ctProp = nonScalarPropsList.get(i); + for (CtCompoundProperty ctProp : nonScalarPropsList) { CtCompoundPropertyElAdapter adapter = new CtCompoundPropertyElAdapter(ctProp); nonScalarMap.put(ctProp.getRelativeName(), adapter); } @@ -102,8 +101,8 @@ public class BeanPropertyCompound extends BeanProperty { @Override public void appendSelect(DbSqlContext ctx, boolean subQuery) { if (!isTransient) { - for (int i = 0; i < scalarProperties.length; i++) { - scalarProperties[i].appendSelect(ctx, subQuery); + for (BeanProperty scalarProperty : scalarProperties) { + scalarProperty.appendSelect(ctx, subQuery); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java index b936781c1..4b54c62c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanQueryAdapterManager.java @@ -31,8 +31,7 @@ public class BeanQueryAdapterManager { */ public void addQueryAdapter(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanQueryAdapter c = list.get(i); + for (BeanQueryAdapter c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanQueryAdapter on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addQueryAdapter(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java index f52116158..6e4a0f4ed 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java @@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory; public class BeanTable { private static final Logger logger = LoggerFactory.getLogger(BeanTable.class); - + private final Class beanType; /** @@ -29,7 +29,7 @@ public class BeanTable { private final String baseTable; private final BeanProperty[] idProperties; - + /** * Create the BeanTable. */ @@ -38,11 +38,11 @@ public class BeanTable { this.baseTable = InternString.intern(mutable.getBaseTable()); this.idProperties = mutable.createIdProperties(owner); } - + public String toString(){ - return baseTable; + return baseTable; } - + /** * Return the base table for this BeanTable. * This is used to determine the join information @@ -51,17 +51,17 @@ public class BeanTable { public String getBaseTable() { return baseTable; } - + /** * Gets the unqualified base table. - * + * * @return the unqualified base table */ public String getUnqualifiedBaseTable(){ final String[] chunks = baseTable.split("\\."); return chunks.length == 2 ? chunks[1] :chunks[0]; } - + /** * Return the Id properties. */ @@ -75,12 +75,12 @@ public class BeanTable { public Class getBeanType() { return beanType; } - + public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse) { - + boolean complexKey = false; BeanProperty[] props = idProperties; - + if (idProperties.length == 1){ if (idProperties[0] instanceof BeanPropertyAssocOne) { BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne)idProperties[0]; @@ -88,30 +88,30 @@ public class BeanTable { complexKey = true; } } - - for (int i = 0; i < props.length; i++) { - - String lc = props[i].getDbColumn(); - String fk = lc; - if (foreignKeyPrefix != null){ - fk = foreignKeyPrefix+"_"+fk; - } - - if (complexKey){ - // just to copy the column name rather than prefix with the foreignKeyPrefix. - // I think that with complex keys this is the more common approach. - String msg = "On table["+baseTable+"] foreign key column ["+lc+"]"; - logger.debug(msg); - fk = lc; - } - - DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); - if (reverse){ - joinCol = joinCol.reverse(); - } - join.addJoinColumn(joinCol); - } - + + for (BeanProperty prop : props) { + + String lc = prop.getDbColumn(); + String fk = lc; + if (foreignKeyPrefix != null) { + fk = foreignKeyPrefix + "_" + fk; + } + + if (complexKey) { + // just to copy the column name rather than prefix with the foreignKeyPrefix. + // I think that with complex keys this is the more common approach. + String msg = "On table[" + baseTable + "] foreign key column [" + lc + "]"; + logger.debug(msg); + fk = lc; + } + + DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); + if (reverse) { + joinCol = joinCol.reverse(); + } + join.addJoinColumn(joinCol); + } + } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java index cf565d1a5..941f59023 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPersistController.java @@ -16,18 +16,18 @@ import java.util.List; public class ChainedBeanPersistController implements BeanPersistController { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanPersistController[] chain; - + /** * Construct adding 2 BeanPersistController's. */ public ChainedBeanPersistController(BeanPersistController c1, BeanPersistController c2) { this(addList(c1, c2)); } - + /** * Helper method used to create a list from 2 BeanPersistController's. */ @@ -37,7 +37,7 @@ public class ChainedBeanPersistController implements BeanPersistController { addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistController's. */ @@ -65,11 +65,11 @@ public class ChainedBeanPersistController implements BeanPersistController { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistController(newList); } } - + /** * De-register a BeanPersistController and return the resulting chain. */ @@ -80,11 +80,11 @@ public class ChainedBeanPersistController implements BeanPersistController { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistController(newList); } } - + /** * Always returns 0 (not used for this object). */ @@ -103,69 +103,69 @@ public class ChainedBeanPersistController implements BeanPersistController { @Override public void postDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postDelete(request); + } } @Override public void postInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postInsert(request); - } + for (BeanPersistController aChain : chain) { + aChain.postInsert(request); + } } @Override public void postUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postUpdate(request); - } + for (BeanPersistController aChain : chain) { + aChain.postUpdate(request); + } } @Override public void postSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - chain[i].postSoftDelete(request); - } + for (BeanPersistController aChain : chain) { + aChain.postSoftDelete(request); + } } @Override public boolean preDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preDelete(request)) { + return false; + } + } return true; } @Override public boolean preSoftDelete(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preSoftDelete(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preSoftDelete(request)) { + return false; + } + } return true; } @Override public boolean preInsert(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preInsert(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preInsert(request)) { + return false; + } + } return true; } @Override public boolean preUpdate(BeanPersistRequest request) { - for (int i = 0; i < chain.length; i++) { - if (!chain[i].preUpdate(request)) { - return false; - } - } + for (BeanPersistController aChain : chain) { + if (!aChain.preUpdate(request)) { + return false; + } + } return true; } @@ -175,11 +175,11 @@ public class ChainedBeanPersistController implements BeanPersistController { private static class Sorter implements Comparator { public int compare(BeanPersistController o1, BeanPersistController o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 list; - + private final BeanPersistListener[] chain; - + /** * Construct adding 2 BeanPersistListener's. */ @@ -44,7 +44,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { addList.add(c2); return addList; } - + /** * Construct given the list of BeanPersistListener's. */ @@ -52,7 +52,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener { this.list = list; this.chain = list.toArray(new BeanPersistListener[list.size()]); } - + /** * Register a new BeanPersistListener and return the resulting chain. */ @@ -63,11 +63,11 @@ public class ChainedBeanPersistListener implements BeanPersistListener { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPersistListener(newList); } } - + /** * De-register a BeanPersistListener and return the resulting chain. */ @@ -78,32 +78,32 @@ public class ChainedBeanPersistListener implements BeanPersistListener { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPersistListener(newList); } } public void deleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].deleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.deleted(bean); + } } public void softDeleted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].softDeleted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.softDeleted(bean); + } } public void inserted(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].inserted(bean); - } + for (BeanPersistListener aChain : chain) { + aChain.inserted(bean); + } } public void updated(Object bean, Set updatedProperties) { - for (int i = 0; i < chain.length; i++) { - chain[i].updated(bean, updatedProperties); - } + for (BeanPersistListener aChain : chain) { + aChain.updated(bean, updatedProperties); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java index 58bdb5f1f..b02d4d945 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostConstructListener.java @@ -70,22 +70,22 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen */ @Override public void postConstruct(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postConstruct(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postConstruct(bean); } } @Override public void autowire(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].autowire(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.autowire(bean); } } @Override public void postCreate(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postCreate(bean); + for (BeanPostConstructListener aChain : chain) { + aChain.postCreate(bean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java index 9558d86dc..316b054a4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanPostLoad.java @@ -21,7 +21,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { this.list = list; this.chain = list.toArray(new BeanPostLoad[list.size()]); } - + /** * Register a new BeanPostLoad and return the resulting chain. */ @@ -32,11 +32,11 @@ public class ChainedBeanPostLoad implements BeanPostLoad { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanPostLoad(newList); } } - + /** * De-register a BeanPostLoad and return the resulting chain. */ @@ -47,7 +47,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanPostLoad(newList); } } @@ -70,8 +70,8 @@ public class ChainedBeanPostLoad implements BeanPostLoad { */ @Override public void postLoad(Object bean) { - for (int i = 0; i < chain.length; i++) { - chain[i].postLoad(bean); - } + for (BeanPostLoad aChain : chain) { + aChain.postLoad(bean); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java index 3987ca537..4d609c0bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java @@ -14,7 +14,7 @@ import com.avaje.ebean.event.BeanQueryRequest; public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static final Sorter SORTER = new Sorter(); - + private final List list; private final BeanQueryAdapter[] chain; @@ -28,7 +28,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { Arrays.sort(c, SORTER); this.chain = c; } - + /** * Register a new BeanQueryAdapter and return the resulting chain. */ @@ -39,11 +39,11 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { List newList = new ArrayList<>(); newList.addAll(list); newList.add(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * De-register a BeanQueryAdapter and return the resulting chain. */ @@ -54,12 +54,12 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { ArrayList newList = new ArrayList<>(); newList.addAll(list); newList.remove(c); - + return new ChainedBeanQueryAdapter(newList); } } - + /** * Return 0 as not used by this Chained adapter. */ @@ -75,10 +75,10 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { } public void preQuery(BeanQueryRequest request) { - - for (int i = 0; i < chain.length; i++) { - chain[i].preQuery(request); - } + + for (BeanQueryAdapter aChain : chain) { + aChain.preQuery(request); + } } /** * Helper to order the BeanQueryAdapter's in a chain. @@ -86,11 +86,11 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { private static class Sorter implements Comparator { public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) { - + int i1 = o1.getExecutionOrder() ; int i2 = o2.getExecutionOrder() ; return (i1 bindValues = er.getBindValues(); - for (int i = 0; i < bindValues.size(); i++) { - bindParams.setParameter(++count, bindValues.get(i)); + for (Object bindValue : bindValues) { + bindParams.setParameter(++count, bindValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java index 992fb2c6f..efdd8518a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/ParamTypeUtil.java @@ -20,17 +20,17 @@ public class ParamTypeUtil { * @param matchType the type which has the generic parameter */ public static Class findParamType(Class cls, Class matchType) { - + // search for: implementing a generic interface Type paramType = matchByInterfaces(cls, matchType); if (paramType == null){ // search for: extending a generic class Type genericSuperclass = cls.getGenericSuperclass(); if (genericSuperclass != null){ - paramType = matchParamType(genericSuperclass, matchType); + paramType = matchParamType(genericSuperclass, matchType); } } - + if (paramType instanceof Class){ // only interested in classes return (Class)paramType; @@ -38,7 +38,7 @@ public class ParamTypeUtil { return null; } } - + /** * Check if the type is a generic one with parameters and of the correct type we are * searching for. Return the parameter type if this matches otherwise return null. @@ -60,19 +60,19 @@ public class ParamTypeUtil { } return null; } - + /** * Search the interfaces this class implements. */ private static Type matchByInterfaces(Class cls, Class matchType) { - + Type[] gis = cls.getGenericInterfaces(); - for (int i = 0; i < gis.length; i++) { - Type match = matchParamType(gis[i], matchType); - if (match != null){ - return match; - } - } + for (Type gi : gis) { + Type match = matchParamType(gi, matchType); + if (match != null) { + return match; + } + } return null; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java index 1c5e09e47..c57eec213 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistControllerManager.java @@ -31,8 +31,7 @@ public class PersistControllerManager { */ public void addPersistControllers(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistController c = list.get(i); + for (BeanPersistController c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPersistController on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPersistController(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java index c1b0f981d..4cc9771e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PersistListenerManager.java @@ -31,13 +31,12 @@ public class PersistListenerManager { */ public void addPersistListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPersistListener listener = list.get(i); + for (BeanPersistListener listener : list) { if (listener.isRegisterFor(deployDesc.getBeanType())) { - logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); - deployDesc.addPersistListener(listener); - } - } + logger.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName()); + deployDesc.addPersistListener(listener); + } + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java index 8e7a84041..50c879656 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostConstructManager.java @@ -30,8 +30,7 @@ public class PostConstructManager { */ public void addPostConstructListeners(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostConstructListener c = list.get(i); + for (BeanPostConstructListener c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostConstructListener(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java index c049b8f15..b4288411c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/PostLoadManager.java @@ -30,8 +30,7 @@ public class PostLoadManager { */ public void addPostLoad(DeployBeanDescriptor deployDesc) { - for (int i = 0; i < list.size(); i++) { - BeanPostLoad c = list.get(i); + for (BeanPostLoad c : list) { if (c.isRegisterFor(deployDesc.getBeanType())) { logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName()); deployDesc.addPostLoad(c); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java index 2c18c2a03..6241519c6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoin.java @@ -22,7 +22,7 @@ public final class TableJoin { private final SqlJoinType type; private final InheritInfo inheritInfo; - + /** * Columns as an array. */ @@ -57,8 +57,8 @@ public final class TableJoin { private int calcQueryHash() { int hc = type.hashCode(); hc = hc * 92821 + (table == null ? 0 : table.hashCode()); - for (int i = 0; i < columns.length; i++) { - hc = hc * 92821 + columns[i].queryHash(); + for (TableJoinColumn column : columns) { + hc = hc * 92821 + column.queryHash(); } return hc; } @@ -99,8 +99,8 @@ public final class TableJoin { public String toString() { StringBuilder sb = new StringBuilder(30); sb.append(type).append(" ").append(table).append(" "); - for (int i = 0; i < columns.length; i++) { - sb.append(columns[i]).append(" "); + for (TableJoinColumn column : columns) { + sb.append(column).append(" "); } return sb.toString(); } @@ -141,8 +141,8 @@ public final class TableJoin { String joinLiteral = joinType.getLiteral(type); ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); - + return joinType.autoToOuter(type); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index 9c421b652..6576e3c7b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -117,15 +117,15 @@ public final class IdBinderEmbedded implements IdBinder { prefix = SplitName.add(prefix, embIdProperty.getName()); - for (int i = 0; i < props.length; i++) { - props[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty prop : props) { + prop.buildRawSqlSelectChain(prefix, selectChain); } } public BeanProperty findBeanProperty(String dbColumnName) { - for (int i = 0; i < props.length; i++) { - if (dbColumnName.equalsIgnoreCase(props[i].getDbColumn())) { - return props[i]; + for (BeanProperty prop : props) { + if (dbColumnName.equalsIgnoreCase(prop.getDbColumn())) { + return prop; } } return null; @@ -156,8 +156,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void addIdInBindValue(SpiExpressionRequest request, Object value) { - for (int i = 0; i < props.length; i++) { - request.addBindValue(props[i].getValue((EntityBean) value)); + for (BeanProperty prop : props) { + request.addBindValue(prop.getValue((EntityBean) value)); } } @@ -235,8 +235,8 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean); Map map = new LinkedHashMap<>(); - for (int i = 0; i < props.length; i++) { - map.put(props[i].getName(), props[i].getValue(ebValue)); + for (BeanProperty prop : props) { + map.put(prop.getName(), prop.getValue(ebValue)); } return map; } @@ -250,26 +250,26 @@ public final class IdBinderEmbedded implements IdBinder { Map map = (Map)value; EntityBean idValue = idDesc.createEntityBean(); - for (int i = 0; i < props.length; i++) { - Object val = map.get(props[i].getName()); - props[i].setValue(idValue, val); + for (BeanProperty prop : props) { + Object val = map.get(prop.getName()); + prop.setValue(idValue, val); } return idValue; } public void bindId(DefaultSqlUpdate sqlUpdate, Object value) { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); sqlUpdate.addParameter(embFieldValue); } } public void bindId(DataBind dataBind, Object value) throws SQLException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) value); - props[i].bind(dataBind, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) value); + prop.bind(dataBind, embFieldValue); } } @@ -278,9 +278,9 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readData(dataInput); - props[i].setValue(embId, value); + for (BeanProperty prop : props) { + Object value = prop.readData(dataInput); + prop.setValue(embId, value); if (value == null) { notNull = false; } @@ -294,15 +294,15 @@ public final class IdBinderEmbedded implements IdBinder { } public void writeData(DataOutput dataOutput, Object idValue) throws IOException { - for (int i = 0; i < props.length; i++) { - Object embFieldValue = props[i].getValue((EntityBean) idValue); - props[i].writeData(dataOutput, embFieldValue); + for (BeanProperty prop : props) { + Object embFieldValue = prop.getValue((EntityBean) idValue); + prop.writeData(dataOutput, embFieldValue); } } public void loadIgnore(DbReadContext ctx) { - for (int i = 0; i < props.length; i++) { - props[i].loadIgnore(ctx); + for (BeanProperty prop : props) { + prop.loadIgnore(ctx); } } @@ -311,8 +311,8 @@ public final class IdBinderEmbedded implements IdBinder { EntityBean embId = idDesc.createEntityBean(); boolean notNull = true; - for (int i = 0; i < props.length; i++) { - Object value = props[i].readSet(ctx, embId); + for (BeanProperty prop : props) { + Object value = prop.readSet(ctx, embId); if (value == null) { notNull = false; } @@ -337,8 +337,8 @@ public final class IdBinderEmbedded implements IdBinder { } public void appendSelect(DbSqlContext ctx, boolean subQuery) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java index 099315d9b..dc29e59b3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java @@ -52,15 +52,15 @@ public class ImportedIdEmbedded implements ImportedId { } public void sqlAppend(DbSqlContext ctx) { - for (int i = 0; i < imported.length; i++) { - ctx.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + ctx.appendColumn(anImported.localDbColumn); } } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < imported.length; i++) { - request.appendColumn(imported[i].localDbColumn); + for (ImportedIdSimple anImported : imported) { + request.appendColumn(anImported.localDbColumn); } } @@ -83,9 +83,9 @@ public class ImportedIdEmbedded implements ImportedId { int pos = position; EntityBean embedded = (EntityBean) foreignAssocOne.getValue(bean); - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); update.setParameter(pos++, scalarValue); } } @@ -101,18 +101,18 @@ public class ImportedIdEmbedded implements ImportedId { } if (embeddedId == null) { - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - request.bind(null, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + request.bind(null, anImported.foreignProperty); } } } else { EntityBean embedded = (EntityBean) embeddedId; - for (int i = 0; i < imported.length; i++) { - if (imported[i].owner.isUpdateable()) { - Object scalarValue = imported[i].foreignProperty.getValue(embedded); - request.bind(scalarValue, imported[i].foreignProperty); + for (ImportedIdSimple anImported : imported) { + if (anImported.owner.isUpdateable()) { + Object scalarValue = anImported.foreignProperty.getValue(embedded); + request.bind(scalarValue, anImported.foreignProperty); } } } @@ -128,9 +128,9 @@ public class ImportedIdEmbedded implements ImportedId { throw new PersistenceException(msg); } - for (int i = 0; i < imported.length; i++) { - Object scalarValue = imported[i].foreignProperty.getValue(embeddedId); - row.put(imported[i].localDbColumn, scalarValue); + for (ImportedIdSimple anImported : imported) { + Object scalarValue = anImported.foreignProperty.getValue(embeddedId); + row.put(anImported.localDbColumn, scalarValue); } } @@ -140,8 +140,8 @@ public class ImportedIdEmbedded implements ImportedId { */ public BeanProperty findMatchImport(String matchDbColumn) { - for (int i = 0; i < imported.length; i++) { - BeanProperty p = imported[i].findMatchImport(matchDbColumn); + for (ImportedIdSimple anImported : imported) { + BeanProperty p = anImported.findMatchImport(matchDbColumn); if (p != null) { return p; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index 37041ab4b..8d254e445 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -302,8 +302,8 @@ public class DeployBeanDescriptor { public boolean isScalaObject() { Class[] interfaces = beanType.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - String iname = interfaces[i].getName(); + for (Class anInterface : interfaces) { + String iname = anInterface.getName(); if (I_SCALAOBJECT.equals(iname)) { return true; } @@ -546,7 +546,7 @@ public class DeployBeanDescriptor { return new ChainedBeanPostConstructListener(postConstructListeners); } } - + public void addPersistController(BeanPersistController controller) { persistControllers.add(controller); } @@ -566,7 +566,7 @@ public class DeployBeanDescriptor { public void addPostConstructListener(BeanPostConstructListener postConstructListener) { postConstructListeners.add(postConstructListener); } - + public String getDraftTable() { return draftTable; } @@ -635,8 +635,8 @@ public class DeployBeanDescriptor { Collections.sort(list, PROP_ORDER); propMap = new LinkedHashMap<>(list.size()); - for (int i = 0; i < list.size(); i++) { - addBeanProperty(list.get(i)); + for (DeployBeanProperty aList : list) { + addBeanProperty(aList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index 57fef0ec5..3c055d507 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -42,7 +42,7 @@ public class DeployBeanPropertyLists { private final List mutable = new ArrayList<>(); private final List> manys = new ArrayList<>(); - + private final List nonManys = new ArrayList<>(); private final List> ones = new ArrayList<>(); @@ -179,7 +179,7 @@ public class DeployBeanPropertyLists { if (prop.isMutableScalarType()) { mutable.add(prop); } - + if (desc.getInheritInfo() != null && prop.isLocal()) { local.add(prop); } @@ -349,22 +349,21 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocOne[] getOne(boolean imported, Mode mode) { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < ones.size(); i++) { - BeanPropertyAssocOne prop = ones.get(i); + for (BeanPropertyAssocOne prop : ones) { if (imported != prop.isOneToOneExported()) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave()) { - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete()) { - list.add(prop); - } - break; - default: - break; + case Save: + if (prop.getCascadeInfo().isSave()) { + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete()) { + list.add(prop); + } + break; + default: + break; } } } @@ -374,8 +373,7 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocMany[] getMany2Many() { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); + for (BeanPropertyAssocMany prop : manys) { if (prop.isManyToMany()) { list.add(prop); } @@ -386,27 +384,25 @@ public class DeployBeanPropertyLists { private BeanPropertyAssocMany[] getMany(Mode mode) { ArrayList> list = new ArrayList<>(); - for (int i = 0; i < manys.size(); i++) { - BeanPropertyAssocMany prop = manys.get(i); - + for (BeanPropertyAssocMany prop : manys) { switch (mode) { - case Save: - if (prop.getCascadeInfo().isSave() || prop.isManyToMany() + case Save: + if (prop.getCascadeInfo().isSave() || prop.isManyToMany() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // Note ManyToMany always included as we always 'save' - // the relationship via insert/delete of intersection table - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - case Delete: - if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { - // REMOVALS means including PrivateOwned relationships - list.add(prop); - } - break; - default: - break; + // Note ManyToMany always included as we always 'save' + // the relationship via insert/delete of intersection table + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + case Delete: + if (prop.getCascadeInfo().isDelete() || ModifyListenMode.REMOVALS.equals(prop.getModifyListenMode())) { + // REMOVALS means including PrivateOwned relationships + list.add(prop); + } + break; + default: + break; } } @@ -419,15 +415,15 @@ public class DeployBeanPropertyLists { if (deployProp instanceof DeployBeanPropertyAssocOne) { return new BeanPropertyAssocOne(owner, desc, (DeployBeanPropertyAssocOne) deployProp); } - + if (deployProp instanceof DeployBeanPropertySimpleCollection) { return new BeanPropertySimpleCollection(desc, (DeployBeanPropertySimpleCollection) deployProp); } - + if (deployProp instanceof DeployBeanPropertyAssocMany) { return new BeanPropertyAssocMany(desc, (DeployBeanPropertyAssocMany) deployProp); } - + if (deployProp instanceof DeployBeanPropertyCompound) { return new BeanPropertyCompound(desc, (DeployBeanPropertyCompound) deployProp); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java index 5296fff32..d810f58ce 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoin.java @@ -54,8 +54,8 @@ public class DeployTableJoin { */ public void setColumns(DeployTableJoinColumn[] cols, boolean reverse) { columns = new ArrayList<>(); - for (int i = 0; i < cols.length; i++) { - addJoinColumn(cols[i].copy(reverse)); + for (DeployTableJoinColumn col : cols) { + addJoinColumn(col.copy(reverse)); } } @@ -86,8 +86,8 @@ public class DeployTableJoin { * Add a JoinColumn array. */ public void addJoinColumn(boolean order, JoinColumn[] jcArray, BeanTable beanTable) { - for (int i = 0; i < jcArray.length; i++) { - addJoinColumn(order, jcArray[i], beanTable); + for (JoinColumn aJcArray : jcArray) { + addJoinColumn(order, aJcArray, beanTable); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index 2bda44973..f5385890f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -228,20 +228,20 @@ public class AnnotationAssocManys extends AnnotationParser { if (!intJoin.hasJoinColumns()) { // define foreign key columns BeanProperty[] localIds = localTable.getIdProperties(); - for (int i = 0; i < localIds.length; i++) { + for (BeanProperty localId : localIds) { // add the source to intersection join columns - String fkCol = localTableName + "_" + localIds[i].getDbColumn(); - intJoin.addJoinColumn(new DeployTableJoinColumn(localIds[i].getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); + String fkCol = localTableName + "_" + localId.getDbColumn(); + intJoin.addJoinColumn(new DeployTableJoinColumn(localId.getDbColumn(), namingConvention.getColumnFromProperty(null, fkCol))); } } if (!destJoin.hasJoinColumns()) { // define inverse foreign key columns BeanProperty[] otherIds = otherTable.getIdProperties(); - for (int i = 0; i < otherIds.length; i++) { + for (BeanProperty otherId : otherIds) { // set the intersection to dest table join columns - final String fkCol = otherTableName + "_" + otherIds[i].getDbColumn(); - destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherIds[i].getDbColumn())); + final String fkCol = otherTableName + "_" + otherId.getDbColumn(); + destJoin.addJoinColumn(new DeployTableJoinColumn(namingConvention.getColumnFromProperty(null, fkCol), otherId.getDbColumn())); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java index e2457ba77..8ddb2422c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -24,7 +24,7 @@ public abstract class AnnotationParser extends AnnotationBase { protected final Class beanType; protected final boolean validationAnnotations; - + public AnnotationParser(DeployBeanInfo info, boolean validationAnnotations) { super(info.getUtil()); this.validationAnnotations = validationAnnotations; @@ -56,9 +56,9 @@ public abstract class AnnotationParser extends AnnotationBase { if (attrOverrides != null) { HashMap propMap = new HashMap<>(); AttributeOverride[] aoArray = attrOverrides.value(); - for (int i = 0; i < aoArray.length; i++) { - String propName = aoArray[i].name(); - String columnName = aoArray[i].column().name(); + for (AttributeOverride anAoArray : aoArray) { + String propName = anAoArray.name(); + String columnName = anAoArray.column().name(); propMap.put(propName, columnName); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index f1a4224e8..272c81b86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -38,7 +38,7 @@ import java.lang.reflect.Type; public class DeployCreateProperties { private static final Logger logger = LoggerFactory.getLogger(DeployCreateProperties.class); - + private final DetermineManyType determineManyType; private final TypeManager typeManager; @@ -183,10 +183,9 @@ public class DeployCreateProperties { String methIsName = "is" + initFieldName; String scalaGet = field.getName(); - for (int i = 0; i < declaredMethods.length; i++) { - Method m = declaredMethods[i]; + for (Method m : declaredMethods) { if ((scalaObject && m.getName().equals(scalaGet)) || m.getName().equals(methGetName) - || m.getName().equals(methIsName)) { + || m.getName().equals(methIsName)) { Class[] params = m.getParameterTypes(); if (params.length == 0) { @@ -222,7 +221,7 @@ public class DeployCreateProperties { private DeployBeanProperty createProp(DeployBeanDescriptor desc, Field field) { Class propertyType = field.getType(); - + ManyToOne manyToOne = AnnotationBase.findAnnotation(field,ManyToOne.class); if (manyToOne != null){ Class tt = manyToOne.targetEntity(); @@ -233,7 +232,7 @@ public class DeployCreateProperties { if (isSpecialScalarType(field)) { return new DeployBeanProperty(desc, propertyType, field.getGenericType()); } - + // check for Collection type (list, set or map) ManyType manyType = determineManyType.getManyType(propertyType); if (manyType != null) { @@ -303,7 +302,7 @@ public class DeployCreateProperties { || (AnnotationBase.findAnnotation(field,DbArray.class) != null) || (AnnotationBase.findAnnotation(field,DbHstore.class) != null); } - + private boolean isTransientField(Field field) { Transient t = AnnotationBase.findAnnotation(field,Transient.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java index 329307b5b..24afe1ed3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/SqlReservedWords.java @@ -10,7 +10,7 @@ import java.util.HashSet; */ public class SqlReservedWords { - private static final String baseKeyWords = + private static final String baseKeyWords = "ALIAS,ALTER,ADD,ALL,ARE,AND,ANY,ARRAY" +",AS,ASC,AT" +",AVG,BEGIN,BETWEEN,BIGINT,BINARY,BIT,BIT_LENGTH,BLOB,BOOLEAN" @@ -44,15 +44,15 @@ public class SqlReservedWords { +",UPDATE,USER,VARCHAR,VIEW,WHEN" +",WHERE,WITH"; - + private static final HashSet keywords = new HashSet<>(); static { - + String[] initialKeywords = baseKeyWords.split(","); - for (int i = 0; i < initialKeywords.length; i++) { - keywords.add(initialKeywords[i].trim()); - } - + for (String initialKeyword : initialKeywords) { + keywords.add(initialKeyword.trim()); + } + } @@ -63,7 +63,7 @@ public class SqlReservedWords { String s = keyword.trim().toUpperCase(); return keywords.contains(s); } - + /** * Add a sql keyword to the known set. */ @@ -71,7 +71,7 @@ public class SqlReservedWords { if (keyword != null){ keyword = keyword.trim().toUpperCase(); if (!keyword.isEmpty()){ - keywords.add(keyword); + keywords.add(keyword); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java index 0d119f0d4..2f8b52d9f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/TransientProperties.java @@ -11,41 +11,38 @@ import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; * Mark transient properties. */ public class TransientProperties { - + public TransientProperties() { } - + /** * Mark any additional properties as transient. */ public void process(DeployBeanDescriptor desc) { - + List props = desc.propertiesBase(); - for (int i = 0; i < props.size(); i++) { - DeployBeanProperty prop = props.get(i); - if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { - // non-transient... - prop.setTransient(); - } - } + for (DeployBeanProperty prop : props) { + if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { + // non-transient... + prop.setTransient(); + } + } List> ones = desc.propertiesAssocOne(); - for (int i = 0; i < ones.size(); i++) { - DeployBeanPropertyAssocOne prop = ones.get(i); - if (prop.getBeanTable() == null) { - if (!prop.isEmbedded()) { - prop.setTransient(); - } - } + for (DeployBeanPropertyAssocOne prop : ones) { + if (prop.getBeanTable() == null) { + if (!prop.isEmbedded()) { + prop.setTransient(); + } } + } List> manys = desc.propertiesAssocMany(); - for (int i = 0; i < manys.size(); i++) { - DeployBeanPropertyAssocMany prop = manys.get(i); - if (prop.getBeanTable() == null) { - prop.setTransient(); - } + for (DeployBeanPropertyAssocMany prop : manys) { + if (prop.getBeanTable() == null) { + prop.setTransient(); } - + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java index 663a92043..9f77d986f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElComparatorCompound.java @@ -18,8 +18,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compare(T o1, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compare(o1, o2); + for (ElComparator anArray : array) { + int ret = anArray.compare(o1, o2); if (ret != 0) { return ret; } @@ -30,8 +30,8 @@ public final class ElComparatorCompound implements Comparator, ElComparato public int compareValue(Object value, T o2) { - for (int i = 0; i < array.length; i++) { - int ret = array[i].compareValue(value, o2); + for (ElComparator anArray : array) { + int ret = anArray.compareValue(value, o2); if (ret != 0) { return ret; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java index c8650d0d7..a37b4dcec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java @@ -47,8 +47,7 @@ public final class ElFilter implements Filter { } protected boolean isMatch(T bean) { - for (int i = 0; i < matches.size(); i++) { - ElMatcher matcher = matches.get(i); + for (ElMatcher matcher : matches) { if (!matcher.isMatch(bean)) { return false; } @@ -235,8 +234,7 @@ public final class ElFilter implements Filter { ArrayList filterList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - T t = list.get(i); + for (T t : list) { if (isMatch(t)) { filterList.add(t); if (maxRows > 0 && filterList.size() >= maxRows) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java index dcb9a0c19..4d298ca4f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElPropertyChain.java @@ -193,8 +193,8 @@ public class ElPropertyChain implements ElPropertyValue { } public boolean isAssocProperty() { - for (int i = 0; i < chain.length; i++) { - if (chain[i].isAssocProperty()) { + for (ElPropertyValue aChain : chain) { + if (aChain.isAssocProperty()) { return true; } } @@ -233,8 +233,8 @@ public class ElPropertyChain implements ElPropertyValue { @Override public Object pathGet(Object bean) { - for (int i = 0; i < chain.length; i++) { - bean = chain[i].pathGet(bean); + for (ElPropertyValue aChain : chain) { + bean = aChain.pathGet(bean); if (bean == null) { return null; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java index a9b419c2c..e82fbd3c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -35,8 +35,8 @@ public class ArrayContainsExpression extends AbstractExpression { } else { context.startBoolMustNot(); } - for (int i = 0; i < values.length; i++) { - context.writeEqualTo(propName, values[i]); + for (Object value : values) { + context.writeEqualTo(propName, value); } context.endBool(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java index f6060a649..9bb9041e9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -124,8 +124,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { list = buildExpressions(desc); if (list != null) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } } @@ -173,8 +173,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -184,8 +184,7 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < list.size(); i++) { - SpiExpression item = list.get(i); + for (SpiExpression item : list) { item.addBindValues(request); } } @@ -218,8 +217,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExampleExpression.class); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -229,8 +228,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio @Override public int queryBindHash() { int hc = DefaultExampleExpression.class.getName().hashCode(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index 8b28e2706..2da0b3c90 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -139,11 +139,10 @@ public class DefaultExpressionList implements SpiExpressionList { if (implicitBool) { context.startBoolGroupList(Junction.Type.SHOULD); } - for (int i = 0; i < size; i++) { - SpiExpression expr = list.get(i); + for (SpiExpression expr : list) { if (explicitBool) { try { - ((SpiJunction)expr).writeDocQueryJunction(context); + ((SpiJunction) expr).writeDocQueryJunction(context); } catch (ClassCastException e) { throw new IllegalStateException("The top level text() expressions should be all be 'Must', 'Should' or 'Must Not' or none of them should be.", e); } @@ -177,8 +176,8 @@ public class DefaultExpressionList implements SpiExpressionList { if (idEquals != null) { idEquals.writeDocQuery(context); } - for (int i = 0; i < size; i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } @@ -226,15 +225,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins) { - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, whereManyJoins); + for (SpiExpression aList : list) { + aList.containsMany(desc, whereManyJoins); } } @Override public void validate(SpiExpressionValidation validation) { - for (int i = 0; i < list.size(); i++) { - list.get(i).validate(validation); + for (SpiExpression aList : list) { + aList.validate(validation); } } @@ -480,15 +479,15 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @Override public void prepareExpression(BeanQueryRequest request) { - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -499,8 +498,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(DefaultExpressionList.class); - for (int i = 0, size = list.size(); i < size; i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -510,8 +509,8 @@ public class DefaultExpressionList implements SpiExpressionList { @Override public int queryBindHash() { int hash = DefaultExpressionList.class.getName().hashCode(); - for (int i = 0, size = list.size(); i < size; i++) { - hash = hash * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hash = hash * 92821 + aList.queryBindHash(); } return hash; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java index 3c983bc6d..027718b4b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java @@ -63,8 +63,7 @@ public class DefaultExpressionRequest implements SpiExpressionRequest { * Bind the values from the underlying expression list. */ public void bind(DataBind dataBind) throws SQLException { - for (int i = 0; i < bindValues.size(); i++) { - Object bindValue = bindValues.get(i); + for (Object bindValue : bindValues) { binder.bindObject(dataBind, bindValue); } if (bindLog != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java index aa1abcfe7..9f43cbb77 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -98,8 +98,8 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java index c74767df2..d39931aea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdExpression.java @@ -50,8 +50,8 @@ class IdExpression extends NonPrepareExpression implements SpiExpression { // into an array of the underlying scalar field values DefaultExpressionRequest r = (DefaultExpressionRequest) request; Object[] bindIdValues = r.getBeanDescriptor().getBindIdValues(value); - for (int i = 0; i < bindIdValues.length; i++) { - request.addBindValue(bindIdValues[i]); + for (Object bindIdValue : bindIdValues) { + request.addBindValue(bindIdValue); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java index 3c153b9ad..2b329000a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IdInExpression.java @@ -50,8 +50,8 @@ public class IdInExpression extends NonPrepareExpression { BeanDescriptor descriptor = r.getBeanDescriptor(); IdBinder idBinder = descriptor.getIdBinder(); - for (int i = 0; i < idList.size(); i++) { - idBinder.addIdInBindValue(request, idList.get(i)); + for (Object anIdList : idList) { + idBinder.addIdInBindValue(request, anIdList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 682fdfcc6..7222d3372 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -59,16 +59,16 @@ class InExpression extends AbstractExpression { prop = null; } - for (int i = 0; i < bindValues.length; i++) { + for (Object bindValue : bindValues) { if (prop == null) { - request.addBindValue(bindValues[i]); + request.addBindValue(bindValue); } else { // extract the id values from the bean - Object[] ids = prop.getAssocIdValues((EntityBean) bindValues[i]); + Object[] ids = prop.getAssocIdValues((EntityBean) bindValue); if (ids != null) { - for (int j = 0; j < ids.length; j++) { - request.addBindValue(ids[j]); + for (Object id : ids) { + request.addBindValue(id); } } } @@ -120,8 +120,8 @@ class InExpression extends AbstractExpression { @Override public int queryBindHash() { int hc = 92821; - for (int i = 0; i < bindValues.length; i++) { - hc = 92821 * hc + bindValues[i].hashCode(); + for (Object bindValue : bindValues) { + hc = 92821 * hc + bindValue.hashCode(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java index ba1bd8857..47abc862f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java @@ -91,8 +91,8 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor @Override public void addBindValues(SpiExpressionRequest request) { - for (int i = 0; i < bindParams.size(); i++) { - request.addBindValue(bindParams.get(i)); + for (Object bindParam : bindParams) { + request.addBindValue(bindParam); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index b7556fd96..657ea35c0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -91,8 +91,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void writeDocQuery(DocQueryContext context) throws IOException { context.startBool(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBool(); } @@ -101,8 +101,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void writeDocQueryJunction(DocQueryContext context) throws IOException { context.startBoolGroupList(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).writeDocQuery(context); + for (SpiExpression aList : list) { + aList.writeDocQuery(context); } context.endBoolGroupList(); } @@ -125,8 +125,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression manyWhereJoin.setRequireOuterJoins(true); } - for (int i = 0; i < list.size(); i++) { - list.get(i).containsMany(desc, manyWhereJoin); + for (SpiExpression aList : list) { + aList.containsMany(desc, manyWhereJoin); } if (type == Type.OR && !parentOuterJoins) { // restore state to not forcing outer joins @@ -155,8 +155,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void addBindValues(SpiExpressionRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).addBindValues(request); + for (SpiExpression aList : list) { + aList.addBindValues(request); } } @@ -182,8 +182,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression @Override public void prepareExpression(BeanQueryRequest request) { List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).prepareExpression(request); + for (SpiExpression aList : list) { + aList.prepareExpression(request); } } @@ -194,8 +194,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public void queryPlanHash(HashQueryPlanBuilder builder) { builder.add(JunctionExpression.class).add(type); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - list.get(i).queryPlanHash(builder); + for (SpiExpression aList : list) { + aList.queryPlanHash(builder); } } @@ -203,8 +203,8 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression public int queryBindHash() { int hc = JunctionExpression.class.getName().hashCode(); List list = exprList.internalList(); - for (int i = 0; i < list.size(); i++) { - hc = hc * 92821 + list.get(i).queryBindHash(); + for (SpiExpression aList : list) { + hc = hc * 92821 + aList.queryBindHash(); } return hc; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java index 3632086cf..d0f065596 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/RawExpression.java @@ -43,8 +43,8 @@ class RawExpression extends NonPrepareExpression { @Override public void addBindValues(SpiExpressionRequest request) { if (values != null) { - for (int i = 0; i < values.length; i++) { - request.addBindValue(values[i]); + for (Object value : values) { + request.addBindValue(value); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java index c50681faa..fbe082f99 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java @@ -64,8 +64,8 @@ public class SimpleExpression extends AbstractValueExpression { if (prop.isAssocId()) { Object[] ids = prop.getAssocIdValues((EntityBean) value()); if (ids != null) { - for (int i = 0; i < ids.length; i++) { - request.addBindValue(ids[i]); + for (Object id : ids) { + request.addBindValue(id); } } return; diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java index e6521da23..78496bc23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java @@ -11,22 +11,22 @@ public class Str { * Append strings together. */ public static String add(String s0, String s1, String ... args) { - + // determine a decent buffer size int len = 16 + s0.length() + s1.length(); - for (int i = 0; i < args.length; i++) { - len += args[i].length(); + for (String arg1 : args) { + len += arg1.length(); } - - // append all the strings into the buffer + + // append all the strings into the buffer StringBuilder sb = new StringBuilder(len); sb.append(s0).append(s1); - for (int i = 0; i < args.length; i++) { - sb.append(args[i]); + for (String arg : args) { + sb.append(arg); } return sb.toString(); } - + /** * Append two strings together. */ @@ -35,5 +35,5 @@ public class Str { StringBuilder sb = new StringBuilder(s0.length() + s1.length() + 5); return sb.append(s0).append(s1).toString(); } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java index eb5e6707b..31159abad 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContext.java @@ -169,8 +169,8 @@ public class DLoadContext implements LoadContext { } int maxBatch = 0; - for (int i = 0; i < secQuery.size(); i++) { - int batchSize = secQuery.get(i).getQueryFetchBatch(); + for (OrmQueryProperties aSecQuery : secQuery) { + int batchSize = aSecQuery.getQueryFetchBatch(); if (batchSize == 0) { batchSize = defaultQueryBatch; } @@ -185,8 +185,8 @@ public class DLoadContext implements LoadContext { public void executeSecondaryQueries(OrmQueryRequest parentRequest, boolean forEach) { if (secQuery != null) { - for (int i = 0; i < secQuery.size(); i++) { - LoadSecondaryQuery load = getLoadSecondaryQuery(secQuery.get(i).getPath()); + for (OrmQueryProperties aSecQuery : secQuery) { + LoadSecondaryQuery load = getLoadSecondaryQuery(aSecQuery.getPath()); load.loadSecondaryQuery(parentRequest, forEach); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index e4efe2cb7..07927bfef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -248,8 +248,8 @@ public final class BatchControl { if (transaction.isLogSummary()) { transaction.logSummary("BatchControl flush " + Arrays.toString(bsArray)); } - for (int i = 0; i < bsArray.length; i++) { - bsArray[i].executeNow(); + for (BatchedBeanHolder aBsArray : bsArray) { + aBsArray.executeNow(); } if (resetTop) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java index ed5be8019..999bf4ef8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmt.java @@ -93,8 +93,8 @@ public class BatchedPstmt { } private void postExecute() { - for (int i = 0; i < list.size(); i++) { - list.get(i).postExecute(); + for (BatchPostExecute aList : list) { + aList.postExecute(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java index f9e329562..3e46b87fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java @@ -74,9 +74,7 @@ public class Binder { String logPrefix = ""; ArrayList list = bindValues.values(); - for (int i = 0; i < list.size(); i++) { - BindValues.Value bindValue = list.get(i); - + for (BindValues.Value bindValue : list) { Object val = bindValue.getValue(); int dt = bindValue.getDbType(); bindObject(dataBind, val, dt); @@ -136,9 +134,7 @@ public class Binder { // the iterator is assumed to be in the correct order Object value = null; try { - for (int i = 0; i < list.size(); i++) { - - BindParams.Param param = list.get(i); + for (BindParams.Param param : list) { if (param.isOutParam() && cstmt != null) { cstmt.registerOutParameter(dataBind.nextPos(), param.getType()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 4c035aa9c..402fdd50a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -197,7 +197,7 @@ public final class DefaultPersister implements Persister { for (T draftBean: draftBeans) { T liveBean = draftHandler.publishToDestinationBean(draftBean); livePublish.add(liveBean); - + // reset @DraftDirty and @DraftReset properties draftHandler.resetDraft(draftBean); @@ -557,8 +557,8 @@ public final class DefaultPersister implements Persister { } private void deleteList(List beanList, Transaction t, boolean softDelete) { - for (int i = 0; i < beanList.size(); i++) { - deleteRecurse((EntityBean) beanList.get(i), t, softDelete); + for (Object aBeanList : beanList) { + deleteRecurse((EntityBean) aBeanList, t, softDelete); } } @@ -634,15 +634,15 @@ public final class DefaultPersister implements Persister { if (t.isPersistCascade()) { // OneToOne exported side with delete cascade BeanPropertyAssocOne[] expOnes = descriptor.propertiesOneExportedDelete(); - for (int i = 0; i < expOnes.length; i++) { - BeanDescriptor targetDesc = expOnes[i].getTargetDescriptor(); + for (BeanPropertyAssocOne expOne : expOnes) { + BeanDescriptor targetDesc = expOne.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { - SqlUpdate sqlDelete = expOnes[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = expOne.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { - List childIds = expOnes[i].findIdsByParentId(id, idList, t); + List childIds = expOne.findIdsByParentId(id, idList, t); deleteChildrenById(t, targetDesc, childIds, softDelete); } } @@ -650,17 +650,17 @@ public final class DefaultPersister implements Persister { // OneToMany's with delete cascade BeanPropertyAssocMany[] manys = descriptor.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - BeanDescriptor targetDesc = manys[i].getTargetDescriptor(); + for (BeanPropertyAssocMany many : manys) { + BeanDescriptor targetDesc = many.getTargetDescriptor(); // only cascade soft deletes when supported by target if (!softDelete || targetDesc.isSoftDelete()) { if (!softDelete && targetDesc.isDeleteByStatement()) { // we can just delete children with a single statement - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); executeSqlUpdate(sqlDelete, t); } else { // we need to fetch the Id's to delete (recurse or notify L2 cache) - List childIds = manys[i].findIdsByParentId(id, idList, t, null); + List childIds = many.findIdsByParentId(id, idList, t, null); if (!childIds.isEmpty()) { delete(targetDesc, null, childIds, t, softDelete); } @@ -672,10 +672,10 @@ public final class DefaultPersister implements Persister { if (!softDelete) { // ManyToMany's ... delete from intersection table BeanPropertyAssocMany[] manys = descriptor.propertiesManyToMany(); - for (int i = 0; i < manys.length; i++) { - SqlUpdate sqlDelete = manys[i].deleteByParentId(id, idList); + for (BeanPropertyAssocMany many : manys) { + SqlUpdate sqlDelete = many.deleteByParentId(id, idList); if (t.isLogSummary()) { - t.logSummary("-- Deleting intersection table entries: " + manys[i].getFullBeanName()); + t.logSummary("-- Deleting intersection table entries: " + many.getFullBeanName()); } executeSqlUpdate(sqlDelete, t); } @@ -720,8 +720,8 @@ public final class DefaultPersister implements Persister { Query q = server.createQuery(desc.getBeanType()); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propImportDelete.length; i++) { - sb.append(propImportDelete[i].getName()).append(","); + for (BeanPropertyAssocOne aPropImportDelete : propImportDelete) { + sb.append(aPropImportDelete.getName()).append(","); } q.setAutoTune(false); q.select(sb.toString()); @@ -786,9 +786,7 @@ public final class DefaultPersister implements Persister { // exported ones with cascade save BeanPropertyAssocOne[] expOnes = desc.propertiesOneExportedSave(); - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; - + for (BeanPropertyAssocOne prop : expOnes) { // check for partial beans if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(parentBean); @@ -805,12 +803,12 @@ public final class DefaultPersister implements Persister { // many's with cascade save BeanPropertyAssocMany[] manys = desc.propertiesManySave(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { // check that property is loaded and collection should be cascaded to - if (request.isLoadedProperty(manys[i]) && !manys[i].isSkipSaveBeanCollection(parentBean, insertedParent)) { - saveMany(new SaveManyPropRequest(insertedParent, manys[i], parentBean, request), insertMode); + if (request.isLoadedProperty(many) && !many.isSkipSaveBeanCollection(parentBean, insertedParent)) { + saveMany(new SaveManyPropRequest(insertedParent, many, parentBean, request), insertMode); if (!insertedParent) { - request.addUpdatedManyProperty(manys[i]); + request.addUpdatedManyProperty(many); } } } @@ -916,7 +914,7 @@ public final class DefaultPersister implements Persister { } } else { if (saveMany.isModifyListenMode()) { - // delete any removed beans via private owned. Needs to occur before + // delete any removed beans via private owned. Needs to occur before // a 'deleteMissingChildren' statement occurs removeAssocManyPrivateOwned(saveMany); } @@ -1188,14 +1186,13 @@ public final class DefaultPersister implements Persister { if (expOnes.length > 0) { DeleteUnloadedForeignKeys unloaded = null; - for (int i = 0; i < expOnes.length; i++) { - BeanPropertyAssocOne prop = expOnes[i]; + for (BeanPropertyAssocOne prop : expOnes) { // for soft delete check cascade type also supports soft delete if (!softDelete || prop.getTargetDescriptor().isSoftDelete()) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(parentBean); if (detailBean != null) { - deleteRecurse((EntityBean)detailBean, t, softDelete); + deleteRecurse((EntityBean) detailBean, t, softDelete); } } else { if (unloaded == null) { @@ -1213,19 +1210,19 @@ public final class DefaultPersister implements Persister { // Many's with delete cascade BeanPropertyAssocMany[] manys = desc.propertiesManyDelete(); - for (int i = 0; i < manys.length; i++) { - if (manys[i].isManyToMany()) { + for (BeanPropertyAssocMany many : manys) { + if (many.isManyToMany()) { if (!softDelete) { // delete associated rows from intersection table (but not during soft delete) - deleteAssocManyIntersection(parentBean, manys[i], t, request.isPublish()); + deleteAssocManyIntersection(parentBean, many, t, request.isPublish()); } } else { - if (ModifyListenMode.REMOVALS.equals(manys[i].getModifyListenMode())) { + if (ModifyListenMode.REMOVALS.equals(many.getModifyListenMode())) { // PrivateOwned ... // if soft delete then check target also supports soft delete - if (!softDelete || manys[i].getTargetDescriptor().isSoftDelete()) { - Object details = manys[i].getValue(parentBean); + if (!softDelete || many.getTargetDescriptor().isSoftDelete()) { + Object details = many.getValue(parentBean); if (details instanceof BeanCollection) { Set modifyRemovals = ((BeanCollection) details).getModifyRemovals(); if (modifyRemovals != null && !modifyRemovals.isEmpty()) { @@ -1233,7 +1230,7 @@ public final class DefaultPersister implements Persister { // delete the orphans that have been removed from the collection for (Object detail : modifyRemovals) { EntityBean detailBean = (EntityBean) detail; - if (manys[i].hasId(detailBean)) { + if (many.hasId(detailBean)) { deleteRecurse(detailBean, t, softDelete); } } @@ -1242,7 +1239,7 @@ public final class DefaultPersister implements Persister { } } - deleteManyDetails(t, desc, parentBean, manys[i], null, softDelete); + deleteManyDetails(t, desc, parentBean, many, null, softDelete); } } @@ -1314,16 +1311,14 @@ public final class DefaultPersister implements Persister { // imported ones with save cascade BeanPropertyAssocOne[] ones = desc.propertiesOneImportedSave(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; - + for (BeanPropertyAssocOne prop : ones) { // check for partial objects if (request.isLoadedProperty(prop)) { EntityBean detailBean = prop.getValueAsEntityBean(request.getEntityBean()); if (detailBean != null - && !prop.isSaveRecurseSkippable(detailBean) - && !prop.isReference(detailBean) - && !request.isParent(detailBean)) { + && !prop.isSaveRecurseSkippable(detailBean) + && !prop.isReference(detailBean) + && !request.isParent(detailBean)) { SpiTransaction t = request.getTransaction(); t.depth(-1); saveRecurse(detailBean, t, null, insertMode, request.isPublish()); @@ -1342,14 +1337,14 @@ public final class DefaultPersister implements Persister { DeleteUnloadedForeignKeys fkeys = null; BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - if (!request.isLoadedProperty(ones[i])) { + for (BeanPropertyAssocOne one : ones) { + 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) if (fkeys == null) { fkeys = new DeleteUnloadedForeignKeys(server, request); } - fkeys.add(ones[i]); + fkeys.add(one); } } @@ -1362,8 +1357,7 @@ public final class DefaultPersister implements Persister { private void deleteAssocOne(PersistRequestBean request) { BeanPropertyAssocOne[] ones = request.getBeanDescriptor().propertiesOneImportedDelete(); - for (int i = 0; i < ones.length; i++) { - BeanPropertyAssocOne prop = ones[i]; + for (BeanPropertyAssocOne prop : ones) { if (request.isLoadedProperty(prop)) { Object detailBean = prop.getValue(request.getEntityBean()); if (detailBean != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java index 175695a21..4d2b97b50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DeleteUnloadedForeignKeys.java @@ -59,8 +59,8 @@ class DeleteUnloadedForeignKeys { Object id = request.getBeanId(); StringBuilder sb = new StringBuilder(30); - for (int i = 0; i < propList.size(); i++) { - sb.append(propList.get(i).getName()).append(","); + for (BeanPropertyAssocOne aPropList : propList) { + sb.append(aPropList.getName()).append(","); } // run query in a separate persistence context @@ -84,8 +84,7 @@ class DeleteUnloadedForeignKeys { */ void deleteCascade() { - for (int i = 0; i < propList.size(); i++) { - BeanPropertyAssocOne prop = propList.get(i); + for (BeanPropertyAssocOne prop : propList) { Object detailBean = prop.getValue(beanWithForeignKeys); // if bean exists with a unique id then delete it diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java index ebfb52d5c..39f00c1a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java @@ -34,8 +34,8 @@ public class BindableCompound implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (BindableProperty item : items) { + item.dmlAppend(request); } } @@ -51,8 +51,8 @@ public class BindableCompound implements Bindable { Object valueObject = compound.getValue(bean); // bind each of the underlying scalar values for this compound type - for (int i = 0; i < items.length; i++) { - items[i].dmlBindObject(bindRequest, valueObject); + for (BindableProperty item : items) { + item.dmlBindObject(bindRequest, valueObject); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java index 29d5b9e70..b1b707f8b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java @@ -34,8 +34,8 @@ public class BindableEmbedded implements Bindable { public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } @@ -50,14 +50,14 @@ public class BindableEmbedded implements Bindable { // get the embedded bean EntityBean embBean = (EntityBean) embProp.getValue(bean); if (embBean == null) { - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, null); + for (Bindable item : items) { + item.dmlBind(bindRequest, null); } } else { //EntityBeanIntercept ebi = embBean._ebean_getIntercept(); - for (int i = 0; i < items.length; i++) { + for (Bindable item : items) { //if (ebi.isLoadedProperty(props[i].getPropertyIndex())) { - items[i].dmlBind(bindRequest, embBean); + item.dmlBind(bindRequest, embBean); //} } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java index b07be39d2..5466754bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java @@ -64,18 +64,18 @@ public final class BindableIdEmbedded implements BindableId { EntityBean idValue = (EntityBean) embId.getValue(bean); - for (int i = 0; i < props.length; i++) { + for (BeanProperty prop : props) { - Object value = props[i].getValue(idValue); - request.bind(value, props[i]); + Object value = prop.getValue(idValue); + request.bind(value, prop); } request.setIdValue(idValue); } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < props.length; i++) { - request.appendColumn(props[i].getDbColumn()); + for (BeanProperty prop : props) { + request.appendColumn(prop.getDbColumn()); } } @@ -94,8 +94,8 @@ public final class BindableIdEmbedded implements BindableId { EntityBean newId = (EntityBean) embId.createEmbeddedId(); // populate it from the assoc one id values... - for (int i = 0; i < matches.length; i++) { - matches[i].populate(bean, newId); + for (MatchedImportedProperty matche : matches) { + matche.populate(bean, newId); } // support PropertyChangeSupport diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index dc7c743e2..79f8fbc03 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -43,23 +43,23 @@ public class BindableList implements Bindable { } public void addToUpdate(PersistRequestBean request, List list) { - for (int i = 0; i < items.length; i++) { - items[i].addToUpdate(request, list); + for (Bindable item : items) { + item.addToUpdate(request, list); } } public void dmlAppend(GenerateDmlRequest request) { - for (int i = 0; i < items.length; i++) { - items[i].dmlAppend(request); + for (Bindable item : items) { + item.dmlAppend(request); } } public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException { - for (int i = 0; i < items.length; i++) { - items[i].dmlBind(bindRequest, bean); + for (Bindable item : items) { + item.dmlBind(bindRequest, bean); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java index 20e21c1e1..e3dc4ad01 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java @@ -21,21 +21,21 @@ public class FactoryAssocOnes { BeanPropertyAssocOne[] ones = desc.propertiesOneImported(); - for (int i = 0; i < ones.length; i++) { - if (!ones[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne one : ones) { + if (!one.isImportedPrimaryKey()) { switch (mode) { case INSERT: - if (!ones[i].isInsertable()) { + if (!one.isInsertable()) { continue; } break; case UPDATE: - if (!ones[i].isUpdateable()) { + if (!one.isUpdateable()) { continue; } break; } - list.add(new BindableAssocOne(ones[i])); + list.add(new BindableAssocOne(one)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index e1378423b..57ea2f4c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -31,13 +31,13 @@ public class FactoryBaseProperties { add(desc.propertiesBaseScalar(), list, mode, withLobs); BeanPropertyCompound[] compoundProps = desc.propertiesBaseCompound(); - for (int i = 0; i < compoundProps.length; i++) { - BeanProperty[] props = compoundProps[i].getScalarProperties(); + for (BeanPropertyCompound compoundProp : compoundProps) { + BeanProperty[] props = compoundProp.getScalarProperties(); List newList = new ArrayList<>(props.length); addCompound(props, newList, mode, withLobs); - BindableCompound compoundBindable = new BindableCompound(compoundProps[i], newList); + BindableCompound compoundBindable = new BindableCompound(compoundProp, newList); list.add(compoundBindable); } @@ -45,8 +45,8 @@ public class FactoryBaseProperties { private void add(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } @@ -55,8 +55,8 @@ public class FactoryBaseProperties { private void addCompound(BeanProperty[] props, List list, DmlMode mode, boolean withLobs) { - for (int i = 0; i < props.length; i++) { - BindableProperty item = (BindableProperty) factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + BindableProperty item = (BindableProperty) factoryProperty.create(prop, mode, withLobs); if (item != null) { list.add(item); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java index 45d1e165e..52beeccc4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java @@ -26,20 +26,20 @@ public class FactoryEmbedded { BeanPropertyAssocOne[] embedded = desc.propertiesEmbedded(); - for (int j = 0; j < embedded.length; j++) { + for (BeanPropertyAssocOne anEmbedded : embedded) { - BeanProperty[] props = embedded[j].getProperties(); + BeanProperty[] props = anEmbedded.getProperties(); List bindList = new ArrayList<>(props.length); - for (int i = 0; i < props.length; i++) { - Bindable item = factoryProperty.create(props[i], mode, withLobs); + for (BeanProperty prop : props) { + Bindable item = factoryProperty.create(prop, mode, withLobs); if (item != null) { bindList.add(item); } } - list.add(new BindableEmbedded(embedded[j], bindList)); + list.add(new BindableEmbedded(anEmbedded, bindList)); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java index 9e4da8a12..a95505f2c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/MatchedImportedProperty.java @@ -66,14 +66,14 @@ class MatchedImportedProperty { String dbColumn = prop.getDbColumn(); BeanPropertyAssocOne[] assocOnes = desc.propertiesOne(); - for (int i = 0; i < assocOnes.length; i++) { - if (assocOnes[i].isImportedPrimaryKey()) { + for (BeanPropertyAssocOne assocOne1 : assocOnes) { + if (assocOne1.isImportedPrimaryKey()) { // search using the ImportedId from the assoc one - BeanProperty foreignMatch = assocOnes[i].getImportedId().findMatchImport(dbColumn); + BeanProperty foreignMatch = assocOne1.getImportedId().findMatchImport(dbColumn); if (foreignMatch != null) { - return new MatchedImportedProperty(assocOnes[i], foreignMatch, prop); + return new MatchedImportedProperty(assocOne1, foreignMatch, prop); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java index 93cf4d102..7c1c86c41 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java @@ -142,8 +142,8 @@ public class CQueryPlan { DataBind bindEncryptedProperties(PreparedStatement stmt, Connection conn) throws SQLException { DataBind dataBind = new DataBind(dataTimeZone, stmt, conn); if (encryptedProps != null) { - for (int i = 0; i < encryptedProps.length; i++) { - String key = encryptedProps[i].getEncryptKey().getStringValue(); + for (BeanProperty encryptedProp : encryptedProps) { + String key = encryptedProp.getEncryptKey().getStringValue(); dataBind.setString(key); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index e53bfc904..f727c2987 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -219,20 +219,20 @@ public class SqlTreeBuilder { List myJoinList = new ArrayList<>(); BeanPropertyAssocOne[] ones = desc.propertiesOne(); - for (int i = 0; i < ones.length; i++) { - String propPrefix = SplitName.add(prefix, ones[i].getName()); + for (BeanPropertyAssocOne one : ones) { + String propPrefix = SplitName.add(prefix, one.getName()); if (isIncludeBean(propPrefix)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, ones[i], ones[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, one, one.getTargetDescriptor(), myJoinList); } } BeanPropertyAssocMany[] manys = desc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { - String propPrefix = SplitName.add(prefix, manys[i].getName()); - if (isIncludeMany(propPrefix, manys[i])) { + for (BeanPropertyAssocMany many : manys) { + String propPrefix = SplitName.add(prefix, many.getName()); + if (isIncludeMany(propPrefix, many)) { selectIncludes.add(propPrefix); - buildSelectChain(propPrefix, manys[i], manys[i].getTargetDescriptor(), myJoinList); + buildSelectChain(propPrefix, many, many.getTargetDescriptor(), myJoinList); } } @@ -458,13 +458,13 @@ public class SqlTreeBuilder { selectProps.add(desc.propertiesEmbedded()); BeanPropertyAssocOne[] propertiesOne = desc.propertiesOne(); - for (int i = 0; i < propertiesOne.length; i++) { + for (BeanPropertyAssocOne aPropertiesOne : propertiesOne) { //noinspection StatementWithEmptyBody - if (queryProps != null && queryProps.isIncludedBeanJoin(propertiesOne[i].getName())) { + if (queryProps != null && queryProps.isIncludedBeanJoin(aPropertiesOne.getName())) { // if it is a joined bean... then don't add the property // as it will have its own entire Node in the SqlTree } else { - selectProps.add(propertiesOne[i]); + selectProps.add(aPropertiesOne); } } @@ -576,8 +576,8 @@ public class SqlTreeBuilder { Arrays.sort(extras); // reverse order so get the leaves first... - for (int i = 0; i < extras.length; i++) { - createExtraJoin(extras[i]); + for (String extra : extras) { + createExtraJoin(extra); } return rootRegister.values(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java index c739fa3f6..b5c2b1332 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -143,8 +143,8 @@ class SqlTreeNodeBean implements SqlTreeNode { BeanPropertyAssocMany[] manys = desc.propertiesMany(); HashMap m = new HashMap<>(); - for (int i = 0; i < manys.length; i++) { - String name = manys[i].getName(); + for (BeanPropertyAssocMany many : manys) { + String name = many.getName(); m.put(name, getPath(prefix, name)); } @@ -167,14 +167,14 @@ class SqlTreeNodeBean implements SqlTreeNode { } idBinder.buildRawSqlSelectChain(prefix, selectChain); } - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].buildRawSqlSelectChain(prefix, selectChain); + for (BeanProperty property : properties) { + property.buildRawSqlSelectChain(prefix, selectChain); } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].buildRawSqlSelectChain(selectChain); + aChildren.buildRawSqlSelectChain(selectChain); } } @@ -269,20 +269,20 @@ class SqlTreeNodeBean implements SqlTreeNode { if (inheritInfo == null) { // normal behavior with no inheritance - for (int i = 0, x = properties.length; i < x; i++) { - properties[i].load(sqlBeanLoad); + for (BeanProperty property : properties) { + property.load(sqlBeanLoad); } } else { // take account of inheritance and due to subclassing approach // need to get a 'local' version of the property - for (int i = 0, x = properties.length; i < x; i++) { + for (BeanProperty property : properties) { // get a local version of the BeanProperty - BeanProperty p = localDesc.getBeanProperty(properties[i].getName()); + BeanProperty p = localDesc.getBeanProperty(property.getName()); if (p != null) { p.load(sqlBeanLoad); } else { - properties[i].loadIgnore(ctx); + property.loadIgnore(ctx); } } } @@ -295,10 +295,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } // recursively continue reading... - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].load(ctx, localBean, contextBean); + aChildren.load(ctx, localBean, contextBean); } if (!lazyLoadMany && localBean != null) { @@ -367,17 +367,17 @@ class SqlTreeNodeBean implements SqlTreeNode { // load the List/Set/Map proxy objects (deferred fetching of lists) BeanPropertyAssocMany[] manys = localDesc.propertiesMany(); - for (int i = 0; i < manys.length; i++) { + for (BeanPropertyAssocMany many : manys) { - if (fetchedMany == null || !fetchedMany.equals(manys[i])) { + if (fetchedMany == null || !fetchedMany.equals(many)) { // create a proxy for the many (deferred fetching) - BeanCollection ref = manys[i].createReferenceIfNull(localBean); + BeanCollection ref = many.createReferenceIfNull(localBean); if (ref != null) { if (disableLazyLoad) { ref.setDisableLazyLoad(true); } if (!ref.isRegisteredWithLoadContext()) { - ctx.register(manys[i].getName(), ref); + ctx.register(many.getName(), ref); } } } @@ -392,9 +392,9 @@ class SqlTreeNodeBean implements SqlTreeNode { if (readId) { appendSelectId(ctx, idBinder.getBeanProperty()); } - for (int i = 0; i < properties.length; i++) { - if (!properties[i].isAggregation()) { - properties[i].appendSelect(ctx, subQuery); + for (BeanProperty property : properties) { + if (!property.isAggregation()) { + property.appendSelect(ctx, subQuery); } } ctx.popTableAlias(); @@ -427,10 +427,10 @@ class SqlTreeNodeBean implements SqlTreeNode { } appendSelect(ctx, subQuery, properties); - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // read each child... and let them set their // values back to this localBean - children[i].appendSelect(ctx, subQuery); + aChildren.appendSelect(ctx, subQuery); } ctx.popTableAlias(); @@ -446,8 +446,8 @@ class SqlTreeNodeBean implements SqlTreeNode { */ private void appendSelect(DbSqlContext ctx, boolean subQuery, BeanProperty[] props) { - for (int i = 0; i < props.length; i++) { - props[i].appendSelect(ctx, subQuery); + for (BeanProperty prop : props) { + prop.appendSelect(ctx, subQuery); } } @@ -480,10 +480,10 @@ class SqlTreeNodeBean implements SqlTreeNode { ctx.append(" ").append(ew).append(" "); } - for (int i = 0; i < children.length; i++) { + for (SqlTreeNode aChildren : children) { // recursively add to the where clause any // fixed predicates (extraWhere etc) - children[i].appendWhere(ctx); + aChildren.appendWhere(ctx); } } @@ -500,13 +500,13 @@ class SqlTreeNodeBean implements SqlTreeNode { // join and return SqlJoinType to use for child joins joinType = appendFromBaseTable(ctx, joinType); - for (int i = 0; i < properties.length; i++) { + for (BeanProperty property : properties) { // usually nothing... except for 1-1 Exported - properties[i].appendFrom(ctx, joinType); + property.appendFrom(ctx, joinType); } - for (int i = 0; i < children.length; i++) { - children[i].appendFrom(ctx, joinType); + for (SqlTreeNode aChildren : children) { + aChildren.appendFrom(ctx, joinType); } ctx.popTableAlias(); @@ -532,8 +532,8 @@ class SqlTreeNodeBean implements SqlTreeNode { if (intersectionAsOfTableAlias) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java index e5977e4a5..b605d51f2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java @@ -129,8 +129,7 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode { joinType = joinType.autoToOuter(); } - for (int i = 0; i < children.size(); i++) { - SqlTreeNodeExtraJoin child = children.get(i); + for (SqlTreeNodeExtraJoin child : children) { child.appendFrom(ctx, joinType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java index 9d03aae91..560709d35 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -36,8 +36,8 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { if (lazyLoadParent != null && lazyLoadParent.isManyToManyWithHistory()) { query.incrementAsOfTableCount(); } - for (int i = 0; i < children.length; i++) { - children[i].addAsOfTableAlias(query); + for (SqlTreeNode aChildren : children) { + aChildren.addAsOfTableAlias(query); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java index df298ab4a..c6c407541 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java @@ -40,8 +40,8 @@ public class SqlTreeProperties { public void add(BeanProperty[] props) { //noinspection ManualArrayToCollectionCopy - for (int i = 0; i < props.length; i++) { - propsList.add(props[i]); + for (BeanProperty prop : props) { + propsList.add(prop); } } @@ -107,4 +107,4 @@ public class SqlTreeProperties { } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 48f39d412..95516ee4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -413,15 +413,13 @@ public class DefaultOrmQuery implements SpiQuery { if (orderBy != null) { // remove any orderBy properties that relate to // paths of the secondary queries - for (int i = 0; i < queryJoins.size(); i++) { - OrmQueryProperties joinPath = queryJoins.get(i); - + for (OrmQueryProperties joinPath : queryJoins) { // loop through the orderBy properties and // move any ones related to the query join List properties = orderBy.getProperties(); Iterator it = properties.iterator(); while (it.hasNext()) { - OrderBy.Property property = it.next(); + Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())) { // remove this orderBy segment and // add it to the secondary join diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index a1c388355..234bfe5ef 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -208,8 +208,7 @@ public class OrmQueryDetail implements Serializable { // the list of secondary queries ArrayList props = new ArrayList<>(); - for (int i = 0; i < matchingPaths.size(); i++) { - String path = matchingPaths.get(i); + for (String path : matchingPaths) { OrmQueryProperties secQuery = fetchPaths.remove(path); if (secQuery != null) { props.add(secQuery); @@ -231,8 +230,8 @@ public class OrmQueryDetail implements Serializable { // Add the secondary queries as select properties // to the parent chunk to ensure the foreign keys // are included in the query - for (int i = 0; i < props.size(); i++) { - String path = props.get(i).getPath(); + for (OrmQueryProperties prop : props) { + String path = prop.getPath(); // split into parent and property String[] split = SplitName.split(path); // add property to parent chunk diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index e41534c31..c7cac78b5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -250,8 +250,7 @@ public class OrmQueryProperties implements Serializable { if (secondaryChildren != null) { int trimPath = path.length() + 1; - for (int i = 0; i < secondaryChildren.size(); i++) { - OrmQueryProperties p = secondaryChildren.get(i); + for (OrmQueryProperties p : secondaryChildren) { String path = p.getPath(); path = path.substring(trimPath); query.fetch(path, p.getProperties(), p.getFetchConfig()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index b6d475c53..6be8be81d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -120,8 +120,8 @@ class OrmQueryPropertiesParser { int count = 0; String temp; - for (int i = 0; i < res.length; i++) { - temp = res[i].trim(); + for (String re : res) { + temp = re.trim(); if (!temp.isEmpty()) { if (count > 0) { sb.append(","); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java index 3fe34fe90..a99acfec4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java @@ -218,26 +218,26 @@ public class TCsvReader implements CsvReader { } private void addPropertiesFromHeader(String[] line) { - for (int i = 0; i < line.length; i++) { - ElPropertyValue elProp = descriptor.getElGetValue(line[i]); - if (elProp == null) { - throw new TextException("Property [" + line[i] + "] not found"); - } + for (String aLine : line) { + ElPropertyValue elProp = descriptor.getElGetValue(aLine); + if (elProp == null) { + throw new TextException("Property [" + aLine + "] not found"); + } - if (Types.TIME == elProp.getJdbcType()) { - addProperty(line[i], TIME_PARSER); + if (Types.TIME == elProp.getJdbcType()) { + addProperty(aLine, TIME_PARSER); - } else if (isDateTimeType(elProp.getJdbcType())) { - addDateTime(line[i], null, null); + } else if (isDateTimeType(elProp.getJdbcType())) { + addDateTime(aLine, null, null); - } else if (elProp.isAssocProperty()) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); - String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); - addProperty(line[i] + "." + idProp); - } else { - addProperty(line[i]); - } - } + } else if (elProp.isAssocProperty()) { + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) elProp.getBeanProperty(); + String idProp = assocOne.getBeanDescriptor().getIdBinder().getIdProperty(); + addProperty(aLine + "." + idProp); + } else { + addProperty(aLine); + } + } } private boolean isDateTimeType(int t) { @@ -257,7 +257,7 @@ public class TCsvReader implements CsvReader { } return bean; - + } catch (RuntimeException e) { String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; throw new RuntimeException(msg, e); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java index aa01245af..f7713cd4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/WriteJson.java @@ -488,15 +488,15 @@ public class WriteJson implements JsonWriter { if (!isReferenceOnly()) { // render all the properties and invoke lazy loading if required BeanProperty[] props = desc.propertiesNonTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop1 : props) { + if (isIncludeProperty(prop1)) { + prop1.jsonWrite(writeJson, currentBean); } } props = desc.propertiesTransient(); - for (int j = 0; j < props.length; j++) { - if (isIncludeTransientProperty(props[j])) { - props[j].jsonWrite(writeJson, currentBean); + for (BeanProperty prop : props) { + if (isIncludeTransientProperty(prop)) { + prop.jsonWrite(writeJson, currentBean); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java index 03c6c344b..4bc583d9b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BeanPersistIds.java @@ -222,14 +222,12 @@ public class BeanPersistIds { beanDescriptor.queryCacheClear(); if (updateIds != null) { - for (int i = 0; i < updateIds.size(); i++) { - Object id = updateIds.get(i); + for (Object id : updateIds) { beanDescriptor.cacheHandleDeleteById(id); } } if (deleteIds != null) { - for (int i = 0; i < deleteIds.size(); i++) { - Object id = deleteIds.get(i); + for (Object id : deleteIds) { beanDescriptor.cacheHandleDeleteById(id); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java index ed56e9946..ca634cf73 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/BulkEventListenerMap.java @@ -55,8 +55,8 @@ public class BulkEventListenerMap { } private void process(BulkTableEvent event) { - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).process(event); + for (BulkTableEventListener listener : listeners) { + listener.process(event); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java index 3f00a02f0..20ed290a9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -31,8 +31,8 @@ public final class DeleteByIdMap { List idValues = deleteIds.getDeleteIds(); if (idValues != null) { d.queryCacheClear(changeSet); - for (int i = 0; i < idValues.size(); i++) { - d.cacheHandleDeleteById(idValues.get(i), changeSet); + for (Object idValue : idValues) { + d.cacheHandleDeleteById(idValue, changeSet); } } } @@ -61,8 +61,8 @@ public final class DeleteByIdMap { public void addList(BeanDescriptor desc, List idList) { BeanPersistIds r = getPersistIds(desc); - for (int i = 0; i < idList.size(); i++) { - r.addId(PersistRequest.Type.DELETE, (Serializable) idList.get(i)); + for (Object anIdList : idList) { + r.addId(PersistRequest.Type.DELETE, (Serializable) anIdList); } } @@ -89,11 +89,11 @@ public final class DeleteByIdMap { String queueId = desc.getDocStoreQueueId(); List idValues = deleteIds.getDeleteIds(); if (idValues != null) { - for (int i = 0; i < idValues.size(); i++) { + for (Object idValue : idValues) { if (queue) { - docStoreUpdates.queueDelete(queueId, idValues.get(i)); + docStoreUpdates.queueDelete(queueId, idValue); } else { - docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValues.get(i))); + docStoreUpdates.addDelete(new DocStoreDeleteEvent(desc, idValue)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java index cc4b2c0e6..8c52986c2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -171,8 +171,8 @@ public final class PostCommitProcessing { private void localPersistListenersNotify() { if (persistBeanRequests != null) { - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).notifyLocalPersistListener(); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.notifyLocalPersistListener(); } } TransactionEventTable eventTables = event.getEventTables(); @@ -191,8 +191,8 @@ public final class PostCommitProcessing { } BeanPersistIdMap m = new BeanPersistIdMap(); - for (int i = 0; i < persistBeanRequests.size(); i++) { - persistBeanRequests.get(i).addToPersistMap(m); + for (PersistRequestBean persistBeanRequest : persistBeanRequests) { + persistBeanRequest.addToPersistMap(m); } return m; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java index 77e72c59b..1983c3cd5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java @@ -49,8 +49,8 @@ public class RemoteTransactionEvent implements Runnable { public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { if (tableList != null) { - for (int i = 0; i < tableList.size(); i++) { - tableList.get(i).writeBinaryMessage(msgList); + for (TableIUD aTableList : tableList) { + aTableList.writeBinaryMessage(msgList); } } @@ -60,8 +60,8 @@ public class RemoteTransactionEvent implements Runnable { } } - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).writeBinaryMessage(msgList); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.writeBinaryMessage(msgList); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java index 68e477df7..9afe59a23 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/TransactionManager.java @@ -390,8 +390,7 @@ public class TransactionManager { List tableIUDList = remoteEvent.getTableIUDList(); if (tableIUDList != null) { - for (int i = 0; i < tableIUDList.size(); i++) { - TableIUD tableIUD = tableIUDList.get(i); + for (TableIUD tableIUD : tableIUDList) { beanDescriptorManager.cacheNotify(tableIUD); } } @@ -400,8 +399,8 @@ public class TransactionManager { // processes both Bean IUD and DeleteById List beanPersistList = remoteEvent.getBeanPersistList(); if (beanPersistList != null) { - for (int i = 0; i < beanPersistList.size(); i++) { - beanPersistList.get(i).notifyCacheAndListener(); + for (BeanPersistIds aBeanPersistList : beanPersistList) { + aBeanPersistList.notifyCacheAndListener(); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java index 7def927ec..24d23a5fa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundType.java @@ -87,8 +87,8 @@ public final class CtCompoundType implements ScalarDataReader { } public void loadIgnore(DataReader dataReader) { - for (int i = 0; i < propReaders.length; i++) { - propReaders[i].loadIgnore(dataReader); + for (ScalarDataReader propReader : propReaders) { + propReader.loadIgnore(dataReader); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 67fb843e3..ef5753f74 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -391,9 +391,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return recursiveCreateScalarDataReader(propertyType); } - for (int i = 0; i < customScalarTypes.size(); i++) { - ScalarType customScalarType = customScalarTypes.get(i); - + for (ScalarType customScalarType : customScalarTypes) { if (sqlType == customScalarType.getJdbcType() && (propertyType.equals(customScalarType.getType()))) { return customScalarType; @@ -623,10 +621,10 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { Map nameValueMap = new HashMap<>(); Field[] fields = enumType.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - EnumValue enumValue = fields[i].getAnnotation(EnumValue.class); + for (Field field : fields) { + EnumValue enumValue = field.getAnnotation(EnumValue.class); if (enumValue != null) { - nameValueMap.put(fields[i].getName(), enumValue.value()); + nameValueMap.put(field.getName(), enumValue.value()); if (integerType && !isIntegerType(enumValue.value())) { // will treat the values as strings integerType = false; @@ -653,11 +651,11 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { public ScalarType createEnumScalarType(Class> enumType) { Method[] methods = enumType.getMethods(); - for (int i = 0; i < methods.length; i++) { - DbEnumValue dbValue = methods[i].getAnnotation(DbEnumValue.class); + for (Method method : methods) { + DbEnumValue dbValue = method.getAnnotation(DbEnumValue.class); if (dbValue != null) { boolean integerValues = DbEnumType.INTEGER == dbValue.storage(); - return createEnumScalarTypeDbValue(enumType, methods[i], integerValues); + return createEnumScalarTypeDbValue(enumType, method, integerValues); } } @@ -677,12 +675,12 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { Map nameValueMap = new HashMap<>(); Enum[] enumConstants = enumType.getEnumConstants(); - for (int i = 0; i < enumConstants.length; i++) { + for (Enum enumConstant : enumConstants) { try { - Object value = method.invoke(enumConstants[i]); - nameValueMap.put(enumConstants[i].name(), value.toString()); + Object value = method.invoke(enumConstant); + nameValueMap.put(enumConstant.name(), value.toString()); } catch (Exception e) { - throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstants[i], e); + throw new IllegalArgumentException("Error trying to invoke DbEnumValue method on " + enumConstant, e); } } if (nameValueMap.isEmpty()) { @@ -737,8 +735,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { List>> foundTypes = bootupClasses.getScalarTypes(); - for (int i = 0; i < foundTypes.size(); i++) { - Class> cls = foundTypes.get(i); + for (Class> cls : foundTypes) { try { ScalarType scalarType; @@ -783,8 +780,8 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { List>> foundTypes = bootupClasses.getScalarConverters(); - for (int i = 0; i < foundTypes.size(); i++) { - Class cls = foundTypes.get(i); + for (Class> foundType : foundTypes) { + Class cls = foundType; try { Class[] paramTypes = TypeReflectHelper.getParams(cls, ScalarTypeConverter.class); @@ -818,9 +815,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { private void initialiseCompoundTypes(BootupClasses bootupClasses) { List>> compoundTypes = bootupClasses.getCompoundTypes(); - for (int j = 0; j < compoundTypes.size(); j++) { + for (Class> compoundType1 : compoundTypes) { - Class type = compoundTypes.get(j); + Class type = compoundType1; try { Class[] paramTypes = TypeReflectHelper.getParams(type, CompoundType.class); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java index 1712c6dfe..dbf2276fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumStandard.java @@ -49,8 +49,8 @@ public class ScalarTypeEnumStandard { LinkedHashSet values = new LinkedHashSet<>(); Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; values.add("'" + e.name() + "'"); } return values; @@ -61,8 +61,8 @@ public class ScalarTypeEnumStandard { int maxLen = 0; Object[] ea = enumType.getEnumConstants(); - for (int i = 0; i < ea.length; i++) { - Enum e = (Enum) ea[i]; + for (Object anEa : ea) { + Enum e = (Enum) anEa; maxLen = Math.max(maxLen, e.name().length()); } @@ -130,8 +130,8 @@ public class ScalarTypeEnumStandard { public Set getDbCheckConstraintValues() { LinkedHashSet values = new LinkedHashSet<>(); - for (int i = 0; i < enumArray.length; i++) { - Enum e = (Enum) enumArray[i]; + for (Object anEnumArray : enumArray) { + Enum e = (Enum) anEnumArray; values.add(Integer.toString(e.ordinal())); } return values; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java b/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java index 90bdab8c6..0504961d2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/TypeReflectHelper.java @@ -27,8 +27,7 @@ public class TypeReflectHelper { private static Type[] getParamType(Class cls, Class matchRawType) { Type[] gis = cls.getGenericInterfaces(); - for (int i = 0; i < gis.length; i++) { - Type type = gis[i]; + for (Type type : gis) { if (type instanceof ParameterizedType) { ParameterizedType paramType = (ParameterizedType) type; Type rawType = paramType.getRawType(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java index 24b5a3cd8..b491511ae 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/CheckImmutable.java @@ -39,11 +39,11 @@ public class CheckImmutable { // find the constructor with the most number of parameters Constructor[] constructors = cls.getConstructors(); - for (int i = 0; i < constructors.length; i++) { - Class[] parameterTypes = constructors[i].getParameterTypes(); + for (Constructor constructor : constructors) { + Class[] parameterTypes = constructor.getParameterTypes(); if (parameterTypes.length > maxLength) { maxLength = parameterTypes.length; - chosen = constructors[i]; + chosen = constructor; } } @@ -90,14 +90,14 @@ public class CheckImmutable { // Check all fields defined in the class for type and if they are final Field[] objFields = cls.getDeclaredFields(); - for (int i = 0; i < objFields.length; i++) { - if (!Modifier.isStatic(objFields[i].getModifiers())) { - if (!Modifier.isFinal(objFields[i].getModifiers())) { - res.setReasonNotImmutable("Non final field " + cls + "." + objFields[i].getName()); + for (Field objField : objFields) { + if (!Modifier.isStatic(objField.getModifiers())) { + if (!Modifier.isFinal(objField.getModifiers())) { + res.setReasonNotImmutable("Non final field " + cls + "." + objField.getName()); return false; } - if (!isImmutable(objFields[i].getType(), res)) { - res.setReasonNotImmutable("Non Immutable field type " + objFields[i].getType()); + if (!isImmutable(objField.getType(), res)) { + res.setReasonNotImmutable("Non Immutable field type " + objField.getType()); return false; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java index 738a8dd19..0be11f55f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java @@ -25,8 +25,8 @@ public class ImmutableMetaFactory { // search the constructors in score order ... // ... we need to find a set of readers for each // ... type in the constructor - for (int i = 0; i < scoreConstructors.length; i++) { - Constructor constructor = scoreConstructors[i].constructor; + for (ScoreConstructor scoreConstructor : scoreConstructors) { + Constructor constructor = scoreConstructor.constructor; try { Method[] getters = findGetters(cls, constructor); @@ -58,31 +58,31 @@ public class ImmutableMetaFactory { Class[] parameterTypes = c.getParameterTypes(); int score = -1000 * parameterTypes.length; - for (int i = 0; i < parameterTypes.length; i++) { - if (parameterTypes[i].equals(String.class)) { + for (Class parameterType : parameterTypes) { + if (parameterType.equals(String.class)) { // string is very generic and we would prefer // a more specific type if that was available score = score + 1; - } else if (parameterTypes[i].equals(BigDecimal.class)) { + } else if (parameterType.equals(BigDecimal.class)) { score = score - 10; - } else if (parameterTypes[i].equals(Timestamp.class)) { + } else if (parameterType.equals(Timestamp.class)) { score = score - 10; - } else if (parameterTypes[i].equals(double.class)) { + } else if (parameterType.equals(double.class)) { score = score - 9; - } else if (parameterTypes[i].equals(Double.class)) { + } else if (parameterType.equals(Double.class)) { score = score - 8; - } else if (parameterTypes[i].equals(float.class)) { + } else if (parameterType.equals(float.class)) { score = score - 7; - } else if (parameterTypes[i].equals(Float.class)) { + } else if (parameterType.equals(Float.class)) { score = score - 6; - } else if (parameterTypes[i].equals(long.class)) { + } else if (parameterType.equals(long.class)) { score = score - 5; - } else if (parameterTypes[i].equals(Long.class)) { + } else if (parameterType.equals(Long.class)) { score = score - 4; - } else if (parameterTypes[i].equals(int.class)) { + } else if (parameterType.equals(int.class)) { score = score - 3; - } else if (parameterTypes[i].equals(Integer.class)) { + } else if (parameterType.equals(Integer.class)) { score = score - 2; } } @@ -112,9 +112,9 @@ public class ImmutableMetaFactory { // filter out any constructors with less parameters than the max ArrayList list = new ArrayList<>(); - for (int i = 0; i < score.length; i++) { - if (score[i].getParamCount() == maxParamCount) { - list.add(score[i]); + for (ScoreConstructor aScore : score) { + if (aScore.getParamCount() == maxParamCount) { + list.add(aScore); } } @@ -160,15 +160,15 @@ public class ImmutableMetaFactory { private Method findGetter(Class paramType, Method[] methods) { - for (int i = 0; i < methods.length; i++) { - if (!Modifier.isStatic(methods[i].getModifiers())) { - if (methods[i].getParameterTypes().length == 0) { + for (Method method : methods) { + if (!Modifier.isStatic(method.getModifiers())) { + if (method.getParameterTypes().length == 0) { // could be a getter - String methName = methods[i].getName(); + String methName = method.getName(); if (!methName.equals("hashCode") && !methName.equals("toString")) { - Class returnType = methods[i].getReturnType(); + Class returnType = method.getReturnType(); if (paramType.equals(returnType)) { - return methods[i]; + return method; } } } @@ -208,8 +208,8 @@ public class ImmutableMetaFactory { return false; } HashSet> set = new HashSet<>(); - for (int i = 0; i < parameterTypes.length; i++) { - if (!set.add(parameterTypes[i])) { + for (Class parameterType : parameterTypes) { + if (!set.add(parameterType)) { return true; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java index 448c4b239..e51b16cbb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/Md5.java @@ -24,8 +24,8 @@ public class Md5 { private static String digestToHex(byte[] digest) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < digest.length; i++) { - sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); + for (byte aDigest : digest) { + sb.append(Integer.toString((aDigest & 0xff) + 0x100, 16).substring(1)); } return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java index b40a596a1..bf2020e5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java +++ b/src/main/java/com/avaje/ebeaninternal/util/SortByClauseParser.java @@ -19,8 +19,8 @@ public final class SortByClauseParser { SortByClause sortBy = new SortByClause(); String[] sections = rawSortBy.split(","); - for (int i = 0; i < sections.length; i++) { - Property p = parseSection(sections[i].trim()); + for (String section : sections) { + Property p = parseSection(section.trim()); if (p == null) { break; } else { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java index 942094df6..bf5ca3249 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java @@ -232,8 +232,8 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< @Override public void updateEmbedded(PersistRequestBean request, DocStoreUpdates docStoreUpdates) { - for (int i = 0; i < embeddedInvalidation.size(); i++) { - embeddedInvalidation.get(i).embeddedInvalidate(request, docStoreUpdates); + for (DocStoreEmbeddedInvalidation anEmbeddedInvalidation : embeddedInvalidation) { + anEmbeddedInvalidation.embeddedInvalidate(request, docStoreUpdates); } } @@ -256,8 +256,8 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< final DocStructure docStructure = new DocStructure(pathProps); BeanProperty[] properties = desc.propertiesNonTransient(); - for (int i = 0; i < properties.length; i++) { - properties[i].docStoreInclude(includeByDefault, docStructure); + for (BeanProperty property : properties) { + property.docStoreInclude(includeByDefault, docStructure); } InheritInfo inheritInfo = desc.getInheritInfo(); diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java index e52824f92..a4b0df3cb 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/InExpressionTest.java @@ -98,8 +98,8 @@ public class InExpressionTest { List values(int... vals) { ArrayList list = new ArrayList(); - for (int i = 0; i < vals.length; i++) { - list.add(vals[i]); + for (int val : vals) { + list.add(val); } return list; } @@ -171,4 +171,4 @@ public class InExpressionTest { assertThat(exp("a", false, 10, "ABC").isSameByBind(exp("a", false, 10, "ABC", 30))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java index 5ccb67a97..71a6768d5 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java +++ b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java @@ -30,8 +30,8 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase { ArrayList inserted = new ArrayList<>(); String[] names = "A,B,C,D,E,F,G,H,I,J".split(","); - for (int i = 0; i < names.length; i++) { - inserted.add(insert(names[i])); + for (String name : names) { + inserted.add(insert(name)); } ServerCacheManager serverCacheManager = Ebean.getDefaultServer().getServerCacheManager(); diff --git a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java index cc0fd4be7..fa86f7b4d 100644 --- a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java +++ b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java @@ -34,8 +34,7 @@ public class TestAutofetchTuneWithJoin extends BaseTestCase { List list = q.findList(); - for (int i = 0; i < list.size(); i++) { - Order order = list.get(i); + for (Order order : list) { order.getOrderDate(); order.getShipDate(); // order.setShipDate(new Date(System.currentTimeMillis())); From 9569b1b0d5ad30c4824bbbf5e21c9a1737111f94 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Tue, 8 Nov 2016 09:56:51 +1300 Subject: [PATCH 36/87] Added test for exception safety when using batchOnCascade --- .../TestBatchOnCascadeExceptionHandling.java | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java new file mode 100644 index 000000000..8a011199d --- /dev/null +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java @@ -0,0 +1,105 @@ +package com.avaje.tests.batchinsert; + +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.config.PersistBatch; +import com.avaje.ebeaninternal.api.SpiTransaction; +import com.avaje.ebeaninternal.server.persist.BatchControl; +import com.avaje.tests.model.basic.EBasicWithUniqueCon; +import com.avaje.tests.model.basic.EOptOneB; +import com.avaje.tests.model.basic.EOptOneC; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.sql.Savepoint; +import org.assertj.core.api.Assertions; +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.StrictAssertions.assertThat; + +public class TestBatchOnCascadeExceptionHandling extends BaseTestCase { + + @Test + public void testBatchScenarioWithSavepoint() throws SQLException { + EbeanServer server = Ebean.getDefaultServer(); + Transaction txn = server.beginTransaction(); + try { + server.save(createEntityWithName("before-savepoint")); + txn.flushBatch(); + Savepoint sp = txn.getConnection().setSavepoint(); + try { + server.save(createEntityWithName("confict")); + server.save(createEntityWithName("confict")); // unique key violation + } catch (PersistenceException e) { + txn.getConnection().rollback(sp); + server.save(createEntityWithName("after-savepoint")); + } + + txn.commit(); + } finally { + txn.end(); + } + + assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "before-savepoint").findList()).isNotEmpty(); + assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "after-savepoint").findList()).isNotEmpty(); + assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "confict").findList()).isEmpty(); + } + + @Test + public void testBatchedInsertFailure() { + final EbeanServer server = Ebean.getDefaultServer(); + server.save(createEntityWithName("foo")); + testBatchOnCascadeIsExceptionSafe(server, () -> { + server.save(createEntityWithName("foo")); // duplicate name on insert + }); + } + + @Test + public void testBatchedUpdateFailure() { + final EbeanServer server = Ebean.getDefaultServer(); + server.save(createEntityWithName("bla")); + final EBasicWithUniqueCon bar = createEntityWithName("bar"); + server.save(bar); + testBatchOnCascadeIsExceptionSafe(server, () -> { + bar.setName("bla"); + server.save(bar); // duplicate name on update + }); + } + + @Test + public void testBatchedDeleteFailure() { + final EbeanServer server = Ebean.getDefaultServer(); + final EOptOneC c = new EOptOneC(); + server.save(c); + final EOptOneB b = new EOptOneB(); + b.setC(c); + server.save(b); + testBatchOnCascadeIsExceptionSafe(server, () -> { + server.delete(c); // foreign key violation + }); + } + + protected void testBatchOnCascadeIsExceptionSafe(EbeanServer server, Runnable failingOperation) { + Transaction txn = server.beginTransaction(); + assertThat(txn.getBatch()).isSameAs(PersistBatch.NONE); + assertThat(txn.getBatchOnCascade()).isSameAs(PersistBatch.ALL); + + try { + failingOperation.run(); + Assertions.fail("PersistenceException expected"); + } catch (PersistenceException e) { + assertThat(txn.getBatch()).as("batch mode").isSameAs(PersistBatch.NONE); // should not have changed + BatchControl bc = ((SpiTransaction) txn).getBatchControl(); + assertThat(bc == null || bc.isEmpty()).as("batch emtpy").isTrue(); + } finally { + txn.end(); + } + } + + protected EBasicWithUniqueCon createEntityWithName(String name) { + EBasicWithUniqueCon it = new EBasicWithUniqueCon(); + it.setName(name); + return it; + } +} From 8661e1fd3f17ed46aeceac80923b969e55bf630d Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Wed, 9 Nov 2016 10:41:51 +1300 Subject: [PATCH 37/87] Reset batch on rollback --- .../ebeaninternal/api/ScopedTransaction.java | 8 +++-- .../ebeaninternal/api/SpiTransaction.java | 6 ++-- .../server/core/PersistRequestBean.java | 16 +++++++++- .../server/persist/BatchControl.java | 18 +++++++---- .../server/persist/BatchedPstmtHolder.java | 12 ++++--- .../server/transaction/JdbcTransaction.java | 31 ++++++++++++++----- 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java index 735675c58..0b437b36d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java @@ -6,11 +6,10 @@ import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.config.PersistBatch; import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.persist.BatchControl; - import javax.persistence.PersistenceException; import javax.persistence.RollbackException; import java.io.IOException; @@ -369,6 +368,11 @@ public class ScopedTransaction implements SpiTransaction { transaction.flushBatchOnCascade(); } + @Override + public void flushBatchOnRollback() { + transaction.flushBatchOnRollback(); + } + @Override public void markNotQueryOnly() { transaction.markNotQueryOnly(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index 1a22bfb66..27f130e1d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -5,11 +5,10 @@ import com.avaje.ebean.annotation.DocStoreMode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.persist.BatchControl; - import java.sql.Connection; /** @@ -117,6 +116,7 @@ public interface SpiTransaction extends Transaction { * Returning 0 implies to use the system wide default batch size. *

*/ + @Override int getBatchSize(); /** @@ -235,6 +235,8 @@ public interface SpiTransaction extends Transaction { */ void flushBatchOnCascade(); + void flushBatchOnRollback(); + /** * Mark the transaction explicitly as not being query only. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index 0ba67bfeb..71f29d6d1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -25,7 +25,6 @@ import com.avaje.ebeaninternal.server.transaction.BeanPersistIdMap; import com.avaje.ebeanservice.docstore.api.DocStoreUpdate; import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; - import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; import java.io.IOException; @@ -233,6 +232,15 @@ public final class PersistRequestBean extends PersistRequest implements BeanP } } + @Override + public void rollbackTransIfRequired() { + if (batchOnCascadeSet) { + transaction.flushBatchOnRollback(); + batchOnCascadeSet = false; + } + super.rollbackTransIfRequired(); + } + /** * Return true is this request was added to the JDBC batch. */ @@ -366,6 +374,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Process the persist request updating the document store. */ + @Override public void docStoreUpdate(DocStoreUpdateContext txn) throws IOException { switch (type) { @@ -387,6 +396,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Add this event to the queue entries in IndexUpdates. */ + @Override public void addToQueue(DocStoreUpdates docStoreUpdates) { switch (type) { case INSERT: @@ -550,6 +560,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Return the bean associated with this request. */ + @Override public T getBean() { return bean; } @@ -700,6 +711,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Set the generated key back to the bean. Only used for inserts with getGeneratedKeys. */ + @Override public void setGeneratedKey(Object idValue) { if (idValue != null) { // remember it for logging summary @@ -718,6 +730,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Check for optimistic concurrency exception. */ + @Override public final void checkRowCount(int rowCount) { if (ConcurrencyMode.VERSION == concurrencyMode && rowCount != 1) { String m = Message.msg("persist.conc2", "" + rowCount); @@ -761,6 +774,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Post processing. */ + @Override public void postExecute() { changeLog(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index 07927bfef..a6834b0a6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -1,15 +1,13 @@ package com.avaje.ebeaninternal.server.persist; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; - -import javax.persistence.PersistenceException; - import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import javax.persistence.PersistenceException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; /** * Controls the batch ordering of persist requests. @@ -226,6 +224,14 @@ public final class BatchControl { flush(true); } + /** + * Clears the batch, discarding all batched statements. + */ + public void clear() { + pstmtHolder.clear(); + beanHoldMap.clear(); + } + /** * execute all the requests currently queued or batched. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java index c726b7a8f..249910ddf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java @@ -1,11 +1,9 @@ package com.avaje.ebeaninternal.server.persist; +import javax.persistence.PersistenceException; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.LinkedHashMap; - -import javax.persistence.PersistenceException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,8 +117,7 @@ public class BatchedPstmtHolder { } // clear the batch cache - stmtMap.clear(); - maxSize = 0; + clear(); if (firstError != null) { String msg = "Error when batch flush on sql: " + errorSql; @@ -128,6 +125,11 @@ public class BatchedPstmtHolder { } } + public void clear() { + stmtMap.clear(); + maxSize = 0; + } + /** * Return the size of the biggest batched statement. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java index 759fccc9b..256cbf68b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java @@ -10,14 +10,11 @@ import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeSet; import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.api.TransactionEvent; +import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.lib.util.Str; import com.avaje.ebeaninternal.server.persist.BatchControl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.persistence.PersistenceException; import javax.persistence.RollbackException; import java.io.IOException; @@ -29,6 +26,8 @@ import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * JDBC Connection based transaction. @@ -235,6 +234,7 @@ public class JdbcTransaction implements SpiTransaction { return logPrefix; } + @Override public String toString() { return logPrefix; } @@ -324,6 +324,7 @@ public class JdbcTransaction implements SpiTransaction { this.docStoreBatchSize = docStoreBatchSize; } + @Override public DocStoreMode getDocStoreMode() { return docStoreMode; } @@ -400,7 +401,7 @@ public class JdbcTransaction implements SpiTransaction { @Override public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName) { if (m2mIntersectionSave == null) { - // first attempt so yes allow this m2m intersection direction + // first attempt so yes allow this m2m intersection direction m2mIntersectionSave = new HashMap<>(); m2mIntersectionSave.put(intersectionTable, beanName); return true; @@ -412,8 +413,8 @@ public class JdbcTransaction implements SpiTransaction { return true; } - // only allow if save coming from the same bean type - // to stop saves coming from both directions of m2m + // only allow if save coming from the same bean type + // to stop saves coming from both directions of m2m return existingBean.equals(beanName); } @@ -480,6 +481,7 @@ public class JdbcTransaction implements SpiTransaction { this.updateAllLoadedProperties = updateAllLoadedProperties; } + @Override public Boolean isUpdateAllLoadedProperties() { return updateAllLoadedProperties; } @@ -599,6 +601,7 @@ public class JdbcTransaction implements SpiTransaction { } } + @Override public void checkBatchEscalationOnCollection() { if (batchMode == PersistBatch.NONE && batchOnCascadeMode != PersistBatch.NONE) { batchMode = batchOnCascadeMode; @@ -606,6 +609,7 @@ public class JdbcTransaction implements SpiTransaction { } } + @Override public void flushBatchOnCollection() { if (batchOnCascadeSet) { if (batchControl != null) { @@ -634,6 +638,19 @@ public class JdbcTransaction implements SpiTransaction { batchMode = oldBatchMode; } + @Override + public void flushBatchOnRollback() { + if (batchControl != null) { + if (logger.isTraceEnabled()) { + logger.trace("... flushBatchOnRollback"); + } + batchControl.clear(); + } + // restore the previous batch mode + batchMode = oldBatchMode; + } + + @Override public boolean checkBatchEscalationOnCascade(PersistRequestBean request) { if (isBatch(batchMode, request.getType())) { From 29dbd5ac5dac78bf942d11512e786e1139da7092 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 10:11:00 +0100 Subject: [PATCH 38/87] No effective code change - add unit test to demonstrate inheritance use case --- .../avaje/tests/family/TestInheritance.java | 133 ++++++++++++++++++ .../avaje/tests/model/family/ChildPerson.java | 66 +++++++++ .../tests/model/family/GrandParentPerson.java | 70 +++++++++ .../tests/model/family/InheritablePerson.java | 43 ++++++ .../tests/model/family/ParentPerson.java | 96 +++++++++++++ 5 files changed, 408 insertions(+) create mode 100644 src/test/java/com/avaje/tests/family/TestInheritance.java create mode 100644 src/test/java/com/avaje/tests/model/family/ChildPerson.java create mode 100644 src/test/java/com/avaje/tests/model/family/GrandParentPerson.java create mode 100644 src/test/java/com/avaje/tests/model/family/InheritablePerson.java create mode 100644 src/test/java/com/avaje/tests/model/family/ParentPerson.java diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java new file mode 100644 index 000000000..f5ac950c0 --- /dev/null +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -0,0 +1,133 @@ + +package com.avaje.tests.family; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; + +import com.avaje.tests.lib.EbeanTestCase; +import com.avaje.tests.model.family.ChildPerson; +import com.avaje.tests.model.family.GrandParentPerson; +import com.avaje.tests.model.family.ParentPerson; + + + +public class TestInheritance extends EbeanTestCase { + + + @Test + public void testInheritance() { + + ChildPerson child1 = new ChildPerson(); + child1.setAge(13); + child1.setName("Fred"); + + ChildPerson child2 = new ChildPerson(); + child2.setAge(8); + child2.setFamilyName("Baz"); + child2.setName("Julia"); + + ChildPerson child3 = new ChildPerson(); + child3.setAge(36); + child3.setName("Roland"); + + ParentPerson parent1 = new ParentPerson(); + parent1.setAge(40); + parent1.setName("Maria"); + parent1.setFamilyName("Bar"); + parent1.getChildren().add(child1); + parent1.getChildren().add(child2); + + ParentPerson parent2 = new ParentPerson(); + parent2.setAge(50); + parent2.setName("Sandra"); + parent2.getChildren().add(child3); + parent2.setAddress("Berlin"); + + + ParentPerson parent3 = new ParentPerson(); + parent3.setAge(60); + parent3.setName("Michael"); + + GrandParentPerson grandparent1 = new GrandParentPerson(); + grandparent1.setAge(65); + grandparent1.setName("Josef"); + grandparent1.setFamilyName("Foo"); + grandparent1.setAddress("Munich"); + + grandparent1.getChildren().add(parent1); + grandparent1.getChildren().add(parent2); + grandparent1.getChildren().add(parent3); + + getServer().save(grandparent1); + // Test setup complete, so retrieve bean from db + grandparent1 = getServer().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).findUnique(); + + assertNotNull(grandparent1); + // check if aggregation works + assertEquals(3, grandparent1.getChildCount().intValue()); + assertEquals(150, grandparent1.getTotalAge().intValue()); + + // check normal properties + assertEquals("Josef", grandparent1.getName()); + assertEquals("Foo", grandparent1.getFamilyName()); + assertEquals("Munich", grandparent1.getAddress()); + + // now check children of grandparent + parent1 = grandparent1.getChildren().get(0); + parent2 = grandparent1.getChildren().get(1); + parent3 = grandparent1.getChildren().get(2); + + assertNotNull(parent1); + assertNotNull(parent2); + assertNotNull(parent3); + // parent1 + assertEquals("Maria", parent1.getName()); + assertEquals("Bar", parent1.getFamilyName()); // overwritten family name + assertEquals("Bar", parent1.getEffectiveFamilyName()); // test inheritance + assertNull(parent1.getAddress()); // no alternative address set + assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich + assertEquals(2, parent1.getChildCount().intValue()); + assertEquals(21, parent1.getTotalAge().intValue()); + + // parent2 + assertEquals("Sandra", parent2.getName()); + assertNull(parent2.getFamilyName()); + assertEquals("Foo", parent2.getEffectiveFamilyName()); + assertEquals("Berlin", parent2.getAddress()); + assertEquals("Berlin", parent2.getEffectiveAddress()); + assertEquals(1, parent2.getChildCount().intValue()); + assertEquals(36, parent2.getTotalAge().intValue()); + + // parent3 + assertEquals("Michael", parent3.getName()); + assertNull(parent3.getFamilyName()); + assertEquals("Foo", parent3.getEffectiveFamilyName()); + assertNull(parent3.getAddress()); + assertEquals("Munich", parent3.getEffectiveAddress()); + assertEquals(0, parent3.getChildCount().intValue()); + assertEquals(0, parent3.getTotalAge().intValue()); + + + child1 = parent1.getChildren().get(0); + child2 = parent1.getChildren().get(1); + + child3 = parent2.getChildren().get(0); + + assertNotNull(child1); + assertNotNull(child2); + assertNotNull(child3); + + assertEquals("Bar", child1.getEffectiveFamilyName()); + assertEquals("Munich", child1.getEffectiveAddress()); + + assertEquals("Baz", child2.getEffectiveFamilyName()); + assertEquals("Munich", child2.getEffectiveAddress()); + + assertEquals("Foo", child3.getEffectiveFamilyName()); + assertEquals("Berlin", child3.getEffectiveAddress()); + + } +} diff --git a/src/test/java/com/avaje/tests/model/family/ChildPerson.java b/src/test/java/com/avaje/tests/model/family/ChildPerson.java new file mode 100644 index 000000000..67b0d2b16 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/family/ChildPerson.java @@ -0,0 +1,66 @@ + +package com.avaje.tests.model.family; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + +import com.avaje.ebean.annotation.Formula; + +@Entity +public class ChildPerson extends InheritablePerson { + + private static final String PARENTS_JOIN = "join parent_person j1 on j1.identifier = ${ta}.parent_identifier " + + "join grand_parent_person j2 on j2.identifier = j1.parent_identifier"; + + @ManyToOne(cascade = CascadeType.ALL) + private ParentPerson parent; + + private String familyName; + + private String address; + + //@Coalesce({ "familyName", "parent.familyName", "parent.parent.familyName" }) + @Formula(select = "coalesce(${ta}.family_name, j1.family_name, j2.family_name)", join = PARENTS_JOIN ) + private String effectiveFamilyName; + + //@Coalesce({ "address", "parent.address", "parent.parent.address" }) + @Formula(select = "coalesce(${ta}.address, j1.address, j2.address)", join = PARENTS_JOIN ) + private String effectiveAddress; + + + public ParentPerson getParent() { + return parent; + } + + public void setParent(ParentPerson parent) { + this.parent = parent; + } + + public String getFamilyName() { + return familyName; + } + + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getEffectiveFamilyName() { + return effectiveFamilyName; + } + + public String getEffectiveAddress() { + return effectiveAddress; + } + + + +} diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java new file mode 100644 index 000000000..41277d016 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -0,0 +1,70 @@ + +package com.avaje.tests.model.family; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +import com.avaje.ebean.annotation.Formula; + +@Entity +public class GrandParentPerson extends InheritablePerson { + + @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) + private List children = new ArrayList<>(); + + // This rather complex formulas should be built later by CustomAnnotationParser + private static final String PARENT_PERSON_AGGREGATE_JOIN = "left join " + + "(select parent_identifier, count(*) as child_count, sum(age) as child_age from parent_person group by parent_identifier) " + + "as f1 on f1.parent_identifier = ${ta}.identifier"; + + //@Count("children") + @Formula(select = "coalesce(f1.child_count, 0)", join = PARENT_PERSON_AGGREGATE_JOIN ) + private Integer childCount; + + //@Sum("children.age") + @Formula(select = "coalesce(f1.child_age, 0)", join = PARENT_PERSON_AGGREGATE_JOIN ) + private Integer totalAge; + + private String familyName; + + private String address; + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + + public Integer getTotalAge() { + return totalAge; + } + + public String getFamilyName() { + return familyName; + } + + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Integer getChildCount() { + return childCount; + } + + +} diff --git a/src/test/java/com/avaje/tests/model/family/InheritablePerson.java b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java new file mode 100644 index 000000000..a76b1200c --- /dev/null +++ b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java @@ -0,0 +1,43 @@ + +package com.avaje.tests.model.family; + +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +@MappedSuperclass +public abstract class InheritablePerson { + + @Id + private Integer identifier; + + private String name; + + private Integer age; + + public Integer getIdentifier() { + return identifier; + } + + public void setIdentifier(Integer identifier) { + this.identifier = identifier; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + + +} diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java new file mode 100644 index 000000000..38aa9e3ea --- /dev/null +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -0,0 +1,96 @@ + +package com.avaje.tests.model.family; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +import com.avaje.ebean.annotation.Formula; + + +@Entity +public class ParentPerson extends InheritablePerson { + + //This rather complex formulas should be built later by CustomAnnotationParser + private static final String CHILD_PERSON_AGGREGATE_JOIN = "left join " + + "(select parent_identifier, count(*) as child_count, sum(age) as child_age from child_person group by parent_identifier) " + + "as f1 on f1.parent_identifier = ${ta}.identifier"; + + private static final String GRAND_PARENT_PERSON_JOIN = "join grand_parent_person j1 on j1.identifier = ${ta}.parent_identifier"; + + @ManyToOne(cascade = CascadeType.ALL) + private GrandParentPerson parent; + + @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) + private List children = new ArrayList<>(); + + //@Count("children") + @Formula(select = "coalesce(f1.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + private Integer childCount; + + //@Sum("children.age") + @Formula(select = "coalesce(f1.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + private Integer totalAge; + + private String familyName; + + private String address; + + //@Coalesce({ "familyName", "parent.familyName" }) + @Formula(select = "coalesce(${ta}.family_name, j1.family_name)", join = GRAND_PARENT_PERSON_JOIN ) + private String effectiveFamilyName; + + //@Coalesce({ "address", "parent.address" }) + @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN ) + private String effectiveAddress; + + public GrandParentPerson getParent() { + return parent; + } + + public void setParent(GrandParentPerson parent) { + this.parent = parent; + } + + public String getFamilyName() { + return familyName; + } + + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public List getChildren() { + return children; + } + + public Integer getChildCount() { + return childCount; + } + + public Integer getTotalAge() { + return totalAge; + } + + public String getEffectiveFamilyName() { + return effectiveFamilyName; + } + + public String getEffectiveAddress() { + return effectiveAddress; + } + + +} From 9a22f9735a2ca635788a1b99b0547af433ceca2d Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 10:26:37 +0100 Subject: [PATCH 39/87] no ebean code change: extended test case to use a bean in @Formula and return ID --- .../avaje/tests/family/TestInheritance.java | 23 +++++++++++++++++-- .../avaje/tests/model/family/ChildPerson.java | 5 ++++ .../tests/model/family/GrandParentPerson.java | 8 ++++++- .../tests/model/family/InheritablePerson.java | 16 +++++++++++-- .../tests/model/family/ParentPerson.java | 6 +++++ 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java index f5ac950c0..06b63b652 100644 --- a/src/test/java/com/avaje/tests/family/TestInheritance.java +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -8,6 +8,7 @@ import java.util.List; import org.junit.Test; import com.avaje.tests.lib.EbeanTestCase; +import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.family.ChildPerson; import com.avaje.tests.model.family.GrandParentPerson; import com.avaje.tests.model.family.ParentPerson; @@ -19,7 +20,15 @@ public class TestInheritance extends EbeanTestCase { @Test public void testInheritance() { - + // create some other beans + EBasic someBean1 = new EBasic(); + someBean1.setName("A Bean"); + getServer().save(someBean1); + + EBasic someBean2 = new EBasic(); + someBean2.setName("An other Bean"); + getServer().save(someBean2); + ChildPerson child1 = new ChildPerson(); child1.setAge(13); child1.setName("Fred"); @@ -37,6 +46,8 @@ public class TestInheritance extends EbeanTestCase { parent1.setAge(40); parent1.setName("Maria"); parent1.setFamilyName("Bar"); + parent1.setSomeBean(someBean1); + child1.setSomeBean(someBean2); parent1.getChildren().add(child1); parent1.getChildren().add(child2); @@ -74,6 +85,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Josef", grandparent1.getName()); assertEquals("Foo", grandparent1.getFamilyName()); assertEquals("Munich", grandparent1.getAddress()); + assertNull(grandparent1.getEffectiveBeanId()); // now check children of grandparent parent1 = grandparent1.getChildren().get(0); @@ -91,6 +103,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich assertEquals(2, parent1.getChildCount().intValue()); assertEquals(21, parent1.getTotalAge().intValue()); + assertEquals(1, parent1.getEffectiveBeanId().intValue()); // parent2 assertEquals("Sandra", parent2.getName()); @@ -100,6 +113,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Berlin", parent2.getEffectiveAddress()); assertEquals(1, parent2.getChildCount().intValue()); assertEquals(36, parent2.getTotalAge().intValue()); + assertNull(parent2.getEffectiveBeanId()); // parent3 assertEquals("Michael", parent3.getName()); @@ -109,7 +123,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Munich", parent3.getEffectiveAddress()); assertEquals(0, parent3.getChildCount().intValue()); assertEquals(0, parent3.getTotalAge().intValue()); - + assertNull(parent3.getEffectiveBeanId()); child1 = parent1.getChildren().get(0); child2 = parent1.getChildren().get(1); @@ -122,12 +136,17 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Bar", child1.getEffectiveFamilyName()); assertEquals("Munich", child1.getEffectiveAddress()); + assertEquals(2, child1.getSomeBean().getId().intValue()); + assertEquals(2, child1.getEffectiveBeanId().intValue()); assertEquals("Baz", child2.getEffectiveFamilyName()); assertEquals("Munich", child2.getEffectiveAddress()); + assertNull(child2.getSomeBean()); + assertEquals(1, child2.getEffectiveBeanId().intValue()); assertEquals("Foo", child3.getEffectiveFamilyName()); assertEquals("Berlin", child3.getEffectiveAddress()); + assertNull(child3.getEffectiveBeanId()); } } diff --git a/src/test/java/com/avaje/tests/model/family/ChildPerson.java b/src/test/java/com/avaje/tests/model/family/ChildPerson.java index 67b0d2b16..9076e46bf 100644 --- a/src/test/java/com/avaje/tests/model/family/ChildPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ChildPerson.java @@ -28,6 +28,8 @@ public class ChildPerson extends InheritablePerson { @Formula(select = "coalesce(${ta}.address, j1.address, j2.address)", join = PARENTS_JOIN ) private String effectiveAddress; + @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id, j2.some_bean_id)") + private Integer effectiveBeanId; public ParentPerson getParent() { return parent; @@ -61,6 +63,9 @@ public class ChildPerson extends InheritablePerson { return effectiveAddress; } + public Integer getEffectiveBeanId() { + return effectiveBeanId; + } } diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java index 41277d016..79ab0d57b 100644 --- a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -33,6 +33,10 @@ public class GrandParentPerson extends InheritablePerson { private String address; + + @Formula(select = "${ta}.some_bean_id") + private Integer effectiveBeanId; + public List getChildren() { return children; } @@ -66,5 +70,7 @@ public class GrandParentPerson extends InheritablePerson { return childCount; } - + public Integer getEffectiveBeanId() { + return effectiveBeanId; + } } diff --git a/src/test/java/com/avaje/tests/model/family/InheritablePerson.java b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java index a76b1200c..8a174932b 100644 --- a/src/test/java/com/avaje/tests/model/family/InheritablePerson.java +++ b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java @@ -2,8 +2,11 @@ package com.avaje.tests.model.family; import javax.persistence.Id; +import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; +import com.avaje.tests.model.basic.EBasic; + @MappedSuperclass public abstract class InheritablePerson { @@ -14,6 +17,9 @@ public abstract class InheritablePerson { private Integer age; + @ManyToOne + private EBasic someBean; + public Integer getIdentifier() { return identifier; } @@ -37,7 +43,13 @@ public abstract class InheritablePerson { public void setAge(Integer age) { this.age = age; } - - + + public void setSomeBean(EBasic someBean) { + this.someBean = someBean; + } + + public EBasic getSomeBean() { + return someBean; + } } diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index 38aa9e3ea..d83b1ffa0 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -48,6 +48,9 @@ public class ParentPerson extends InheritablePerson { @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN ) private String effectiveAddress; + @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)") + private Integer effectiveBeanId; + public GrandParentPerson getParent() { return parent; } @@ -92,5 +95,8 @@ public class ParentPerson extends InheritablePerson { return effectiveAddress; } + public Integer getEffectiveBeanId() { + return effectiveBeanId; + } } From 95ee163d8bc3ad52bfd0a8cbd96b10f4eb4a3a24 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 13:53:14 +0100 Subject: [PATCH 40/87] extended test cases --- .../avaje/tests/family/TestInheritance.java | 54 +++++++++++++------ .../avaje/tests/model/family/ChildPerson.java | 9 ++-- .../tests/model/family/GrandParentPerson.java | 11 ++-- .../tests/model/family/ParentPerson.java | 8 +-- 4 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java index 06b63b652..70b0e8a6a 100644 --- a/src/test/java/com/avaje/tests/family/TestInheritance.java +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -1,12 +1,17 @@ package com.avaje.tests.family; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.util.List; +import org.junit.Ignore; import org.junit.Test; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeaninternal.server.deploy.BeanProperty; +import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.tests.lib.EbeanTestCase; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.family.ChildPerson; @@ -15,19 +20,29 @@ import com.avaje.tests.model.family.ParentPerson; -public class TestInheritance extends EbeanTestCase { +public class TestInheritance extends BaseTestCase { + @Test + public void testDescriptor() { + BeanDescriptor desc = spiEbeanServer().getBeanDescriptor(GrandParentPerson.class); + BeanProperty prop1 = desc.getBeanProperty("someBean"); + BeanProperty prop2 = desc.getBeanProperty("effectiveBean"); + + assertEquals(BeanPropertyAssocOne.class, prop1.getClass()); + assertEquals(BeanPropertyAssocOne.class, prop2.getClass()); + } + @Test public void testInheritance() { // create some other beans EBasic someBean1 = new EBasic(); someBean1.setName("A Bean"); - getServer().save(someBean1); + server().save(someBean1); EBasic someBean2 = new EBasic(); someBean2.setName("An other Bean"); - getServer().save(someBean2); + server().save(someBean2); ChildPerson child1 = new ChildPerson(); child1.setAge(13); @@ -71,12 +86,21 @@ public class TestInheritance extends EbeanTestCase { grandparent1.getChildren().add(parent1); grandparent1.getChildren().add(parent2); grandparent1.getChildren().add(parent3); - - getServer().save(grandparent1); - // Test setup complete, so retrieve bean from db - grandparent1 = getServer().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).findUnique(); + + server().save(grandparent1); + // Test setup complete, so retrieve bean from db + //grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where() + // .in("effectiveBean.id",2,null) // geht nicht! + // .findUnique(); + grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where() + .or() + .in("effectiveBean.id",2) + .isNull("effectiveBean.id") + .endOr() + .findUnique(); assertNotNull(grandparent1); + // check if aggregation works assertEquals(3, grandparent1.getChildCount().intValue()); assertEquals(150, grandparent1.getTotalAge().intValue()); @@ -85,7 +109,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Josef", grandparent1.getName()); assertEquals("Foo", grandparent1.getFamilyName()); assertEquals("Munich", grandparent1.getAddress()); - assertNull(grandparent1.getEffectiveBeanId()); + // assertEquals(2, grandparent1.getEffectiveBean().getId().intValue()); // now check children of grandparent parent1 = grandparent1.getChildren().get(0); @@ -103,7 +127,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich assertEquals(2, parent1.getChildCount().intValue()); assertEquals(21, parent1.getTotalAge().intValue()); - assertEquals(1, parent1.getEffectiveBeanId().intValue()); + assertEquals(1, parent1.getEffectiveBean().getId().intValue()); // parent2 assertEquals("Sandra", parent2.getName()); @@ -113,7 +137,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Berlin", parent2.getEffectiveAddress()); assertEquals(1, parent2.getChildCount().intValue()); assertEquals(36, parent2.getTotalAge().intValue()); - assertNull(parent2.getEffectiveBeanId()); + assertNull(parent2.getEffectiveBean()); // parent3 assertEquals("Michael", parent3.getName()); @@ -123,7 +147,7 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Munich", parent3.getEffectiveAddress()); assertEquals(0, parent3.getChildCount().intValue()); assertEquals(0, parent3.getTotalAge().intValue()); - assertNull(parent3.getEffectiveBeanId()); + assertNull(parent3.getEffectiveBean()); child1 = parent1.getChildren().get(0); child2 = parent1.getChildren().get(1); @@ -137,16 +161,16 @@ public class TestInheritance extends EbeanTestCase { assertEquals("Bar", child1.getEffectiveFamilyName()); assertEquals("Munich", child1.getEffectiveAddress()); assertEquals(2, child1.getSomeBean().getId().intValue()); - assertEquals(2, child1.getEffectiveBeanId().intValue()); + assertEquals(2, child1.getEffectiveBean().getId().intValue()); assertEquals("Baz", child2.getEffectiveFamilyName()); assertEquals("Munich", child2.getEffectiveAddress()); assertNull(child2.getSomeBean()); - assertEquals(1, child2.getEffectiveBeanId().intValue()); + assertEquals(1, child2.getEffectiveBean().getId().intValue()); assertEquals("Foo", child3.getEffectiveFamilyName()); assertEquals("Berlin", child3.getEffectiveAddress()); - assertNull(child3.getEffectiveBeanId()); + assertNull(child3.getEffectiveBean()); } } diff --git a/src/test/java/com/avaje/tests/model/family/ChildPerson.java b/src/test/java/com/avaje/tests/model/family/ChildPerson.java index 9076e46bf..77032e59a 100644 --- a/src/test/java/com/avaje/tests/model/family/ChildPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ChildPerson.java @@ -6,6 +6,7 @@ import javax.persistence.Entity; import javax.persistence.ManyToOne; import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; @Entity public class ChildPerson extends InheritablePerson { @@ -29,7 +30,8 @@ public class ChildPerson extends InheritablePerson { private String effectiveAddress; @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id, j2.some_bean_id)") - private Integer effectiveBeanId; + @ManyToOne + private EBasic effectiveBean; public ParentPerson getParent() { return parent; @@ -63,9 +65,8 @@ public class ChildPerson extends InheritablePerson { return effectiveAddress; } - public Integer getEffectiveBeanId() { - return effectiveBeanId; + public EBasic getEffectiveBean() { + return effectiveBean; } - } diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java index 79ab0d57b..21f032e36 100644 --- a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -6,9 +6,11 @@ import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; @Entity public class GrandParentPerson extends InheritablePerson { @@ -34,8 +36,9 @@ public class GrandParentPerson extends InheritablePerson { private String address; - @Formula(select = "${ta}.some_bean_id") - private Integer effectiveBeanId; + @Formula(select = "${ta}.some_bean_id+1") + @ManyToOne + private EBasic effectiveBean; public List getChildren() { return children; @@ -70,7 +73,7 @@ public class GrandParentPerson extends InheritablePerson { return childCount; } - public Integer getEffectiveBeanId() { - return effectiveBeanId; + public EBasic getEffectiveBean() { + return effectiveBean; } } diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index d83b1ffa0..32e235eff 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -10,6 +10,7 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; @Entity @@ -49,7 +50,8 @@ public class ParentPerson extends InheritablePerson { private String effectiveAddress; @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)") - private Integer effectiveBeanId; + @ManyToOne + private EBasic effectiveBean; public GrandParentPerson getParent() { return parent; @@ -95,8 +97,8 @@ public class ParentPerson extends InheritablePerson { return effectiveAddress; } - public Integer getEffectiveBeanId() { - return effectiveBeanId; + public EBasic getEffectiveBean() { + return effectiveBean; } } From e8237cc04fa36c387f63df0a80884d646b4cca6e Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 15:59:01 +0100 Subject: [PATCH 41/87] ENH: Support for @Formula in combination with @ManyToOne --- .../server/deploy/BeanDescriptor.java | 5 +- .../server/deploy/BeanPropertyAssocOne.java | 5 +- .../server/deploy/BeanTable.java | 6 +- .../server/deploy/TableJoinColumn.java | 23 ++++++- .../deploy/meta/DeployTableJoinColumn.java | 60 +++++++++++++++++-- .../deploy/parse/AnnotationAssocManys.java | 2 +- .../deploy/parse/AnnotationAssocOnes.java | 2 +- .../server/deploy/parse/AnnotationFields.java | 5 ++ .../server/query/DefaultDbSqlContext.java | 15 ++++- 9 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java index 38d979e14..8d8c17d7a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java @@ -85,6 +85,7 @@ import javax.persistence.PersistenceException; import java.io.IOException; import java.lang.reflect.Modifier; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.Types; import java.util.ArrayList; import java.util.Collection; @@ -868,7 +869,9 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { public void initialiseFkeys() { for (BeanPropertyAssocOne aPropertiesOneImported : propertiesOneImported) { - aPropertiesOneImported.addFkey(); + if (!aPropertiesOneImported.isFormula()) { + aPropertiesOneImported.addFkey(); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 66b57efed..1d4ff4b3f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -561,7 +561,9 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { @Override public void appendSelect(DbSqlContext ctx, boolean subQuery) { - if (!isTransient) { + if (formula) { + ctx.appendFormulaSelect(sqlFormulaSelect); + } else if (!isTransient) { localHelp.appendSelect(ctx, subQuery); } } @@ -569,6 +571,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { @Override public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { if (!isTransient) { + // TODO JOINS localHelp.appendFrom(ctx, joinType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java index 6e4a0f4ed..b19123965 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanTable.java @@ -76,7 +76,7 @@ public class BeanTable { return beanType; } - public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse) { + public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse, String sqlFormulaSelect) { boolean complexKey = false; BeanProperty[] props = idProperties; @@ -104,8 +104,12 @@ public class BeanTable { logger.debug(msg); fk = lc; } + if (sqlFormulaSelect != null) { + fk = sqlFormulaSelect; + } DeployTableJoinColumn joinCol = new DeployTableJoinColumn(lc, fk); + joinCol.setForeignSqlFormula(sqlFormulaSelect); if (reverse) { joinCol = joinCol.reverse(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java index d64679402..4c5314a72 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/TableJoinColumn.java @@ -13,14 +13,19 @@ public class TableJoinColumn { */ private final String localDbColumn; + private final String localSqlFormula; + /** * The foreign database column name. */ private final String foreignDbColumn; + + private final String foreignSqlFormula; private final boolean insertable; private final boolean updateable; + /** * Hash for including in a query plan @@ -33,6 +38,9 @@ public class TableJoinColumn { public TableJoinColumn(DeployTableJoinColumn deploy) { this.localDbColumn = InternString.intern(deploy.getLocalDbColumn()); this.foreignDbColumn = InternString.intern(deploy.getForeignDbColumn()); + this.localSqlFormula = InternString.intern(deploy.getLocalSqlFormula()); + this.foreignSqlFormula = InternString.intern(deploy.getForeignSqlFormula()); + this.insertable = deploy.isInsertable(); this.updateable = deploy.isUpdateable(); this.queryHash = hash(); @@ -41,8 +49,11 @@ public class TableJoinColumn { int hash() { int result = localDbColumn != null ? localDbColumn.hashCode() : 0; result = 92821 * result + (foreignDbColumn != null ? foreignDbColumn.hashCode() : 0); + result = 92821 * result + (localSqlFormula != null ? localSqlFormula.hashCode() : 0); + result = 92821 * result + (foreignSqlFormula != null ? foreignSqlFormula.hashCode() : 0); result = 92821 * result + (insertable ? 1 : 0); result = 92821 * result + (updateable ? 1 : 0); + return result; } @@ -64,7 +75,8 @@ public class TableJoinColumn { } public String toString() { - return localDbColumn + " = " + foreignDbColumn; + return (localSqlFormula == null ? localDbColumn : localSqlFormula) + " = " + + (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula); } /** @@ -101,4 +113,13 @@ public class TableJoinColumn { public boolean isUpdateable() { return updateable; } + + public String getLocalSqlFormula() { + return localSqlFormula; + } + + public String getForeignSqlFormula() { + return foreignSqlFormula; + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java index cc2a8ca50..293857cdc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java @@ -15,14 +15,26 @@ public class DeployTableJoinColumn { */ String localDbColumn; + /** + * SQL formula used for local column + */ + String localSqlFormula; + /** * The foreign database column name. */ String foreignDbColumn; + + /** + * SQL formula used for foreign column + */ + String foreignSqlFormula; - final boolean insertable; + boolean insertable; + + boolean updateable; + - final boolean updateable; /** * Construct when automatically determining the join. @@ -43,7 +55,34 @@ public class DeployTableJoinColumn { this.insertable = insertable; this.updateable = updateable; } - + + public void setLocalSqlFormula(String localSqlFormula) { + if (localSqlFormula != null) { + this.localSqlFormula = localSqlFormula; + this.localDbColumn = null; + this.insertable = false; + this.updateable = false; + } + } + + public String getLocalSqlFormula() { + return localSqlFormula; + } + + public void setForeignSqlFormula(String foreignSqlFormula) { + if (foreignSqlFormula != null) { + this.foreignSqlFormula = foreignSqlFormula; + this.foreignDbColumn = null; + this.insertable = false; + this.updateable = false; + } + } + + public String getForeignSqlFormula() { + return foreignSqlFormula; + } + + public DeployTableJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) { this(jc.referencedColumnName(), jc.name(), jc.insertable(), jc.updatable()); setReferencedColumn(beanTable); @@ -68,6 +107,10 @@ public class DeployTableJoinColumn { String temp = localDbColumn; localDbColumn = foreignDbColumn; foreignDbColumn = temp; + + temp = localSqlFormula; + localSqlFormula = foreignSqlFormula; + foreignSqlFormula = temp; return this; } @@ -86,12 +129,18 @@ public class DeployTableJoinColumn { // Note that the insertable and updateable are just copied // which may not always be the correct thing to do // but will leave it like this for now + DeployTableJoinColumn ret; if (reverse){ - return new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); + ret = new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); + ret.setLocalSqlFormula(foreignSqlFormula); + ret.setForeignSqlFormula(localSqlFormula); } else { - return new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); + ret = new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); + ret.setLocalSqlFormula(localSqlFormula); + ret.setForeignSqlFormula(foreignSqlFormula); } + return ret; } public String toString() { @@ -132,4 +181,5 @@ public class DeployTableJoinColumn { public void setLocalDbColumn(String localDbColumn) { this.localDbColumn = localDbColumn; } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index f5385890f..e597d8a12 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -136,7 +136,7 @@ public class AnnotationAssocManys extends AnnotationParser { // Use the owning bean table to define the join BeanTable owningBeanTable = factory.getBeanTable(descriptor.getBeanType()); - owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false); + owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false, prop.getSqlFormulaSelect()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 6ade29cba..64242e408 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -142,7 +142,7 @@ public class AnnotationAssocOnes extends AnnotationParser { fkeyPrefix = nc.getColumnFromProperty(beanType, prop.getName()); } - beanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), true); + beanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), true, prop.getSqlFormulaSelect()); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java index ac5172534..8e04be070 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -103,6 +103,11 @@ public class AnnotationFields extends AnnotationParser { } readEmbeddedAttributeOverrides((DeployBeanPropertyAssocOne) prop); } + + Formula formula = get(prop, Formula.class); + if (formula != null) { + prop.setSqlFormula(formula.select(), formula.join()); + } } private void readField(DeployBeanProperty prop) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java index 67a3e7ceb..0329ddbb4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java @@ -136,9 +136,20 @@ class DefaultDbSqlContext implements DbSqlContext { if (i > 0) { sb.append(" and "); } - sb.append(a2).append(".").append(pair.getForeignDbColumn()); + + if (pair.getForeignSqlFormula() != null) { + sb.append(pair.getForeignSqlFormula().replace(tableAliasPlaceHolder, a2)); + } else { + sb.append(a2).append(".").append(pair.getForeignDbColumn()); + } + sb.append(" = "); - sb.append(a1).append(".").append(pair.getLocalDbColumn()); + + if (pair.getLocalSqlFormula() != null) { + sb.append(pair.getLocalSqlFormula().replace(tableAliasPlaceHolder, a1)); + } else { + sb.append(a1).append(".").append(pair.getLocalDbColumn()); + } } // add on any inheritance where clause From 119edbdb9d791fdc7407a696538f78557ecf02b8 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 16:16:53 +0100 Subject: [PATCH 42/87] FIX: Missing comma in bindlog --- .../com/avaje/ebeaninternal/server/query/CQueryPredicates.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java index 3465ffe8f..00f3b1703 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java @@ -152,6 +152,7 @@ public class CQueryPredicates { // this is a find by id type query... request.getBeanDescriptor().bindId(dataBind, idValue); dataBind.append(idValue); + dataBind.append(", "); } if (bindParams != null) { From 019fdd3a1269c585671fedf6e2be0abcd9ef8e2d Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 16:31:26 +0100 Subject: [PATCH 43/87] fix test --- .../avaje/tests/family/TestInheritance.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java index 70b0e8a6a..28e51c247 100644 --- a/src/test/java/com/avaje/tests/family/TestInheritance.java +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -33,6 +33,17 @@ public class TestInheritance extends BaseTestCase { assertEquals(BeanPropertyAssocOne.class, prop2.getClass()); } + /** + *

+   * grandparent1   Josef Foo(65) from Munich
+   * +- parent1     Maria Bar (40) has someBean1
+   * |  +- child1   Fred(13) has someBean2
+   * |  '- child2   Julia Baz(8)
+   * +- parent2     Sandra (50) from Berlin
+   * |  '- child3   Roland(36)
+   * +- parent3     Michael(60)
+   * 
+ */ @Test public void testInheritance() { // create some other beans @@ -127,7 +138,7 @@ public class TestInheritance extends BaseTestCase { assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich assertEquals(2, parent1.getChildCount().intValue()); assertEquals(21, parent1.getTotalAge().intValue()); - assertEquals(1, parent1.getEffectiveBean().getId().intValue()); + assertEquals("A Bean", parent1.getEffectiveBean().getName()); // parent2 assertEquals("Sandra", parent2.getName()); @@ -160,13 +171,15 @@ public class TestInheritance extends BaseTestCase { assertEquals("Bar", child1.getEffectiveFamilyName()); assertEquals("Munich", child1.getEffectiveAddress()); - assertEquals(2, child1.getSomeBean().getId().intValue()); - assertEquals(2, child1.getEffectiveBean().getId().intValue()); + assertEquals("An other Bean", child1.getSomeBean().getName()); + assertEquals("An other Bean", child1.getEffectiveBean().getName()); + + assertTrue(child1.getSomeBean() == child1.getEffectiveBean()); assertEquals("Baz", child2.getEffectiveFamilyName()); assertEquals("Munich", child2.getEffectiveAddress()); assertNull(child2.getSomeBean()); - assertEquals(1, child2.getEffectiveBean().getId().intValue()); + assertEquals("A Bean", child2.getEffectiveBean().getName()); assertEquals("Foo", child3.getEffectiveFamilyName()); assertEquals("Berlin", child3.getEffectiveAddress()); From 5c142a61f6913a9807c252b0be450e885f947e4e Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 11 Nov 2016 17:11:15 +1300 Subject: [PATCH 44/87] No effective change - add javadoc --- src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index 27f130e1d..5224acf57 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -235,6 +235,9 @@ public interface SpiTransaction extends Transaction { */ void flushBatchOnCascade(); + /** + * If batch was on then effectively clear the batch such that we can handle exceptions and continue. + */ void flushBatchOnRollback(); /** From 2953418683ae049b8ee909756eb0daab5292f2ce Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 11 Nov 2016 17:14:12 +1300 Subject: [PATCH 45/87] No effective change - add .editorconfig --- .editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..837d975fa --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +spaces_around_operators = true From e4e850717de4138581116a7dab0e264edf545d7c Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 9 Nov 2016 20:50:33 +0100 Subject: [PATCH 46/87] FIX: @Formula: support for discriminator & joins added --- .../server/deploy/BeanPropertyAssoc.java | 7 ++++--- .../server/deploy/BeanPropertyAssocOne.java | 8 ++++---- .../server/deploy/id/ImportedIdSimple.java | 11 +++++++++-- .../deploy/meta/DeployBeanPropertyAssocOne.java | 9 +++++++++ .../server/query/DefaultDbSqlContext.java | 6 ++++-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java index 2e85c8377..f41e5839d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -330,7 +330,7 @@ public abstract class BeanPropertyAssoc extends BeanProperty { if (descriptor.isRawSqlBased()) { String dbColumn = owner.getDbColumn(); - return new ImportedIdSimple(owner, dbColumn, idProp, 0); + return new ImportedIdSimple(owner, dbColumn, null, idProp, 0); } TableJoinColumn[] cols = join.columns(); @@ -373,16 +373,17 @@ public abstract class BeanPropertyAssoc extends BeanProperty { String matchColumn = col.getForeignDbColumn(); String localColumn = col.getLocalDbColumn(); + String localSqlFormula = col.getLocalSqlFormula(); for (int j = 0; j < props.length; j++) { if (props[j].getDbColumn().equalsIgnoreCase(matchColumn)) { - return new ImportedIdSimple(owner, localColumn, props[j], j); + return new ImportedIdSimple(owner, localColumn, localSqlFormula, props[j], j); } } for (int j = 0; j < others.length; j++) { if (others[j].getDbColumn().equalsIgnoreCase(matchColumn)) { - return new ImportedIdSimple(owner, localColumn, others[j], j + props.length); + return new ImportedIdSimple(owner, localColumn, localSqlFormula, others[j], j + props.length); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 1d4ff4b3f..ef723bd65 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -561,9 +561,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { @Override public void appendSelect(DbSqlContext ctx, boolean subQuery) { - if (formula) { - ctx.appendFormulaSelect(sqlFormulaSelect); - } else if (!isTransient) { + if (!isTransient) { localHelp.appendSelect(ctx, subQuery); } } @@ -571,8 +569,10 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { @Override public void appendFrom(DbSqlContext ctx, SqlJoinType joinType) { if (!isTransient) { - // TODO JOINS localHelp.appendFrom(ctx, joinType); + if (sqlFormulaJoin != null) { + ctx.appendFormulaJoin(sqlFormulaJoin, joinType); + } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java index 85fdf7b17..06ac324b9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/id/ImportedIdSimple.java @@ -37,6 +37,8 @@ public final class ImportedIdSimple implements ImportedId, Comparable owner; protected final String localDbColumn; + + protected final String localSqlFormula; protected final String logicalName; @@ -44,9 +46,10 @@ public final class ImportedIdSimple implements ImportedId, Comparable owner, String localDbColumn, BeanProperty foreignProperty, int position) { + public ImportedIdSimple(BeanPropertyAssoc owner, String localDbColumn, String localSqlFormula, BeanProperty foreignProperty, int position) { this.owner = owner; this.localDbColumn = InternString.intern(localDbColumn); + this.localSqlFormula = InternString.intern(localSqlFormula); this.foreignProperty = foreignProperty; this.position = position; this.logicalName = InternString.intern(owner.getName() + "." + foreignProperty.getName()); @@ -103,7 +106,11 @@ public final class ImportedIdSimple implements ImportedId, Comparable extends DeployBeanPropertyAssoc { tableJoin.setLocalColumn(dbColumn); } } + + @Override + public void setSqlFormula(String formulaSelect, String formulaJoin) { + super.setSqlFormula(formulaSelect, formulaJoin); + DeployTableJoinColumn[] columns = tableJoin.columns(); + if (columns.length == 1) { + columns[0].setLocalSqlFormula(formulaSelect); + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java index 0329ddbb4..5896f6165 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java @@ -138,7 +138,7 @@ class DefaultDbSqlContext implements DbSqlContext { } if (pair.getForeignSqlFormula() != null) { - sb.append(pair.getForeignSqlFormula().replace(tableAliasPlaceHolder, a2)); + sb.append(StringHelper.replaceString(pair.getForeignSqlFormula(), tableAliasPlaceHolder, a2)); } else { sb.append(a2).append(".").append(pair.getForeignDbColumn()); } @@ -146,7 +146,7 @@ class DefaultDbSqlContext implements DbSqlContext { sb.append(" = "); if (pair.getLocalSqlFormula() != null) { - sb.append(pair.getLocalSqlFormula().replace(tableAliasPlaceHolder, a1)); + sb.append(StringHelper.replaceString(pair.getLocalSqlFormula(), tableAliasPlaceHolder, a1)); } else { sb.append(a1).append(".").append(pair.getLocalDbColumn()); } @@ -255,6 +255,8 @@ class DefaultDbSqlContext implements DbSqlContext { sb.append(COMMA); sb.append(converted); + + appendColumnAlias(); } @Override From 56c96923c4b6e20eb3afa68f35b32e17f661d01c Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Fri, 11 Nov 2016 09:56:12 +0100 Subject: [PATCH 47/87] extended the test cases --- .../avaje/tests/family/TestInheritance.java | 40 +++++++++++++++++-- .../tests/model/family/GrandParentPerson.java | 5 ++- .../tests/model/family/ParentPerson.java | 8 ++-- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java index 28e51c247..093a3ae0c 100644 --- a/src/test/java/com/avaje/tests/family/TestInheritance.java +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -104,9 +104,16 @@ public class TestInheritance extends BaseTestCase { //grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where() // .in("effectiveBean.id",2,null) // geht nicht! // .findUnique(); - grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where() + parent1 = server().find(ParentPerson.class).setId(1).fetch("someBean").findUnique(); + assertEquals("A Bean", parent1.getSomeBean().getName()); + grandparent1 = server().find(GrandParentPerson.class) + .fetch("children","*") // FIXME If I do not fetch childrenBean, I will get an exception + .fetch("children.effectiveBean","*") + .fetch("children.children","*") + .fetch("children.children.effectiveBean","*") + .setId(grandparent1.getIdentifier()).where() .or() - .in("effectiveBean.id",2) + .in("effectiveBean.id",1) .isNull("effectiveBean.id") .endOr() .findUnique(); @@ -120,7 +127,7 @@ public class TestInheritance extends BaseTestCase { assertEquals("Josef", grandparent1.getName()); assertEquals("Foo", grandparent1.getFamilyName()); assertEquals("Munich", grandparent1.getAddress()); - // assertEquals(2, grandparent1.getEffectiveBean().getId().intValue()); + assertEquals(1, grandparent1.getEffectiveBean().getId().intValue()); // now check children of grandparent parent1 = grandparent1.getChildren().get(0); @@ -185,5 +192,32 @@ public class TestInheritance extends BaseTestCase { assertEquals("Berlin", child3.getEffectiveAddress()); assertNull(child3.getEffectiveBean()); + // Now start from bottom up + child2 = server().find(ChildPerson.class).where().eq("name", "Julia").select("parent.name").findUnique(); + assertEquals("Baz", child2.getEffectiveFamilyName()); + assertEquals("Munich", child2.getEffectiveAddress()); + assertNull(child2.getSomeBean()); + assertEquals("A Bean", child2.getEffectiveBean().getName()); + + parent1 = child2.getParent(); + assertEquals("Maria", parent1.getName()); + assertEquals("Bar", parent1.getFamilyName()); // overwritten family name + assertEquals("Bar", parent1.getEffectiveFamilyName()); // test inheritance + assertNull(parent1.getAddress()); // no alternative address set + assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich + assertEquals(2, parent1.getChildCount().intValue()); + assertEquals(21, parent1.getTotalAge().intValue()); + assertEquals("A Bean", parent1.getEffectiveBean().getName()); + + grandparent1 = parent1.getParent(); + // check if aggregation works + assertEquals(3, grandparent1.getChildCount().intValue()); + assertEquals(150, grandparent1.getTotalAge().intValue()); + + // check normal properties + assertEquals("Josef", grandparent1.getName()); + assertEquals("Foo", grandparent1.getFamilyName()); + assertEquals("Munich", grandparent1.getAddress()); + assertEquals(1, grandparent1.getEffectiveBean().getId().intValue()); } } diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java index 21f032e36..b842fcae6 100644 --- a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -20,7 +20,7 @@ public class GrandParentPerson extends InheritablePerson { // This rather complex formulas should be built later by CustomAnnotationParser private static final String PARENT_PERSON_AGGREGATE_JOIN = "left join " - + "(select parent_identifier, count(*) as child_count, sum(age) as child_age from parent_person group by parent_identifier) " + + "(select i1.parent_identifier, count(*) as child_count, sum(i1.age) as child_age from parent_person i1 group by i1.parent_identifier) " + "as f1 on f1.parent_identifier = ${ta}.identifier"; //@Count("children") @@ -36,7 +36,8 @@ public class GrandParentPerson extends InheritablePerson { private String address; - @Formula(select = "${ta}.some_bean_id+1") + // Demonstrate formula usage + @Formula(select = "coalesce(${ta}.some_bean_id,1)") @ManyToOne private EBasic effectiveBean; diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index 32e235eff..1503255d3 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -18,8 +18,8 @@ public class ParentPerson extends InheritablePerson { //This rather complex formulas should be built later by CustomAnnotationParser private static final String CHILD_PERSON_AGGREGATE_JOIN = "left join " - + "(select parent_identifier, count(*) as child_count, sum(age) as child_age from child_person group by parent_identifier) " - + "as f1 on f1.parent_identifier = ${ta}.identifier"; + + "(select i2.parent_identifier, count(*) as child_count, sum(i2.age) as child_age from child_person i2 group by i2.parent_identifier) " + + "as f2 on f2.parent_identifier = ${ta}.identifier"; private static final String GRAND_PARENT_PERSON_JOIN = "join grand_parent_person j1 on j1.identifier = ${ta}.parent_identifier"; @@ -30,11 +30,11 @@ public class ParentPerson extends InheritablePerson { private List children = new ArrayList<>(); //@Count("children") - @Formula(select = "coalesce(f1.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) private Integer childCount; //@Sum("children.age") - @Formula(select = "coalesce(f1.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) private Integer totalAge; private String familyName; From 7341f742de1ccf2f3ab482edd0b02c285d9fb8eb Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Fri, 11 Nov 2016 10:08:08 +0100 Subject: [PATCH 48/87] ADD missing join in test --- .../com/avaje/tests/model/family/ParentPerson.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index 1503255d3..14c73bb7c 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -30,11 +30,11 @@ public class ParentPerson extends InheritablePerson { private List children = new ArrayList<>(); //@Count("children") - @Formula(select = "coalesce(f2.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) private Integer childCount; //@Sum("children.age") - @Formula(select = "coalesce(f2.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) private Integer totalAge; private String familyName; @@ -42,14 +42,14 @@ public class ParentPerson extends InheritablePerson { private String address; //@Coalesce({ "familyName", "parent.familyName" }) - @Formula(select = "coalesce(${ta}.family_name, j1.family_name)", join = GRAND_PARENT_PERSON_JOIN ) + @Formula(select = "coalesce(${ta}.family_name, j1.family_name)", join = GRAND_PARENT_PERSON_JOIN ) private String effectiveFamilyName; //@Coalesce({ "address", "parent.address" }) - @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN ) + @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN ) private String effectiveAddress; - @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)") + @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)", join = GRAND_PARENT_PERSON_JOIN ) @ManyToOne private EBasic effectiveBean; From 482d454fc3a0eac7c0693416e00af1fe2d0cde48 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 11 Nov 2016 23:43:13 +1300 Subject: [PATCH 49/87] #875 - Changes to support ElasticSearch 5.x --- src/main/java/com/avaje/ebean/Junction.java | 5 +++ .../avaje/ebean/search/TextQueryString.java | 35 ------------------- .../ebeaninternal/api/SpiExpressionList.java | 10 ++++-- .../expression/DefaultExpressionList.java | 5 +++ .../server/querydefn/OrmQueryProperties.java | 6 ++-- 5 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/avaje/ebean/Junction.java b/src/main/java/com/avaje/ebean/Junction.java index 35ec6aa90..5d2121882 100644 --- a/src/main/java/com/avaje/ebean/Junction.java +++ b/src/main/java/com/avaje/ebean/Junction.java @@ -96,6 +96,11 @@ public interface Junction extends Expression, ExpressionList { */ NOT(" and ", "not ", false), + /** + * FILTER group (for internal use only). + */ + FILTER("filter", "", true), + /** * Text search AND group. */ diff --git a/src/main/java/com/avaje/ebean/search/TextQueryString.java b/src/main/java/com/avaje/ebean/search/TextQueryString.java index a50af6ff1..40f0d5e55 100644 --- a/src/main/java/com/avaje/ebean/search/TextQueryString.java +++ b/src/main/java/com/avaje/ebean/search/TextQueryString.java @@ -38,7 +38,6 @@ package com.avaje.ebean.search; public class TextQueryString { public static final int DEFAULT_FUZZY_MAX_EXPANSIONS = 50; - public static final int DEFAULT_MAX_DETERMINIZED_STATES = 10000; protected final String[] fields; @@ -62,8 +61,6 @@ public class TextQueryString { protected boolean lowercaseExpandedTerms = true; - protected boolean enablePositionIncrements = true; - protected int fuzzyMaxExpansions = DEFAULT_FUZZY_MAX_EXPANSIONS; protected String fuzziness; @@ -78,8 +75,6 @@ public class TextQueryString { protected boolean autoGeneratePhraseQueries; - protected int maxDeterminizedStates = DEFAULT_MAX_DETERMINIZED_STATES; - protected String minShouldMatch; protected boolean lenient; @@ -192,14 +187,6 @@ public class TextQueryString { return this; } - /** - * Set enable position increments mode. - */ - public TextQueryString enablePositionIncrements(boolean enablePositionIncrements) { - this.enablePositionIncrements = enablePositionIncrements; - return this; - } - /** * Set fuzzy max expansions. */ @@ -255,14 +242,6 @@ public class TextQueryString { return this; } - /** - * Set the max determinized states. - */ - public TextQueryString maxDeterminizedStates(int maxDeterminizedStates) { - this.maxDeterminizedStates = maxDeterminizedStates; - return this; - } - /** * Set the time zone. */ @@ -363,13 +342,6 @@ public class TextQueryString { return lowercaseExpandedTerms; } - /** - * Return the enable position increments mode. - */ - public boolean isEnablePositionIncrements() { - return enablePositionIncrements; - } - /** * Return the fuzzy max expansions. */ @@ -419,13 +391,6 @@ public class TextQueryString { return autoGeneratePhraseQueries; } - /** - * Return the max determinized states. - */ - public int getMaxDeterminizedStates() { - return maxDeterminizedStates; - } - /** * Return the time zone. */ diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java index c035d1b55..4c19c61a2 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java @@ -1,6 +1,7 @@ package com.avaje.ebeaninternal.api; import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.Junction; import com.avaje.ebeaninternal.server.expression.DocQueryContext; import java.io.IOException; @@ -11,16 +12,21 @@ import java.util.List; */ public interface SpiExpressionList extends ExpressionList, SpiExpression { + /** + * Return the expression list as a Junction (for ElasticSearch). + */ + Junction toJunction(); + /** * Return the underlying list of expressions. */ List getUnderlyingList(); - + /** * Return a copy of the ExpressionList with the path trimmed for filterMany() expressions. */ SpiExpressionList trimPath(int prefixTrim); - + /** * Return true if this list is empty. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index 2da0b3c90..fc0274859 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -103,6 +103,11 @@ public class DefaultExpressionList implements SpiExpressionList { } } + @Override + public Junction toJunction() { + return new JunctionExpression<>(Junction.Type.FILTER, this); + } + public void simplify() { simplifyEntries(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java index c7cac78b5..c22b06e34 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryProperties.java @@ -77,7 +77,7 @@ public class OrmQueryProperties implements Serializable { * Construct for root so path (and parentPath) are null. */ public OrmQueryProperties() { - this((String)null); + this((String) null); } /** @@ -123,7 +123,7 @@ public class OrmQueryProperties implements Serializable { this.parentPath = SplitName.parent(path); // for rawSql parsedProperties can be empty (when only fetching Id property) this.included = parsedProperties; - this.rawProperties = join(parsedProperties); + this.rawProperties = join(parsedProperties); this.trimmedProperties = rawProperties; this.cache = false; this.readOnly = false; @@ -263,7 +263,7 @@ public class OrmQueryProperties implements Serializable { } } - boolean hasSelectClause() { + public boolean hasSelectClause() { if ("*".equals(trimmedProperties)) { // explicitly selected all properties return true; From 01f551a9513ce3e75767c0c78133cf57b2762793 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 12 Nov 2016 01:05:13 +1300 Subject: [PATCH 50/87] #875 - Changes to support ElasticSearch 5.x --- .../ebeaninternal/server/expression/IsEmptyExpression.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java index 950bf0ef9..c79424d1c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java @@ -41,12 +41,12 @@ class IsEmptyExpression extends AbstractExpression { if (nestedPath == null) { context.writeExists(!empty, propName); } else { - // wrap NOT around the outside of nested path exists expression - context.startNot(); + // wrap bool must not around the outside of nested path exists expression + context.startBoolMustNot(); context.startNested(nestedPath); context.writeExists(empty, propName); context.endNested(); - context.endNot(); + context.endBool(); } } From 97f1834c4d537f5f815fdf2085e20f7b91286e5f Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Mon, 14 Nov 2016 12:47:19 +1300 Subject: [PATCH 51/87] Batching exception safety: Update test to reflect real world scenario more closely (and actually fail before the change) --- .../TestBatchOnCascadeExceptionHandling.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java index 8a011199d..f7033f8c6 100644 --- a/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java @@ -1,7 +1,6 @@ package com.avaje.tests.batchinsert; import com.avaje.ebean.BaseTestCase; -import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Transaction; import com.avaje.ebean.config.PersistBatch; @@ -22,61 +21,61 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase { @Test public void testBatchScenarioWithSavepoint() throws SQLException { - EbeanServer server = Ebean.getDefaultServer(); - Transaction txn = server.beginTransaction(); + server().save(createEntityWithName("conflict", "before")); + + Transaction txn = server().beginTransaction(); try { - server.save(createEntityWithName("before-savepoint")); + EBasicWithUniqueCon v2 = createEntityWithName("conflict", "after"); txn.flushBatch(); Savepoint sp = txn.getConnection().setSavepoint(); try { - server.save(createEntityWithName("confict")); - server.save(createEntityWithName("confict")); // unique key violation + server().save(v2); // unique key violation } catch (PersistenceException e) { txn.getConnection().rollback(sp); - server.save(createEntityWithName("after-savepoint")); - } + EBasicWithUniqueCon conflicting = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findUnique(); + assertThat(conflicting).isNotNull(); + server().delete(conflicting); + server().save(v2); // try again + } txn.commit(); } finally { txn.end(); } - assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "before-savepoint").findList()).isNotEmpty(); - assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "after-savepoint").findList()).isNotEmpty(); - assertThat(server.find(EBasicWithUniqueCon.class).where().eq("name", "confict").findList()).isEmpty(); + EBasicWithUniqueCon winner = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findUnique(); + assertThat(winner).isNotNull(); + assertThat(winner.getDescription()).isEqualTo("after"); } @Test public void testBatchedInsertFailure() { - final EbeanServer server = Ebean.getDefaultServer(); - server.save(createEntityWithName("foo")); - testBatchOnCascadeIsExceptionSafe(server, () -> { - server.save(createEntityWithName("foo")); // duplicate name on insert + server().save(createEntityWithName("foo")); + testBatchOnCascadeIsExceptionSafe(server(), () -> { + server().save(createEntityWithName("foo")); // duplicate name on insert }); } @Test public void testBatchedUpdateFailure() { - final EbeanServer server = Ebean.getDefaultServer(); - server.save(createEntityWithName("bla")); + server().save(createEntityWithName("bla")); final EBasicWithUniqueCon bar = createEntityWithName("bar"); - server.save(bar); - testBatchOnCascadeIsExceptionSafe(server, () -> { + server().save(bar); + testBatchOnCascadeIsExceptionSafe(server(), () -> { bar.setName("bla"); - server.save(bar); // duplicate name on update + server().save(bar); // duplicate name on update }); } @Test public void testBatchedDeleteFailure() { - final EbeanServer server = Ebean.getDefaultServer(); final EOptOneC c = new EOptOneC(); - server.save(c); + server().save(c); final EOptOneB b = new EOptOneB(); b.setC(c); - server.save(b); - testBatchOnCascadeIsExceptionSafe(server, () -> { - server.delete(c); // foreign key violation + server().save(b); + testBatchOnCascadeIsExceptionSafe(server(), () -> { + server().delete(c); // foreign key violation }); } @@ -98,8 +97,13 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase { } protected EBasicWithUniqueCon createEntityWithName(String name) { + return createEntityWithName(name, null); + } + + protected EBasicWithUniqueCon createEntityWithName(String name, String description) { EBasicWithUniqueCon it = new EBasicWithUniqueCon(); it.setName(name); + it.setDescription(description); return it; } } From b41f3e9d1f3e964c1a7521ddc8a3de43d5a7ff35 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 15 Nov 2016 22:12:54 +1300 Subject: [PATCH 52/87] #877 - DBMigration Generates wrong ddl for UUID type --- .../com/avaje/ebean/config/DbTypeConfig.java | 123 ++++++++++++++++++ .../com/avaje/ebean/config/ServerConfig.java | 49 +++---- .../config/dbplatform/DatabasePlatform.java | 19 ++- .../dbplatform/DbPlatformTypeMapping.java | 3 +- .../ebean/config/dbplatform/H2Platform.java | 15 +-- .../config/dbplatform/PostgresPlatform.java | 18 +-- .../server/core/DefaultContainer.java | 2 +- .../server/type/DefaultTypeManager.java | 2 +- .../avaje/ebean/config/ServerConfigTest.java | 5 +- .../dbplatform/DatabasePlatformTest.java | 16 +-- .../config/dbplatform/MySqlPlatformTest.java | 11 +- .../config/dbplatform/OraclePlatformTest.java | 11 +- .../dbplatform/PostgresPlatformTest.java | 6 +- 13 files changed, 192 insertions(+), 88 deletions(-) create mode 100644 src/main/java/com/avaje/ebean/config/DbTypeConfig.java diff --git a/src/main/java/com/avaje/ebean/config/DbTypeConfig.java b/src/main/java/com/avaje/ebean/config/DbTypeConfig.java new file mode 100644 index 000000000..64c45ade4 --- /dev/null +++ b/src/main/java/com/avaje/ebean/config/DbTypeConfig.java @@ -0,0 +1,123 @@ +package com.avaje.ebean.config; + +import com.avaje.ebean.config.dbplatform.DbType; +import com.avaje.ebean.config.dbplatform.IdType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Configuration for DB types such as UUID, Geometry etc. + */ +public class DbTypeConfig { + + /** + * The Geometry SRID value (default 4326). + */ + private int geometrySRID = 4326; + + /** + * Set for DB's that support both Sequence and Identity (and the default choice is not desired). + */ + private IdType idType; + + /** + * Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres). + */ + private ServerConfig.DbUuid dbUuid = ServerConfig.DbUuid.AUTO_VARCHAR; + + /** + * Modify the default mapping of standard types such as default precision for DECIMAL etc. + */ + private List customDbTypeMappings = new ArrayList<>(); + + /** + * Return the Geometry SRID. + */ + public int getGeometrySRID() { + return geometrySRID; + } + + /** + * Set the Geometry SRID. + */ + public void setGeometrySRID(int geometrySRID) { + this.geometrySRID = geometrySRID; + } + + /** + * Return the DB type used to store UUID. + */ + public ServerConfig.DbUuid getDbUuid() { + return dbUuid; + } + + /** + * Set the DB type used to store UUID. + */ + public void setDbUuid(ServerConfig.DbUuid dbUuid) { + this.dbUuid = dbUuid; + } + + /** + * Return the IdType to use (or null for the default choice). + */ + public IdType getIdType() { + return idType; + } + + /** + * Set the IdType to use (when the DB supports both SEQUENCE and IDENTITY and the default is not desired). + */ + public void setIdType(IdType idType) { + this.idType = idType; + } + + /** + * Add a custom type mapping. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal.class/decimal
+   *   serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String.class/varchar but only for Postgres
+   *   serverConfig.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
+   *
+   * }
+ * + * @param type The DB type this mapping should apply to + * @param columnDefinition The column definition that should be used + * @param platform Optionally specify the platform this mapping should apply to. + */ + public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { + customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform)); + } + + /** + * Add a custom type mapping that applies to all platforms. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal/decimal
+   *   serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String/varchar
+   *   serverConfig.addCustomMapping(DbType.VARCHAR, "text");
+   *
+   * }
+ * + * @param type The DB type this mapping should apply to + * @param columnDefinition The column definition that should be used + */ + public void addCustomMapping(DbType type, String columnDefinition) { + customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition)); + } + + /** + * Return the list of custom type mappings. + */ + public List getCustomTypeMappings() { + return customDbTypeMappings; + } +} diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 7ca2590ea..7bc138f82 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -91,8 +91,6 @@ public class ServerConfig { private ContainerConfig containerConfig; - private List customDbTypeMappings = new ArrayList<>(); - /** * The underlying properties that were used during configuration. */ @@ -118,11 +116,6 @@ public class ServerConfig { */ private boolean disableClasspathSearch; - /** - * The Geometry SRID value (default 4326). - */ - private int geometrySRID = 4326; - /** * List of interesting classes such as entities, embedded, ScalarTypes, * Listeners, Finders, Controllers etc. @@ -332,10 +325,9 @@ public class ServerConfig { private boolean updatesDeleteMissingChildren = true; /** - * Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres). + * Database type configuration. */ - private DbUuid dbUuid = DbUuid.AUTO_VARCHAR; - + private DbTypeConfig dbTypeConfig = new DbTypeConfig(); private List idGenerators = new ArrayList<>(); private List findControllers = new ArrayList<>(); @@ -912,14 +904,14 @@ public class ServerConfig { * Return the Geometry SRID. */ public int getGeometrySRID() { - return geometrySRID; + return dbTypeConfig.getGeometrySRID(); } /** * Set the Geometry SRID. */ public void setGeometrySRID(int geometrySRID) { - this.geometrySRID = geometrySRID; + dbTypeConfig.setGeometrySRID(geometrySRID); } /** @@ -1568,17 +1560,17 @@ public class ServerConfig { } /** - * Return the DB type used to store UUID. + * Return the configuration for DB types (such as UUID and custom mappings). */ - public DbUuid getDbUuid() { - return dbUuid; + public DbTypeConfig getDbTypeConfig() { + return dbTypeConfig; } /** * Set the DB type used to store UUID. */ public void setDbUuid(DbUuid dbUuid) { - this.dbUuid = dbUuid; + this.dbTypeConfig.setDbUuid(dbUuid); } /** @@ -2006,7 +1998,7 @@ public class ServerConfig { * @param platform Optionally specify the platform this mapping should apply to. */ public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { - customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform)); + dbTypeConfig.addCustomMapping(type, columnDefinition, platform); } /** @@ -2026,14 +2018,7 @@ public class ServerConfig { * @param columnDefinition The column definition that should be used */ public void addCustomMapping(DbType type, String columnDefinition) { - customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition)); - } - - /** - * Return the list of custom type mappings. - */ - public List getCustomTypeMappings() { - return customDbTypeMappings; + dbTypeConfig.addCustomMapping(type, columnDefinition); } /** @@ -2414,7 +2399,11 @@ public class ServerConfig { } loadDocStoreSettings(p); - geometrySRID = p.getInt("geometrySRID", geometrySRID); + int srid = p.getInt("geometrySRID", 0); + if (srid > 0) { + dbTypeConfig.setGeometrySRID(srid); + } + disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache); explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode); autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode); @@ -2474,9 +2463,13 @@ public class ServerConfig { databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue); databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse); databasePlatformName = p.get("databasePlatformName", databasePlatformName); - dbUuid = p.getEnum(DbUuid.class, "dbuuid", dbUuid); + + DbUuid dbUuid = p.getEnum(DbUuid.class, "dbuuid", null); + if (dbUuid != null) { + dbTypeConfig.setDbUuid(dbUuid); + } if (p.getBoolean("uuidStoreAsBinary", false)) { - dbUuid = DbUuid.BINARY; + dbTypeConfig.setDbUuid(DbUuid.BINARY); } localTimeWithNanos = p.getBoolean("localTimeWithNanos", localTimeWithNanos); jodaLocalTimeMode = p.get("jodaLocalTimeMode", jodaLocalTimeMode); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java index 97671b6ed..951f0fb53 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java @@ -3,6 +3,7 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.Query; import com.avaje.ebean.config.CustomDbTypeMapping; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.config.PersistBatch; import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.ServerConfig; @@ -180,15 +181,27 @@ public class DatabasePlatform { /** * Configure UUID Storage etc based on ServerConfig settings. */ - public void configure(ServerConfig serverConfig) { - dbTypeMap.config(nativeUuidType, serverConfig.getDbUuid()); - for (CustomDbTypeMapping mapping : serverConfig.getCustomTypeMappings()) { + public void configure(DbTypeConfig config) { + addGeoTypes(config.getGeometrySRID()); + configureIdType(config.getIdType()); + dbTypeMap.config(nativeUuidType, config.getDbUuid()); + for (CustomDbTypeMapping mapping : config.getCustomTypeMappings()) { if (platformMatch(mapping.getPlatform())) { dbTypeMap.put(mapping.getType(), parse(mapping.getColumnDefinition())); } } } + protected void configureIdType(IdType idType) { + if (idType != null) { + this.dbIdentity.setIdType(idType); + } + } + + protected void addGeoTypes(int srid) { + // default has no geo type support + } + private DbPlatformType parse(String columnDefinition) { return DbPlatformType.parse(columnDefinition); } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java index c2c2d791c..27b90996b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeMapping.java @@ -103,7 +103,8 @@ public class DbPlatformTypeMapping { put(DbType.JSONCLOB, JSON_CLOB_PLACEHOLDER); put(DbType.JSONBLOB, JSON_BLOB_PLACEHOLDER); put(DbType.JSONVARCHAR, JSON_VARCHAR_PLACEHOLDER); - put(DbType.UUID, UUID_PLACEHOLDER); + // use reasonable default of varchar(40) - ideally set via DatabasePlatform.configure(DbTypeConfig) + put(DbType.UUID, get(DbType.VARCHAR).withLength(40)); } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java index 25ba2073d..a1e0949fe 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java @@ -30,20 +30,7 @@ public class H2Platform extends DatabasePlatform { // escape clause for now noting that backslash is an escape char for like in H2 this.likeClause = "like ?"; - // H2 data types match default JDBC types - // so no changes to dbTypeMap required - } - - @Override - public void configure(ServerConfig serverConfig) { - super.configure(serverConfig); - Properties properties = serverConfig.getProperties(); - if (properties != null) { - String idType = properties.getProperty("ebean.h2.idtype"); - if (idType != null) { - this.dbIdentity.setIdType(IdType.valueOf(idType)); - } - } + dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false)); } /** diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java index 18aa77446..97a6323ec 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java @@ -7,7 +7,6 @@ import com.avaje.ebean.dbmigration.ddlgeneration.platform.PostgresDdl; import javax.sql.DataSource; import java.sql.Types; -import java.util.Properties; /** * Postgres v9 specific platform. @@ -44,6 +43,7 @@ public class PostgresPlatform extends DatabasePlatform { DbPlatformType dbTypeText = new DbPlatformType("text"); DbPlatformType dbBytea = new DbPlatformType("bytea", false); + dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false)); dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false)); dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false)); dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false)); @@ -63,21 +63,7 @@ public class PostgresPlatform extends DatabasePlatform { dbTypeMap.put(DbType.LONGVARCHAR, dbTypeText); } - @Override - public void configure(ServerConfig serverConfig) { - super.configure(serverConfig); - Properties properties = serverConfig.getProperties(); - if (properties != null) { - String tsType = properties.getProperty("ebean.postgres.timestamp"); - if (tsType != null) { - // set timestamp type to "timestamp" without time zone - dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType(tsType)); - } - } - addGeoTypes(serverConfig.getGeometrySRID()); - } - - private void addGeoTypes(int srid) { + protected void addGeoTypes(int srid) { dbTypeMap.put(DbType.POINT, geoType("point",srid)); dbTypeMap.put(DbType.POLYGON, geoType("polygon",srid)); dbTypeMap.put(DbType.LINESTRING, geoType("linestring",srid)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java index 38e781d70..e6c9df9dd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java @@ -238,7 +238,7 @@ public class DefaultContainer implements SpiContainer { if (dbPlatform == null) { DatabasePlatformFactory factory = new DatabasePlatformFactory(); DatabasePlatform db = factory.create(config); - db.configure(config); + db.configure(config.getDbTypeConfig()); config.setDatabasePlatform(db); logger.info("DatabasePlatform name:{} platform:{}", config.getName(), db.getName()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index ef5753f74..3aed66650 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -1013,7 +1013,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { nativeMap.put(Types.BIT, booleanType); } - ServerConfig.DbUuid dbUuid = config.getDbUuid(); + ServerConfig.DbUuid dbUuid = config.getDbTypeConfig().getDbUuid(); if (offlineMigrationGeneration || (databasePlatform.isNativeUuidType() && dbUuid.useNativeType())) { typeMap.put(UUID.class, new ScalarTypeUUIDNative()); diff --git a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java index 01c1b4029..9b95de0e7 100644 --- a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java +++ b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java @@ -8,7 +8,6 @@ import static org.junit.Assert.*; public class ServerConfigTest { - @Test public void testLoadFromEbeanProperties() { @@ -41,7 +40,7 @@ public class ServerConfigTest { assertTrue(serverConfig.isH2ProductionMode()); assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch()); assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade()); - assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid()); + assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbTypeConfig().getDbUuid()); assertEquals(42, serverConfig.getJdbcFetchSizeFindEach()); assertEquals(43, serverConfig.getJdbcFetchSizeFindList()); assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize()); @@ -60,4 +59,4 @@ public class ServerConfigTest { assertEquals(PersistBatch.ALL, serverConfig.getPersistBatch()); assertEquals(PersistBatch.ALL, serverConfig.getPersistBatchOnCascade()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/DatabasePlatformTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/DatabasePlatformTest.java index 923834382..e185b7413 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/DatabasePlatformTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/DatabasePlatformTest.java @@ -1,10 +1,10 @@ package com.avaje.ebean.config.dbplatform; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.config.Platform; -import com.avaje.ebean.config.ServerConfig; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DatabasePlatformTest { @@ -19,19 +19,19 @@ public class DatabasePlatformTest { @Test public void configure_customType() throws Exception { - ServerConfig serverConfig = new ServerConfig(); - serverConfig.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES); - serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(24,4)"); + DbTypeConfig config = new DbTypeConfig(); + config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES); + config.addCustomMapping(DbType.DECIMAL, "decimal(24,4)"); // PG renders custom decimal and varchar PostgresPlatform pgPlatform = new PostgresPlatform(); - pgPlatform.configure(serverConfig); + pgPlatform.configure(config); assertEquals(defaultDecimalDefn(pgPlatform), "decimal(24,4)"); assertEquals(defaultDefn(DbType.VARCHAR, pgPlatform), "text"); // H2 only renders custom decimal H2Platform h2Platform = new H2Platform(); - h2Platform.configure(serverConfig); + h2Platform.configure(config); assertEquals(defaultDecimalDefn(h2Platform), "decimal(24,4)"); assertEquals(defaultDefn(DbType.VARCHAR, h2Platform), "varchar(255)"); } @@ -43,4 +43,4 @@ public class DatabasePlatformTest { private String defaultDefn(DbType type, DatabasePlatform dbPlatform) { return dbPlatform.getDbTypeMap().get(type).renderType(0, 0); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/MySqlPlatformTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/MySqlPlatformTest.java index bbf77fa0c..df2c16960 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/MySqlPlatformTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/MySqlPlatformTest.java @@ -1,5 +1,6 @@ package com.avaje.ebean.config.dbplatform; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl; import org.junit.Test; @@ -25,7 +26,7 @@ public class MySqlPlatformTest { public void uuid_default() { MySqlPlatform platform = new MySqlPlatform(); - platform.configure(new ServerConfig()); + platform.configure(new DbTypeConfig()); DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID); assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)"); @@ -36,12 +37,12 @@ public class MySqlPlatformTest { public void uuid_as_binary() { MySqlPlatform platform = new MySqlPlatform(); - ServerConfig serverConfig = new ServerConfig(); - serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY); - platform.configure(serverConfig); + DbTypeConfig config = new DbTypeConfig(); + config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY); + platform.configure(config); DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID); assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/OraclePlatformTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/OraclePlatformTest.java index 5fd5c9fe7..3633fc2e0 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/OraclePlatformTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/OraclePlatformTest.java @@ -1,5 +1,6 @@ package com.avaje.ebean.config.dbplatform; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl; import org.junit.Test; @@ -34,7 +35,7 @@ public class OraclePlatformTest { public void uuid_default() { OraclePlatform platform = new OraclePlatform(); - platform.configure(new ServerConfig()); + platform.configure(new DbTypeConfig()); DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID); assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)"); @@ -45,12 +46,12 @@ public class OraclePlatformTest { public void uuid_as_binary() { OraclePlatform platform = new OraclePlatform(); - ServerConfig serverConfig = new ServerConfig(); - serverConfig.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY); + DbTypeConfig config = new DbTypeConfig(); + config.setDbUuid(ServerConfig.DbUuid.AUTO_BINARY); - platform.configure(serverConfig); + platform.configure(config); DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID); assertThat(dbType.renderType(0, 0)).isEqualTo("raw(16)"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java index 41577423f..9078e53f2 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java @@ -1,6 +1,6 @@ package com.avaje.ebean.config.dbplatform; -import com.avaje.ebean.config.ServerConfig; +import com.avaje.ebean.config.DbTypeConfig; import com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl; import org.junit.Test; @@ -36,7 +36,7 @@ public class PostgresPlatformTest { public void testUuidType() { PostgresPlatform platform = new PostgresPlatform(); - platform.configure(new ServerConfig()); + platform.configure(new DbTypeConfig()); DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID); String columnDefn = dbType.renderType(0, 0); @@ -44,4 +44,4 @@ public class PostgresPlatformTest { assertThat(columnDefn).isEqualTo("uuid"); } -} \ No newline at end of file +} From 632cf10096c62e1f640dc797891fd6e2c772d278 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 15 Nov 2016 22:48:36 +1300 Subject: [PATCH 53/87] #878 - @AttributeOverride (not wrapped in @AttributeOverrides) is not applied --- .../server/deploy/parse/AnnotationParser.java | 6 +++ .../tests/model/embedded/PrimaryRevision.java | 51 ++++++++++++++++++ .../tests/model/embedded/RevisionId.java | 53 +++++++++++++++++++ .../embedded/TestEmbeddedAttrOverride.java | 27 ++++++++++ src/test/resources/logback-test.xml | 8 +-- 5 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java create mode 100644 src/test/java/com/avaje/tests/model/embedded/RevisionId.java create mode 100644 src/test/java/com/avaje/tests/model/embedded/TestEmbeddedAttrOverride.java diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java index 8ddb2422c..da7ac51a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -62,7 +62,13 @@ public abstract class AnnotationParser extends AnnotationBase { propMap.put(propName, columnName); } + prop.getDeployEmbedded().putAll(propMap); + } + AttributeOverride attrOverride = get(prop, AttributeOverride.class); + if (attrOverride != null) { + HashMap propMap = new HashMap<>(); + propMap.put(attrOverride.name(), attrOverride.column().name()); prop.getDeployEmbedded().putAll(propMap); } diff --git a/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java b/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java new file mode 100644 index 000000000..c69c3a0b0 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java @@ -0,0 +1,51 @@ +package com.avaje.tests.model.embedded; + +import javax.persistence.AttributeOverride; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Version; + +@Entity +public class PrimaryRevision { + + @EmbeddedId +// @AttributeOverrides({ +// @AttributeOverride(name="primaryId", column = @Column(name="id")) +// }) + @AttributeOverride(name="primaryId", column = @Column(name="id")) + private RevisionId revisionId; + + String name; + + @Version + long version; + + public PrimaryRevision(long someId) { + this.revisionId = new RevisionId(someId, 1); + } + + public RevisionId getRevisionId() { + return revisionId; + } + + public void setRevisionId(RevisionId revisionId) { + this.revisionId = revisionId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getVersion() { + return version; + } + + public void setVersion(long version) { + this.version = version; + } +} diff --git a/src/test/java/com/avaje/tests/model/embedded/RevisionId.java b/src/test/java/com/avaje/tests/model/embedded/RevisionId.java new file mode 100644 index 000000000..eb56c616f --- /dev/null +++ b/src/test/java/com/avaje/tests/model/embedded/RevisionId.java @@ -0,0 +1,53 @@ +package com.avaje.tests.model.embedded; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class RevisionId { + + Long primaryId; + + Integer revision; + + public RevisionId() { + } + + public RevisionId(Long primaryId, Integer revision) { + this.revision = revision; + this.primaryId = primaryId; + } + + @Column(name = "revision") + public Integer getRevision() { + return revision; + } + + public void setRevision(Integer revision) { + this.revision = revision; + } + + public Long getPrimaryId() { + return primaryId; + } + + public void setPrimaryId(Long primaryId) { + this.primaryId = primaryId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RevisionId that = (RevisionId) o; + if (!primaryId.equals(that.primaryId)) return false; + return revision.equals(that.revision); + } + + @Override + public int hashCode() { + int result = primaryId.hashCode(); + result = 31 * result + revision.hashCode(); + return result; + } +} diff --git a/src/test/java/com/avaje/tests/model/embedded/TestEmbeddedAttrOverride.java b/src/test/java/com/avaje/tests/model/embedded/TestEmbeddedAttrOverride.java new file mode 100644 index 000000000..4b1be9a9a --- /dev/null +++ b/src/test/java/com/avaje/tests/model/embedded/TestEmbeddedAttrOverride.java @@ -0,0 +1,27 @@ +package com.avaje.tests.model.embedded; + +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Test; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestEmbeddedAttrOverride extends BaseTestCase { + + @Test + public void insert() { + + PrimaryRevision bean = new PrimaryRevision(100); + bean.setName("hello"); + + LoggedSqlCollector.start(); + Ebean.save(bean); + + List sql = LoggedSqlCollector.stop(); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("insert into primary_revision (id, revision, name, version) values (?,?,?,?)"); + } +} diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 35785369c..c89a0efdd 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -79,9 +79,9 @@ - - - + + + @@ -96,4 +96,4 @@ - \ No newline at end of file + From 7e7951df09fbc87dc9cdf623db69da2db3630f0b Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 15 Nov 2016 11:15:54 +0100 Subject: [PATCH 54/87] ADD @OrderBy to fix Postgres-tests --- src/test/java/com/avaje/tests/model/family/ParentPerson.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index 14c73bb7c..98d46b09e 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -8,6 +8,7 @@ import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.OrderBy; import com.avaje.ebean.annotation.Formula; import com.avaje.tests.model.basic.EBasic; @@ -27,6 +28,7 @@ public class ParentPerson extends InheritablePerson { private GrandParentPerson parent; @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) + @OrderBy("identifier") private List children = new ArrayList<>(); //@Count("children") From de9576835c28aabb5561adacc8ad02e1763e8352 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 15 Nov 2016 23:27:08 +1300 Subject: [PATCH 55/87] #872 - test models for DDL check constraint issue (not reproduced) --- .../avaje/tests/model/embedded/EAddress.java | 16 +++++++++++-- .../tests/model/embedded/EAddressStatus.java | 6 +++++ .../avaje/tests/model/embedded/EInvoice.java | 23 ++++++++++--------- .../avaje/tests/model/embedded/EPerson.java | 7 ++++++ 4 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 src/test/java/com/avaje/tests/model/embedded/EAddressStatus.java diff --git a/src/test/java/com/avaje/tests/model/embedded/EAddress.java b/src/test/java/com/avaje/tests/model/embedded/EAddress.java index b857fb5b6..a663c5e87 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EAddress.java +++ b/src/test/java/com/avaje/tests/model/embedded/EAddress.java @@ -1,16 +1,21 @@ package com.avaje.tests.model.embedded; import javax.persistence.Embeddable; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; @Embeddable public class EAddress { String street; - + String suburb; - + String city; + @Enumerated(EnumType.STRING) + EAddressStatus status; + public String getStreet() { return street; } @@ -35,4 +40,11 @@ public class EAddress { this.city = city; } + public EAddressStatus getStatus() { + return status; + } + + public void setStatus(EAddressStatus status) { + this.status = status; + } } diff --git a/src/test/java/com/avaje/tests/model/embedded/EAddressStatus.java b/src/test/java/com/avaje/tests/model/embedded/EAddressStatus.java new file mode 100644 index 000000000..8e327ed76 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/embedded/EAddressStatus.java @@ -0,0 +1,6 @@ +package com.avaje.tests.model.embedded; + +public enum EAddressStatus { + ONE, + TWO +} diff --git a/src/test/java/com/avaje/tests/model/embedded/EInvoice.java b/src/test/java/com/avaje/tests/model/embedded/EInvoice.java index 01a75f8f8..0636d69d5 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EInvoice.java +++ b/src/test/java/com/avaje/tests/model/embedded/EInvoice.java @@ -20,28 +20,29 @@ public class EInvoice { public enum State { New, Processing, Approved } - + @Id Long id; - + @Version Long version; - + Date invoiceDate; - + State state; - + @ManyToOne EPerson person; - + @Embedded @AttributeOverrides({ @AttributeOverride(name = "street", column = @Column(name = "ship_street")), @AttributeOverride(name = "suburb", column = @Column(name = "ship_suburb")), - @AttributeOverride(name = "city", column = @Column(name = "ship_city")) - }) + @AttributeOverride(name = "city", column = @Column(name = "ship_city")), + @AttributeOverride(name = "status", column = @Column(name = "ship_status")) + }) EAddress shipAddress; - + @Embedded EAddress billAddress; @@ -60,7 +61,7 @@ public class EInvoice { public void setVersion(Long version) { this.version = version; } - + public State getState() { return state; } @@ -100,5 +101,5 @@ public class EInvoice { public void setBillAddress(EAddress billAddress) { this.billAddress = billAddress; } - + } diff --git a/src/test/java/com/avaje/tests/model/embedded/EPerson.java b/src/test/java/com/avaje/tests/model/embedded/EPerson.java index c7c496b38..fa122f0a3 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EPerson.java +++ b/src/test/java/com/avaje/tests/model/embedded/EPerson.java @@ -1,5 +1,8 @@ package com.avaje.tests.model.embedded; +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.Id; @@ -19,6 +22,10 @@ public class EPerson { String notes; @Embedded + @AttributeOverrides({ + @AttributeOverride(name="city", column = @Column(name="addr_city")), + @AttributeOverride(name="status", column = @Column(name="addr_status")) + }) EAddress address; public Long getId() { From 0f3f79ab2c4599bcb768b5d0d14a53ab99aa4e2a Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 15 Nov 2016 12:03:25 +0100 Subject: [PATCH 56/87] ADD @OrderBy to fix Postgres-tests --- .../java/com/avaje/tests/model/family/GrandParentPerson.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java index b842fcae6..8e27aae3b 100644 --- a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -8,6 +8,7 @@ import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.OrderBy; import com.avaje.ebean.annotation.Formula; import com.avaje.tests.model.basic.EBasic; @@ -16,6 +17,7 @@ import com.avaje.tests.model.basic.EBasic; public class GrandParentPerson extends InheritablePerson { @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) + @OrderBy("identifier") private List children = new ArrayList<>(); // This rather complex formulas should be built later by CustomAnnotationParser From cf81d1699b92a40edb9de661ac6d41736dd2d0fb Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 16 Nov 2016 00:23:54 +1300 Subject: [PATCH 57/87] Modify scm in pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 15568eaa7..4f072c369 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - scm:git:https://github.com/ebean-orm/ebean.git + scm:git:git@github.com:ebean-orm/ebean.git HEAD From f815415eb02aad3452833fbe54a1a0ec0035b03d Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 16 Nov 2016 00:24:44 +1300 Subject: [PATCH 58/87] [maven-release-plugin] prepare release ebean-9.1.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4f072c369..adf6d421a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.avaje.ebean ebean - 9.1.2-SNAPSHOT + 9.1.2 jar ebean @@ -21,7 +21,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - HEAD + ebean-9.1.2 From 2584fe9b7bd154c29883f46443be820b95d392b6 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 16 Nov 2016 00:24:54 +1300 Subject: [PATCH 59/87] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index adf6d421a..37a7b1e08 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.avaje.ebean ebean - 9.1.2 + 9.1.3-SNAPSHOT jar ebean @@ -21,7 +21,7 @@ scm:git:git@github.com:ebean-orm/ebean.git - ebean-9.1.2 + HEAD From 259814f4d9e332598b7abc4dd7f63b59579f2836 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 16 Nov 2016 21:57:38 +1300 Subject: [PATCH 60/87] #849 - AbstractNamingConvention.getTableName inheritance logic differs from InheritInfo --- .../config/AbstractNamingConvention.java | 22 +++++++++++++++---- .../server/deploy/parse/AnnotationClass.java | 10 ++++++--- .../inheritance/TestInheritanceOnMany.java | 22 ++++++++++++------- .../com/avaje/tests/model/basic/Animal.java | 2 -- .../com/avaje/tests/model/basic/BigDog.java | 19 ++++++++++++++++ 5 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 src/test/java/com/avaje/tests/model/basic/BigDog.java diff --git a/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java b/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java index 5a07a44ef..3f836a709 100644 --- a/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/AbstractNamingConvention.java @@ -2,8 +2,10 @@ package com.avaje.ebean.config; import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import javax.persistence.DiscriminatorValue; import javax.persistence.Inheritance; import javax.persistence.Table; +import java.lang.annotation.Annotation; /** * Provides some base implementation for NamingConventions. @@ -182,11 +184,9 @@ public abstract class AbstractNamingConvention implements NamingConvention { TableName tableName = getTableNameFromAnnotation(beanClass); if (tableName == null) { - Class supCls = beanClass.getSuperclass(); - Inheritance inheritance = supCls.getAnnotation(Inheritance.class); - if (inheritance != null) { - // get the table as per inherited class in case their + if (hasInheritance(supCls)) { + // get the table as per inherited class in case there // is not a table annotation in the inheritance hierarchy return getTableName(supCls); } @@ -207,6 +207,20 @@ public abstract class AbstractNamingConvention implements NamingConvention { return new TableName(catalog, schema, tableName.getName()); } + /** + * Return true if this class is part of entity inheritance. + */ + protected boolean hasInheritance(Class supCls) { + return hasAnnotation(supCls, Inheritance.class) || hasAnnotation(supCls, DiscriminatorValue.class); + } + + /** + * Return true if the class has the given annotation. + */ + protected boolean hasAnnotation(Class supCls, Class annotation) { + return supCls.getAnnotation(annotation) != null; + } + public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) { StringBuilder buffer = new StringBuilder(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java index 3fe8be9a7..9aac99081 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java @@ -14,6 +14,7 @@ import com.avaje.ebean.annotation.View; import com.avaje.ebean.config.TableName; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor.EntityType; import com.avaje.ebeaninternal.server.deploy.IndexDefinition; +import com.avaje.ebeaninternal.server.deploy.InheritInfo; import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -94,10 +95,13 @@ public class AnnotationClass extends AnnotationParser { private void setTableName() { if (descriptor.isBaseTableType()) { - + Class beanType = descriptor.getBeanType(); + InheritInfo inheritInfo = descriptor.getInheritInfo(); + if (inheritInfo != null) { + beanType = inheritInfo.getRoot().getType(); + } // default the TableName using NamingConvention. - TableName tableName = namingConvention.getTableName(descriptor.getBeanType()); - + TableName tableName = namingConvention.getTableName(beanType); descriptor.setBaseTable(tableName, asOfViewSuffix, versionsBetweenSuffix); } } diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java b/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java index 4aa3bb795..90d7abc60 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java @@ -6,6 +6,7 @@ import com.avaje.ebean.bean.BeanCollection.ModifyListenMode; import com.avaje.ebean.common.BeanList; import com.avaje.tests.model.basic.Animal; import com.avaje.tests.model.basic.AnimalShelter; +import com.avaje.tests.model.basic.BigDog; import com.avaje.tests.model.basic.Cat; import com.avaje.tests.model.basic.Dog; import org.junit.Test; @@ -18,31 +19,36 @@ public class TestInheritanceOnMany extends BaseTestCase { @Test public void test() { - + Cat cat = new Cat(); cat.setName("Puss"); Ebean.save(cat); - + Dog dog = new Dog(); dog.setRegistrationNumber("DOGGIE"); Ebean.save(dog); - + + BigDog bd = new BigDog(); + bd.setDogSize("large"); + bd.setRegistrationNumber("BG1"); + Ebean.save(bd); + AnimalShelter shelter = new AnimalShelter(); shelter.setName("My Animal Shelter"); shelter.getAnimals().add(cat); shelter.getAnimals().add(dog); - + Ebean.save(shelter); - + AnimalShelter shelter2 = Ebean.find(AnimalShelter.class, shelter.getId()); List animals = shelter2.getAnimals(); - + BeanList beanList = (BeanList)animals; ModifyListenMode modifyListenMode = beanList.getModifyListenMode(); - + assertNotNull(modifyListenMode); assertNotNull(Ebean.find(Animal.class).findList()); } - + } diff --git a/src/test/java/com/avaje/tests/model/basic/Animal.java b/src/test/java/com/avaje/tests/model/basic/Animal.java index 5c8f4ed80..942e023f8 100644 --- a/src/test/java/com/avaje/tests/model/basic/Animal.java +++ b/src/test/java/com/avaje/tests/model/basic/Animal.java @@ -7,11 +7,9 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.ManyToOne; -import javax.persistence.Table; import javax.persistence.Version; @Entity -@Table(name = "animals") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "species") public abstract class Animal { diff --git a/src/test/java/com/avaje/tests/model/basic/BigDog.java b/src/test/java/com/avaje/tests/model/basic/BigDog.java new file mode 100644 index 000000000..162095940 --- /dev/null +++ b/src/test/java/com/avaje/tests/model/basic/BigDog.java @@ -0,0 +1,19 @@ +package com.avaje.tests.model.basic; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +@Entity +@DiscriminatorValue("BDG") +public class BigDog extends Dog { + + String dogSize; + + public String getDogSize() { + return dogSize; + } + + public void setDogSize(String dogSize) { + this.dogSize = dogSize; + } +} From 442f24124cab70f31800641f88e16d2f4fc0aff5 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 17:15:14 +1300 Subject: [PATCH 61/87] #879 - Ebean not fetching complete list of attribute beans when equals(Object o) is implemented --- .../java/com/avaje/ebean/common/BeanList.java | 14 +++++- .../com/avaje/ebean/common/BeanListTest.java | 49 ++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/avaje/ebean/common/BeanList.java b/src/main/java/com/avaje/ebean/common/BeanList.java index 37fd9c309..c5616a1e2 100644 --- a/src/main/java/com/avaje/ebean/common/BeanList.java +++ b/src/main/java/com/avaje/ebean/common/BeanList.java @@ -85,11 +85,23 @@ public final class BeanList extends AbstractBeanCollection implements List @Override public void internalAddWithCheck(Object bean) { - if (list == null || !list.contains(bean)) { + if (list == null || !containsInstance(bean)) { internalAdd(bean); } } + /** + * Contains using instance equality for List (specifically not .equals() based). + */ + private boolean containsInstance(Object bean) { + for (Object element : list) { + if (element == bean) { + return true; + } + } + return false; + } + public boolean checkEmptyLazyLoad() { if (list == null) { list = new ArrayList<>(); diff --git a/src/test/java/com/avaje/ebean/common/BeanListTest.java b/src/test/java/com/avaje/ebean/common/BeanListTest.java index 712c5b7ad..6dca3d9ec 100644 --- a/src/test/java/com/avaje/ebean/common/BeanListTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanListTest.java @@ -230,4 +230,51 @@ public class BeanListTest { assertThat(list.getModifyRemovals()).containsExactly(object1); } -} \ No newline at end of file + @Test + public void internalAddWithCheck_when_interestingEquals_usesInstanceEquality() { + + BeanList list = new BeanList<>(); + assertThat(list).hasSize(0); + + SomeBean a = new SomeBean("A"); + list.internalAddWithCheck(a); + list.internalAddWithCheck(a); + assertThat(list).hasSize(1); + + // expect to ignore equals and add as it is a diff instance (aka don't use equals()) + list.internalAddWithCheck(new SomeBean("A")); + assertThat(list).hasSize(2); + + list.internalAddWithCheck(new SomeBean("B")); + assertThat(list).hasSize(3); + } + + /** + * A entity bean with interesting equals implementation. + */ + private static class SomeBean { + + final String val; + + SomeBean(String val) { + this.val = val; + } + + public int hashCode() { + return 42; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other instanceof SomeBean) { + return this.val.equals(((SomeBean)other).val); + } else { + return false; + } + } + } + +} From f4e422a239e916d41ac5e66b6eaa881028088d9d Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 17:15:49 +1300 Subject: [PATCH 62/87] no effective change - formatting only --- src/test/resources/ebean.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/ebean.properties b/src/test/resources/ebean.properties index 8eb6e2842..dd244ee25 100644 --- a/src/test/resources/ebean.properties +++ b/src/test/resources/ebean.properties @@ -4,7 +4,7 @@ ## Load (Dev/Test/Prod) server specific properties ## ------------------------------------------------------------- ## This is a possible alternative to using JNDI to set environment -## properties externally (to the WAR file). This is another way +## properties externally (to the WAR file). This is another way ## your Dev, Test and Prod servers can have different properties. #load.properties=${HOME}/config/myapp.ebean.properties @@ -47,7 +47,7 @@ ebean.migration.migrationPath=dbmigration/myapp ## ------------------------------------------------------------- ## DataSources (If using default Ebean DataSourceFactory) -## ------------------------------------------------------------- +## ------------------------------------------------------------- From d8e3f127c08a16308cf6c4051ac0906877b84497 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 17:20:27 +1300 Subject: [PATCH 63/87] no effective change - reduce access to AbstractBeanCollection --- .../ebean/common/AbstractBeanCollection.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java index acd15d700..2512a126d 100644 --- a/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java +++ b/src/main/java/com/avaje/ebean/common/AbstractBeanCollection.java @@ -11,10 +11,8 @@ import java.util.Set; /** * Base class for List Set and Map implementations of BeanCollection. - * - * @author rbygrave */ -public abstract class AbstractBeanCollection implements BeanCollection { +abstract class AbstractBeanCollection implements BeanCollection { private static final long serialVersionUID = 3365725236140187588L; @@ -56,13 +54,13 @@ public abstract class AbstractBeanCollection implements BeanCollection { /** * Constructor not non-lazy loading collection. */ - public AbstractBeanCollection() { + AbstractBeanCollection() { } /** * Used to create deferred fetch proxy. */ - public AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { + AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) { this.loader = loader; this.ebeanServerName = loader.getName(); this.ownerBean = ownerBean; @@ -91,14 +89,14 @@ public abstract class AbstractBeanCollection implements BeanCollection { this.disableLazyLoad = disableLazyLoad; } - protected void lazyLoadCollection(boolean onlyIds) { + void lazyLoadCollection(boolean onlyIds) { if (loader == null) { loader = (BeanCollectionLoader) Ebean.getServer(ebeanServerName); } if (loader == null) { String msg = "Lazy loading but LazyLoadEbeanServer is null?" - + " The LazyLoadEbeanServer needs to be set after deserialization" - + " to support lazy loading."; + + " The LazyLoadEbeanServer needs to be set after deserialization" + + " to support lazy loading."; throw new PersistenceException(msg); } @@ -124,7 +122,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { this.readOnly = readOnly; } - protected void checkReadOnly() { + void checkReadOnly() { if (readOnly) { String msg = "This collection is in ReadOnly mode"; throw new IllegalStateException(msg); @@ -157,7 +155,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { return modifyListenMode; } - protected ModifyHolder getModifyHolder() { + ModifyHolder getModifyHolder() { if (modifyHolder == null) { modifyHolder = new ModifyHolder<>(); } @@ -201,7 +199,7 @@ public abstract class AbstractBeanCollection implements BeanCollection { /** * Return true if there are underlying additions or removals. */ - public boolean holdsModifications() { + boolean holdsModifications() { return modifyHolder != null && modifyHolder.hasModifications(); } } From 709d4151f2a0e18b9b7a041646f44d5a09d27a56 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 17:21:25 +1300 Subject: [PATCH 64/87] no effective change - format only --- src/main/java/com/avaje/ebean/common/BeanMap.java | 6 +++--- src/main/java/com/avaje/ebean/common/ModifyCollection.java | 4 ++-- src/main/java/com/avaje/ebean/common/ModifyIterator.java | 4 ++-- src/main/java/com/avaje/ebean/common/ModifyList.java | 4 ++-- .../java/com/avaje/ebean/common/ModifyListIterator.java | 4 ++-- src/main/java/com/avaje/ebean/common/ModifySet.java | 4 ++-- src/main/java/com/avaje/ebean/common/SpiContainer.java | 5 ++--- src/main/java/com/avaje/ebean/common/package.html | 6 +++--- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/avaje/ebean/common/BeanMap.java b/src/main/java/com/avaje/ebean/common/BeanMap.java index 54d5cd4d2..232d23a84 100644 --- a/src/main/java/com/avaje/ebean/common/BeanMap.java +++ b/src/main/java/com/avaje/ebean/common/BeanMap.java @@ -54,7 +54,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma @Override @SuppressWarnings("unchecked") public void loadFrom(BeanCollection other) { - BeanMap otherMap = (BeanMap)other; + BeanMap otherMap = (BeanMap) other; internalPutNull(); map.putAll(otherMap.getActualMap()); } @@ -65,7 +65,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma } } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") public void internalPut(Object key, Object bean) { if (map == null) { map = new LinkedHashMap<>(); @@ -219,7 +219,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma return map.containsValue(value); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Set> entrySet() { init(); if (isReadOnly()) { diff --git a/src/main/java/com/avaje/ebean/common/ModifyCollection.java b/src/main/java/com/avaje/ebean/common/ModifyCollection.java index cd71bc42c..041476768 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyCollection.java +++ b/src/main/java/com/avaje/ebean/common/ModifyCollection.java @@ -1,10 +1,10 @@ package com.avaje.ebean.common; +import com.avaje.ebean.bean.BeanCollection; + import java.util.Collection; import java.util.Iterator; -import com.avaje.ebean.bean.BeanCollection; - /** * Wraps a collection for the purposes of notifying removals and additions to * the BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifyIterator.java b/src/main/java/com/avaje/ebean/common/ModifyIterator.java index 30f6a2e85..08e7a30c7 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyIterator.java +++ b/src/main/java/com/avaje/ebean/common/ModifyIterator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.Iterator; - import com.avaje.ebean.bean.BeanCollection; +import java.util.Iterator; + /** * Wraps an iterator for the purposes of notifying removals and additions to the * BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifyList.java b/src/main/java/com/avaje/ebean/common/ModifyList.java index b0ee8e971..112670dd1 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyList.java +++ b/src/main/java/com/avaje/ebean/common/ModifyList.java @@ -1,11 +1,11 @@ package com.avaje.ebean.common; +import com.avaje.ebean.bean.BeanCollection; + import java.util.Collection; import java.util.List; import java.util.ListIterator; -import com.avaje.ebean.bean.BeanCollection; - /** * Wraps a List for the purposes of notifying removals and additions to the * BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifyListIterator.java b/src/main/java/com/avaje/ebean/common/ModifyListIterator.java index 82a6cc738..d6155b6af 100644 --- a/src/main/java/com/avaje/ebean/common/ModifyListIterator.java +++ b/src/main/java/com/avaje/ebean/common/ModifyListIterator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.ListIterator; - import com.avaje.ebean.bean.BeanCollection; +import java.util.ListIterator; + /** * Wraps a ListIterator for the purposes of notifying removals and additions to * the BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/ModifySet.java b/src/main/java/com/avaje/ebean/common/ModifySet.java index 6d9ebc2dc..8cacde77d 100644 --- a/src/main/java/com/avaje/ebean/common/ModifySet.java +++ b/src/main/java/com/avaje/ebean/common/ModifySet.java @@ -1,9 +1,9 @@ package com.avaje.ebean.common; -import java.util.Set; - import com.avaje.ebean.bean.BeanCollection; +import java.util.Set; + /** * Wraps a Set for the purposes of notifying removals and additions to the * BeanCollection owner. diff --git a/src/main/java/com/avaje/ebean/common/SpiContainer.java b/src/main/java/com/avaje/ebean/common/SpiContainer.java index ed3c000a7..2715576de 100644 --- a/src/main/java/com/avaje/ebean/common/SpiContainer.java +++ b/src/main/java/com/avaje/ebean/common/SpiContainer.java @@ -11,9 +11,8 @@ public interface SpiContainer { /** * Create the EbeanServer for a given configuration. - * - * @param configuration - * The configuration information for this server. + * + * @param configuration The configuration information for this server. */ EbeanServer createServer(ServerConfig configuration); diff --git a/src/main/java/com/avaje/ebean/common/package.html b/src/main/java/com/avaje/ebean/common/package.html index 21956c462..924650876 100644 --- a/src/main/java/com/avaje/ebean/common/package.html +++ b/src/main/java/com/avaje/ebean/common/package.html @@ -1,11 +1,11 @@ - - Common non-public interfaces and implementation + + Common non-public interfaces and implementation Common non-public interfaces and implementation. - \ No newline at end of file + From 82151872fd3013c72d620648ddea8737ec79c64f Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:06:26 +1300 Subject: [PATCH 65/87] no effective change - format only --- .../ebeanservice/docstore/api/DocStoreQueryUpdate.java | 2 +- .../docstore/api/DocStoreUpdateProcessor.java | 6 +++--- .../docstore/api/mapping/DocMappingBuilder.java | 8 ++++---- .../docstore/api/mapping/DocPropertyMapping.java | 2 +- .../docstore/api/support/DocStoreBeanBaseAdapter.java | 5 ++--- .../docstore/api/support/DocStoreDeleteEvent.java | 2 +- .../support/DocStoreEmbeddedInvalidationProperties.java | 2 +- .../docstore/api/support/DocStoreIndexEvent.java | 2 +- .../ebeanservice/docstore/api/support/DocStructure.java | 6 +++--- .../ebeanservice/docstore/none/NoneDocStoreFactory.java | 2 +- 10 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreQueryUpdate.java b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreQueryUpdate.java index 2a0ff8b41..ba377dd91 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreQueryUpdate.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreQueryUpdate.java @@ -5,7 +5,7 @@ import java.io.IOException; /** * Update the document store using a Ebean ORM query. *

- * Executes a forEach query and updates the document store with the bean object graph returned by the query. + * Executes a forEach query and updates the document store with the bean object graph returned by the query. *

*/ public interface DocStoreQueryUpdate { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdateProcessor.java b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdateProcessor.java index abf491bc2..2de6e8a2a 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdateProcessor.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/DocStoreUpdateProcessor.java @@ -25,9 +25,9 @@ public interface DocStoreUpdateProcessor { * to a queue for future processing. *

* - * @param docStoreUpdates The 'Bulk' and 'Queue' updates to the indexes for the transaction. - * @param bulkBatchSize The batch size to use for Bulk API calls specified on the transaction. - * If this is 0 then the default batch size is used. + * @param docStoreUpdates The 'Bulk' and 'Queue' updates to the indexes for the transaction. + * @param bulkBatchSize The batch size to use for Bulk API calls specified on the transaction. + * If this is 0 then the default batch size is used. */ void process(DocStoreUpdates docStoreUpdates, int bulkBatchSize); diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java index 434f7cc3f..35883c3f1 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocMappingBuilder.java @@ -20,7 +20,7 @@ public class DocMappingBuilder { private final Stack properties = new Stack<>(); - private final Map map = new LinkedHashMap<>(); + private final Map map = new LinkedHashMap<>(); /** * Create with the document structure paths and docStore deployment annotation. @@ -90,7 +90,7 @@ public class DocMappingBuilder { DocPropertyMapping mapping = map.get(fullName); if (mapping == null) { - throw new IllegalStateException("DocMapping for ["+fullName+"] but property not included in document?"); + throw new IllegalStateException("DocMapping for [" + fullName + "] but property not included in document?"); } mapping.apply(docMapping); } @@ -124,7 +124,7 @@ public class DocMappingBuilder { */ private static class SortableVisitor extends DocPropertyAdapter { - private Map sortableMap = new LinkedHashMap<>(); + private Map sortableMap = new LinkedHashMap<>(); @Override public void visitProperty(DocPropertyMapping property) { @@ -132,7 +132,7 @@ public class DocMappingBuilder { DocPropertyOptions options = property.getOptions(); if (options != null && Boolean.TRUE.equals(options.getSortable())) { String fullPath = pathStack.peekFullPath(property.getName()); - sortableMap.put(fullPath, fullPath+".raw"); + sortableMap.put(fullPath, fullPath + ".raw"); } } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java index 515aeb601..cfc4c871d 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/mapping/DocPropertyMapping.java @@ -76,7 +76,7 @@ public class DocPropertyMapping { } public String toString() { - return "name:"+name+" type:"+type+" options("+options+")"; + return "name:" + name + " type:" + type + " options(" + options + ")"; } /** diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java index bf5ca3249..7fa9f4e83 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapter.java @@ -12,7 +12,6 @@ import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.InheritInfo; -import com.avaje.ebeaninternal.server.deploy.InheritInfoVisitor; import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import com.avaje.ebeanservice.docstore.api.DocStoreBeanAdapter; import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; @@ -224,7 +223,7 @@ public abstract class DocStoreBeanBaseAdapter implements DocStoreBeanAdapter< } } int[] pos = new int[posList.size()]; - for (int i = 0; i implements DocStoreBeanAdapter< protected DocStructure derivePathProperties(PathProperties pathProps) { boolean includeByDefault = (pathProps == null); - if (pathProps == null) { + if (pathProps == null) { pathProps = new PathProperties(); } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java index 3bb51b6c9..fe7812b14 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEvent.java @@ -1,8 +1,8 @@ package com.avaje.ebeanservice.docstore.api.support; import com.avaje.ebean.plugin.BeanType; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdate; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import java.io.IOException; diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java index c133d73a6..01e2e1fe1 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreEmbeddedInvalidationProperties.java @@ -5,7 +5,7 @@ import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; /** * Checks if a persist request means an embedded/nested object in another document needs updating. - * + *

* This has specific properties to check (so not all properties invalidate). */ public final class DocStoreEmbeddedInvalidationProperties extends DocStoreEmbeddedInvalidation { diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEvent.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEvent.java index 763fbf8f2..335ee5307 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEvent.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEvent.java @@ -1,8 +1,8 @@ package com.avaje.ebeanservice.docstore.api.support; import com.avaje.ebean.plugin.BeanType; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdate; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import java.io.IOException; diff --git a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java index 4903c50a4..34ed95ebf 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/api/support/DocStructure.java @@ -22,9 +22,9 @@ public class DocStructure { /** * The embedded document structures by path. */ - private final Map embedded = new HashMap<>(); + private final Map embedded = new HashMap<>(); - private final Map manyRoot = new HashMap<>(); + private final Map manyRoot = new HashMap<>(); /** * Create given an initial deployment doc mapping. @@ -72,7 +72,7 @@ public class DocStructure { public void prepareMany(BeanDescriptor desc) { Set strings = embedded.keySet(); for (String prop : strings) { - BeanPropertyAssoc embProp = (BeanPropertyAssoc)desc.findBeanProperty(prop); + BeanPropertyAssoc embProp = (BeanPropertyAssoc) desc.findBeanProperty(prop); if (embProp.isMany()) { prepare(prop, embProp); } diff --git a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java index 963ef0642..f67527331 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStoreFactory.java @@ -3,8 +3,8 @@ package com.avaje.ebeanservice.docstore.none; import com.avaje.ebean.DocumentStore; import com.avaje.ebean.plugin.SpiServer; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; -import com.avaje.ebeanservice.docstore.api.DocStoreBeanAdapter; import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; +import com.avaje.ebeanservice.docstore.api.DocStoreBeanAdapter; import com.avaje.ebeanservice.docstore.api.DocStoreFactory; import com.avaje.ebeanservice.docstore.api.DocStoreIntegration; import com.avaje.ebeanservice.docstore.api.DocStoreUpdateProcessor; From b49a52057aa2528f4522d73e2903531439db64e5 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:07:23 +1300 Subject: [PATCH 66/87] no effective change - format only --- .../avaje/ebeaninternal/util/EncodeUtil.java | 4 +- .../xmlmapping/model/ObjectFactory.java | 124 +++++----- .../xmlmapping/model/XmAliasMapping.java | 95 ++++---- .../xmlmapping/model/XmColumnMapping.java | 95 ++++---- .../xmlmapping/model/XmEbean.java | 69 +++--- .../xmlmapping/model/XmEntity.java | 171 +++++++------- .../xmlmapping/model/XmNamedQuery.java | 97 ++++---- .../xmlmapping/model/XmQuery.java | 53 ++--- .../xmlmapping/model/XmRawSql.java | 217 ++++++++---------- 9 files changed, 422 insertions(+), 503 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/util/EncodeUtil.java b/src/main/java/com/avaje/ebeaninternal/util/EncodeUtil.java index 946066c7e..765adefe8 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/EncodeUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/util/EncodeUtil.java @@ -92,7 +92,7 @@ public final class EncodeUtil { try { return new String(data, encoding); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("Error decoding bytes with "+encoding, e); + throw new RuntimeException("Error decoding bytes with " + encoding, e); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/ObjectFactory.java index 9d13626d9..84f91d529 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/ObjectFactory.java @@ -1,88 +1,78 @@ - package com.avaje.ebeaninternal.xmlmapping.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.xmlmapping.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.xmlmapping.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.xmlmapping.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.xmlmapping.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link XmRawSql } - * - */ - public XmRawSql createRawSql() { - return new XmRawSql(); - } + /** + * Create an instance of {@link XmRawSql } + */ + public XmRawSql createRawSql() { + return new XmRawSql(); + } - /** - * Create an instance of {@link XmAliasMapping } - * - */ - public XmAliasMapping createAliasMapping() { - return new XmAliasMapping(); - } + /** + * Create an instance of {@link XmAliasMapping } + */ + public XmAliasMapping createAliasMapping() { + return new XmAliasMapping(); + } - /** - * Create an instance of {@link XmColumnMapping } - * - */ - public XmColumnMapping createColumnMapping() { - return new XmColumnMapping(); - } + /** + * Create an instance of {@link XmColumnMapping } + */ + public XmColumnMapping createColumnMapping() { + return new XmColumnMapping(); + } - /** - * Create an instance of {@link XmQuery } - * - */ - public XmQuery createQuery() { - return new XmQuery(); - } + /** + * Create an instance of {@link XmQuery } + */ + public XmQuery createQuery() { + return new XmQuery(); + } - /** - * Create an instance of {@link XmEbean } - * - */ - public XmEbean createEbean() { - return new XmEbean(); - } + /** + * Create an instance of {@link XmEbean } + */ + public XmEbean createEbean() { + return new XmEbean(); + } - /** - * Create an instance of {@link XmEntity } - * - */ - public XmEntity createEntity() { - return new XmEntity(); - } + /** + * Create an instance of {@link XmEntity } + */ + public XmEntity createEntity() { + return new XmEntity(); + } - /** - * Create an instance of {@link XmNamedQuery } - * - */ - public XmNamedQuery createNamedQuery() { - return new XmNamedQuery(); - } + /** + * Create an instance of {@link XmNamedQuery } + */ + public XmNamedQuery createNamedQuery() { + return new XmNamedQuery(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmAliasMapping.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmAliasMapping.java index d28e745c8..35d69b86c 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmAliasMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmAliasMapping.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.xmlmapping.model; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "alias-mapping") public class XmAliasMapping { - @XmlAttribute(name = "alias", required = true) - protected String alias; - @XmlAttribute(name = "property", required = true) - protected String property; + @XmlAttribute(name = "alias", required = true) + protected String alias; + @XmlAttribute(name = "property", required = true) + protected String property; - /** - * Gets the value of the alias property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAlias() { - return alias; - } + /** + * Gets the value of the alias property. + * + * @return possible object is + * {@link String } + */ + public String getAlias() { + return alias; + } - /** - * Sets the value of the alias property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAlias(String value) { - this.alias = value; - } + /** + * Sets the value of the alias property. + * + * @param value allowed object is + * {@link String } + */ + public void setAlias(String value) { + this.alias = value; + } - /** - * Gets the value of the property property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getProperty() { - return property; - } + /** + * Gets the value of the property property. + * + * @return possible object is + * {@link String } + */ + public String getProperty() { + return property; + } - /** - * Sets the value of the property property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setProperty(String value) { - this.property = value; - } + /** + * Sets the value of the property property. + * + * @param value allowed object is + * {@link String } + */ + public void setProperty(String value) { + this.property = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmColumnMapping.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmColumnMapping.java index f00f8664d..6c9a94526 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmColumnMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmColumnMapping.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.xmlmapping.model; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "column-mapping") public class XmColumnMapping { - @XmlAttribute(name = "column", required = true) - protected String column; - @XmlAttribute(name = "property", required = true) - protected String property; + @XmlAttribute(name = "column", required = true) + protected String column; + @XmlAttribute(name = "property", required = true) + protected String property; - /** - * Gets the value of the column property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumn() { - return column; - } + /** + * Gets the value of the column property. + * + * @return possible object is + * {@link String } + */ + public String getColumn() { + return column; + } - /** - * Sets the value of the column property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumn(String value) { - this.column = value; - } + /** + * Sets the value of the column property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumn(String value) { + this.column = value; + } - /** - * Gets the value of the property property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getProperty() { - return property; - } + /** + * Gets the value of the property property. + * + * @return possible object is + * {@link String } + */ + public String getProperty() { + return property; + } - /** - * Sets the value of the property property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setProperty(String value) { - this.property = value; - } + /** + * Sets the value of the property property. + * + * @param value allowed object is + * {@link String } + */ + public void setProperty(String value) { + this.property = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java index 6ec91de9a..bb8b4aae2 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEbean.java @@ -1,20 +1,19 @@ - package com.avaje.ebeaninternal.xmlmapping.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "entity" + "entity" }) @XmlRootElement(name = "ebean") public class XmEbean { - @XmlElement(required = true) - protected List entity; + @XmlElement(required = true) + protected List entity; - /** - * Gets the value of the entity property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the entity property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getEntity().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link XmEntity } - * - * - */ - public List getEntity() { - if (entity == null) { - entity = new ArrayList<>(); - } - return this.entity; + /** + * Gets the value of the entity property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the entity property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getEntity().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link XmEntity } + */ + public List getEntity() { + if (entity == null) { + entity = new ArrayList<>(); } + return this.entity; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java index 5092f3cc4..622d15c2e 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmEntity.java @@ -1,21 +1,20 @@ - package com.avaje.ebeaninternal.xmlmapping.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -29,104 +28,94 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "namedQuery", - "rawSql" + "namedQuery", + "rawSql" }) @XmlRootElement(name = "entity") public class XmEntity { - @XmlElement(name = "named-query", required = true) - protected List namedQuery; - @XmlElement(name = "raw-sql", required = true) - protected List rawSql; - @XmlAttribute(name = "class", required = true) - protected String clazz; + @XmlElement(name = "named-query", required = true) + protected List namedQuery; + @XmlElement(name = "raw-sql", required = true) + protected List rawSql; + @XmlAttribute(name = "class", required = true) + protected String clazz; - /** - * Gets the value of the namedQuery property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the namedQuery property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getNamedQuery().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link XmNamedQuery } - * - * - */ - public List getNamedQuery() { - if (namedQuery == null) { - namedQuery = new ArrayList<>(); - } - return this.namedQuery; + /** + * Gets the value of the namedQuery property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the namedQuery property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getNamedQuery().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link XmNamedQuery } + */ + public List getNamedQuery() { + if (namedQuery == null) { + namedQuery = new ArrayList<>(); } + return this.namedQuery; + } - /** - * Gets the value of the rawSql property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the rawSql property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getRawSql().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link XmRawSql } - * - * - */ - public List getRawSql() { - if (rawSql == null) { - rawSql = new ArrayList<>(); - } - return this.rawSql; + /** + * Gets the value of the rawSql property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the rawSql property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getRawSql().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link XmRawSql } + */ + public List getRawSql() { + if (rawSql == null) { + rawSql = new ArrayList<>(); } + return this.rawSql; + } - /** - * Gets the value of the clazz property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getClazz() { - return clazz; - } + /** + * Gets the value of the clazz property. + * + * @return possible object is + * {@link String } + */ + public String getClazz() { + return clazz; + } - /** - * Sets the value of the clazz property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setClazz(String value) { - this.clazz = value; - } + /** + * Sets the value of the clazz property. + * + * @param value allowed object is + * {@link String } + */ + public void setClazz(String value) { + this.clazz = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmNamedQuery.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmNamedQuery.java index b6ea79401..88a018618 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmNamedQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmNamedQuery.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.xmlmapping.model; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,67 +25,57 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "query" + "query" }) @XmlRootElement(name = "named-query") public class XmNamedQuery { - @XmlElement(required = true) - protected XmQuery query; - @XmlAttribute(name = "name", required = true) - protected String name; + @XmlElement(required = true) + protected XmQuery query; + @XmlAttribute(name = "name", required = true) + protected String name; - /** - * Gets the value of the query property. - * - * @return - * possible object is - * {@link XmQuery } - * - */ - public XmQuery getQuery() { - return query; - } + /** + * Gets the value of the query property. + * + * @return possible object is + * {@link XmQuery } + */ + public XmQuery getQuery() { + return query; + } - /** - * Sets the value of the query property. - * - * @param value - * allowed object is - * {@link XmQuery } - * - */ - public void setQuery(XmQuery value) { - this.query = value; - } + /** + * Sets the value of the query property. + * + * @param value allowed object is + * {@link XmQuery } + */ + public void setQuery(XmQuery value) { + this.query = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmQuery.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmQuery.java index f331726ed..bf669bbb0 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmQuery.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.xmlmapping.model; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -21,41 +20,35 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "query") public class XmQuery { - @XmlValue - protected String value; + @XmlValue + protected String value; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java index e042d0965..9fd3237a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java +++ b/src/main/java/com/avaje/ebeaninternal/xmlmapping/model/XmRawSql.java @@ -1,21 +1,20 @@ - package com.avaje.ebeaninternal.xmlmapping.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -30,131 +29,117 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "aliasMapping", - "columnMapping", - "query" + "aliasMapping", + "columnMapping", + "query" }) @XmlRootElement(name = "raw-sql") public class XmRawSql { - @XmlElement(name = "alias-mapping") - protected List aliasMapping; - @XmlElement(name = "column-mapping") - protected List columnMapping; - @XmlElement(required = true) - protected XmQuery query; - @XmlAttribute(name = "name", required = true) - protected String name; + @XmlElement(name = "alias-mapping") + protected List aliasMapping; + @XmlElement(name = "column-mapping") + protected List columnMapping; + @XmlElement(required = true) + protected XmQuery query; + @XmlAttribute(name = "name", required = true) + protected String name; - /** - * Gets the value of the aliasMapping property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the aliasMapping property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getAliasMapping().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link XmAliasMapping } - * - * - */ - public List getAliasMapping() { - if (aliasMapping == null) { - aliasMapping = new ArrayList<>(); - } - return this.aliasMapping; + /** + * Gets the value of the aliasMapping property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the aliasMapping property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getAliasMapping().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link XmAliasMapping } + */ + public List getAliasMapping() { + if (aliasMapping == null) { + aliasMapping = new ArrayList<>(); } + return this.aliasMapping; + } - /** - * Gets the value of the columnMapping property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the columnMapping property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getColumnMapping().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link XmColumnMapping } - * - * - */ - public List getColumnMapping() { - if (columnMapping == null) { - columnMapping = new ArrayList<>(); - } - return this.columnMapping; + /** + * Gets the value of the columnMapping property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the columnMapping property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getColumnMapping().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link XmColumnMapping } + */ + public List getColumnMapping() { + if (columnMapping == null) { + columnMapping = new ArrayList<>(); } + return this.columnMapping; + } - /** - * Gets the value of the query property. - * - * @return - * possible object is - * {@link XmQuery } - * - */ - public XmQuery getQuery() { - return query; - } + /** + * Gets the value of the query property. + * + * @return possible object is + * {@link XmQuery } + */ + public XmQuery getQuery() { + return query; + } - /** - * Sets the value of the query property. - * - * @param value - * allowed object is - * {@link XmQuery } - * - */ - public void setQuery(XmQuery value) { - this.query = value; - } + /** + * Sets the value of the query property. + * + * @param value allowed object is + * {@link XmQuery } + */ + public void setQuery(XmQuery value) { + this.query = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } } From 15973c8992fa51d1a610da795ac0b4713405ad4c Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:10:02 +1300 Subject: [PATCH 67/87] no effective change - format only --- .../server/text/csv/CsvUtilReader.java | 423 ++++++++-------- .../server/text/csv/TCsvReader.java | 464 +++++++++--------- .../server/text/json/DJsonBeanReader.java | 2 +- .../server/text/json/DJsonContext.java | 2 +- .../server/text/json/DJsonScalar.java | 2 +- .../server/text/json/ReadJson.java | 12 +- .../AutoCommitTransactionManager.java | 4 +- .../server/transaction/DeleteByIdMap.java | 7 +- .../transaction/ExplicitJdbcTransaction.java | 2 +- .../ExplicitTransactionManager.java | 2 +- .../server/transaction/JdbcTransaction.java | 5 +- .../transaction/JtaTransactionManager.java | 2 +- .../transaction/PostCommitProcessing.java | 2 +- .../transaction/RemoteTransactionEvent.java | 4 +- .../server/type/ConvertInetAddresses.java | 5 +- .../server/type/DefaultTypeManager.java | 25 +- .../type/reflect/ImmutableMetaFactory.java | 4 +- .../reflect/ReflectionBasedCompoundType.java | 6 +- .../ReflectionBasedCompoundTypeProperty.java | 4 +- .../ReflectionBasedScalarTypeConverter.java | 6 +- .../reflect/ReflectionBasedTypeBuilder.java | 8 +- .../server/util/BindParamsParser.java | 7 +- .../ebeaninternal/server/util/package.html | 7 +- 23 files changed, 507 insertions(+), 498 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java index 4a7fc27e1..161df976e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/CsvUtilReader.java @@ -4,19 +4,19 @@ package com.avaje.ebeaninternal.server.text.csv; // rbygrave: Made some Java Generics tweaks to remove warnings /** - Copyright 2005 Bytecode Pty Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * Copyright 2005 Bytecode Pty Ltd. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import java.io.BufferedReader; @@ -27,223 +27,222 @@ import java.util.List; /** * Glen Smith's CSV reader released under Apache License version 2. - * + * * @author Glen Smith - * + * */ public class CsvUtilReader { - private final BufferedReader br; + private final BufferedReader br; - private boolean hasNext = true; + private boolean hasNext = true; - private final char separator; + private final char separator; - private final char quotechar; - - private final int skipLines; + private final char quotechar; - private boolean linesSkiped; + private final int skipLines; - /** The default separator to use if none is supplied to the constructor. */ - public static final char DEFAULT_SEPARATOR = ','; + private boolean linesSkiped; - /** - * The default quote character to use if none is supplied to the - * constructor. - */ - public static final char DEFAULT_QUOTE_CHARACTER = '"'; - - /** - * The default line to start reading. - */ - public static final int DEFAULT_SKIP_LINES = 0; + /** The default separator to use if none is supplied to the constructor. */ + public static final char DEFAULT_SEPARATOR = ','; - /** - * Constructs CSVReader using a comma for the separator. - * - * @param reader - * the reader to an underlying CSV source. - */ - public CsvUtilReader(Reader reader) { - this(reader, DEFAULT_SEPARATOR); + /** + * The default quote character to use if none is supplied to the + * constructor. + */ + public static final char DEFAULT_QUOTE_CHARACTER = '"'; + + /** + * The default line to start reading. + */ + public static final int DEFAULT_SKIP_LINES = 0; + + /** + * Constructs CSVReader using a comma for the separator. + * + * @param reader + * the reader to an underlying CSV source. + */ + public CsvUtilReader(Reader reader) { + this(reader, DEFAULT_SEPARATOR); + } + + /** + * Constructs CSVReader with supplied separator. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries. + */ + public CsvUtilReader(Reader reader, char separator) { + this(reader, separator, DEFAULT_QUOTE_CHARACTER); + } + + + /** + * Constructs CSVReader with supplied separator and quote char. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + */ + public CsvUtilReader(Reader reader, char separator, char quotechar) { + this(reader, separator, quotechar, DEFAULT_SKIP_LINES); + } + + /** + * Constructs CSVReader with supplied separator and quote char. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param line + * the line number to skip for start reading + */ + public CsvUtilReader(Reader reader, char separator, char quotechar, int line) { + this.br = new BufferedReader(reader); + this.separator = separator; + this.quotechar = quotechar; + this.skipLines = line; + } + + /** + * Reads the entire file into a List with each element being a String[] of + * tokens. + * + * @return a List of String[], with each String[] representing a line of the + * file. + * + * @throws IOException + * if bad things happen during the read + */ + public List readAll() throws IOException { + + List allElements = new ArrayList<>(); + while (hasNext) { + String[] nextLineAsTokens = readNext(); + if (nextLineAsTokens != null) + allElements.add(nextLineAsTokens); + } + return allElements; + + } + + /** + * Reads the next line from the buffer and converts to a string array. + * + * @return a string array with each comma-separated element as a separate + * entry. + * + * @throws IOException + * if bad things happen during the read + */ + public String[] readNext() throws IOException { + + String nextLine = getNextLine(); + return hasNext ? parseLine(nextLine) : null; + } + + /** + * Reads the next line from the file. + * + * @return the next line from the file without trailing newline + * @throws IOException + * if bad things happen during the read + */ + private String getNextLine() throws IOException { + if (!this.linesSkiped) { + for (int i = 0; i < skipLines; i++) { + br.readLine(); + } + this.linesSkiped = true; + } + String nextLine = br.readLine(); + if (nextLine == null) { + hasNext = false; + } + return hasNext ? nextLine : null; + } + + /** + * Parses an incoming String and returns an array of elements. + * + * @param nextLine + * the string to parse + * @return the comma-tokenized list of elements, or null if nextLine is null + * @throws IOException if bad things happen during the read + */ + private String[] parseLine(String nextLine) throws IOException { + + if (nextLine == null) { + return null; } - /** - * Constructs CSVReader with supplied separator. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries. - */ - public CsvUtilReader(Reader reader, char separator) { - this(reader, separator, DEFAULT_QUOTE_CHARACTER); - } - - + List tokensOnThisLine = new ArrayList<>(); - /** - * Constructs CSVReader with supplied separator and quote char. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries - * @param quotechar - * the character to use for quoted elements - */ - public CsvUtilReader(Reader reader, char separator, char quotechar) { - this(reader, separator, quotechar, DEFAULT_SKIP_LINES); - } - - /** - * Constructs CSVReader with supplied separator and quote char. - * - * @param reader - * the reader to an underlying CSV source. - * @param separator - * the delimiter to use for separating entries - * @param quotechar - * the character to use for quoted elements - * @param line - * the line number to skip for start reading - */ - public CsvUtilReader(Reader reader, char separator, char quotechar, int line) { - this.br = new BufferedReader(reader); - this.separator = separator; - this.quotechar = quotechar; - this.skipLines = line; - } + StringBuilder sb = new StringBuilder(); + boolean inQuotes = false; + do { + if (inQuotes) { + // continuing a quoted section, reappend newline + sb.append("\n"); + nextLine = getNextLine(); + if (nextLine == null) + break; + } + for (int i = 0; i < nextLine.length(); i++) { - /** - * Reads the entire file into a List with each element being a String[] of - * tokens. - * - * @return a List of String[], with each String[] representing a line of the - * file. - * - * @throws IOException - * if bad things happen during the read - */ - public List readAll() throws IOException { - - List allElements = new ArrayList<>(); - while (hasNext) { - String[] nextLineAsTokens = readNext(); - if (nextLineAsTokens != null) - allElements.add(nextLineAsTokens); - } - return allElements; - - } - - /** - * Reads the next line from the buffer and converts to a string array. - * - * @return a string array with each comma-separated element as a separate - * entry. - * - * @throws IOException - * if bad things happen during the read - */ - public String[] readNext() throws IOException { - - String nextLine = getNextLine(); - return hasNext ? parseLine(nextLine) : null; - } - - /** - * Reads the next line from the file. - * - * @return the next line from the file without trailing newline - * @throws IOException - * if bad things happen during the read - */ - private String getNextLine() throws IOException { - if (!this.linesSkiped) { - for (int i = 0; i < skipLines; i++) { - br.readLine(); + char c = nextLine.charAt(i); + if (c == quotechar) { + // this gets complex... the quote may end a quoted block, or escape another quote. + // do a 1-char lookahead: + if (inQuotes // we are in quotes, therefore there can be escaped quotes in here. + && nextLine.length() > (i + 1) // there is indeed another character to check. + && nextLine.charAt(i + 1) == quotechar) { // ..and that char. is a quote also. + // we have two quote chars in a row == one quote char, so consume them both and + // put one on the token. we do *not* exit the quoted text. + sb.append(nextLine.charAt(i + 1)); + i++; + } else { + inQuotes = !inQuotes; + // the tricky case of an embedded quote in the middle: a,bc"d"ef,g + if (i > 2 //not on the begining of the line + && nextLine.charAt(i - 1) != this.separator //not at the begining of an escape sequence + && nextLine.length() > (i + 1) && + nextLine.charAt(i + 1) != this.separator //not at the end of an escape sequence + ) { + sb.append(c); } - this.linesSkiped = true; + } + } else if (c == separator && !inQuotes) { + tokensOnThisLine.add(sb.toString().trim()); + sb = new StringBuilder(); // start work on next token + } else { + sb.append(c); } - String nextLine = br.readLine(); - if (nextLine == null) { - hasNext = false; - } - return hasNext ? nextLine : null; - } + } + } while (inQuotes); + tokensOnThisLine.add(sb.toString().trim()); + return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]); + } - /** - * Parses an incoming String and returns an array of elements. - * - * @param nextLine - * the string to parse - * @return the comma-tokenized list of elements, or null if nextLine is null - * @throws IOException if bad things happen during the read - */ - private String[] parseLine(String nextLine) throws IOException { + /** + * Closes the underlying reader. + * + * @throws IOException if the close fails + */ + public void close() throws IOException { + br.close(); + } - if (nextLine == null) { - return null; - } - - List tokensOnThisLine = new ArrayList<>(); - - StringBuilder sb = new StringBuilder(); - boolean inQuotes = false; - do { - if (inQuotes) { - // continuing a quoted section, reappend newline - sb.append("\n"); - nextLine = getNextLine(); - if (nextLine == null) - break; - } - for (int i = 0; i < nextLine.length(); i++) { - - char c = nextLine.charAt(i); - if (c == quotechar) { - // this gets complex... the quote may end a quoted block, or escape another quote. - // do a 1-char lookahead: - if( inQuotes // we are in quotes, therefore there can be escaped quotes in here. - && nextLine.length() > (i+1) // there is indeed another character to check. - && nextLine.charAt(i+1) == quotechar ){ // ..and that char. is a quote also. - // we have two quote chars in a row == one quote char, so consume them both and - // put one on the token. we do *not* exit the quoted text. - sb.append(nextLine.charAt(i+1)); - i++; - }else{ - inQuotes = !inQuotes; - // the tricky case of an embedded quote in the middle: a,bc"d"ef,g - if(i>2 //not on the begining of the line - && nextLine.charAt(i-1) != this.separator //not at the begining of an escape sequence - && nextLine.length()>(i+1) && - nextLine.charAt(i+1) != this.separator //not at the end of an escape sequence - ){ - sb.append(c); - } - } - } else if (c == separator && !inQuotes) { - tokensOnThisLine.add(sb.toString().trim()); - sb = new StringBuilder(); // start work on next token - } else { - sb.append(c); - } - } - } while (inQuotes); - tokensOnThisLine.add(sb.toString().trim()); - return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]); - } - - /** - * Closes the underlying reader. - * - * @throws IOException if the close fails - */ - public void close() throws IOException{ - br.close(); - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java index a99acfec4..fffcff5b6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/csv/TCsvReader.java @@ -1,16 +1,5 @@ package com.avaje.ebeaninternal.server.text.csv; -import java.io.Reader; -import java.sql.Types; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Locale; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.bean.EntityBean; import com.avaje.ebean.plugin.ExpressionPath; @@ -24,200 +13,211 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.el.ElPropertyValue; +import java.io.Reader; +import java.sql.Types; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Locale; + /** * Implementation of the CsvReader */ public class TCsvReader implements CsvReader { - private static final TimeStringParser TIME_PARSER = new TimeStringParser(); + private static final TimeStringParser TIME_PARSER = new TimeStringParser(); - private final EbeanServer server; + private final EbeanServer server; - private final BeanDescriptor descriptor; + private final BeanDescriptor descriptor; - private final List columnList = new ArrayList<>(); + private final List columnList = new ArrayList<>(); - private final CsvColumn ignoreColumn = new CsvColumn(); + private final CsvColumn ignoreColumn = new CsvColumn(); - private boolean hasHeader; + private boolean hasHeader; - private int logInfoFrequency = 1000; + private int logInfoFrequency = 1000; - private String defaultTimeFormat = "HH:mm:ss"; - private String defaultDateFormat = "yyyy-MM-dd"; - private String defaultTimestampFormat = "yyyy-MM-dd hh:mm:ss.fffffffff"; - private Locale defaultLocale = Locale.getDefault(); + private String defaultTimeFormat = "HH:mm:ss"; + private String defaultDateFormat = "yyyy-MM-dd"; + private String defaultTimestampFormat = "yyyy-MM-dd hh:mm:ss.fffffffff"; + private Locale defaultLocale = Locale.getDefault(); - /** - * The batch size used for JDBC statement batching. - */ - protected int persistBatchSize = 30; + /** + * The batch size used for JDBC statement batching. + */ + protected int persistBatchSize = 30; - private boolean addPropertiesFromHeader; + private boolean addPropertiesFromHeader; - public TCsvReader(EbeanServer server, BeanDescriptor descriptor) { - this.server = server; - this.descriptor = descriptor; - } + public TCsvReader(EbeanServer server, BeanDescriptor descriptor) { + this.server = server; + this.descriptor = descriptor; + } - public void setDefaultLocale(Locale defaultLocale) { - this.defaultLocale = defaultLocale; - } + public void setDefaultLocale(Locale defaultLocale) { + this.defaultLocale = defaultLocale; + } - public void setDefaultTimeFormat(String defaultTimeFormat) { - this.defaultTimeFormat = defaultTimeFormat; - } + public void setDefaultTimeFormat(String defaultTimeFormat) { + this.defaultTimeFormat = defaultTimeFormat; + } - public void setDefaultDateFormat(String defaultDateFormat) { - this.defaultDateFormat = defaultDateFormat; - } + public void setDefaultDateFormat(String defaultDateFormat) { + this.defaultDateFormat = defaultDateFormat; + } - public void setDefaultTimestampFormat(String defaultTimestampFormat) { - this.defaultTimestampFormat = defaultTimestampFormat; - } + public void setDefaultTimestampFormat(String defaultTimestampFormat) { + this.defaultTimestampFormat = defaultTimestampFormat; + } - public void setPersistBatchSize(int persistBatchSize) { - this.persistBatchSize = persistBatchSize; - } + public void setPersistBatchSize(int persistBatchSize) { + this.persistBatchSize = persistBatchSize; + } - public void setIgnoreHeader() { - setHasHeader(true, false); - } + public void setIgnoreHeader() { + setHasHeader(true, false); + } - public void setAddPropertiesFromHeader() { - setHasHeader(true, true); - } + public void setAddPropertiesFromHeader() { + setHasHeader(true, true); + } - public void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader) { - this.hasHeader = hasHeader; - this.addPropertiesFromHeader = addPropertiesFromHeader; - } + public void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader) { + this.hasHeader = hasHeader; + this.addPropertiesFromHeader = addPropertiesFromHeader; + } - public void setLogInfoFrequency(int logInfoFrequency) { - this.logInfoFrequency = logInfoFrequency; - } + public void setLogInfoFrequency(int logInfoFrequency) { + this.logInfoFrequency = logInfoFrequency; + } - public void addIgnore() { - columnList.add(ignoreColumn); - } + public void addIgnore() { + columnList.add(ignoreColumn); + } - public void addProperty(String propertyName) { - addProperty(propertyName, null); - } + public void addProperty(String propertyName) { + addProperty(propertyName, null); + } - public void addDateTime(String propertyName, String dateTimeFormat) { - addDateTime(propertyName, dateTimeFormat, Locale.getDefault()); - } + public void addDateTime(String propertyName, String dateTimeFormat) { + addDateTime(propertyName, dateTimeFormat, Locale.getDefault()); + } - public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) { + public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) { - ExpressionPath elProp = descriptor.getExpressionPath(propertyName); - if (!elProp.isDateTimeCapable()) { - throw new TextException("Property " + propertyName + " is not DateTime capable"); - } - if (dateTimeFormat == null) { - dateTimeFormat = getDefaultDateTimeFormat(elProp.getJdbcType()); - } + ExpressionPath elProp = descriptor.getExpressionPath(propertyName); + if (!elProp.isDateTimeCapable()) { + throw new TextException("Property " + propertyName + " is not DateTime capable"); + } + if (dateTimeFormat == null) { + dateTimeFormat = getDefaultDateTimeFormat(elProp.getJdbcType()); + } - if (locale == null) { - locale = defaultLocale; - } + if (locale == null) { + locale = defaultLocale; + } - SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, locale); - DateTimeParser parser = new DateTimeParser(sdf, dateTimeFormat, elProp); + SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, locale); + DateTimeParser parser = new DateTimeParser(sdf, dateTimeFormat, elProp); - CsvColumn column = new CsvColumn(elProp, parser); - columnList.add(column); - } + CsvColumn column = new CsvColumn(elProp, parser); + columnList.add(column); + } - private String getDefaultDateTimeFormat(int jdbcType) { - switch (jdbcType) { - case Types.TIME: - return defaultTimeFormat; - case Types.DATE: - return defaultDateFormat; - case Types.TIMESTAMP: - return defaultTimestampFormat; + private String getDefaultDateTimeFormat(int jdbcType) { + switch (jdbcType) { + case Types.TIME: + return defaultTimeFormat; + case Types.DATE: + return defaultDateFormat; + case Types.TIMESTAMP: + return defaultTimestampFormat; - default: - throw new RuntimeException("Expected java.sql.Types TIME,DATE or TIMESTAMP but got [" + jdbcType + "]"); - } - } + default: + throw new RuntimeException("Expected java.sql.Types TIME,DATE or TIMESTAMP but got [" + jdbcType + "]"); + } + } - public void addProperty(String propertyName, StringParser parser) { + public void addProperty(String propertyName, StringParser parser) { - ExpressionPath elProp = descriptor.getExpressionPath(propertyName); - if (parser == null) { - parser = elProp.getStringParser(); - } - CsvColumn column = new CsvColumn(elProp, parser); - columnList.add(column); - } + ExpressionPath elProp = descriptor.getExpressionPath(propertyName); + if (parser == null) { + parser = elProp.getStringParser(); + } + CsvColumn column = new CsvColumn(elProp, parser); + columnList.add(column); + } - public void process(Reader reader) throws Exception { - DefaultCsvCallback callback = new DefaultCsvCallback<>(persistBatchSize, logInfoFrequency); - process(reader, callback); - } + public void process(Reader reader) throws Exception { + DefaultCsvCallback callback = new DefaultCsvCallback<>(persistBatchSize, logInfoFrequency); + process(reader, callback); + } - public void process(Reader reader, CsvCallback callback) throws Exception { + public void process(Reader reader, CsvCallback callback) throws Exception { - if (reader == null) { - throw new NullPointerException("reader is null?"); - } - if (callback == null) { - throw new NullPointerException("callback is null?"); - } + if (reader == null) { + throw new NullPointerException("reader is null?"); + } + if (callback == null) { + throw new NullPointerException("callback is null?"); + } - CsvUtilReader utilReader = new CsvUtilReader(reader); + CsvUtilReader utilReader = new CsvUtilReader(reader); - callback.begin(server); + callback.begin(server); - int row = 0; + int row = 0; - if (hasHeader) { - String[] line = utilReader.readNext(); - if (addPropertiesFromHeader) { - addPropertiesFromHeader(line); - } - callback.readHeader(line); - } + if (hasHeader) { + String[] line = utilReader.readNext(); + if (addPropertiesFromHeader) { + addPropertiesFromHeader(line); + } + callback.readHeader(line); + } - try { - do { - ++row; - String[] line = utilReader.readNext(); - if (line == null) { - --row; - break; - } + try { + do { + ++row; + String[] line = utilReader.readNext(); + if (line == null) { + --row; + break; + } - if (callback.processLine(row, line)) { - // the line content is expected to be ok for processing - if (line.length != columnList.size()) { - // we have not got the expected number of columns - String msg = "Error at line " + row + ". Expected [" + columnList.size() + "] columns " - + "but instead we have [" + line.length + "]. Line[" + Arrays.toString(line) + "]"; - throw new TextException(msg); - } + if (callback.processLine(row, line)) { + // the line content is expected to be ok for processing + if (line.length != columnList.size()) { + // we have not got the expected number of columns + String msg = "Error at line " + row + ". Expected [" + columnList.size() + "] columns " + + "but instead we have [" + line.length + "]. Line[" + Arrays.toString(line) + "]"; + throw new TextException(msg); + } - T bean = buildBeanFromLineContent(row, line); + T bean = buildBeanFromLineContent(row, line); - callback.processBean(row, line, bean); + callback.processBean(row, line, bean); - } - } while (true); + } + } while (true); - callback.end(row); + callback.end(row); - } catch (Exception e) { - // notify that an error occurred so that any - // transaction can be rolled back if required - callback.endWithError(row, e); - throw e; - } - } + } catch (Exception e) { + // notify that an error occurred so that any + // transaction can be rolled back if required + callback.endWithError(row, e); + throw e; + } + } - private void addPropertiesFromHeader(String[] line) { + private void addPropertiesFromHeader(String[] line) { for (String aLine : line) { ElPropertyValue elProp = descriptor.getElGetValue(aLine); if (elProp == null) { @@ -238,106 +238,106 @@ public class TCsvReader implements CsvReader { addProperty(aLine); } } - } + } - private boolean isDateTimeType(int t) { + private boolean isDateTimeType(int t) { return t == Types.TIMESTAMP || t == Types.DATE || t == Types.TIME; } - @SuppressWarnings("unchecked") - protected T buildBeanFromLineContent(int row, String[] line) { + @SuppressWarnings("unchecked") + protected T buildBeanFromLineContent(int row, String[] line) { - try { - EntityBean entityBean = descriptor.createEntityBean(); - T bean = (T) entityBean; + try { + EntityBean entityBean = descriptor.createEntityBean(); + T bean = (T) entityBean; - int columnPos = 0; - for (; columnPos < line.length; columnPos++) { - convertAndSetColumn(columnPos, line[columnPos], entityBean); - } + int columnPos = 0; + for (; columnPos < line.length; columnPos++) { + convertAndSetColumn(columnPos, line[columnPos], entityBean); + } - return bean; + return bean; - } catch (RuntimeException e) { - String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; - throw new RuntimeException(msg, e); - } - } + } catch (RuntimeException e) { + String msg = "Error at line: " + row + " line[" + Arrays.toString(line) + "]"; + throw new RuntimeException(msg, e); + } + } - protected void convertAndSetColumn(int columnPos, String strValue, EntityBean bean) { + protected void convertAndSetColumn(int columnPos, String strValue, EntityBean bean) { - strValue = strValue.trim(); + strValue = strValue.trim(); - if (strValue.isEmpty()) { - return; - } + if (strValue.isEmpty()) { + return; + } - CsvColumn c = columnList.get(columnPos); - c.convertAndSet(strValue, bean); - } + CsvColumn c = columnList.get(columnPos); + c.convertAndSet(strValue, bean); + } - /** - * Processes a column in the csv content. - */ - public static class CsvColumn { + /** + * Processes a column in the csv content. + */ + public static class CsvColumn { - private final ExpressionPath path; - private final StringParser parser; + private final ExpressionPath path; + private final StringParser parser; - /** - * Constructor for the IGNORE column. - */ - private CsvColumn() { - this.path = null; - this.parser = null; - } + /** + * Constructor for the IGNORE column. + */ + private CsvColumn() { + this.path = null; + this.parser = null; + } - /** - * Construct with a property and parser. - */ - public CsvColumn(ExpressionPath path, StringParser parser) { - this.path = path; - this.parser = parser; - } + /** + * Construct with a property and parser. + */ + public CsvColumn(ExpressionPath path, StringParser parser) { + this.path = path; + this.parser = parser; + } - /** - * Convert the string to the appropriate value and set it to the bean. - */ - public void convertAndSet(String strValue, EntityBean bean) { + /** + * Convert the string to the appropriate value and set it to the bean. + */ + public void convertAndSet(String strValue, EntityBean bean) { - if (parser != null && path != null) { - Object value = parser.parse(strValue); - path.pathSet(bean, value); - } - } - } + if (parser != null && path != null) { + Object value = parser.parse(strValue); + path.pathSet(bean, value); + } + } + } - /** - * A StringParser for converting custom date/time/datetime strings into - * appropriate java types (Date, Calendar, SQL Date, Time, Timestamp, JODA - * etc). - */ - private static class DateTimeParser implements StringParser { + /** + * A StringParser for converting custom date/time/datetime strings into + * appropriate java types (Date, Calendar, SQL Date, Time, Timestamp, JODA + * etc). + */ + private static class DateTimeParser implements StringParser { - private final DateFormat dateFormat; - private final ExpressionPath path; - private final String format; + private final DateFormat dateFormat; + private final ExpressionPath path; + private final String format; - DateTimeParser(DateFormat dateFormat, String format, ExpressionPath path) { - this.dateFormat = dateFormat; - this.path = path; - this.format = format; - } + DateTimeParser(DateFormat dateFormat, String format, ExpressionPath path) { + this.dateFormat = dateFormat; + this.path = path; + this.format = format; + } - public Object parse(String value) { - try { - Date dt = dateFormat.parse(value); - return path.parseDateTime(dt.getTime()); + public Object parse(String value) { + try { + Date dt = dateFormat.parse(value); + return path.parseDateTime(dt.getTime()); - } catch (ParseException e) { - throw new TextException("Error parsing [" + value + "] using format[" + format + "]", e); - } - } + } catch (ParseException e) { + throw new TextException("Error parsing [" + value + "] using format[" + format + "]", e); + } + } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java index 0497146e9..e6e2e720a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonBeanReader.java @@ -11,7 +11,7 @@ import java.io.IOException; /** * A 'context' for reading entity beans from JSON. *

- * This is used such that a load context and persistence context can be used to span multiple marshalling requests. + * This is used such that a load context and persistence context can be used to span multiple marshalling requests. *

*/ public class DJsonBeanReader implements JsonBeanReader { diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java index 92a4603ae..eef1f1d8f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonContext.java @@ -129,7 +129,7 @@ public class DJsonContext implements JsonContext { @Override public DJsonBeanReader createBeanReader(BeanType beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException { - BeanDescriptor desc = (BeanDescriptor)beanType; + BeanDescriptor desc = (BeanDescriptor) beanType; ReadJson readJson = new ReadJson(desc, parser, options, determineObjectMapper(options)); return new DJsonBeanReader<>(desc, readJson); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java index c55c9be34..ed63ca3aa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/DJsonScalar.java @@ -21,7 +21,7 @@ public class DJsonScalar { public void write(JsonGenerator gen, Object value) throws IOException { if (value instanceof String) { - gen.writeString((String)value); + gen.writeString((String) value); } else { ScalarType scalarType = typeManager.getScalarType(value.getClass()); diff --git a/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java b/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java index e815de642..782ddd7e5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java +++ b/src/main/java/com/avaje/ebeaninternal/server/text/json/ReadJson.java @@ -116,7 +116,7 @@ public class ReadJson { */ public void persistenceContextPut(Object beanId, T currentBean) { - persistenceContextPutIfAbsent(beanId, (EntityBean)currentBean, rootDesc); + persistenceContextPutIfAbsent(beanId, (EntityBean) currentBean, rootDesc); } /** @@ -132,7 +132,7 @@ public class ReadJson { Object existing = beanDesc.contextPutIfAbsent(persistenceContext, id, bean); if (existing != null) { - beanDesc.merge(bean, (EntityBean)existing); + beanDesc.merge(bean, (EntityBean) existing); } else { if (loadContext != null) { @@ -156,10 +156,10 @@ public class ReadJson { public ObjectMapper getObjectMapper() { if (objectMapper == null) { throw new IllegalStateException( - "Jackson ObjectMapper required but has not set. The ObjectMapper can be set on" - +" either the ServerConfig or on JsonReadOptions."); + "Jackson ObjectMapper required but has not set. The ObjectMapper can be set on" + + " either the ServerConfig or on JsonReadOptions."); } - return (ObjectMapper)objectMapper; + return (ObjectMapper) objectMapper; } /** @@ -214,7 +214,7 @@ public class ReadJson { * Typically this is used to read Transient properties where the type is unknown to Ebean. */ public Object readValueUsingObjectMapper(Class propertyType) throws IOException { - return getObjectMapper().readValue(parser, propertyType); + return getObjectMapper().readValue(parser, propertyType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java index c2c40ebe4..934d5fabc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/AutoCommitTransactionManager.java @@ -17,8 +17,8 @@ import java.sql.Connection; public class AutoCommitTransactionManager extends TransactionManager { public AutoCommitTransactionManager(boolean localL2Caching, ServerConfig serverConfig, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, - DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { - + DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { + super(localL2Caching, serverConfig, clusterManager, backgroundExecutor, indexUpdateProcessor, descMgr); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java index 20ed290a9..72ce09be7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/DeleteByIdMap.java @@ -1,8 +1,11 @@ package com.avaje.ebeaninternal.server.transaction; +import com.avaje.ebean.annotation.DocStoreMode; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; +import com.avaje.ebeanservice.docstore.api.support.DocStoreDeleteEvent; import java.io.Serializable; import java.util.Collection; @@ -10,10 +13,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import com.avaje.ebean.annotation.DocStoreMode; -import com.avaje.ebeanservice.docstore.api.support.DocStoreDeleteEvent; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; - /** * Beans deleted by Id used for updating L2 Cache. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java index b8fc830da..fd33ea3ee 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitJdbcTransaction.java @@ -6,7 +6,7 @@ import java.sql.SQLException; /** * This only works for Postgres and H2 (and doesn't work for Oracle). - * + *

* Uses explicit begin statement to start the transactions. */ public class ExplicitJdbcTransaction extends JdbcTransaction { diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java index 70b4ee7b1..3875f5a8c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/ExplicitTransactionManager.java @@ -17,7 +17,7 @@ import java.sql.Connection; public class ExplicitTransactionManager extends TransactionManager { public ExplicitTransactionManager(boolean localL2Caching, ServerConfig serverConfig, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, - DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { + DocStoreUpdateProcessor indexUpdateProcessor, BeanDescriptorManager descMgr) { super(localL2Caching, serverConfig, clusterManager, backgroundExecutor, indexUpdateProcessor, descMgr); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java index 256cbf68b..9a13bbe8e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JdbcTransaction.java @@ -15,6 +15,9 @@ import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.lib.util.Str; import com.avaje.ebeaninternal.server.persist.BatchControl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.persistence.PersistenceException; import javax.persistence.RollbackException; import java.io.IOException; @@ -26,8 +29,6 @@ import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * JDBC Connection based transaction. diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java index 8162164fa..0917a56d3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/JtaTransactionManager.java @@ -151,7 +151,7 @@ public class JtaTransactionManager implements ExternalTransactionManager { } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, - SecurityException, IllegalStateException, SystemException { + SecurityException, IllegalStateException, SystemException { } public int getStatus() throws SystemException { diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java index 8c52986c2..2ecb1a2bf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/PostCommitProcessing.java @@ -6,10 +6,10 @@ import com.avaje.ebeaninternal.api.TransactionEvent; import com.avaje.ebeaninternal.api.TransactionEventTable; import com.avaje.ebeaninternal.api.TransactionEventTable.TableIUD; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import com.avaje.ebeaninternal.server.cluster.ClusterManager; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java index 1983c3cd5..3d2735bce 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/server/transaction/RemoteTransactionEvent.java @@ -67,8 +67,8 @@ public class RemoteTransactionEvent implements Runnable { public boolean isEmpty() { return beanPersistList.isEmpty() - && (tableList == null || tableList.isEmpty()) - && (deleteByIdMap == null || deleteByIdMap.isEmpty()); + && (tableList == null || tableList.isEmpty()) + && (deleteByIdMap == null || deleteByIdMap.isEmpty()); } public void addBeanPersistIds(BeanPersistIds beanPersist) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java index 2473e140a..b576e7ebb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ConvertInetAddresses.java @@ -140,7 +140,7 @@ public final class ConvertInetAddresses { // The argument was malformed, i.e. not an IP string literal. if (addr == null) { throw new IllegalArgumentException( - String.format("'%s' is not an IP string literal.", ipString)); + String.format("'%s' is not an IP string literal.", ipString)); } try { @@ -159,8 +159,7 @@ public final class ConvertInetAddresses { * {@link IPAddressUtil#textToNumericFormatV4} or * {@link IPAddressUtil#textToNumericFormatV6}. */ - throw new IllegalArgumentException( - String.format("'%s' is extremely broken.", ipString), e); + throw new IllegalArgumentException(String.format("'%s' is extremely broken.", ipString), e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 3aed66650..867a6c0c9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -62,7 +62,21 @@ import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Currency; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.TimeZone; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; /** @@ -330,7 +344,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { for (Object value : EnumSet.allOf(enumClass).toArray()) { mappedClasses.add(value.getClass()); } - for (Class cls: mappedClasses) { + for (Class cls : mappedClasses) { typeMap.put(cls, scalarType); } logAdd(scalarType); @@ -363,8 +377,8 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { if (found == null) { if (type.getName().equals("org.joda.time.LocalTime")) { throw new IllegalStateException( - "ScalarType of Joda LocalTime not defined. You need to set ServerConfig.jodaLocalTimeMode to" - + " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode."); + "ScalarType of Joda LocalTime not defined. You need to set ServerConfig.jodaLocalTimeMode to" + + " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode."); } found = checkInterfaceTypes(type); } @@ -882,8 +896,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { // determine the types from generic parameter types using reflection Class[] propParamTypes = TypeReflectHelper.getParams(prop.getClass(), CompoundTypeProperty.class); if (propParamTypes.length != 2) { - throw new RuntimeException("Expecting 2 generic paramter types but got " + Arrays.toString(propParamTypes) + " for " - + prop.getClass()); + throw new RuntimeException("Expecting 2 generic paramter types but got " + Arrays.toString(propParamTypes) + " for " + prop.getClass()); } return propParamTypes[1]; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java index 0be11f55f..6f2f04c3f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ImmutableMetaFactory.java @@ -40,7 +40,7 @@ public class ImmutableMetaFactory { } String msg = "Was unable to use reflection to find a constructor and appropriate getters for" + - "immutable type " + cls + ". The errors while looking for the getter methods follow:"; + "immutable type " + cls + ". The errors while looking for the getter methods follow:"; logger.error(msg); for (RuntimeException runtimeException : errors) { @@ -48,7 +48,7 @@ public class ImmutableMetaFactory { } msg = "Unable to use reflection to build ImmutableMeta for " + cls - + ". Associated Errors trying to find a constructor and getter methods have been logged"; + + ". Associated Errors trying to find a constructor and getter methods have been logged"; throw new RuntimeException(msg); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundType.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundType.java index 5815e850d..fdab64005 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundType.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundType.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.type.reflect; -import java.lang.reflect.Constructor; -import java.util.Arrays; - import com.avaje.ebean.config.CompoundType; import com.avaje.ebean.config.CompoundTypeProperty; +import java.lang.reflect.Constructor; +import java.util.Arrays; + @SuppressWarnings({"rawtypes"}) public class ReflectionBasedCompoundType implements CompoundType { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundTypeProperty.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundTypeProperty.java index 57b81ecd6..b4a76776f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundTypeProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedCompoundTypeProperty.java @@ -1,9 +1,9 @@ package com.avaje.ebeaninternal.server.type.reflect; -import java.lang.reflect.Method; - import com.avaje.ebean.config.CompoundTypeProperty; +import java.lang.reflect.Method; + @SuppressWarnings({"rawtypes"}) public class ReflectionBasedCompoundTypeProperty implements CompoundTypeProperty { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedScalarTypeConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedScalarTypeConverter.java index 27074f9b2..25f8d8c86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedScalarTypeConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedScalarTypeConverter.java @@ -1,10 +1,10 @@ package com.avaje.ebeaninternal.server.type.reflect; +import com.avaje.ebean.config.ScalarTypeConverter; + import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import com.avaje.ebean.config.ScalarTypeConverter; - @SuppressWarnings({"rawtypes"}) public class ReflectionBasedScalarTypeConverter implements ScalarTypeConverter { @@ -31,7 +31,7 @@ public class ReflectionBasedScalarTypeConverter implements ScalarTypeConverter { return reader.invoke(beanType, NO_ARGS); } catch (Exception e) { String msg = "Error invoking read method " + reader.getName() - + " on " + beanType.getClass().getName(); + + " on " + beanType.getClass().getName(); throw new RuntimeException(msg); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedTypeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedTypeBuilder.java index de9c7c203..b7edee132 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedTypeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/reflect/ReflectionBasedTypeBuilder.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.type.reflect; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - import com.avaje.ebeaninternal.server.type.ScalarType; import com.avaje.ebeaninternal.server.type.ScalarTypeWrapper; import com.avaje.ebeaninternal.server.type.TypeManager; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + public class ReflectionBasedTypeBuilder { private final TypeManager typeManager; @@ -68,7 +68,7 @@ public class ReflectionBasedTypeBuilder { return lowerFirstChar(name.substring(3)); } String msg = "Expecting method " + name + " to start with is or get " - + " so as to follow bean specification?"; + + " so as to follow bean specification?"; throw new RuntimeException(msg); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java b/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java index 6c7113605..933e3f81b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/util/BindParamsParser.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.util; -import java.util.Collection; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.config.EncryptKey; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.BindParams.OrderedList; import com.avaje.ebeaninternal.api.BindParams.Param; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import javax.persistence.PersistenceException; +import java.util.Collection; + /** * Parses the BindParams if they are using named parameters. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/util/package.html b/src/main/java/com/avaje/ebeaninternal/server/util/package.html index 84ed601cc..1bc4da98e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/util/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/util/package.html @@ -1,12 +1,11 @@ - - Server side Utility objects + + Server side Utility objects Server side Utility objects - - \ No newline at end of file + From 983306ed86e31101943a44dbd14188c4661125bd Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:11:28 +1300 Subject: [PATCH 68/87] no effective change - format only --- .../server/query/CQueryBuilder.java | 2 +- .../server/query/CQueryDraftSupport.java | 2 +- .../server/query/CQueryEngine.java | 4 +-- .../query/CQueryFetchSingleAttribute.java | 8 ++--- .../server/query/CQueryHistorySupport.java | 2 +- .../server/query/CQueryIteratorSimple.java | 9 +++--- .../query/CQueryIteratorWithBuffer.java | 11 +++---- .../server/query/CQueryOrderBy.java | 4 +-- .../server/query/CQueryPlan.java | 4 +-- .../server/query/CQueryPlanStats.java | 6 ++-- .../server/query/CQueryPredicates.java | 2 +- .../server/query/CQueryRowCount.java | 8 ++--- .../server/query/CQueryUpdate.java | 8 ++--- .../server/query/CallableQueryIds.java | 6 ++-- .../server/query/CallableQueryList.java | 6 ++-- .../server/query/CallableQueryRowCount.java | 4 +-- .../server/query/DefaultDbSqlContext.java | 12 +++---- .../server/query/DefaultSqlRow.java | 8 ++--- .../server/query/LimitOffsetPagedList.java | 9 +++--- .../server/query/QueryFutureList.java | 11 +++---- .../server/query/QueryFutureRowCount.java | 4 +-- .../server/query/SqlBeanLoad.java | 4 +-- .../ebeaninternal/server/query/SqlTree.java | 2 +- .../server/query/SqlTreeBuilder.java | 2 +- .../server/query/SqlTreeNodeBean.java | 4 +-- .../server/query/SqlTreeNodeRoot.java | 2 +- .../server/query/SqlTreeProperties.java | 2 +- .../server/querydefn/DefaultOrmQuery.java | 31 ++++++++++++++----- .../server/querydefn/DefaultOrmUpdate.java | 4 +-- .../server/querydefn/ONamedParam.java | 2 +- .../server/querydefn/OrmQueryDetail.java | 4 +-- .../querydefn/OrmQueryDetailParser.java | 2 +- .../server/querydefn/OrmQueryPlanKey.java | 9 ++++-- .../querydefn/OrmQueryPropertiesParser.java | 4 +-- .../server/querydefn/OrmUpdateProperties.java | 2 +- 35 files changed, 110 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java index fa039444b..39ac47505 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryBuilder.java @@ -496,7 +496,7 @@ class CQueryBuilder { String idSql = desc.getIdBinderIdSql(); if (idSql.isEmpty()) { throw new IllegalStateException("Executing FindById query on entity bean " + desc.getName() - + " that doesn't have an @Id property??"); + + " that doesn't have an @Id property??"); } if (stripAlias) { // strip the table alias for use in update statement diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java index be5a171a6..ef84db1db 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryDraftSupport.java @@ -18,7 +18,7 @@ class CQueryDraftSupport { /** * Return the draft table associated to the base table. - * + *

* This returns null for entities that are not draftable and in that case * the usual base table is used. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java index 1c07a868e..3c95a3850 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryEngine.java @@ -1,5 +1,6 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebean.QueryIterator; import com.avaje.ebean.ValuePair; import com.avaje.ebean.Version; import com.avaje.ebean.bean.BeanCollection; @@ -10,7 +11,6 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebeaninternal.api.SpiQuery; import com.avaje.ebeaninternal.server.core.DiffHelp; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; -import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.lib.util.Str; import com.avaje.ebeaninternal.server.persist.Binder; @@ -99,7 +99,7 @@ public class CQueryEngine { @SuppressWarnings("unchecked") private List findAttributeList(OrmQueryRequest request, CQueryFetchSingleAttribute rcQuery) { try { - List list = (List)rcQuery.findList(); + List list = (List) rcQuery.findList(); if (request.isLogSql()) { logGeneratedSql(request, rcQuery.getGeneratedSql(), rcQuery.getBindLog()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java index 6e901c29a..997b5c12b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryFetchSingleAttribute.java @@ -76,10 +76,10 @@ class CQueryFetchSingleAttribute { protected String getSummary() { StringBuilder sb = new StringBuilder(80); sb.append("FindAttr exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java index 6a4e38437..a62ad346f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryHistorySupport.java @@ -60,7 +60,7 @@ class CQueryHistorySupport { /** * Return the predicate appended to the end of the query. - * + *

* Note used for Oracle total recall etc with the more standard approach. */ String getAsOfPredicate(String tableAlias) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java index 88dba323a..fac87a5a6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorSimple.java @@ -1,12 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; + /** * QueryIterator that does not require a buffer for secondary queries. */ @@ -44,4 +43,4 @@ class CQueryIteratorSimple implements QueryIterator { public void remove() { throw new PersistenceException("Remove not allowed"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java index 889912202..1ffdeac1c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryIteratorWithBuffer.java @@ -1,13 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.QueryIterator; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.ArrayList; + /** * A QueryIterator that uses a buffer to execute secondary queries periodically. */ @@ -64,4 +63,4 @@ class CQueryIteratorWithBuffer implements QueryIterator { public void remove() { throw new PersistenceException("Remove not allowed"); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java index 9bde80ff9..0d8be611b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryOrderBy.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; - import com.avaje.ebean.OrderBy; import com.avaje.ebean.OrderBy.Property; import com.avaje.ebeaninternal.api.SpiQuery; @@ -11,6 +9,8 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssoc; import com.avaje.ebeaninternal.server.deploy.id.IdBinder; import com.avaje.ebeaninternal.server.el.ElPropertyValue; +import java.util.List; + /** * Creates the order by expression clause. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java index 7c1c86c41..e20e9c491 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlan.java @@ -5,11 +5,11 @@ import com.avaje.ebean.config.dbplatform.SqlLimitResponse; import com.avaje.ebeaninternal.api.CQueryPlanKey; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.core.OrmQueryRequest; +import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.query.CQueryPlanStats.Snapshot; import com.avaje.ebeaninternal.server.type.DataBind; import com.avaje.ebeaninternal.server.type.DataReader; -import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.type.RsetDataReader; import com.avaje.ebeaninternal.server.util.Md5; import org.slf4j.Logger; @@ -101,7 +101,7 @@ public class CQueryPlan { * Create a query plan for a raw sql query. */ CQueryPlan(OrmQueryRequest request, String sql, SqlTree sqlTree, - boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { + boolean rawSql, boolean rowNumberIncluded, String logWhereSql) { this.server = request.getServer(); this.dataTimeZone = server.getDataTimeZone(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java index a46162571..36a55fcc9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPlanStats.java @@ -173,7 +173,7 @@ public final class CQueryPlanStats { private final List origins; Snapshot(CQueryPlan queryPlan, long count, long totalTime, long totalBeans, long maxTime, long startTime, long lastQueryTime, - List origins) { + List origins) { this.queryPlan = queryPlan; this.count = count; @@ -187,7 +187,7 @@ public final class CQueryPlanStats { public String toString() { return queryPlan + " count:" + count + " time:" + totalTime + " maxTime:" + maxTime + " beans:" + totalBeans - + " start:" + startTime + " lastQuery:" + lastQueryTime + " origins:" + origins; + + " start:" + startTime + " lastQuery:" + lastQueryTime + " origins:" + origins; } @Override @@ -257,4 +257,4 @@ public final class CQueryPlanStats { } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java index 00f3b1703..dcd59eaa3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryPredicates.java @@ -114,7 +114,7 @@ public class CQueryPredicates { this.idValue = query.getId(); } - public String bind(PreparedStatement stmt, Connection connection) throws SQLException { + public String bind(PreparedStatement stmt, Connection connection) throws SQLException { return bind(binder.dataBind(stmt, connection)); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java index 58d2a3b75..e3011c17c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryRowCount.java @@ -70,10 +70,10 @@ class CQueryRowCount { //noinspection StringBufferReplaceableByString StringBuilder sb = new StringBuilder(80); sb.append("FindRowCount exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getFullName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getFullName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java index 91b757d35..fb1abb580 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CQueryUpdate.java @@ -62,10 +62,10 @@ class CQueryUpdate { public String getSummary() { StringBuilder sb = new StringBuilder(80); sb.append(type).append(" exeMicros[").append(executionTimeMicros) - .append("] rows[").append(rowCount) - .append("] type[").append(desc.getName()) - .append("] predicates[").append(predicates.getLogWhereSql()) - .append("] bind[").append(bindLog).append("]"); + .append("] rows[").append(rowCount) + .append("] type[").append(desc.getName()) + .append("] predicates[").append(predicates.getLogWhereSql()) + .append("] bind[").append(bindLog).append("]"); return sb.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java index cfd1a7aa6..d8a6aec89 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryIds.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.List; +import java.util.concurrent.Callable; + /** * Represent the fetch Id's query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java index 8a1ed154e..352c63e8e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryList.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.List; +import java.util.concurrent.Callable; + /** * Represent the findList query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java index 0eeeb105f..d583675da 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/CallableQueryRowCount.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.util.concurrent.Callable; - import com.avaje.ebean.Transaction; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiQuery; +import java.util.concurrent.Callable; + /** * Represent the findRowCount query as a Callable. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java index 5896f6165..e1af25150 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultDbSqlContext.java @@ -55,7 +55,7 @@ class DefaultDbSqlContext implements DbSqlContext { * Construct for SELECT clause (with column alias settings). */ DefaultDbSqlContext(SqlTreeAlias alias, String tableAliasPlaceHolder, - String columnAliasPrefix, boolean alwaysUseColumnAlias, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { + String columnAliasPrefix, boolean alwaysUseColumnAlias, CQueryHistorySupport historySupport, CQueryDraftSupport draftSupport) { this.alias = alias; this.tableAliasPlaceHolder = tableAliasPlaceHolder; @@ -136,15 +136,15 @@ class DefaultDbSqlContext implements DbSqlContext { if (i > 0) { sb.append(" and "); } - + if (pair.getForeignSqlFormula() != null) { sb.append(StringHelper.replaceString(pair.getForeignSqlFormula(), tableAliasPlaceHolder, a2)); } else { sb.append(a2).append(".").append(pair.getForeignDbColumn()); } - + sb.append(" = "); - + if (pair.getLocalSqlFormula() != null) { sb.append(StringHelper.replaceString(pair.getLocalSqlFormula(), tableAliasPlaceHolder, a1)); } else { @@ -251,11 +251,11 @@ class DefaultDbSqlContext implements DbSqlContext { String tableAlias = tableAliasStack.peek(); String converted = StringHelper.replaceString(sqlFormulaSelect, tableAliasPlaceHolder, - tableAlias); + tableAlias); sb.append(COMMA); sb.append(converted); - + appendColumnAlias(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java index ee4024ee7..0cb102c09 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/DefaultSqlRow.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.server.query; +import com.avaje.ebean.SqlQuery; +import com.avaje.ebean.SqlRow; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.math.BigDecimal; import java.sql.Date; import java.sql.Timestamp; @@ -10,10 +14,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import com.avaje.ebean.SqlQuery; -import com.avaje.ebean.SqlRow; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * Used to return raw SQL query results. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java b/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java index 301fc884f..6dc4e9232 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/LimitOffsetPagedList.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.Future; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.PagedList; import com.avaje.ebeaninternal.api.Monitor; import com.avaje.ebeaninternal.api.SpiQuery; +import javax.persistence.PersistenceException; +import java.util.List; +import java.util.concurrent.Future; + /** * PagedList implementation based on limit offset types of queries. * diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java index 73dc46a65..7f68a84c6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureList.java @@ -1,16 +1,15 @@ package com.avaje.ebeaninternal.server.query; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - import com.avaje.ebean.FutureList; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; import javax.persistence.PersistenceException; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * Default implementation for FutureList. diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java index a19626bc1..f5202883d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/QueryFutureRowCount.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.query; -import java.util.concurrent.FutureTask; - import com.avaje.ebean.FutureRowCount; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; +import java.util.concurrent.FutureTask; + /** * Future implementation for the row count query. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java index c61077d6c..546dbf4c8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlBeanLoad.java @@ -58,8 +58,8 @@ public class SqlBeanLoad { } if ((bean == null) - || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) - || (type != null && !prop.isAssignableFrom(type))) { + || (lazyLoading && ebi.isLoadedProperty(prop.getPropertyIndex())) + || (type != null && !prop.isAssignableFrom(type))) { // ignore this property // ... null: bean already in persistence context diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java index 97d64134f..ac9c4f867 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTree.java @@ -49,7 +49,7 @@ class SqlTree { * Create the SqlSelectClause. */ SqlTree(String summary, SqlTreeNode rootNode, String selectSql, String fromSql, String groupBy, String inheritanceWhereSql, - BeanProperty[] encryptedProps, BeanPropertyAssocMany manyProperty, Set includes, boolean includeJoins) { + BeanProperty[] encryptedProps, BeanPropertyAssocMany manyProperty, Set includes, boolean includeJoins) { this.summary = summary; this.rootNode = rootNode; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java index f727c2987..6e7b7e660 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeBuilder.java @@ -142,7 +142,7 @@ public class SqlTreeBuilder { boolean includeJoins = alias != null && alias.isIncludeJoins(); return new SqlTree(summary.toString(), rootNode, selectSql, fromSql, groupBy, inheritanceWhereSql, encryptedProps, - manyProperty, queryDetail.getFetchPaths(), includeJoins); + manyProperty, queryDetail.getFetchPaths(), includeJoins); } private String buildSelectClause() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java index b5c2b1332..bfd69c980 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeBean.java @@ -89,7 +89,7 @@ class SqlTreeNodeBean implements SqlTreeNode { * Construct for leaf node. */ SqlTreeNodeBean(String prefix, BeanPropertyAssoc beanProp, SqlTreeProperties props, - List myChildren, boolean disableLazyLoad) { + List myChildren, boolean disableLazyLoad) { this(prefix, beanProp, beanProp.getTargetDescriptor(), props, myChildren, true, null, SpiQuery.TemporalMode.CURRENT, disableLazyLoad); } @@ -98,7 +98,7 @@ class SqlTreeNodeBean implements SqlTreeNode { * Construct for root node. */ SqlTreeNodeBean(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, - BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { + BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { this(null, null, desc, props, myList, withId, many, temporalMode, disableLazyLoad); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java index 560709d35..d75fbb140 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeNodeRoot.java @@ -19,7 +19,7 @@ final class SqlTreeNodeRoot extends SqlTreeNodeBean { * Specify for SqlSelect to include an Id property or not. */ SqlTreeNodeRoot(BeanDescriptor desc, SqlTreeProperties props, List myList, boolean withId, - TableJoin includeJoin, BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { + TableJoin includeJoin, BeanPropertyAssocMany many, SpiQuery.TemporalMode temporalMode, boolean disableLazyLoad) { super(desc, props, myList, withId, many, temporalMode, disableLazyLoad); this.includeJoin = includeJoin; diff --git a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java index c6c407541..e674f3146 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/query/SqlTreeProperties.java @@ -82,7 +82,7 @@ public class SqlTreeProperties { aggregation = true; manyWhereJoins.addAggregationJoin(joinProperty); return false; - } else{ + } else { return manyWhereJoins.requireSqlDistinct(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 95516ee4a..9a32050f1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1,7 +1,24 @@ package com.avaje.ebeaninternal.server.querydefn; -import com.avaje.ebean.*; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Expression; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FetchConfig; +import com.avaje.ebean.FetchPath; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.OrderBy; import com.avaje.ebean.OrderBy.Property; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.Version; import com.avaje.ebean.bean.CallStack; import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.ObjectGraphOrigin; @@ -135,7 +152,7 @@ public class DefaultOrmQuery implements SpiQuery { */ private Object id; - private Map namedParams; + private Map namedParams; /** * Bind parameters when using the query language. @@ -874,9 +891,9 @@ public class DefaultOrmQuery implements SpiQuery { CQueryPlanKey createQueryPlanKey() { queryPlanKey = new OrmQueryPlanKey(m2mIncludeJoin, type, detail, maxRows, firstRow, - disableLazyLoading, orderBy, - distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions, - temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties); + disableLazyLoading, orderBy, + distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions, + temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties); return queryPlanKey; } @@ -985,7 +1002,7 @@ public class DefaultOrmQuery implements SpiQuery { public boolean isExcludeBeanCache() { // not using L2 cache for asDraft() query - return excludeBeanCache || isAsDraft() ; + return excludeBeanCache || isAsDraft(); } @Override @@ -1152,7 +1169,7 @@ public class DefaultOrmQuery implements SpiQuery { @Override @SuppressWarnings("unchecked") public List findSingleAttributeList() { - return (List)server.findSingleAttributeList(this, null); + return (List) server.findSingleAttributeList(this, null); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java index 8b0a65a51..3939c9a87 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmUpdate.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.querydefn; -import java.io.Serializable; - import com.avaje.ebean.EbeanServer; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiUpdate; +import java.io.Serializable; + /** * Default implementation of OrmUpdate. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java index 004aea830..261361da3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/ONamedParam.java @@ -39,7 +39,7 @@ class ONamedParam implements SpiNamedParam { */ void checkValueSet() { if (value == null) { - throw new PersistenceException("Named parameter ["+name+"] has not had it's value set."); + throw new PersistenceException("Named parameter [" + name + "] has not had it's value set."); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java index 234bfe5ef..b9706d23a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetail.java @@ -379,8 +379,8 @@ public class OrmQueryDetail implements Serializable { */ private boolean isQueryJoinCandidate(String lazyLoadManyPath, OrmQueryProperties chunk) { return chunk.isFetchJoin() - && !isLazyLoadManyRoot(lazyLoadManyPath, chunk) - && !hasParentSecJoin(lazyLoadManyPath, chunk); + && !isLazyLoadManyRoot(lazyLoadManyPath, chunk) + && !hasParentSecJoin(lazyLoadManyPath, chunk); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java index a84cfad46..5fa81c4d8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParser.java @@ -51,7 +51,7 @@ public class OrmQueryDetailParser { detail.fetch(readFindFetch()); } else { throw new PersistenceException("Query expected 'fetch', 'where','order by' or 'limit' keyword but got [" - + parser.getWord() + "] \r " + parser.getOql()); + + parser.getWord() + "] \r " + parser.getOql()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java index be40243d1..10e2fae98 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKey.java @@ -118,11 +118,14 @@ class OrmQueryPlanKey implements CQueryPlanKey { if (hasIdValue != that.hasIdValue) return false; if (type != that.type) return false; if (temporalMode != that.temporalMode) return false; - if (m2mIncludeTable != null ? !m2mIncludeTable.equals(that.m2mIncludeTable) : that.m2mIncludeTable != null) return false; - if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != null) return false; + if (m2mIncludeTable != null ? !m2mIncludeTable.equals(that.m2mIncludeTable) : that.m2mIncludeTable != null) + return false; + if (orderByAsSting != null ? !orderByAsSting.equals(that.orderByAsSting) : that.orderByAsSting != null) + return false; if (where != null ? !where.isSameByPlan(that.where) : that.where != null) return false; if (having != null ? !having.isSameByPlan(that.having) : that.having != null) return false; - if (updateProperties != null ? !updateProperties.isSameByPlan(that.updateProperties) : that.updateProperties != null) return false; + if (updateProperties != null ? !updateProperties.isSameByPlan(that.updateProperties) : that.updateProperties != null) + return false; if (rawSqlKey != null ? !rawSqlKey.equals(that.rawSqlKey) : that.rawSqlKey != null) return false; if (mapKey != null ? !mapKey.equals(that.mapKey) : that.mapKey != null) return false; return rootTableAlias != null ? rootTableAlias.equals(that.rootTableAlias) : that.rootTableAlias == null; diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java index 6be8be81d..31eb2555a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesParser.java @@ -61,7 +61,7 @@ class OrmQueryPropertiesParser { private int queryFetchBatch = -1; private int lazyFetchBatch = -1; - private OrmQueryPropertiesParser(String inputProperties) { + private OrmQueryPropertiesParser(String inputProperties) { this.inputProperties = inputProperties; } @@ -148,7 +148,7 @@ class OrmQueryPropertiesParser { return propertySet; } - private int parseBatchHint( int pos, String option) { + private int parseBatchHint(int pos, String option) { int startPos = pos + option.length(); int endPos = findEndPos(startPos, inputProperties); diff --git a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java index cb5ebaaa8..08ff01d7f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/querydefn/OrmUpdateProperties.java @@ -151,7 +151,7 @@ public class OrmUpdateProperties { */ public boolean isSameByPlan(OrmUpdateProperties that) { return that.values.size() == values.size() - && logicalSetClause().equals(that.logicalSetClause()); + && logicalSetClause().equals(that.logicalSetClause()); } /** From 63b08af3d2e5e0b8778cd9ab0c7086f60a1e101b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:14:02 +1300 Subject: [PATCH 69/87] no effective change - format only --- .../server/persist/BatchControl.java | 1 + .../server/persist/BatchedPstmtHolder.java | 5 +- .../server/persist/BeanPersister.java | 4 +- .../ebeaninternal/server/persist/Binder.java | 21 ++-- .../server/persist/DefaultPersister.java | 8 +- .../server/persist/PstmtFactory.java | 6 +- .../server/persist/dml/DeleteHandler.java | 60 +++++------ .../server/persist/dml/DeleteMeta.java | 30 +++--- .../server/persist/dml/DmlBeanPersister.java | 100 +++++++++--------- .../persist/dml/DmlBeanPersisterFactory.java | 42 ++++---- .../server/persist/dml/DmlHandler.java | 6 +- .../server/persist/dml/DmlMode.java | 20 ++-- .../server/persist/dml/UpdateMeta.java | 2 +- .../server/persist/dml/UpdatePlan.java | 2 +- .../server/persist/dml/package.html | 6 +- .../server/persist/dmlbind/Bindable.java | 6 +- .../persist/dmlbind/BindableCompound.java | 8 +- .../dmlbind/BindableDiscriminator.java | 9 +- .../persist/dmlbind/BindableEmbedded.java | 8 +- .../dmlbind/BindableEncryptedProperty.java | 11 +- .../persist/dmlbind/BindableIdEmbedded.java | 15 ++- .../persist/dmlbind/BindableIdEmpty.java | 6 +- .../persist/dmlbind/BindableIdScalar.java | 9 +- .../server/persist/dmlbind/BindableList.java | 5 +- .../persist/dmlbind/BindableProperty.java | 6 +- .../BindablePropertyInsertGenerated.java | 4 +- .../BindablePropertyUpdateGenerated.java | 6 +- .../dmlbind/BindableUnidirectional.java | 9 +- .../persist/dmlbind/FactoryAssocOnes.java | 4 +- .../dmlbind/FactoryBaseProperties.java | 6 +- .../persist/dmlbind/FactoryEmbedded.java | 6 +- .../server/persist/dmlbind/package.html | 6 +- .../ebeaninternal/server/persist/package.html | 10 +- .../properties/BeanPropertiesReader.java | 18 ++-- .../server/properties/BeanPropertyGetter.java | 10 +- .../server/properties/BeanPropertyInfo.java | 28 ++--- .../properties/BeanPropertyInfoFactory.java | 8 +- .../server/properties/BeanPropertySetter.java | 22 ++-- .../properties/EnhanceBeanPropertyInfo.java | 10 +- .../EnhanceBeanPropertyInfoFactory.java | 8 +- .../server/properties/package.html | 10 +- 41 files changed, 275 insertions(+), 286 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java index a6834b0a6..3242809af 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchControl.java @@ -4,6 +4,7 @@ import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; + import javax.persistence.PersistenceException; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java index 249910ddf..1cc374303 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchedPstmtHolder.java @@ -1,11 +1,12 @@ package com.avaje.ebeaninternal.server.persist; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.persistence.PersistenceException; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.LinkedHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Used to hold BatchedPstmt objects for batch based execution. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java index 96f75ab7f..c4e192288 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BeanPersister.java @@ -1,9 +1,9 @@ package com.avaje.ebeaninternal.server.persist; -import javax.persistence.PersistenceException; - import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import javax.persistence.PersistenceException; + /** * Defines bean insert update and delete implementation. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java index 3e46b87fe..4049b26a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/Binder.java @@ -1,16 +1,5 @@ package com.avaje.ebeaninternal.server.persist; -import java.math.BigDecimal; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Types; -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.config.dbplatform.DbPlatformType; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.server.core.DbExpressionHandler; @@ -22,6 +11,16 @@ import com.avaje.ebeaninternal.server.type.TypeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import java.math.BigDecimal; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; + /** * Binds bean values to a PreparedStatement. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java index 402fdd50a..f676bc153 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/DefaultPersister.java @@ -148,7 +148,7 @@ public final class DefaultPersister implements Persister { BeanManager mgr = beanDescriptorManager.getBeanManager(beanType); - for (T liveBean: liveBeans) { + for (T liveBean : liveBeans) { T draftBean = draftHandler.publishToDestinationBean(liveBean); // reset @DraftDirty and @DraftReset properties draftHandler.resetDraft(draftBean); @@ -166,7 +166,7 @@ public final class DefaultPersister implements Persister { */ private List getBeanIds(BeanDescriptor desc, List beans) { List idList = new ArrayList<>(); - for (T liveBean: beans) { + for (T liveBean : beans) { idList.add(desc.getBeanId(liveBean)); } return idList; @@ -194,7 +194,7 @@ public final class DefaultPersister implements Persister { BeanManager mgr = beanDescriptorManager.getBeanManager(beanType); List livePublish = new ArrayList<>(draftBeans.size()); - for (T draftBean: draftBeans) { + for (T draftBean : draftBeans) { T liveBean = draftHandler.publishToDestinationBean(draftBean); livePublish.add(liveBean); @@ -889,7 +889,7 @@ public final class DefaultPersister implements Persister { private void resetModifyState() { Object details = getValue(); if (details instanceof BeanCollection) { - modifyListenReset((BeanCollection)details); + modifyListenReset((BeanCollection) details); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java index f9f995805..0cfae26b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/PstmtFactory.java @@ -38,8 +38,7 @@ public class PstmtFactory { /** * Return a prepared statement taking into account batch requirements. */ - public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) - throws SQLException { + public PreparedStatement getPstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); PreparedStatement stmt = batch.getStmt(sql, batchExe); @@ -63,8 +62,7 @@ public class PstmtFactory { /** * Return a callable statement taking into account batch requirements. */ - public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) - throws SQLException { + public CallableStatement getCstmt(SpiTransaction t, boolean logSql, String sql, BatchPostExecute batchExe) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); CallableStatement stmt = (CallableStatement) batch.getStmt(sql, batchExe); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java index ffd57b352..677f80112 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteHandler.java @@ -12,41 +12,41 @@ import java.sql.SQLException; */ public class DeleteHandler extends DmlHandler { - private final DeleteMeta meta; + private final DeleteMeta meta; - public DeleteHandler(PersistRequestBean persist, DeleteMeta meta) { - super(persist, meta.isEmptyStringAsNull()); - this.meta = meta; - } + public DeleteHandler(PersistRequestBean persist, DeleteMeta meta) { + super(persist, meta.isEmptyStringAsNull()); + this.meta = meta; + } - /** - * Generate and bind the delete statement. - */ + /** + * Generate and bind the delete statement. + */ @Override - public void bind() throws SQLException { - - sql = meta.getSql(persistRequest); - SpiTransaction t = persistRequest.getTransaction(); + public void bind() throws SQLException { - PreparedStatement pstmt; - if (persistRequest.isBatched()) { - pstmt = getPstmt(t, sql, persistRequest, false); - } else { - pstmt = getPstmt(t, sql, false); - } - dataBind = bind(pstmt); - meta.bind(persistRequest, this); - logSql(sql); - } + sql = meta.getSql(persistRequest); + SpiTransaction t = persistRequest.getTransaction(); - /** - * Execute the delete non-batch. - */ + PreparedStatement pstmt; + if (persistRequest.isBatched()) { + pstmt = getPstmt(t, sql, persistRequest, false); + } else { + pstmt = getPstmt(t, sql, false); + } + dataBind = bind(pstmt); + meta.bind(persistRequest, this); + logSql(sql); + } + + /** + * Execute the delete non-batch. + */ @Override - public int execute() throws SQLException, OptimisticLockException { - int rowCount = dataBind.executeUpdate(); - checkRowCount(rowCount); + public int execute() throws SQLException, OptimisticLockException { + int rowCount = dataBind.executeUpdate(); + checkRowCount(rowCount); return rowCount; - } - + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java index 8b6684586..f09b41531 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DeleteMeta.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dml; -import java.sql.SQLException; - -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; import com.avaje.ebeaninternal.server.persist.dmlbind.BindableId; +import java.sql.SQLException; + /** * Meta data for delete handler. The meta data is for a particular bean type. It * is considered immutable and is thread safe. @@ -69,12 +69,12 @@ public final class DeleteMeta { id.dmlBind(bind, bean); switch (persist.getConcurrencyMode()) { - case VERSION: - version.dmlBind(bind, bean); - break; + case VERSION: + version.dmlBind(bind, bean); + break; - default: - break; + default: + break; } } @@ -89,14 +89,14 @@ public final class DeleteMeta { boolean publish = request.isPublish(); switch (request.determineConcurrencyMode()) { - case NONE: - return publish ? sqlNone : sqlDraftNone; + case NONE: + return publish ? sqlNone : sqlDraftNone; - case VERSION: - return publish ? sqlVersion : sqlDraftVersion; + case VERSION: + return publish ? sqlVersion : sqlDraftVersion; - default: - throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode()); + default: + throw new RuntimeException("Invalid mode " + request.determineConcurrencyMode()); } } @@ -118,7 +118,7 @@ public final class DeleteMeta { } version.dmlAppend(request); } - + return request.toString(); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java index 737e8000a..c37a60098 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersister.java @@ -18,77 +18,77 @@ import java.sql.SQLException; */ public final class DmlBeanPersister implements BeanPersister { - private final UpdateMeta updateMeta; + private final UpdateMeta updateMeta; - private final InsertMeta insertMeta; + private final InsertMeta insertMeta; - private final DeleteMeta deleteMeta; + private final DeleteMeta deleteMeta; - - public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) { - this.updateMeta = updateMeta; - this.insertMeta = insertMeta; - this.deleteMeta = deleteMeta; - } + public DmlBeanPersister(UpdateMeta updateMeta, InsertMeta insertMeta, DeleteMeta deleteMeta) { - /** - * execute the bean delete request. - */ - public int delete(PersistRequestBean request) { + this.updateMeta = updateMeta; + this.insertMeta = insertMeta; + this.deleteMeta = deleteMeta; + } - DeleteHandler delete = new DeleteHandler(request, deleteMeta); - return execute(request, delete); - } + /** + * execute the bean delete request. + */ + public int delete(PersistRequestBean request) { - /** - * execute the bean insert request. - */ - public void insert(PersistRequestBean request) { + DeleteHandler delete = new DeleteHandler(request, deleteMeta); + return execute(request, delete); + } - InsertHandler insert = new InsertHandler(request, insertMeta); - execute(request, insert); - } + /** + * execute the bean insert request. + */ + public void insert(PersistRequestBean request) { - /** - * execute the bean update request. - */ - public void update(PersistRequestBean request) { + InsertHandler insert = new InsertHandler(request, insertMeta); + execute(request, insert); + } - UpdateHandler update = new UpdateHandler(request, updateMeta); - execute(request, update); - } + /** + * execute the bean update request. + */ + public void update(PersistRequestBean request) { - /** - * execute request taking batching into account. - */ - private int execute(PersistRequestBean request, PersistHandler handler) { + UpdateHandler update = new UpdateHandler(request, updateMeta); + execute(request, update); + } + + /** + * execute request taking batching into account. + */ + private int execute(PersistRequestBean request, PersistHandler handler) { boolean batched = request.isBatched(); - try { - handler.bind(); - if (batched) { - handler.addBatch(); + try { + handler.bind(); + if (batched) { + handler.addBatch(); return -1; - } else { - return handler.execute(); - } + } else { + return handler.execute(); + } - } catch (SQLException e) { + } catch (SQLException e) { // log the error to the transaction log - String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r","\n"}, "\\n "); - String msg = "ERROR executing DML bindLog["+handler.getBindLog()+"] error["+errMsg+"]"; + String errMsg = StringHelper.replaceStringMulti(e.getMessage(), new String[]{"\r", "\n"}, "\\n "); + String msg = "ERROR executing DML bindLog[" + handler.getBindLog() + "] error[" + errMsg + "]"; if (request.getTransaction().isLogSummary()) { request.getTransaction().logSummary(msg); } - throw new PersistenceException(msg, e); + throw new PersistenceException(msg, e); - } finally { - if (!batched && handler != null) { + } finally { + if (!batched && handler != null) { handler.close(); - } - } - } + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java index 5bfcf5957..d4b9fcebd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlBeanPersisterFactory.java @@ -9,25 +9,25 @@ import com.avaje.ebeaninternal.server.persist.BeanPersisterFactory; * Factory for creating a DmlBeanPersister for a bean type. */ public class DmlBeanPersisterFactory implements BeanPersisterFactory { - - private final MetaFactory metaFactory; - - public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) { - this.metaFactory = new MetaFactory(dbPlatform); - } - - - /** - * Create a DmlBeanPersister for the given bean type. - */ - public BeanPersister create(BeanDescriptor desc) { - - UpdateMeta updMeta = metaFactory.createUpdate(desc); - DeleteMeta delMeta = metaFactory.createDelete(desc); - InsertMeta insMeta = metaFactory.createInsert(desc); - - return new DmlBeanPersister(updMeta, insMeta, delMeta); - - } - + + private final MetaFactory metaFactory; + + public DmlBeanPersisterFactory(DatabasePlatform dbPlatform) { + this.metaFactory = new MetaFactory(dbPlatform); + } + + + /** + * Create a DmlBeanPersister for the given bean type. + */ + public BeanPersister create(BeanDescriptor desc) { + + UpdateMeta updMeta = metaFactory.createUpdate(desc); + DeleteMeta delMeta = metaFactory.createDelete(desc); + InsertMeta insMeta = metaFactory.createInsert(desc); + + return new DmlBeanPersister(updMeta, insMeta, delMeta); + + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java index f49c35936..98721b20d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlHandler.java @@ -254,13 +254,13 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest { * Check with useGeneratedKeys to get appropriate PreparedStatement. */ protected PreparedStatement getPstmt(SpiTransaction t, String sql, boolean genKeys) throws SQLException { - + Connection conn = t.getInternalConnection(); if (genKeys) { // the Id generated is always the first column // Required to stop Oracle10 giving us Oracle rowId?? // Other jdbc drivers seem fine without this hint. - int[] columns = { 1 }; + int[] columns = {1}; return conn.prepareStatement(sql, columns); } else { @@ -272,7 +272,7 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest { * Return a prepared statement taking into account batch requirements. */ protected PreparedStatement getPstmt(SpiTransaction t, String sql, PersistRequestBean request, - boolean genKeys) throws SQLException { + boolean genKeys) throws SQLException { BatchedPstmtHolder batch = t.getBatchControl().getPstmtHolder(); PreparedStatement stmt = batch.getStmt(sql, request); diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java index 797bfcf01..c29af82e9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/DmlMode.java @@ -5,14 +5,14 @@ package com.avaje.ebeaninternal.server.persist.dml; */ public enum DmlMode { - /** - * The Insert SET. - */ - INSERT, - - /** - * The Update SET. - */ - UPDATE, - + /** + * The Insert SET. + */ + INSERT, + + /** + * The Update SET. + */ + UPDATE, + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java index 32bc1f022..2d5680599 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdateMeta.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.persist.dml; -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.api.SpiUpdatePlan; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java index 596a4a5e7..012548a7e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/UpdatePlan.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.persist.dml; -import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.api.ConcurrencyMode; import com.avaje.ebeaninternal.api.SpiUpdatePlan; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html index 05ba5dce1..7a60e6148 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dml/package.html @@ -1,10 +1,10 @@ - - Bean DML persistence implementation + + Bean DML persistence implementation Bean DML persistence implementation - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java index 797b31609..a3d877203 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/Bindable.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Item held by Meta objects used to generate and bind bean insert update and * delete statements. diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java index 39f00c1a0..f40d6275e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableCompound.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a Immutable Compound value object. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java index 21235b5f9..881875ff6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableDiscriminator.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.InheritInfo; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for inserting a discriminator value. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java index b1b707f8b..9461ab30c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEmbedded.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a Embedded bean. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java index 4863f7e51..03ffe0392 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableEncryptedProperty.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.sql.Types; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.sql.Types; +import java.util.List; + /** * Bindable for a DB encrypted BeanProperty. */ @@ -48,8 +48,7 @@ public class BindableEncryptedProperty implements Bindable { /** * Bind a value in a Insert SET clause. */ - public void dmlBind(BindableRequest request, EntityBean bean) - throws SQLException { + public void dmlBind(BindableRequest request, EntityBean bean) throws SQLException { Object value = null; if (bean != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java index 5466754bf..e0bd48f6c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmbedded.java @@ -1,11 +1,5 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; @@ -13,6 +7,11 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; + /** * Bindable for a EmbeddedId. */ @@ -83,8 +82,8 @@ public final class BindableIdEmbedded implements BindableId { if (matches == null) { String m = "Matches for the concatenated key columns where not found?" - + " I expect that the concatenated key was null, and this bean does" - + " not have ManyToOne assoc beans matching the primary key columns?"; + + " I expect that the concatenated key was null, and this bean does" + + " not have ManyToOne assoc beans matching the primary key columns?"; throw new PersistenceException(m); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java index 3c2584a70..357b5bbb9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdEmpty.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + public class BindableIdEmpty implements BindableId { public boolean isEmpty() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java index 2cba8c20a..1db027f63 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableIdScalar.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a single scalar id property. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java index 79f8fbc03..2843c8684 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableList.java @@ -49,15 +49,12 @@ public class BindableList implements Bindable { } public void dmlAppend(GenerateDmlRequest request) { - for (Bindable item : items) { item.dmlAppend(request); } } - public void dmlBind(BindableRequest bindRequest, EntityBean bean) - throws SQLException { - + public void dmlBind(BindableRequest bindRequest, EntityBean bean) throws SQLException { for (Bindable item : items) { item.dmlBind(bindRequest, bean); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java index 5b3b85d1b..d5286035d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableProperty.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a single BeanProperty. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java index c7b6e8016..f036e3031 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyInsertGenerated.java @@ -1,12 +1,12 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; + /** * Bindable for insert on a property with a GeneratedProperty. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java index 5d28a68af..68331e690 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindablePropertyUpdateGenerated.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for update on a property with a GeneratedProperty. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java index c980c9be6..cd87ec737 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/BindableUnidirectional.java @@ -1,10 +1,5 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.sql.SQLException; -import java.util.List; - -import javax.persistence.PersistenceException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; @@ -12,6 +7,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.deploy.id.ImportedId; import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.List; + /** * Bindable for a unidirectional relationship. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java index e3dc4ad01..58c8a57ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryAssocOnes.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.List; + /** * A factory that builds Bindable for BeanPropertyAssocOne properties. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java index 57ea2f4c7..e0c75fdac 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryBaseProperties.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyCompound; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.ArrayList; +import java.util.List; + /** * Add base properties to the BindableList for a bean type. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java index 52beeccc4..709c5524c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/FactoryEmbedded.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.persist.dmlbind; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.persist.dml.DmlMode; +import java.util.ArrayList; +import java.util.List; + /** * A factory that builds Bindable for embedded bean properties. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html index 829152eca..e2b530d0f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/dmlbind/package.html @@ -1,10 +1,10 @@ - - Bindable objects to support Bean DML + + Bindable objects to support Bean DML Bindable objects to support Bean DML - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/package.html b/src/main/java/com/avaje/ebeaninternal/server/persist/package.html index 5faa44c3e..589539fc1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/package.html @@ -1,15 +1,15 @@ - - Persistence Implementation + + Persistence Implementation Persistence Implementation

-Implementing the saving and deleting of beans, and the executing of -updateable and callable sql. + Implementing the saving and deleting of beans, and the executing of + updateable and callable sql.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java index d466fb7cb..62c23aa7c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertiesReader.java @@ -10,21 +10,21 @@ import java.util.Map; */ public class BeanPropertiesReader { - private final Map propertyIndexMap = new HashMap<>(); - + private final Map propertyIndexMap = new HashMap<>(); + private final String[] props; - + public BeanPropertiesReader(Class clazz) { this.props = getProperties(clazz); - for (int i=0; i clazz) { try { Field field = clazz.getField("_ebean_props"); return (String[]) field.get(null); } catch (Exception e) { - throw new IllegalStateException("Error getting _ebean_props field on type "+clazz, e); + throw new IllegalStateException("Error getting _ebean_props field on type " + clazz, e); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java index 652735249..65687da8b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyGetter.java @@ -7,11 +7,11 @@ import com.avaje.ebean.bean.EntityBean; */ public interface BeanPropertyGetter { - /** - * Return the value of a given bean property. - */ - Object get(EntityBean bean); + /** + * Return the value of a given bean property. + */ + Object get(EntityBean bean); - Object getIntercept(EntityBean bean); + Object getIntercept(EntityBean bean); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java index ebe1764c1..d40a4f607 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfo.java @@ -9,18 +9,18 @@ package com.avaje.ebeaninternal.server.properties; */ public interface BeanPropertyInfo { - /** - * Create an EntityBean for this type. - */ - Object createEntityBean(); - - /** - * Return the getter for a given bean property. - */ - BeanPropertyGetter getGetter(int position); - - /** - * Return the setter for a given bean property. - */ - BeanPropertySetter getSetter(int position); + /** + * Create an EntityBean for this type. + */ + Object createEntityBean(); + + /** + * Return the getter for a given bean property. + */ + BeanPropertyGetter getGetter(int position); + + /** + * Return the setter for a given bean property. + */ + BeanPropertySetter getSetter(int position); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java index 5b2befa02..1f5e550e3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertyInfoFactory.java @@ -7,8 +7,8 @@ package com.avaje.ebeaninternal.server.properties; */ public interface BeanPropertyInfoFactory { - /** - * Create the BeanReflect for the given plain bean and its EntityBean equivalent. - */ - BeanPropertyInfo create(Class entityBeanType); + /** + * Create the BeanReflect for the given plain bean and its EntityBean equivalent. + */ + BeanPropertyInfo create(Class entityBeanType); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java index c66a4cc0c..a3e31b331 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/BeanPropertySetter.java @@ -7,17 +7,17 @@ import com.avaje.ebean.bean.EntityBean; */ public interface BeanPropertySetter { - /** - * Set the property value of a bean. - */ - void set(EntityBean bean, Object value); + /** + * Set the property value of a bean. + */ + void set(EntityBean bean, Object value); - /** - * Set the property value of a bean with interception checks. - *

- * This could invoke lazy loading and or oldValues creation. - *

- */ - void setIntercept(EntityBean bean, Object value); + /** + * Set the property value of a bean with interception checks. + *

+ * This could invoke lazy loading and or oldValues creation. + *

+ */ + void setIntercept(EntityBean bean, Object value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java index 69429e449..0ff037f1c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfo.java @@ -1,11 +1,10 @@ package com.avaje.ebeaninternal.server.properties; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; +import com.avaje.ebean.bean.EntityBean; import javax.persistence.PersistenceException; - -import com.avaje.ebean.bean.EntityBean; +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; /** * A BeanReflect implementation based on the enhancement that creates EntityBean @@ -20,11 +19,10 @@ public final class EnhanceBeanPropertyInfo implements BeanPropertyInfo { public EnhanceBeanPropertyInfo(Class clazz) { try { if (Modifier.isAbstract(clazz.getModifiers())) { - this.constructor = null; + this.constructor = null; } else { this.constructor = defaultConstructor(clazz); } - } catch (Exception e) { throw new PersistenceException(e); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java index d70911890..fe8fa1fec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/EnhanceBeanPropertyInfoFactory.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.properties; /** - * Creates a BeanReflectFactory based on the enhancement that + * Creates a BeanReflectFactory based on the enhancement that * creates EntityBean implementations. */ public final class EnhanceBeanPropertyInfoFactory implements BeanPropertyInfoFactory { - public BeanPropertyInfo create(Class entityBeanType) { - return new EnhanceBeanPropertyInfo(entityBeanType); - } + public BeanPropertyInfo create(Class entityBeanType) { + return new EnhanceBeanPropertyInfo(entityBeanType); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/properties/package.html b/src/main/java/com/avaje/ebeaninternal/server/properties/package.html index 4c4321727..a0f5dda50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/properties/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/properties/package.html @@ -1,15 +1,15 @@ - - Bean Reflection + + Bean Reflection Bean reflection Implementation

-Abstracts the bean property getter and setter methods. -Allows Code generation or reflection to be used. + Abstracts the bean property getter and setter methods. + Allows Code generation or reflection to be used.

- \ No newline at end of file + From bdd4370fe3fd7340121a6d9361bd7daa072b5f71 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:17:34 +1300 Subject: [PATCH 70/87] no effective change - format only --- .../expression/AllEqualsExpression.java | 2 +- .../expression/ArrayContainsExpression.java | 4 +- .../expression/ArrayIsEmptyExpression.java | 3 +- .../server/expression/BetweenExpression.java | 3 +- .../expression/BetweenPropertyExpression.java | 3 +- .../expression/DefaultExpressionFactory.java | 25 +- .../expression/DefaultExpressionList.java | 24 +- .../expression/DefaultExpressionRequest.java | 8 +- .../expression/ExistsQueryExpression.java | 12 +- .../expression/FilterExpressionList.java | 8 +- .../server/expression/InExpression.java | 4 +- .../server/expression/InQueryExpression.java | 6 +- .../server/expression/IsEmptyExpression.java | 9 +- .../server/expression/JsonPathExpression.java | 8 +- .../server/expression/JunctionExpression.java | 18 +- .../server/expression/LikeExpression.java | 4 +- .../server/expression/LogicExpression.java | 6 +- .../server/expression/NamedParamHelp.java | 2 +- .../NestedPathWrapperExpression.java | 4 +- .../server/expression/NullExpression.java | 2 +- .../server/expression/PrepareDocNested.java | 8 +- .../server/expression/SimpleExpression.java | 3 +- .../server/expression/package.html | 22 +- .../server/grammer/EqlAdapter.java | 37 +- .../server/grammer/EqlAdapterHelper.java | 14 +- .../server/grammer/OperatorMapping.java | 2 +- .../server/grammer/ParseFetchConfig.java | 2 +- .../server/grammer/antlr/EQLBaseListener.java | 1260 ++-- .../server/grammer/antlr/EQLLexer.java | 570 +- .../server/grammer/antlr/EQLListener.java | 962 +-- .../server/grammer/antlr/EQLParser.java | 5208 +++++++++-------- .../ebeaninternal/server/idgen/package.html | 6 +- .../server/lib/DaemonScheduleThreadPool.java | 6 +- .../server/lib/DaemonThreadFactory.java | 50 +- .../server/lib/ShutdownManager.java | 168 +- .../ebeaninternal/server/lib/package.html | 10 +- .../ebeaninternal/server/lib/util/Str.java | 2 +- .../server/lib/util/StringHelper.java | 494 +- .../server/lib/util/package.html | 6 +- 39 files changed, 4865 insertions(+), 4120 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java index 75d0504c0..0325a322d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpression.java @@ -49,7 +49,7 @@ class AllEqualsExpression extends NonPrepareExpression { @Override public void validate(SpiExpressionValidation validation) { - for (String propName: propMap.keySet()) { + for (String propName : propMap.keySet()) { validation.validate(propName); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java index e82fbd3c7..b65eed668 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -64,8 +64,8 @@ public class ArrayContainsExpression extends AbstractExpression { } ArrayContainsExpression that = (ArrayContainsExpression) other; return this.propName.equals(that.propName) - && this.contains == that.contains - && this.values.length == that.values.length; + && this.contains == that.contains + && this.values.length == that.values.length; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java index 818ffa57d..2b7338c9e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ArrayIsEmptyExpression.java @@ -39,8 +39,7 @@ public class ArrayIsEmptyExpression extends AbstractExpression { return false; } ArrayIsEmptyExpression that = (ArrayIsEmptyExpression) other; - return this.propName.equals(that.propName) - && this.empty == that.empty; + return this.propName.equals(that.propName) && this.empty == that.empty; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java index 4d46dbafd..9888e89fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenExpression.java @@ -71,7 +71,6 @@ class BetweenExpression extends AbstractExpression { @Override public boolean isSameByBind(SpiExpression other) { BetweenExpression that = (BetweenExpression) other; - return low().equals(that.low()) - && high().equals(that.high()); + return low().equals(that.low()) && high().equals(that.high()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java index 1a5958989..d8cc71871 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/BetweenPropertyExpression.java @@ -103,8 +103,7 @@ class BetweenPropertyExpression extends NonPrepareExpression { } BetweenPropertyExpression that = (BetweenPropertyExpression) other; - return lowProperty.equals(that.lowProperty) - && highProperty.equals(that.highProperty); + return lowProperty.equals(that.lowProperty) && highProperty.equals(that.highProperty); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java index 2e0a7c1f9..3bcc1392c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionFactory.java @@ -26,7 +26,7 @@ import java.util.Map; */ public class DefaultExpressionFactory implements SpiExpressionFactory { - private static final Object[] EMPTY_ARRAY = new Object[] {}; + private static final Object[] EMPTY_ARRAY = new Object[]{}; private final boolean nativeIlike; @@ -37,7 +37,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { this.nativeIlike = nativeIlike; } - public ExpressionFactory createExpressionFactory(){ + public ExpressionFactory createExpressionFactory() { return this; } @@ -233,9 +233,9 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { if (bean == null || (!(bean instanceof EntityBean))) { throw new IllegalStateException("Expecting an EntityBean"); } - return (EntityBean)bean; + return (EntityBean) bean; } - + /** * Case insensitive {@link #exampleLike(Object)} */ @@ -372,19 +372,19 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { } /** - * Exists subquery + * Exists subquery */ @Override public Expression exists(Query subQuery) { - return new ExistsQueryExpression((SpiQuery) subQuery, false); + return new ExistsQueryExpression((SpiQuery) subQuery, false); } - + /** - * Not exists subquery + * Not exists subquery */ @Override public Expression notExists(Query subQuery) { - return new ExistsQueryExpression((SpiQuery) subQuery, true); + return new ExistsQueryExpression((SpiQuery) subQuery, true); } @Override @@ -427,9 +427,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ public Expression allEq(Map propertyMap) { return new AllEqualsExpression(propertyMap); @@ -443,7 +442,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory { *

*/ public Expression raw(String raw, Object value) { - return new RawExpression(raw, new Object[] { value }); + return new RawExpression(raw, new Object[]{value}); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java index fc0274859..381e93e86 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionList.java @@ -1,6 +1,20 @@ package com.avaje.ebeaninternal.server.expression; -import com.avaje.ebean.*; +import com.avaje.ebean.Expression; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FetchPath; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.Junction; +import com.avaje.ebean.OrderBy; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.Version; import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebean.search.Match; import com.avaje.ebean.search.MultiMatch; @@ -131,7 +145,7 @@ public class DefaultExpressionList implements SpiExpressionList { // this is a Top level "text" expressions so we may need to wrap in Bool SHOULD etc. if (list.isEmpty()) throw new IllegalStateException("empty expression list?"); - if (allDocNestedPath!=null) context.startNested(allDocNestedPath); + if (allDocNestedPath != null) context.startNested(allDocNestedPath); int size = list.size(); SpiExpression first = list.get(0); @@ -161,13 +175,13 @@ public class DefaultExpressionList implements SpiExpressionList { if (implicitBool || explicitBool) { context.endBoolGroup(); } - if (allDocNestedPath!=null) context.endNested(); + if (allDocNestedPath != null) context.endNested(); } } public void writeDocQuery(DocQueryContext context, SpiExpression idEquals) throws IOException { - if (allDocNestedPath!=null) context.startNested(allDocNestedPath); + if (allDocNestedPath != null) context.startNested(allDocNestedPath); int size = list.size(); if (size == 1 && idEquals == null) { // only 1 expression - skip bool @@ -186,7 +200,7 @@ public class DefaultExpressionList implements SpiExpressionList { } context.endBool(); } - if (allDocNestedPath!=null) context.endNested(); + if (allDocNestedPath != null) context.endNested(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java index 027718b4b..35b75c931 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionRequest.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.expression; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.api.SpiExpressionList; import com.avaje.ebeaninternal.api.SpiExpressionRequest; import com.avaje.ebeaninternal.server.core.DbExpressionHandler; @@ -13,6 +9,10 @@ import com.avaje.ebeaninternal.server.deploy.DeployParser; import com.avaje.ebeaninternal.server.persist.Binder; import com.avaje.ebeaninternal.server.type.DataBind; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + public class DefaultExpressionRequest implements SpiExpressionRequest { private final SpiOrmQueryRequest queryRequest; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java index 9f43cbb77..8de510482 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -1,8 +1,5 @@ package com.avaje.ebeaninternal.server.expression; -import java.io.IOException; -import java.util.List; - import com.avaje.ebean.event.BeanQueryRequest; import com.avaje.ebeaninternal.api.HashQueryPlanBuilder; import com.avaje.ebeaninternal.api.ManyWhereJoins; @@ -14,6 +11,9 @@ import com.avaje.ebeaninternal.api.SpiQuery; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.query.CQuery; +import java.io.IOException; +import java.util.List; + class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression { protected final boolean not; @@ -29,7 +29,7 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress this.not = not; } - ExistsQueryExpression(boolean not, String sql , List bindParams) { + ExistsQueryExpression(boolean not, String sql, List bindParams) { this.not = not; this.sql = sql; this.bindParams = bindParams; @@ -111,8 +111,8 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress ExistsQueryExpression that = (ExistsQueryExpression) other; return this.sql.equals(that.sql) - && this.not == that.not - && this.bindParams.size() == that.bindParams.size(); + && this.not == that.not + && this.bindParams.size() == that.bindParams.size(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java index a852d3593..e9cf35d22 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/FilterExpressionList.java @@ -1,6 +1,12 @@ package com.avaje.ebeaninternal.server.expression; -import com.avaje.ebean.*; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.OrderBy; +import com.avaje.ebean.Query; import com.avaje.ebeaninternal.api.SpiExpressionList; import javax.persistence.PersistenceException; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java index 7222d3372..4abffd0e1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InExpression.java @@ -134,8 +134,8 @@ class InExpression extends AbstractExpression { InExpression that = (InExpression) other; return propName.equals(that.propName) - && not == that.not - && bindValues.length == that.bindValues.length; + && not == that.not + && bindValues.length == that.bindValues.length; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java index 47abc862f..2a7026dea 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/InQueryExpression.java @@ -104,9 +104,9 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor InQueryExpression that = (InQueryExpression) other; return propName.equals(that.propName) - && sql.equals(that.sql) - && not == that.not - && bindParams.size() == that.bindParams.size(); + && sql.equals(that.sql) + && not == that.not + && bindParams.size() == that.bindParams.size(); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java index c79424d1c..744bd4a0f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpression.java @@ -85,9 +85,9 @@ class IsEmptyExpression extends AbstractExpression { request.append("not "); } request - .append("exists (select 1 from ") - .append(prop.getAssocIsEmpty(request, propertyPath)) - .append(")"); + .append("exists (select 1 from ") + .append(prop.getAssocIsEmpty(request, propertyPath)) + .append(")"); } /** @@ -110,8 +110,7 @@ class IsEmptyExpression extends AbstractExpression { } IsEmptyExpression that = (IsEmptyExpression) other; - return this.propName.equals(that.propName) - && this.empty == that.empty; + return this.propName.equals(that.propName) && this.empty == that.empty; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java index 4c0fce9c0..63032bd38 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JsonPathExpression.java @@ -91,10 +91,10 @@ class JsonPathExpression extends AbstractExpression { JsonPathExpression that = (JsonPathExpression) other; return propName.equals(that.propName) - && operator == that.operator - && Same.sameByValue(path, that.path) - && Same.sameByNull(value, that.value) - && Same.sameByNull(upperValue, that.upperValue); + && operator == that.operator + && Same.sameByValue(path, that.path) + && Same.sameByNull(value, that.value) + && Same.sameByNull(upperValue, that.upperValue); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java index 657ea35c0..e3a25ee46 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/JunctionExpression.java @@ -69,7 +69,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression List list = exprList.list; if (list.size() == 1 && list.get(0) instanceof JunctionExpression) { - JunctionExpression nested = (JunctionExpression)list.get(0); + JunctionExpression nested = (JunctionExpression) list.get(0); if (type == Type.AND && !nested.type.isText()) { // and (and (a, b, c)) -> and (a, b, c) // and (not (a, b, c)) -> not (a, b, c) @@ -429,7 +429,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Path does not exist - for the given path in a JSON document. */ @Override - public ExpressionList jsonNotExists(String propertyName, String path){ + public ExpressionList jsonNotExists(String propertyName, String path) { return exprList.jsonNotExists(propertyName, path); } @@ -437,7 +437,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Equal to - for the value at the given path in the JSON document. */ @Override - public ExpressionList jsonEqualTo(String propertyName, String path, Object value){ + public ExpressionList jsonEqualTo(String propertyName, String path, Object value) { return exprList.jsonEqualTo(propertyName, path, value); } @@ -445,7 +445,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Not Equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonNotEqualTo(String propertyName, String path, Object val){ + public ExpressionList jsonNotEqualTo(String propertyName, String path, Object val) { return exprList.jsonNotEqualTo(propertyName, path, val); } @@ -453,7 +453,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Greater than - for the given path in a JSON document. */ @Override - public ExpressionList jsonGreaterThan(String propertyName, String path, Object val){ + public ExpressionList jsonGreaterThan(String propertyName, String path, Object val) { return exprList.jsonGreaterThan(propertyName, path, val); } @@ -461,7 +461,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Greater than or equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonGreaterOrEqual(String propertyName, String path, Object val){ + public ExpressionList jsonGreaterOrEqual(String propertyName, String path, Object val) { return exprList.jsonGreaterOrEqual(propertyName, path, val); } @@ -469,7 +469,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Less than - for the given path in a JSON document. */ @Override - public ExpressionList jsonLessThan(String propertyName, String path, Object val){ + public ExpressionList jsonLessThan(String propertyName, String path, Object val) { return exprList.jsonLessThan(propertyName, path, val); } @@ -477,7 +477,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Less than or equal to - for the given path in a JSON document. */ @Override - public ExpressionList jsonLessOrEqualTo(String propertyName, String path, Object val){ + public ExpressionList jsonLessOrEqualTo(String propertyName, String path, Object val) { return exprList.jsonLessOrEqualTo(propertyName, path, val); } @@ -485,7 +485,7 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression * Between - for the given path in a JSON document. */ @Override - public ExpressionList jsonBetween(String propertyName, String path, Object lowerValue, Object upperValue){ + public ExpressionList jsonBetween(String propertyName, String path, Object lowerValue, Object upperValue) { return exprList.jsonBetween(propertyName, path, lowerValue, upperValue); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java index 7e4b330e3..f34de403a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/LikeExpression.java @@ -82,8 +82,8 @@ class LikeExpression extends AbstractValueExpression { LikeExpression that = (LikeExpression) other; return this.propName.equals(that.propName) - && this.caseInsensitive == that.caseInsensitive - && this.type == that.type; + && this.caseInsensitive == that.caseInsensitive + && this.type == that.type; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java index b2e0913f9..67d4ac8fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/LogicExpression.java @@ -159,15 +159,15 @@ abstract class LogicExpression implements SpiExpression { LogicExpression that = (LogicExpression) other; return this.joinType.equals(that.joinType) - && this.expOne.isSameByPlan(that.expOne) - && this.expTwo.isSameByPlan(that.expTwo); + && this.expOne.isSameByPlan(that.expOne) + && this.expTwo.isSameByPlan(that.expTwo); } @Override public boolean isSameByBind(SpiExpression other) { LogicExpression that = (LogicExpression) other; return this.expOne.isSameByBind(that.expOne) - && this.expTwo.isSameByBind(that.expTwo); + && this.expTwo.isSameByBind(that.expTwo); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java index b35005020..cda7e69d9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NamedParamHelp.java @@ -35,7 +35,7 @@ class NamedParamHelp { Object value = value(sourceValue); if (value instanceof Collection) { - values.addAll((Collection)value); + values.addAll((Collection) value); } else { values.add(value); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java index 6f4434486..da2bba9a3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NestedPathWrapperExpression.java @@ -70,9 +70,9 @@ class NestedPathWrapperExpression implements SpiExpression { @Override public boolean isSameByPlan(SpiExpression other) { if (other instanceof NestedPathWrapperExpression) { - NestedPathWrapperExpression that = (NestedPathWrapperExpression)other; + NestedPathWrapperExpression that = (NestedPathWrapperExpression) other; return nestedPath.equals(that.nestedPath) - && delegate.isSameByPlan(that.delegate); + && delegate.isSameByPlan(that.delegate); } return false; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java index ce05680c4..7fed6fa76 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/NullExpression.java @@ -80,7 +80,7 @@ class NullExpression extends AbstractExpression { NullExpression that = (NullExpression) other; return this.propName.equals(that.propName) - && this.notNull == that.notNull; + && this.notNull == that.notNull; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java index 2c05609b1..2b8b142a4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/PrepareDocNested.java @@ -68,12 +68,12 @@ class PrepareDocNested { /** * Reorganise the flat list of expressions into a tree grouping expressions by nested path. - * + *

* Returns the new top level list of expressions. */ private List group() { - Map groups = new LinkedHashMap<>(); + Map groups = new LinkedHashMap<>(); // organise expressions by nestedPath for (int i = 0; i < origSize; i++) { @@ -122,8 +122,8 @@ class PrepareDocNested { String nestedPath = expr.nestedPath(beanDescriptor); if (nestedPath == null) { hasMixedNesting = true; - - } if (nestedPath != null) { + } + if (nestedPath != null) { hasNesting = true; if (firstNestedPath == null) { firstNestedPath = nestedPath; diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java index fbe082f99..ec457e5fc 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/SimpleExpression.java @@ -122,8 +122,7 @@ public class SimpleExpression extends AbstractValueExpression { } SimpleExpression that = (SimpleExpression) other; - return this.propName.equals(that.propName) - && this.type == that.type; + return this.propName.equals(that.propName) && this.type == that.type; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/expression/package.html b/src/main/java/com/avaje/ebeaninternal/server/expression/package.html index b06ccffc1..aa87c6cf1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/expression/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/expression/package.html @@ -1,36 +1,36 @@ - - Collection objects for lazy loading + + Collection objects for lazy loading Expressions for building WHERE clauses.

-You will most likely use expressions directly off the ExpressionList. + You will most likely use expressions directly off the ExpressionList.

   Query<Order> query = Ebean.createQuery(Order.class)
     .where()
       .like("customer.name","rob%")
       .gt("orderDate",lastWeek);
-    
+
   List<Order> orderList = query.findList();
   ...
 

-In the code above the LIKE and GREATER THAN Expressions are added to the where clause. -The way this works is that where() returns an ExpressionList which has methods on -it to create the standard expressions (EQUAL TO, LIKE etc). + In the code above the LIKE and GREATER THAN Expressions are added to the where clause. + The way this works is that where() returns an ExpressionList which has methods on + it to create the standard expressions (EQUAL TO, LIKE etc).

-I expect most people to add their expressions in this way. The Expr expression factory -object also has the ability to create the standard expressions. + I expect most people to add their expressions in this way. The Expr expression factory + object also has the ability to create the standard expressions.

-You can build your own Expression objects by implementing the Expression interface. + You can build your own Expression objects by implementing the Expression interface.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java index 762ec25b5..b1cd04c17 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapter.java @@ -182,7 +182,7 @@ class EqlAdapter extends EQLBaseListener { */ private String trimParenthesis(String text) { text = text.substring(1); - text = text.substring(0, text.length()-1); + text = text.substring(0, text.length() - 1); return text; } @@ -198,20 +198,20 @@ class EqlAdapter extends EQLBaseListener { String path = getLeftHandSidePath(ctx); EqlOperator op = getOperator(ctx); if (op != EqlOperator.BETWEEN) { - throw new IllegalStateException("Expecting BETWEEN operator but got "+op); + throw new IllegalStateException("Expecting BETWEEN operator but got " + op); } - helper.addBetween(path, child(ctx,2), child(ctx,4)); + helper.addBetween(path, child(ctx, 2), child(ctx, 4)); } @Override public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { checkChildren(ctx, 5); - String rawValue = child(ctx,0); + String rawValue = child(ctx, 0); EqlOperator op = getOperator(ctx); if (op != EqlOperator.BETWEEN) { - throw new IllegalStateException("Expecting BETWEEN operator but got "+op); + throw new IllegalStateException("Expecting BETWEEN operator but got " + op); } - helper.addBetweenProperty(rawValue, child(ctx,2), child(ctx,4)); + helper.addBetweenProperty(rawValue, child(ctx, 2), child(ctx, 4)); } @Override @@ -308,16 +308,23 @@ class EqlAdapter extends EQLBaseListener { private EqlOperator invert(EqlOperator op) { switch (op) { // no change - case EQ : return EqlOperator.EQ; - case IEQ : return EqlOperator.IEQ; - case NE : return EqlOperator.NE; + case EQ: + return EqlOperator.EQ; + case IEQ: + return EqlOperator.IEQ; + case NE: + return EqlOperator.NE; // invert - case LT : return EqlOperator.GT; - case LTE : return EqlOperator.GTE; - case GT : return EqlOperator.LT; - case GTE : return EqlOperator.LTE; + case LT: + return EqlOperator.GT; + case LTE: + return EqlOperator.GTE; + case GT: + return EqlOperator.LT; + case GTE: + return EqlOperator.LTE; default: - throw new IllegalStateException("Can not invert operator "+op); + throw new IllegalStateException("Can not invert operator " + op); } } @@ -366,7 +373,7 @@ class EqlAdapter extends EQLBaseListener { } private EqlOperator getOperator(ParserRuleContext ctx) { - String operator = child(ctx,1); + String operator = child(ctx, 1); EqlOperator op = operatorMapping.get(operator); if (op == null) { throw new IllegalStateException("No operator found for " + operator); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java index b08e642eb..41df9bbaa 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/EqlAdapterHelper.java @@ -122,12 +122,16 @@ class EqlAdapterHelper { private Object getBindValue(ValueType valueType, String value) { switch (valueType) { - case BOOL: return Boolean.parseBoolean(value); - case NUMBER: return new BigDecimal(value); - case STRING: return unquote(value); - case NAMED_PARAM: return owner.namedParam(value.substring(1)); + case BOOL: + return Boolean.parseBoolean(value); + case NUMBER: + return new BigDecimal(value); + case STRING: + return unquote(value); + case NAMED_PARAM: + return owner.namedParam(value.substring(1)); default: - throw new IllegalArgumentException("Unhandled valueType "+valueType); + throw new IllegalArgumentException("Unhandled valueType " + valueType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java index 94d300e66..8ad872cb0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/OperatorMapping.java @@ -5,7 +5,7 @@ import java.util.Map; class OperatorMapping { - Map map = new HashMap<>(); + Map map = new HashMap<>(); public OperatorMapping() { map.put("eq", EqlOperator.EQ); diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java index db014c6c0..0432345d2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/ParseFetchConfig.java @@ -43,7 +43,7 @@ class ParseFetchConfig { } private static int parseBatchSize(String path) { - path = path.substring(0, path.length()-1); + path = path.substring(0, path.length() - 1); return Integer.parseInt(path); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java index 9c4201e44..e6ab2e11b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLBaseListener.java @@ -11,509 +11,759 @@ import org.antlr.v4.runtime.tree.TerminalNode; * of the available methods. */ public class EQLBaseListener implements EQLListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSelect_statement(EQLParser.Select_statementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSelect_statement(EQLParser.Select_statementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSelect_clause(EQLParser.Select_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSelect_clause(EQLParser.Select_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDistinct(EQLParser.DistinctContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDistinct(EQLParser.DistinctContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_clause(EQLParser.Fetch_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_clause(EQLParser.Fetch_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterWhere_clause(EQLParser.Where_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhere_clause(EQLParser.Where_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOrderby_property(EQLParser.Orderby_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAsc_desc(EQLParser.Asc_descContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAsc_desc(EQLParser.Asc_descContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLimit_clause(EQLParser.Limit_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOffset_clause(EQLParser.Offset_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOffset_clause(EQLParser.Offset_clauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_path(EQLParser.Fetch_pathContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_property(EQLParser.Fetch_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_property(EQLParser.Fetch_propertyContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_option(EQLParser.Fetch_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_option(EQLParser.Fetch_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_term(EQLParser.Conditional_termContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_term(EQLParser.Conditional_termContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConditional_primary(EQLParser.Conditional_primaryContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConditional_primary(EQLParser.Conditional_primaryContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAny_expression(EQLParser.Any_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAny_expression(EQLParser.Any_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIn_expression(EQLParser.In_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIn_expression(EQLParser.In_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIn_value(EQLParser.In_valueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIn_value(EQLParser.In_valueContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBetween_expression(EQLParser.Between_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBetween_expression(EQLParser.Between_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLike_expression(EQLParser.Like_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLike_expression(EQLParser.Like_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLike_op(EQLParser.Like_opContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLike_op(EQLParser.Like_opContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComparison_expression(EQLParser.Comparison_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComparison_operator(EQLParser.Comparison_operatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComparison_operator(EQLParser.Comparison_operatorContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterValue_expression(EQLParser.Value_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitValue_expression(EQLParser.Value_expressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLiteral(EQLParser.LiteralContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLiteral(EQLParser.LiteralContext ctx) { } + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterSelect_statement(EQLParser.Select_statementContext ctx) { + } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } -} \ No newline at end of file + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitSelect_statement(EQLParser.Select_statementContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterSelect_clause(EQLParser.Select_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitSelect_clause(EQLParser.Select_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterDistinct(EQLParser.DistinctContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitDistinct(EQLParser.DistinctContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_clause(EQLParser.Fetch_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_clause(EQLParser.Fetch_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterWhere_clause(EQLParser.Where_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitWhere_clause(EQLParser.Where_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOrderby_property(EQLParser.Orderby_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterAsc_desc(EQLParser.Asc_descContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitAsc_desc(EQLParser.Asc_descContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLimit_clause(EQLParser.Limit_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterOffset_clause(EQLParser.Offset_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitOffset_clause(EQLParser.Offset_clauseContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_path(EQLParser.Fetch_pathContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_property(EQLParser.Fetch_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_property(EQLParser.Fetch_propertyContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_option(EQLParser.Fetch_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_option(EQLParser.Fetch_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_term(EQLParser.Conditional_termContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_term(EQLParser.Conditional_termContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterConditional_primary(EQLParser.Conditional_primaryContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitConditional_primary(EQLParser.Conditional_primaryContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterAny_expression(EQLParser.Any_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitAny_expression(EQLParser.Any_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIn_expression(EQLParser.In_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIn_expression(EQLParser.In_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIn_value(EQLParser.In_valueContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIn_value(EQLParser.In_valueContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterBetween_expression(EQLParser.Between_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitBetween_expression(EQLParser.Between_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLike_expression(EQLParser.Like_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLike_expression(EQLParser.Like_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLike_op(EQLParser.Like_opContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLike_op(EQLParser.Like_opContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitComparison_expression(EQLParser.Comparison_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterComparison_operator(EQLParser.Comparison_operatorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitComparison_operator(EQLParser.Comparison_operatorContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterValue_expression(EQLParser.Value_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitValue_expression(EQLParser.Value_expressionContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterLiteral(EQLParser.LiteralContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitLiteral(EQLParser.LiteralContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void enterEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void exitEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void visitTerminal(TerminalNode node) { + } + + /** + * {@inheritDoc} + *

+ *

The default implementation does nothing.

+ */ + @Override + public void visitErrorNode(ErrorNode node) { + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java index 42b4b904f..6ecbf17d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLLexer.java @@ -1,301 +1,319 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; -import org.antlr.v4.runtime.Lexer; + import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.LexerATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class EQLLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } + static { + RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); + } - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, INPUT_VARIABLE=58, PATH_VARIABLE=59, - BOOLEAN_LITERAL=60, NUMBER_LITERAL=61, DOUBLE=62, INT=63, ZERO=64, STRING_LITERAL=65, - WS=66; - public static String[] modeNames = { - "DEFAULT_MODE" - }; + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, + T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, + T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, + T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, + T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, T__36 = 37, T__37 = 38, + T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, + T__45 = 46, T__46 = 47, T__47 = 48, T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, + T__52 = 53, T__53 = 54, T__54 = 55, T__55 = 56, T__56 = 57, INPUT_VARIABLE = 58, PATH_VARIABLE = 59, + BOOLEAN_LITERAL = 60, NUMBER_LITERAL = 61, DOUBLE = 62, INT = 63, ZERO = 64, STRING_LITERAL = 65, + WS = 66; + public static String[] modeNames = { + "DEFAULT_MODE" + }; - public static final String[] ruleNames = { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", - "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", - "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", - "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", - "INPUT_VARIABLE", "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", - "DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS" - }; + public static final String[] ruleNames = { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", + "T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56", + "INPUT_VARIABLE", "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", + "DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS" + }; - private static final String[] _LITERAL_NAMES = { - null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", - "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", - "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", - "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", - "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", - "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", - "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", - "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", - null, null, null, null, null, null, "'0'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", - "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", - "ZERO", "STRING_LITERAL", "WS" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + private static final String[] _LITERAL_NAMES = { + null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", + "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", + "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", + "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", + "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", + "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", + "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", + "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", + null, null, null, null, null, null, "'0'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", + "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", + "ZERO", "STRING_LITERAL", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } - @Override + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } - public Vocabulary getVocabulary() { - return VOCABULARY; - } + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } - @Override - public void recover(RecognitionException e) { - throw new RuntimeException("Error in grammer - " + e.getMessage()); - } + @Override + public void recover(RecognitionException e) { + throw new RuntimeException("Error in grammer - " + e.getMessage()); + } - public EQLLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } + public EQLLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + } - @Override - public String getGrammarFileName() { return "EQL.g4"; } + @Override + public String getGrammarFileName() { + return "EQL.g4"; + } - @Override - public String[] getRuleNames() { return ruleNames; } + @Override + public String[] getRuleNames() { + return ruleNames; + } - @Override - public String getSerializedATN() { return _serializedATN; } + @Override + public String getSerializedATN() { + return _serializedATN; + } - @Override - public String[] getModeNames() { return modeNames; } + @Override + public String[] getModeNames() { + return modeNames; + } - @Override - public ATN getATN() { return _ATN; } + @Override + public ATN getATN() { + return _ATN; + } - public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2D\u0200\b\1\4\2\t"+ - "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ - "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ - ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ - "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ - "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3"+ - "\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6"+ - "\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3"+ - "\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16"+ - "\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20"+ - "\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23"+ - "\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26"+ - "\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31"+ - "\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34"+ - "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36"+ - "\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3 \3"+ - " \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3"+ - "\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%"+ - "\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3"+ - "\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3"+ - ")\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3.\3"+ - "/\3/\3/\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\63\3\63\3\63\3"+ - "\64\3\64\3\64\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\3\67\38\38"+ - "\38\39\39\39\3:\3:\3:\3:\3;\3;\3;\7;\u01bb\n;\f;\16;\u01be\13;\3<\3<\7"+ - "<\u01c2\n<\f<\16<\u01c5\13<\3=\3=\3=\3=\3=\3=\3=\3=\3=\5=\u01d0\n=\3>"+ - "\5>\u01d3\n>\3>\3>\5>\u01d7\n>\3>\3>\5>\u01db\n>\3?\6?\u01de\n?\r?\16"+ - "?\u01df\3?\3?\7?\u01e4\n?\f?\16?\u01e7\13?\3@\3@\7@\u01eb\n@\f@\16@\u01ee"+ - "\13@\3A\3A\3B\3B\3B\3B\7B\u01f6\nB\fB\16B\u01f9\13B\3B\3B\3C\3C\3C\3C"+ - "\2\2D\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35"+ - "\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36"+ - ";\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67"+ - "m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\3\2\t\5\2C\\aac|\6\2\62;"+ - "C\\aac|\7\2\60\60\62;C\\aac|\3\2\62;\3\2\63;\3\2))\5\2\13\f\17\17\"\""+ - "\u020b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2"+ - "\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3"+ - "\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2"+ - "\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2"+ - "/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2"+ - "\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2"+ - "G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3"+ - "\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2"+ - "\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2"+ - "m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3"+ - "\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2"+ - "\2\2\2\u0085\3\2\2\2\3\u0087\3\2\2\2\5\u008e\3\2\2\2\7\u0090\3\2\2\2\t"+ - "\u0092\3\2\2\2\13\u009b\3\2\2\2\r\u00a1\3\2\2\2\17\u00a7\3\2\2\2\21\u00aa"+ - "\3\2\2\2\23\u00ac\3\2\2\2\25\u00b2\3\2\2\2\27\u00b8\3\2\2\2\31\u00bd\3"+ - "\2\2\2\33\u00c1\3\2\2\2\35\u00c6\3\2\2\2\37\u00cc\3\2\2\2!\u00d3\3\2\2"+ - "\2#\u00d9\3\2\2\2%\u00db\3\2\2\2\'\u00e1\3\2\2\2)\u00e6\3\2\2\2+\u00e9"+ - "\3\2\2\2-\u00ed\3\2\2\2/\u00f1\3\2\2\2\61\u00f4\3\2\2\2\63\u00fc\3\2\2"+ - "\2\65\u00ff\3\2\2\2\67\u0104\3\2\2\29\u010b\3\2\2\2;\u0115\3\2\2\2=\u011d"+ - "\3\2\2\2?\u0123\3\2\2\2A\u012b\3\2\2\2C\u0136\3\2\2\2E\u013f\3\2\2\2G"+ - "\u0144\3\2\2\2I\u014a\3\2\2\2K\u0153\3\2\2\2M\u015d\3\2\2\2O\u0168\3\2"+ - "\2\2Q\u0174\3\2\2\2S\u017d\3\2\2\2U\u0187\3\2\2\2W\u0189\3\2\2\2Y\u018c"+ - "\3\2\2\2[\u018e\3\2\2\2]\u0191\3\2\2\2_\u0194\3\2\2\2a\u0197\3\2\2\2c"+ - "\u019b\3\2\2\2e\u019d\3\2\2\2g\u01a0\3\2\2\2i\u01a3\3\2\2\2k\u01a6\3\2"+ - "\2\2m\u01aa\3\2\2\2o\u01ad\3\2\2\2q\u01b0\3\2\2\2s\u01b3\3\2\2\2u\u01b7"+ - "\3\2\2\2w\u01bf\3\2\2\2y\u01cf\3\2\2\2{\u01da\3\2\2\2}\u01dd\3\2\2\2\177"+ - "\u01e8\3\2\2\2\u0081\u01ef\3\2\2\2\u0083\u01f1\3\2\2\2\u0085\u01fc\3\2"+ - "\2\2\u0087\u0088\7u\2\2\u0088\u0089\7g\2\2\u0089\u008a\7n\2\2\u008a\u008b"+ - "\7g\2\2\u008b\u008c\7e\2\2\u008c\u008d\7v\2\2\u008d\4\3\2\2\2\u008e\u008f"+ - "\7*\2\2\u008f\6\3\2\2\2\u0090\u0091\7+\2\2\u0091\b\3\2\2\2\u0092\u0093"+ - "\7f\2\2\u0093\u0094\7k\2\2\u0094\u0095\7u\2\2\u0095\u0096\7v\2\2\u0096"+ - "\u0097\7k\2\2\u0097\u0098\7p\2\2\u0098\u0099\7e\2\2\u0099\u009a\7v\2\2"+ - "\u009a\n\3\2\2\2\u009b\u009c\7y\2\2\u009c\u009d\7j\2\2\u009d\u009e\7g"+ - "\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7g\2\2\u00a0\f\3\2\2\2\u00a1\u00a2"+ - "\7q\2\2\u00a2\u00a3\7t\2\2\u00a3\u00a4\7f\2\2\u00a4\u00a5\7g\2\2\u00a5"+ - "\u00a6\7t\2\2\u00a6\16\3\2\2\2\u00a7\u00a8\7d\2\2\u00a8\u00a9\7{\2\2\u00a9"+ - "\20\3\2\2\2\u00aa\u00ab\7.\2\2\u00ab\22\3\2\2\2\u00ac\u00ad\7p\2\2\u00ad"+ - "\u00ae\7w\2\2\u00ae\u00af\7n\2\2\u00af\u00b0\7n\2\2\u00b0\u00b1\7u\2\2"+ - "\u00b1\24\3\2\2\2\u00b2\u00b3\7h\2\2\u00b3\u00b4\7k\2\2\u00b4\u00b5\7"+ - "t\2\2\u00b5\u00b6\7u\2\2\u00b6\u00b7\7v\2\2\u00b7\26\3\2\2\2\u00b8\u00b9"+ - "\7n\2\2\u00b9\u00ba\7c\2\2\u00ba\u00bb\7u\2\2\u00bb\u00bc\7v\2\2\u00bc"+ - "\30\3\2\2\2\u00bd\u00be\7c\2\2\u00be\u00bf\7u\2\2\u00bf\u00c0\7e\2\2\u00c0"+ - "\32\3\2\2\2\u00c1\u00c2\7f\2\2\u00c2\u00c3\7g\2\2\u00c3\u00c4\7u\2\2\u00c4"+ - "\u00c5\7e\2\2\u00c5\34\3\2\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7k\2\2\u00c8"+ - "\u00c9\7o\2\2\u00c9\u00ca\7k\2\2\u00ca\u00cb\7v\2\2\u00cb\36\3\2\2\2\u00cc"+ - "\u00cd\7q\2\2\u00cd\u00ce\7h\2\2\u00ce\u00cf\7h\2\2\u00cf\u00d0\7u\2\2"+ - "\u00d0\u00d1\7g\2\2\u00d1\u00d2\7v\2\2\u00d2 \3\2\2\2\u00d3\u00d4\7h\2"+ - "\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7v\2\2\u00d6\u00d7\7e\2\2\u00d7\u00d8"+ - "\7j\2\2\u00d8\"\3\2\2\2\u00d9\u00da\7-\2\2\u00da$\3\2\2\2\u00db\u00dc"+ - "\7s\2\2\u00dc\u00dd\7w\2\2\u00dd\u00de\7g\2\2\u00de\u00df\7t\2\2\u00df"+ - "\u00e0\7{\2\2\u00e0&\3\2\2\2\u00e1\u00e2\7n\2\2\u00e2\u00e3\7c\2\2\u00e3"+ - "\u00e4\7|\2\2\u00e4\u00e5\7{\2\2\u00e5(\3\2\2\2\u00e6\u00e7\7q\2\2\u00e7"+ - "\u00e8\7t\2\2\u00e8*\3\2\2\2\u00e9\u00ea\7c\2\2\u00ea\u00eb\7p\2\2\u00eb"+ - "\u00ec\7f\2\2\u00ec,\3\2\2\2\u00ed\u00ee\7p\2\2\u00ee\u00ef\7q\2\2\u00ef"+ - "\u00f0\7v\2\2\u00f0.\3\2\2\2\u00f1\u00f2\7k\2\2\u00f2\u00f3\7p\2\2\u00f3"+ - "\60\3\2\2\2\u00f4\u00f5\7d\2\2\u00f5\u00f6\7g\2\2\u00f6\u00f7\7v\2\2\u00f7"+ - "\u00f8\7y\2\2\u00f8\u00f9\7g\2\2\u00f9\u00fa\7g\2\2\u00fa\u00fb\7p\2\2"+ - "\u00fb\62\3\2\2\2\u00fc\u00fd\7k\2\2\u00fd\u00fe\7u\2\2\u00fe\64\3\2\2"+ - "\2\u00ff\u0100\7p\2\2\u0100\u0101\7w\2\2\u0101\u0102\7n\2\2\u0102\u0103"+ - "\7n\2\2\u0103\66\3\2\2\2\u0104\u0105\7k\2\2\u0105\u0106\7u\2\2\u0106\u0107"+ - "\7P\2\2\u0107\u0108\7w\2\2\u0108\u0109\7n\2\2\u0109\u010a\7n\2\2\u010a"+ - "8\3\2\2\2\u010b\u010c\7k\2\2\u010c\u010d\7u\2\2\u010d\u010e\7P\2\2\u010e"+ - "\u010f\7q\2\2\u010f\u0110\7v\2\2\u0110\u0111\7P\2\2\u0111\u0112\7w\2\2"+ - "\u0112\u0113\7n\2\2\u0113\u0114\7n\2\2\u0114:\3\2\2\2\u0115\u0116\7p\2"+ - "\2\u0116\u0117\7q\2\2\u0117\u0118\7v\2\2\u0118\u0119\7P\2\2\u0119\u011a"+ - "\7w\2\2\u011a\u011b\7n\2\2\u011b\u011c\7n\2\2\u011c<\3\2\2\2\u011d\u011e"+ - "\7g\2\2\u011e\u011f\7o\2\2\u011f\u0120\7r\2\2\u0120\u0121\7v\2\2\u0121"+ - "\u0122\7{\2\2\u0122>\3\2\2\2\u0123\u0124\7k\2\2\u0124\u0125\7u\2\2\u0125"+ - "\u0126\7G\2\2\u0126\u0127\7o\2\2\u0127\u0128\7r\2\2\u0128\u0129\7v\2\2"+ - "\u0129\u012a\7{\2\2\u012a@\3\2\2\2\u012b\u012c\7k\2\2\u012c\u012d\7u\2"+ - "\2\u012d\u012e\7P\2\2\u012e\u012f\7q\2\2\u012f\u0130\7v\2\2\u0130\u0131"+ - "\7G\2\2\u0131\u0132\7o\2\2\u0132\u0133\7r\2\2\u0133\u0134\7v\2\2\u0134"+ - "\u0135\7{\2\2\u0135B\3\2\2\2\u0136\u0137\7p\2\2\u0137\u0138\7q\2\2\u0138"+ - "\u0139\7v\2\2\u0139\u013a\7G\2\2\u013a\u013b\7o\2\2\u013b\u013c\7r\2\2"+ - "\u013c\u013d\7v\2\2\u013d\u013e\7{\2\2\u013eD\3\2\2\2\u013f\u0140\7n\2"+ - "\2\u0140\u0141\7k\2\2\u0141\u0142\7m\2\2\u0142\u0143\7g\2\2\u0143F\3\2"+ - "\2\2\u0144\u0145\7k\2\2\u0145\u0146\7n\2\2\u0146\u0147\7k\2\2\u0147\u0148"+ - "\7m\2\2\u0148\u0149\7g\2\2\u0149H\3\2\2\2\u014a\u014b\7e\2\2\u014b\u014c"+ - "\7q\2\2\u014c\u014d\7p\2\2\u014d\u014e\7v\2\2\u014e\u014f\7c\2\2\u014f"+ - "\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7u\2\2\u0152J\3\2\2\2\u0153"+ - "\u0154\7k\2\2\u0154\u0155\7e\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2"+ - "\u0157\u0158\7v\2\2\u0158\u0159\7c\2\2\u0159\u015a\7k\2\2\u015a\u015b"+ - "\7p\2\2\u015b\u015c\7u\2\2\u015cL\3\2\2\2\u015d\u015e\7u\2\2\u015e\u015f"+ - "\7v\2\2\u015f\u0160\7c\2\2\u0160\u0161\7t\2\2\u0161\u0162\7v\2\2\u0162"+ - "\u0163\7u\2\2\u0163\u0164\7Y\2\2\u0164\u0165\7k\2\2\u0165\u0166\7v\2\2"+ - "\u0166\u0167\7j\2\2\u0167N\3\2\2\2\u0168\u0169\7k\2\2\u0169\u016a\7u\2"+ - "\2\u016a\u016b\7v\2\2\u016b\u016c\7c\2\2\u016c\u016d\7t\2\2\u016d\u016e"+ - "\7v\2\2\u016e\u016f\7u\2\2\u016f\u0170\7Y\2\2\u0170\u0171\7k\2\2\u0171"+ - "\u0172\7v\2\2\u0172\u0173\7j\2\2\u0173P\3\2\2\2\u0174\u0175\7g\2\2\u0175"+ - "\u0176\7p\2\2\u0176\u0177\7f\2\2\u0177\u0178\7u\2\2\u0178\u0179\7Y\2\2"+ - "\u0179\u017a\7k\2\2\u017a\u017b\7v\2\2\u017b\u017c\7j\2\2\u017cR\3\2\2"+ - "\2\u017d\u017e\7k\2\2\u017e\u017f\7g\2\2\u017f\u0180\7p\2\2\u0180\u0181"+ - "\7f\2\2\u0181\u0182\7u\2\2\u0182\u0183\7Y\2\2\u0183\u0184\7k\2\2\u0184"+ - "\u0185\7v\2\2\u0185\u0186\7j\2\2\u0186T\3\2\2\2\u0187\u0188\7?\2\2\u0188"+ - "V\3\2\2\2\u0189\u018a\7g\2\2\u018a\u018b\7s\2\2\u018bX\3\2\2\2\u018c\u018d"+ - "\7@\2\2\u018dZ\3\2\2\2\u018e\u018f\7i\2\2\u018f\u0190\7v\2\2\u0190\\\3"+ - "\2\2\2\u0191\u0192\7@\2\2\u0192\u0193\7?\2\2\u0193^\3\2\2\2\u0194\u0195"+ - "\7i\2\2\u0195\u0196\7g\2\2\u0196`\3\2\2\2\u0197\u0198\7i\2\2\u0198\u0199"+ - "\7v\2\2\u0199\u019a\7g\2\2\u019ab\3\2\2\2\u019b\u019c\7>\2\2\u019cd\3"+ - "\2\2\2\u019d\u019e\7n\2\2\u019e\u019f\7v\2\2\u019ff\3\2\2\2\u01a0\u01a1"+ - "\7>\2\2\u01a1\u01a2\7?\2\2\u01a2h\3\2\2\2\u01a3\u01a4\7n\2\2\u01a4\u01a5"+ - "\7g\2\2\u01a5j\3\2\2\2\u01a6\u01a7\7n\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9"+ - "\7g\2\2\u01a9l\3\2\2\2\u01aa\u01ab\7>\2\2\u01ab\u01ac\7@\2\2\u01acn\3"+ - "\2\2\2\u01ad\u01ae\7#\2\2\u01ae\u01af\7?\2\2\u01afp\3\2\2\2\u01b0\u01b1"+ - "\7p\2\2\u01b1\u01b2\7g\2\2\u01b2r\3\2\2\2\u01b3\u01b4\7k\2\2\u01b4\u01b5"+ - "\7g\2\2\u01b5\u01b6\7s\2\2\u01b6t\3\2\2\2\u01b7\u01b8\7<\2\2\u01b8\u01bc"+ - "\t\2\2\2\u01b9\u01bb\t\3\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc"+ - "\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bdv\3\2\2\2\u01be\u01bc\3\2\2\2"+ - "\u01bf\u01c3\t\2\2\2\u01c0\u01c2\t\4\2\2\u01c1\u01c0\3\2\2\2\u01c2\u01c5"+ - "\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c3\u01c4\3\2\2\2\u01c4x\3\2\2\2\u01c5"+ - "\u01c3\3\2\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8\7t\2\2\u01c8\u01c9\7w\2"+ - "\2\u01c9\u01d0\7g\2\2\u01ca\u01cb\7h\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd"+ - "\7n\2\2\u01cd\u01ce\7u\2\2\u01ce\u01d0\7g\2\2\u01cf\u01c6\3\2\2\2\u01cf"+ - "\u01ca\3\2\2\2\u01d0z\3\2\2\2\u01d1\u01d3\7/\2\2\u01d2\u01d1\3\2\2\2\u01d2"+ - "\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01db\5}?\2\u01d5\u01d7\7/\2"+ - "\2\u01d6\u01d5\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2\2\u01d8\u01db"+ - "\5\177@\2\u01d9\u01db\5\u0081A\2\u01da\u01d2\3\2\2\2\u01da\u01d6\3\2\2"+ - "\2\u01da\u01d9\3\2\2\2\u01db|\3\2\2\2\u01dc\u01de\t\5\2\2\u01dd\u01dc"+ - "\3\2\2\2\u01de\u01df\3\2\2\2\u01df\u01dd\3\2\2\2\u01df\u01e0\3\2\2\2\u01e0"+ - "\u01e1\3\2\2\2\u01e1\u01e5\7\60\2\2\u01e2\u01e4\t\5\2\2\u01e3\u01e2\3"+ - "\2\2\2\u01e4\u01e7\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6"+ - "~\3\2\2\2\u01e7\u01e5\3\2\2\2\u01e8\u01ec\t\6\2\2\u01e9\u01eb\t\5\2\2"+ - "\u01ea\u01e9\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed"+ - "\3\2\2\2\u01ed\u0080\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7\62\2\2"+ - "\u01f0\u0082\3\2\2\2\u01f1\u01f7\7)\2\2\u01f2\u01f6\n\7\2\2\u01f3\u01f4"+ - "\7)\2\2\u01f4\u01f6\7)\2\2\u01f5\u01f2\3\2\2\2\u01f5\u01f3\3\2\2\2\u01f6"+ - "\u01f9\3\2\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fa\3\2"+ - "\2\2\u01f9\u01f7\3\2\2\2\u01fa\u01fb\7)\2\2\u01fb\u0084\3\2\2\2\u01fc"+ - "\u01fd\t\b\2\2\u01fd\u01fe\3\2\2\2\u01fe\u01ff\bC\2\2\u01ff\u0086\3\2"+ - "\2\2\16\2\u01bc\u01c3\u01cf\u01d2\u01d6\u01da\u01df\u01e5\u01ec\u01f5"+ - "\u01f7\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2D\u0200\b\1\4\2\t" + + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13" + + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4" + + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t" + + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t=" + + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3" + + "\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6" + + "\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3" + + "\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16" + + "\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20" + + "\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23" + + "\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26" + + "\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31" + + "\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34" + + "\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36" + + "\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3 \3" + + " \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3" + + "\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%" + + "\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3" + + "\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3" + + ")\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3.\3" + + "/\3/\3/\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\63\3\63\3\63\3" + + "\64\3\64\3\64\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\3\67\38\38" + + "\38\39\39\39\3:\3:\3:\3:\3;\3;\3;\7;\u01bb\n;\f;\16;\u01be\13;\3<\3<\7" + + "<\u01c2\n<\f<\16<\u01c5\13<\3=\3=\3=\3=\3=\3=\3=\3=\3=\5=\u01d0\n=\3>" + + "\5>\u01d3\n>\3>\3>\5>\u01d7\n>\3>\3>\5>\u01db\n>\3?\6?\u01de\n?\r?\16" + + "?\u01df\3?\3?\7?\u01e4\n?\f?\16?\u01e7\13?\3@\3@\7@\u01eb\n@\f@\16@\u01ee" + + "\13@\3A\3A\3B\3B\3B\3B\7B\u01f6\nB\fB\16B\u01f9\13B\3B\3B\3C\3C\3C\3C" + + "\2\2D\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35" + + "\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36" + + ";\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67" + + "m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\3\2\t\5\2C\\aac|\6\2\62;" + + "C\\aac|\7\2\60\60\62;C\\aac|\3\2\62;\3\2\63;\3\2))\5\2\13\f\17\17\"\"" + + "\u020b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2" + + "\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3" + + "\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2" + + "\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2" + + "/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2" + + "\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2" + + "G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3" + + "\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2" + + "\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2" + + "m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3" + + "\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2" + + "\2\2\2\u0085\3\2\2\2\3\u0087\3\2\2\2\5\u008e\3\2\2\2\7\u0090\3\2\2\2\t" + + "\u0092\3\2\2\2\13\u009b\3\2\2\2\r\u00a1\3\2\2\2\17\u00a7\3\2\2\2\21\u00aa" + + "\3\2\2\2\23\u00ac\3\2\2\2\25\u00b2\3\2\2\2\27\u00b8\3\2\2\2\31\u00bd\3" + + "\2\2\2\33\u00c1\3\2\2\2\35\u00c6\3\2\2\2\37\u00cc\3\2\2\2!\u00d3\3\2\2" + + "\2#\u00d9\3\2\2\2%\u00db\3\2\2\2\'\u00e1\3\2\2\2)\u00e6\3\2\2\2+\u00e9" + + "\3\2\2\2-\u00ed\3\2\2\2/\u00f1\3\2\2\2\61\u00f4\3\2\2\2\63\u00fc\3\2\2" + + "\2\65\u00ff\3\2\2\2\67\u0104\3\2\2\29\u010b\3\2\2\2;\u0115\3\2\2\2=\u011d" + + "\3\2\2\2?\u0123\3\2\2\2A\u012b\3\2\2\2C\u0136\3\2\2\2E\u013f\3\2\2\2G" + + "\u0144\3\2\2\2I\u014a\3\2\2\2K\u0153\3\2\2\2M\u015d\3\2\2\2O\u0168\3\2" + + "\2\2Q\u0174\3\2\2\2S\u017d\3\2\2\2U\u0187\3\2\2\2W\u0189\3\2\2\2Y\u018c" + + "\3\2\2\2[\u018e\3\2\2\2]\u0191\3\2\2\2_\u0194\3\2\2\2a\u0197\3\2\2\2c" + + "\u019b\3\2\2\2e\u019d\3\2\2\2g\u01a0\3\2\2\2i\u01a3\3\2\2\2k\u01a6\3\2" + + "\2\2m\u01aa\3\2\2\2o\u01ad\3\2\2\2q\u01b0\3\2\2\2s\u01b3\3\2\2\2u\u01b7" + + "\3\2\2\2w\u01bf\3\2\2\2y\u01cf\3\2\2\2{\u01da\3\2\2\2}\u01dd\3\2\2\2\177" + + "\u01e8\3\2\2\2\u0081\u01ef\3\2\2\2\u0083\u01f1\3\2\2\2\u0085\u01fc\3\2" + + "\2\2\u0087\u0088\7u\2\2\u0088\u0089\7g\2\2\u0089\u008a\7n\2\2\u008a\u008b" + + "\7g\2\2\u008b\u008c\7e\2\2\u008c\u008d\7v\2\2\u008d\4\3\2\2\2\u008e\u008f" + + "\7*\2\2\u008f\6\3\2\2\2\u0090\u0091\7+\2\2\u0091\b\3\2\2\2\u0092\u0093" + + "\7f\2\2\u0093\u0094\7k\2\2\u0094\u0095\7u\2\2\u0095\u0096\7v\2\2\u0096" + + "\u0097\7k\2\2\u0097\u0098\7p\2\2\u0098\u0099\7e\2\2\u0099\u009a\7v\2\2" + + "\u009a\n\3\2\2\2\u009b\u009c\7y\2\2\u009c\u009d\7j\2\2\u009d\u009e\7g" + + "\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7g\2\2\u00a0\f\3\2\2\2\u00a1\u00a2" + + "\7q\2\2\u00a2\u00a3\7t\2\2\u00a3\u00a4\7f\2\2\u00a4\u00a5\7g\2\2\u00a5" + + "\u00a6\7t\2\2\u00a6\16\3\2\2\2\u00a7\u00a8\7d\2\2\u00a8\u00a9\7{\2\2\u00a9" + + "\20\3\2\2\2\u00aa\u00ab\7.\2\2\u00ab\22\3\2\2\2\u00ac\u00ad\7p\2\2\u00ad" + + "\u00ae\7w\2\2\u00ae\u00af\7n\2\2\u00af\u00b0\7n\2\2\u00b0\u00b1\7u\2\2" + + "\u00b1\24\3\2\2\2\u00b2\u00b3\7h\2\2\u00b3\u00b4\7k\2\2\u00b4\u00b5\7" + + "t\2\2\u00b5\u00b6\7u\2\2\u00b6\u00b7\7v\2\2\u00b7\26\3\2\2\2\u00b8\u00b9" + + "\7n\2\2\u00b9\u00ba\7c\2\2\u00ba\u00bb\7u\2\2\u00bb\u00bc\7v\2\2\u00bc" + + "\30\3\2\2\2\u00bd\u00be\7c\2\2\u00be\u00bf\7u\2\2\u00bf\u00c0\7e\2\2\u00c0" + + "\32\3\2\2\2\u00c1\u00c2\7f\2\2\u00c2\u00c3\7g\2\2\u00c3\u00c4\7u\2\2\u00c4" + + "\u00c5\7e\2\2\u00c5\34\3\2\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7k\2\2\u00c8" + + "\u00c9\7o\2\2\u00c9\u00ca\7k\2\2\u00ca\u00cb\7v\2\2\u00cb\36\3\2\2\2\u00cc" + + "\u00cd\7q\2\2\u00cd\u00ce\7h\2\2\u00ce\u00cf\7h\2\2\u00cf\u00d0\7u\2\2" + + "\u00d0\u00d1\7g\2\2\u00d1\u00d2\7v\2\2\u00d2 \3\2\2\2\u00d3\u00d4\7h\2" + + "\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7v\2\2\u00d6\u00d7\7e\2\2\u00d7\u00d8" + + "\7j\2\2\u00d8\"\3\2\2\2\u00d9\u00da\7-\2\2\u00da$\3\2\2\2\u00db\u00dc" + + "\7s\2\2\u00dc\u00dd\7w\2\2\u00dd\u00de\7g\2\2\u00de\u00df\7t\2\2\u00df" + + "\u00e0\7{\2\2\u00e0&\3\2\2\2\u00e1\u00e2\7n\2\2\u00e2\u00e3\7c\2\2\u00e3" + + "\u00e4\7|\2\2\u00e4\u00e5\7{\2\2\u00e5(\3\2\2\2\u00e6\u00e7\7q\2\2\u00e7" + + "\u00e8\7t\2\2\u00e8*\3\2\2\2\u00e9\u00ea\7c\2\2\u00ea\u00eb\7p\2\2\u00eb" + + "\u00ec\7f\2\2\u00ec,\3\2\2\2\u00ed\u00ee\7p\2\2\u00ee\u00ef\7q\2\2\u00ef" + + "\u00f0\7v\2\2\u00f0.\3\2\2\2\u00f1\u00f2\7k\2\2\u00f2\u00f3\7p\2\2\u00f3" + + "\60\3\2\2\2\u00f4\u00f5\7d\2\2\u00f5\u00f6\7g\2\2\u00f6\u00f7\7v\2\2\u00f7" + + "\u00f8\7y\2\2\u00f8\u00f9\7g\2\2\u00f9\u00fa\7g\2\2\u00fa\u00fb\7p\2\2" + + "\u00fb\62\3\2\2\2\u00fc\u00fd\7k\2\2\u00fd\u00fe\7u\2\2\u00fe\64\3\2\2" + + "\2\u00ff\u0100\7p\2\2\u0100\u0101\7w\2\2\u0101\u0102\7n\2\2\u0102\u0103" + + "\7n\2\2\u0103\66\3\2\2\2\u0104\u0105\7k\2\2\u0105\u0106\7u\2\2\u0106\u0107" + + "\7P\2\2\u0107\u0108\7w\2\2\u0108\u0109\7n\2\2\u0109\u010a\7n\2\2\u010a" + + "8\3\2\2\2\u010b\u010c\7k\2\2\u010c\u010d\7u\2\2\u010d\u010e\7P\2\2\u010e" + + "\u010f\7q\2\2\u010f\u0110\7v\2\2\u0110\u0111\7P\2\2\u0111\u0112\7w\2\2" + + "\u0112\u0113\7n\2\2\u0113\u0114\7n\2\2\u0114:\3\2\2\2\u0115\u0116\7p\2" + + "\2\u0116\u0117\7q\2\2\u0117\u0118\7v\2\2\u0118\u0119\7P\2\2\u0119\u011a" + + "\7w\2\2\u011a\u011b\7n\2\2\u011b\u011c\7n\2\2\u011c<\3\2\2\2\u011d\u011e" + + "\7g\2\2\u011e\u011f\7o\2\2\u011f\u0120\7r\2\2\u0120\u0121\7v\2\2\u0121" + + "\u0122\7{\2\2\u0122>\3\2\2\2\u0123\u0124\7k\2\2\u0124\u0125\7u\2\2\u0125" + + "\u0126\7G\2\2\u0126\u0127\7o\2\2\u0127\u0128\7r\2\2\u0128\u0129\7v\2\2" + + "\u0129\u012a\7{\2\2\u012a@\3\2\2\2\u012b\u012c\7k\2\2\u012c\u012d\7u\2" + + "\2\u012d\u012e\7P\2\2\u012e\u012f\7q\2\2\u012f\u0130\7v\2\2\u0130\u0131" + + "\7G\2\2\u0131\u0132\7o\2\2\u0132\u0133\7r\2\2\u0133\u0134\7v\2\2\u0134" + + "\u0135\7{\2\2\u0135B\3\2\2\2\u0136\u0137\7p\2\2\u0137\u0138\7q\2\2\u0138" + + "\u0139\7v\2\2\u0139\u013a\7G\2\2\u013a\u013b\7o\2\2\u013b\u013c\7r\2\2" + + "\u013c\u013d\7v\2\2\u013d\u013e\7{\2\2\u013eD\3\2\2\2\u013f\u0140\7n\2" + + "\2\u0140\u0141\7k\2\2\u0141\u0142\7m\2\2\u0142\u0143\7g\2\2\u0143F\3\2" + + "\2\2\u0144\u0145\7k\2\2\u0145\u0146\7n\2\2\u0146\u0147\7k\2\2\u0147\u0148" + + "\7m\2\2\u0148\u0149\7g\2\2\u0149H\3\2\2\2\u014a\u014b\7e\2\2\u014b\u014c" + + "\7q\2\2\u014c\u014d\7p\2\2\u014d\u014e\7v\2\2\u014e\u014f\7c\2\2\u014f" + + "\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7u\2\2\u0152J\3\2\2\2\u0153" + + "\u0154\7k\2\2\u0154\u0155\7e\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2" + + "\u0157\u0158\7v\2\2\u0158\u0159\7c\2\2\u0159\u015a\7k\2\2\u015a\u015b" + + "\7p\2\2\u015b\u015c\7u\2\2\u015cL\3\2\2\2\u015d\u015e\7u\2\2\u015e\u015f" + + "\7v\2\2\u015f\u0160\7c\2\2\u0160\u0161\7t\2\2\u0161\u0162\7v\2\2\u0162" + + "\u0163\7u\2\2\u0163\u0164\7Y\2\2\u0164\u0165\7k\2\2\u0165\u0166\7v\2\2" + + "\u0166\u0167\7j\2\2\u0167N\3\2\2\2\u0168\u0169\7k\2\2\u0169\u016a\7u\2" + + "\2\u016a\u016b\7v\2\2\u016b\u016c\7c\2\2\u016c\u016d\7t\2\2\u016d\u016e" + + "\7v\2\2\u016e\u016f\7u\2\2\u016f\u0170\7Y\2\2\u0170\u0171\7k\2\2\u0171" + + "\u0172\7v\2\2\u0172\u0173\7j\2\2\u0173P\3\2\2\2\u0174\u0175\7g\2\2\u0175" + + "\u0176\7p\2\2\u0176\u0177\7f\2\2\u0177\u0178\7u\2\2\u0178\u0179\7Y\2\2" + + "\u0179\u017a\7k\2\2\u017a\u017b\7v\2\2\u017b\u017c\7j\2\2\u017cR\3\2\2" + + "\2\u017d\u017e\7k\2\2\u017e\u017f\7g\2\2\u017f\u0180\7p\2\2\u0180\u0181" + + "\7f\2\2\u0181\u0182\7u\2\2\u0182\u0183\7Y\2\2\u0183\u0184\7k\2\2\u0184" + + "\u0185\7v\2\2\u0185\u0186\7j\2\2\u0186T\3\2\2\2\u0187\u0188\7?\2\2\u0188" + + "V\3\2\2\2\u0189\u018a\7g\2\2\u018a\u018b\7s\2\2\u018bX\3\2\2\2\u018c\u018d" + + "\7@\2\2\u018dZ\3\2\2\2\u018e\u018f\7i\2\2\u018f\u0190\7v\2\2\u0190\\\3" + + "\2\2\2\u0191\u0192\7@\2\2\u0192\u0193\7?\2\2\u0193^\3\2\2\2\u0194\u0195" + + "\7i\2\2\u0195\u0196\7g\2\2\u0196`\3\2\2\2\u0197\u0198\7i\2\2\u0198\u0199" + + "\7v\2\2\u0199\u019a\7g\2\2\u019ab\3\2\2\2\u019b\u019c\7>\2\2\u019cd\3" + + "\2\2\2\u019d\u019e\7n\2\2\u019e\u019f\7v\2\2\u019ff\3\2\2\2\u01a0\u01a1" + + "\7>\2\2\u01a1\u01a2\7?\2\2\u01a2h\3\2\2\2\u01a3\u01a4\7n\2\2\u01a4\u01a5" + + "\7g\2\2\u01a5j\3\2\2\2\u01a6\u01a7\7n\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9" + + "\7g\2\2\u01a9l\3\2\2\2\u01aa\u01ab\7>\2\2\u01ab\u01ac\7@\2\2\u01acn\3" + + "\2\2\2\u01ad\u01ae\7#\2\2\u01ae\u01af\7?\2\2\u01afp\3\2\2\2\u01b0\u01b1" + + "\7p\2\2\u01b1\u01b2\7g\2\2\u01b2r\3\2\2\2\u01b3\u01b4\7k\2\2\u01b4\u01b5" + + "\7g\2\2\u01b5\u01b6\7s\2\2\u01b6t\3\2\2\2\u01b7\u01b8\7<\2\2\u01b8\u01bc" + + "\t\2\2\2\u01b9\u01bb\t\3\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc" + + "\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bdv\3\2\2\2\u01be\u01bc\3\2\2\2" + + "\u01bf\u01c3\t\2\2\2\u01c0\u01c2\t\4\2\2\u01c1\u01c0\3\2\2\2\u01c2\u01c5" + + "\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c3\u01c4\3\2\2\2\u01c4x\3\2\2\2\u01c5" + + "\u01c3\3\2\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8\7t\2\2\u01c8\u01c9\7w\2" + + "\2\u01c9\u01d0\7g\2\2\u01ca\u01cb\7h\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd" + + "\7n\2\2\u01cd\u01ce\7u\2\2\u01ce\u01d0\7g\2\2\u01cf\u01c6\3\2\2\2\u01cf" + + "\u01ca\3\2\2\2\u01d0z\3\2\2\2\u01d1\u01d3\7/\2\2\u01d2\u01d1\3\2\2\2\u01d2" + + "\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01db\5}?\2\u01d5\u01d7\7/\2" + + "\2\u01d6\u01d5\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2\2\u01d8\u01db" + + "\5\177@\2\u01d9\u01db\5\u0081A\2\u01da\u01d2\3\2\2\2\u01da\u01d6\3\2\2" + + "\2\u01da\u01d9\3\2\2\2\u01db|\3\2\2\2\u01dc\u01de\t\5\2\2\u01dd\u01dc" + + "\3\2\2\2\u01de\u01df\3\2\2\2\u01df\u01dd\3\2\2\2\u01df\u01e0\3\2\2\2\u01e0" + + "\u01e1\3\2\2\2\u01e1\u01e5\7\60\2\2\u01e2\u01e4\t\5\2\2\u01e3\u01e2\3" + + "\2\2\2\u01e4\u01e7\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6" + + "~\3\2\2\2\u01e7\u01e5\3\2\2\2\u01e8\u01ec\t\6\2\2\u01e9\u01eb\t\5\2\2" + + "\u01ea\u01e9\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed" + + "\3\2\2\2\u01ed\u0080\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7\62\2\2" + + "\u01f0\u0082\3\2\2\2\u01f1\u01f7\7)\2\2\u01f2\u01f6\n\7\2\2\u01f3\u01f4" + + "\7)\2\2\u01f4\u01f6\7)\2\2\u01f5\u01f2\3\2\2\2\u01f5\u01f3\3\2\2\2\u01f6" + + "\u01f9\3\2\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fa\3\2" + + "\2\2\u01f9\u01f7\3\2\2\2\u01fa\u01fb\7)\2\2\u01fb\u0084\3\2\2\2\u01fc" + + "\u01fd\t\b\2\2\u01fd\u01fe\3\2\2\2\u01fe\u01ff\bC\2\2\u01ff\u0086\3\2" + + "\2\2\16\2\u01bc\u01c3\u01cf\u01d2\u01d6\u01da\u01df\u01e5\u01ec\u01f5" + + "\u01f7\3\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java index 8a340bf8a..3a6e3d4ec 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLListener.java @@ -1,5 +1,6 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; + import org.antlr.v4.runtime.tree.ParseTreeListener; /** @@ -7,404 +8,563 @@ import org.antlr.v4.runtime.tree.ParseTreeListener; * {@link EQLParser}. */ public interface EQLListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link EQLParser#select_statement}. - * @param ctx the parse tree - */ - void enterSelect_statement(EQLParser.Select_statementContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#select_statement}. - * @param ctx the parse tree - */ - void exitSelect_statement(EQLParser.Select_statementContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#select_clause}. - * @param ctx the parse tree - */ - void enterSelect_clause(EQLParser.Select_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#select_clause}. - * @param ctx the parse tree - */ - void exitSelect_clause(EQLParser.Select_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#distinct}. - * @param ctx the parse tree - */ - void enterDistinct(EQLParser.DistinctContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#distinct}. - * @param ctx the parse tree - */ - void exitDistinct(EQLParser.DistinctContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_clause}. - * @param ctx the parse tree - */ - void enterFetch_clause(EQLParser.Fetch_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_clause}. - * @param ctx the parse tree - */ - void exitFetch_clause(EQLParser.Fetch_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#where_clause}. - * @param ctx the parse tree - */ - void enterWhere_clause(EQLParser.Where_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#where_clause}. - * @param ctx the parse tree - */ - void exitWhere_clause(EQLParser.Where_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#orderby_clause}. - * @param ctx the parse tree - */ - void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#orderby_clause}. - * @param ctx the parse tree - */ - void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#orderby_property}. - * @param ctx the parse tree - */ - void enterOrderby_property(EQLParser.Orderby_propertyContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#orderby_property}. - * @param ctx the parse tree - */ - void exitOrderby_property(EQLParser.Orderby_propertyContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#nulls_firstlast}. - * @param ctx the parse tree - */ - void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#nulls_firstlast}. - * @param ctx the parse tree - */ - void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#asc_desc}. - * @param ctx the parse tree - */ - void enterAsc_desc(EQLParser.Asc_descContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#asc_desc}. - * @param ctx the parse tree - */ - void exitAsc_desc(EQLParser.Asc_descContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#limit_clause}. - * @param ctx the parse tree - */ - void enterLimit_clause(EQLParser.Limit_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#limit_clause}. - * @param ctx the parse tree - */ - void exitLimit_clause(EQLParser.Limit_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#offset_clause}. - * @param ctx the parse tree - */ - void enterOffset_clause(EQLParser.Offset_clauseContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#offset_clause}. - * @param ctx the parse tree - */ - void exitOffset_clause(EQLParser.Offset_clauseContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_path}. - * @param ctx the parse tree - */ - void enterFetch_path(EQLParser.Fetch_pathContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_path}. - * @param ctx the parse tree - */ - void exitFetch_path(EQLParser.Fetch_pathContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property_set}. - * @param ctx the parse tree - */ - void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property_set}. - * @param ctx the parse tree - */ - void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property_group}. - * @param ctx the parse tree - */ - void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property_group}. - * @param ctx the parse tree - */ - void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_property}. - * @param ctx the parse tree - */ - void enterFetch_property(EQLParser.Fetch_propertyContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_property}. - * @param ctx the parse tree - */ - void exitFetch_property(EQLParser.Fetch_propertyContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_query_hint}. - * @param ctx the parse tree - */ - void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_query_hint}. - * @param ctx the parse tree - */ - void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_lazy_hint}. - * @param ctx the parse tree - */ - void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_lazy_hint}. - * @param ctx the parse tree - */ - void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_option}. - * @param ctx the parse tree - */ - void enterFetch_option(EQLParser.Fetch_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_option}. - * @param ctx the parse tree - */ - void exitFetch_option(EQLParser.Fetch_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_query_option}. - * @param ctx the parse tree - */ - void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_query_option}. - * @param ctx the parse tree - */ - void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_lazy_option}. - * @param ctx the parse tree - */ - void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_lazy_option}. - * @param ctx the parse tree - */ - void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#fetch_batch_size}. - * @param ctx the parse tree - */ - void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#fetch_batch_size}. - * @param ctx the parse tree - */ - void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_expression}. - * @param ctx the parse tree - */ - void enterConditional_expression(EQLParser.Conditional_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_expression}. - * @param ctx the parse tree - */ - void exitConditional_expression(EQLParser.Conditional_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_term}. - * @param ctx the parse tree - */ - void enterConditional_term(EQLParser.Conditional_termContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_term}. - * @param ctx the parse tree - */ - void exitConditional_term(EQLParser.Conditional_termContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_factor}. - * @param ctx the parse tree - */ - void enterConditional_factor(EQLParser.Conditional_factorContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_factor}. - * @param ctx the parse tree - */ - void exitConditional_factor(EQLParser.Conditional_factorContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#conditional_primary}. - * @param ctx the parse tree - */ - void enterConditional_primary(EQLParser.Conditional_primaryContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#conditional_primary}. - * @param ctx the parse tree - */ - void exitConditional_primary(EQLParser.Conditional_primaryContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#any_expression}. - * @param ctx the parse tree - */ - void enterAny_expression(EQLParser.Any_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#any_expression}. - * @param ctx the parse tree - */ - void exitAny_expression(EQLParser.Any_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#in_expression}. - * @param ctx the parse tree - */ - void enterIn_expression(EQLParser.In_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#in_expression}. - * @param ctx the parse tree - */ - void exitIn_expression(EQLParser.In_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#in_value}. - * @param ctx the parse tree - */ - void enterIn_value(EQLParser.In_valueContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#in_value}. - * @param ctx the parse tree - */ - void exitIn_value(EQLParser.In_valueContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#between_expression}. - * @param ctx the parse tree - */ - void enterBetween_expression(EQLParser.Between_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#between_expression}. - * @param ctx the parse tree - */ - void exitBetween_expression(EQLParser.Between_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#propertyBetween_expression}. - * @param ctx the parse tree - */ - void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#propertyBetween_expression}. - * @param ctx the parse tree - */ - void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNull_expression}. - * @param ctx the parse tree - */ - void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNull_expression}. - * @param ctx the parse tree - */ - void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNotNull_expression}. - * @param ctx the parse tree - */ - void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNotNull_expression}. - * @param ctx the parse tree - */ - void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isEmpty_expression}. - * @param ctx the parse tree - */ - void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isEmpty_expression}. - * @param ctx the parse tree - */ - void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#isNotEmpty_expression}. - * @param ctx the parse tree - */ - void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#isNotEmpty_expression}. - * @param ctx the parse tree - */ - void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#like_expression}. - * @param ctx the parse tree - */ - void enterLike_expression(EQLParser.Like_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#like_expression}. - * @param ctx the parse tree - */ - void exitLike_expression(EQLParser.Like_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#like_op}. - * @param ctx the parse tree - */ - void enterLike_op(EQLParser.Like_opContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#like_op}. - * @param ctx the parse tree - */ - void exitLike_op(EQLParser.Like_opContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#comparison_expression}. - * @param ctx the parse tree - */ - void enterComparison_expression(EQLParser.Comparison_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#comparison_expression}. - * @param ctx the parse tree - */ - void exitComparison_expression(EQLParser.Comparison_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#comparison_operator}. - * @param ctx the parse tree - */ - void enterComparison_operator(EQLParser.Comparison_operatorContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#comparison_operator}. - * @param ctx the parse tree - */ - void exitComparison_operator(EQLParser.Comparison_operatorContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#value_expression}. - * @param ctx the parse tree - */ - void enterValue_expression(EQLParser.Value_expressionContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#value_expression}. - * @param ctx the parse tree - */ - void exitValue_expression(EQLParser.Value_expressionContext ctx); - /** - * Enter a parse tree produced by {@link EQLParser#literal}. - * @param ctx the parse tree - */ - void enterLiteral(EQLParser.LiteralContext ctx); - /** - * Exit a parse tree produced by {@link EQLParser#literal}. - * @param ctx the parse tree - */ - void exitLiteral(EQLParser.LiteralContext ctx); -} \ No newline at end of file + /** + * Enter a parse tree produced by {@link EQLParser#select_statement}. + * + * @param ctx the parse tree + */ + void enterSelect_statement(EQLParser.Select_statementContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#select_statement}. + * + * @param ctx the parse tree + */ + void exitSelect_statement(EQLParser.Select_statementContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#select_clause}. + * + * @param ctx the parse tree + */ + void enterSelect_clause(EQLParser.Select_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#select_clause}. + * + * @param ctx the parse tree + */ + void exitSelect_clause(EQLParser.Select_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#distinct}. + * + * @param ctx the parse tree + */ + void enterDistinct(EQLParser.DistinctContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#distinct}. + * + * @param ctx the parse tree + */ + void exitDistinct(EQLParser.DistinctContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_clause}. + * + * @param ctx the parse tree + */ + void enterFetch_clause(EQLParser.Fetch_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_clause}. + * + * @param ctx the parse tree + */ + void exitFetch_clause(EQLParser.Fetch_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#where_clause}. + * + * @param ctx the parse tree + */ + void enterWhere_clause(EQLParser.Where_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#where_clause}. + * + * @param ctx the parse tree + */ + void exitWhere_clause(EQLParser.Where_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#orderby_clause}. + * + * @param ctx the parse tree + */ + void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#orderby_clause}. + * + * @param ctx the parse tree + */ + void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#orderby_property}. + * + * @param ctx the parse tree + */ + void enterOrderby_property(EQLParser.Orderby_propertyContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#orderby_property}. + * + * @param ctx the parse tree + */ + void exitOrderby_property(EQLParser.Orderby_propertyContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#nulls_firstlast}. + * + * @param ctx the parse tree + */ + void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#nulls_firstlast}. + * + * @param ctx the parse tree + */ + void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#asc_desc}. + * + * @param ctx the parse tree + */ + void enterAsc_desc(EQLParser.Asc_descContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#asc_desc}. + * + * @param ctx the parse tree + */ + void exitAsc_desc(EQLParser.Asc_descContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#limit_clause}. + * + * @param ctx the parse tree + */ + void enterLimit_clause(EQLParser.Limit_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#limit_clause}. + * + * @param ctx the parse tree + */ + void exitLimit_clause(EQLParser.Limit_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#offset_clause}. + * + * @param ctx the parse tree + */ + void enterOffset_clause(EQLParser.Offset_clauseContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#offset_clause}. + * + * @param ctx the parse tree + */ + void exitOffset_clause(EQLParser.Offset_clauseContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_path}. + * + * @param ctx the parse tree + */ + void enterFetch_path(EQLParser.Fetch_pathContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_path}. + * + * @param ctx the parse tree + */ + void exitFetch_path(EQLParser.Fetch_pathContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property_set}. + * + * @param ctx the parse tree + */ + void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property_set}. + * + * @param ctx the parse tree + */ + void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property_group}. + * + * @param ctx the parse tree + */ + void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property_group}. + * + * @param ctx the parse tree + */ + void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_property}. + * + * @param ctx the parse tree + */ + void enterFetch_property(EQLParser.Fetch_propertyContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_property}. + * + * @param ctx the parse tree + */ + void exitFetch_property(EQLParser.Fetch_propertyContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_query_hint}. + * + * @param ctx the parse tree + */ + void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_query_hint}. + * + * @param ctx the parse tree + */ + void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_lazy_hint}. + * + * @param ctx the parse tree + */ + void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_lazy_hint}. + * + * @param ctx the parse tree + */ + void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_option}. + * + * @param ctx the parse tree + */ + void enterFetch_option(EQLParser.Fetch_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_option}. + * + * @param ctx the parse tree + */ + void exitFetch_option(EQLParser.Fetch_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_query_option}. + * + * @param ctx the parse tree + */ + void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_query_option}. + * + * @param ctx the parse tree + */ + void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_lazy_option}. + * + * @param ctx the parse tree + */ + void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_lazy_option}. + * + * @param ctx the parse tree + */ + void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#fetch_batch_size}. + * + * @param ctx the parse tree + */ + void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#fetch_batch_size}. + * + * @param ctx the parse tree + */ + void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_expression}. + * + * @param ctx the parse tree + */ + void enterConditional_expression(EQLParser.Conditional_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_expression}. + * + * @param ctx the parse tree + */ + void exitConditional_expression(EQLParser.Conditional_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_term}. + * + * @param ctx the parse tree + */ + void enterConditional_term(EQLParser.Conditional_termContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_term}. + * + * @param ctx the parse tree + */ + void exitConditional_term(EQLParser.Conditional_termContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_factor}. + * + * @param ctx the parse tree + */ + void enterConditional_factor(EQLParser.Conditional_factorContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_factor}. + * + * @param ctx the parse tree + */ + void exitConditional_factor(EQLParser.Conditional_factorContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#conditional_primary}. + * + * @param ctx the parse tree + */ + void enterConditional_primary(EQLParser.Conditional_primaryContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#conditional_primary}. + * + * @param ctx the parse tree + */ + void exitConditional_primary(EQLParser.Conditional_primaryContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#any_expression}. + * + * @param ctx the parse tree + */ + void enterAny_expression(EQLParser.Any_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#any_expression}. + * + * @param ctx the parse tree + */ + void exitAny_expression(EQLParser.Any_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#in_expression}. + * + * @param ctx the parse tree + */ + void enterIn_expression(EQLParser.In_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#in_expression}. + * + * @param ctx the parse tree + */ + void exitIn_expression(EQLParser.In_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#in_value}. + * + * @param ctx the parse tree + */ + void enterIn_value(EQLParser.In_valueContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#in_value}. + * + * @param ctx the parse tree + */ + void exitIn_value(EQLParser.In_valueContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#between_expression}. + * + * @param ctx the parse tree + */ + void enterBetween_expression(EQLParser.Between_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#between_expression}. + * + * @param ctx the parse tree + */ + void exitBetween_expression(EQLParser.Between_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#propertyBetween_expression}. + * + * @param ctx the parse tree + */ + void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#propertyBetween_expression}. + * + * @param ctx the parse tree + */ + void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNull_expression}. + * + * @param ctx the parse tree + */ + void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNull_expression}. + * + * @param ctx the parse tree + */ + void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNotNull_expression}. + * + * @param ctx the parse tree + */ + void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNotNull_expression}. + * + * @param ctx the parse tree + */ + void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isEmpty_expression}. + * + * @param ctx the parse tree + */ + void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isEmpty_expression}. + * + * @param ctx the parse tree + */ + void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#isNotEmpty_expression}. + * + * @param ctx the parse tree + */ + void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#isNotEmpty_expression}. + * + * @param ctx the parse tree + */ + void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#like_expression}. + * + * @param ctx the parse tree + */ + void enterLike_expression(EQLParser.Like_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#like_expression}. + * + * @param ctx the parse tree + */ + void exitLike_expression(EQLParser.Like_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#like_op}. + * + * @param ctx the parse tree + */ + void enterLike_op(EQLParser.Like_opContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#like_op}. + * + * @param ctx the parse tree + */ + void exitLike_op(EQLParser.Like_opContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#comparison_expression}. + * + * @param ctx the parse tree + */ + void enterComparison_expression(EQLParser.Comparison_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#comparison_expression}. + * + * @param ctx the parse tree + */ + void exitComparison_expression(EQLParser.Comparison_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#comparison_operator}. + * + * @param ctx the parse tree + */ + void enterComparison_operator(EQLParser.Comparison_operatorContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#comparison_operator}. + * + * @param ctx the parse tree + */ + void exitComparison_operator(EQLParser.Comparison_operatorContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#value_expression}. + * + * @param ctx the parse tree + */ + void enterValue_expression(EQLParser.Value_expressionContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#value_expression}. + * + * @param ctx the parse tree + */ + void exitValue_expression(EQLParser.Value_expressionContext ctx); + + /** + * Enter a parse tree produced by {@link EQLParser#literal}. + * + * @param ctx the parse tree + */ + void enterLiteral(EQLParser.LiteralContext ctx); + + /** + * Exit a parse tree produced by {@link EQLParser#literal}. + * + * @param ctx the parse tree + */ + void exitLiteral(EQLParser.LiteralContext ctx); +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java index a2f63fc6f..3bf7eb517 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java +++ b/src/main/java/com/avaje/ebeaninternal/server/grammer/antlr/EQLParser.java @@ -1,124 +1,145 @@ // Generated from /home/rob/github/ebean/src/test/resources/EQL.g4 by ANTLR 4.5.3 package com.avaje.ebeaninternal.server.grammer.antlr; -import org.antlr.v4.runtime.atn.*; + +import org.antlr.v4.runtime.NoViableAltException; +import org.antlr.v4.runtime.Parser; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.RuntimeMetaData; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.Vocabulary; +import org.antlr.v4.runtime.VocabularyImpl; +import org.antlr.v4.runtime.atn.ATN; +import org.antlr.v4.runtime.atn.ATNDeserializer; +import org.antlr.v4.runtime.atn.ParserATNSimulator; +import org.antlr.v4.runtime.atn.PredictionContextCache; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.misc.*; -import org.antlr.v4.runtime.tree.*; +import org.antlr.v4.runtime.tree.ParseTreeListener; +import org.antlr.v4.runtime.tree.TerminalNode; + import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class EQLParser extends Parser { - static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); } + static { + RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); + } - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, - T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, - T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, - T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, - T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, INPUT_VARIABLE=58, PATH_VARIABLE=59, - BOOLEAN_LITERAL=60, NUMBER_LITERAL=61, DOUBLE=62, INT=63, ZERO=64, STRING_LITERAL=65, - WS=66; - public static final int - RULE_select_statement = 0, RULE_select_clause = 1, RULE_distinct = 2, - RULE_fetch_clause = 3, RULE_where_clause = 4, RULE_orderby_clause = 5, - RULE_orderby_property = 6, RULE_nulls_firstlast = 7, RULE_asc_desc = 8, - RULE_limit_clause = 9, RULE_offset_clause = 10, RULE_fetch_path = 11, - RULE_fetch_property_set = 12, RULE_fetch_property_group = 13, RULE_fetch_property = 14, - RULE_fetch_query_hint = 15, RULE_fetch_lazy_hint = 16, RULE_fetch_option = 17, - RULE_fetch_query_option = 18, RULE_fetch_lazy_option = 19, RULE_fetch_batch_size = 20, - RULE_conditional_expression = 21, RULE_conditional_term = 22, RULE_conditional_factor = 23, - RULE_conditional_primary = 24, RULE_any_expression = 25, RULE_in_expression = 26, - RULE_in_value = 27, RULE_between_expression = 28, RULE_propertyBetween_expression = 29, - RULE_isNull_expression = 30, RULE_isNotNull_expression = 31, RULE_isEmpty_expression = 32, - RULE_isNotEmpty_expression = 33, RULE_like_expression = 34, RULE_like_op = 35, - RULE_comparison_expression = 36, RULE_comparison_operator = 37, RULE_value_expression = 38, - RULE_literal = 39; - public static final String[] ruleNames = { - "select_statement", "select_clause", "distinct", "fetch_clause", "where_clause", - "orderby_clause", "orderby_property", "nulls_firstlast", "asc_desc", "limit_clause", - "offset_clause", "fetch_path", "fetch_property_set", "fetch_property_group", - "fetch_property", "fetch_query_hint", "fetch_lazy_hint", "fetch_option", - "fetch_query_option", "fetch_lazy_option", "fetch_batch_size", "conditional_expression", - "conditional_term", "conditional_factor", "conditional_primary", "any_expression", - "in_expression", "in_value", "between_expression", "propertyBetween_expression", - "isNull_expression", "isNotNull_expression", "isEmpty_expression", "isNotEmpty_expression", - "like_expression", "like_op", "comparison_expression", "comparison_operator", - "value_expression", "literal" - }; + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, + T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, + T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, + T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, + T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, T__36 = 37, T__37 = 38, + T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, + T__45 = 46, T__46 = 47, T__47 = 48, T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, + T__52 = 53, T__53 = 54, T__54 = 55, T__55 = 56, T__56 = 57, INPUT_VARIABLE = 58, PATH_VARIABLE = 59, + BOOLEAN_LITERAL = 60, NUMBER_LITERAL = 61, DOUBLE = 62, INT = 63, ZERO = 64, STRING_LITERAL = 65, + WS = 66; + public static final int + RULE_select_statement = 0, RULE_select_clause = 1, RULE_distinct = 2, + RULE_fetch_clause = 3, RULE_where_clause = 4, RULE_orderby_clause = 5, + RULE_orderby_property = 6, RULE_nulls_firstlast = 7, RULE_asc_desc = 8, + RULE_limit_clause = 9, RULE_offset_clause = 10, RULE_fetch_path = 11, + RULE_fetch_property_set = 12, RULE_fetch_property_group = 13, RULE_fetch_property = 14, + RULE_fetch_query_hint = 15, RULE_fetch_lazy_hint = 16, RULE_fetch_option = 17, + RULE_fetch_query_option = 18, RULE_fetch_lazy_option = 19, RULE_fetch_batch_size = 20, + RULE_conditional_expression = 21, RULE_conditional_term = 22, RULE_conditional_factor = 23, + RULE_conditional_primary = 24, RULE_any_expression = 25, RULE_in_expression = 26, + RULE_in_value = 27, RULE_between_expression = 28, RULE_propertyBetween_expression = 29, + RULE_isNull_expression = 30, RULE_isNotNull_expression = 31, RULE_isEmpty_expression = 32, + RULE_isNotEmpty_expression = 33, RULE_like_expression = 34, RULE_like_op = 35, + RULE_comparison_expression = 36, RULE_comparison_operator = 37, RULE_value_expression = 38, + RULE_literal = 39; + public static final String[] ruleNames = { + "select_statement", "select_clause", "distinct", "fetch_clause", "where_clause", + "orderby_clause", "orderby_property", "nulls_firstlast", "asc_desc", "limit_clause", + "offset_clause", "fetch_path", "fetch_property_set", "fetch_property_group", + "fetch_property", "fetch_query_hint", "fetch_lazy_hint", "fetch_option", + "fetch_query_option", "fetch_lazy_option", "fetch_batch_size", "conditional_expression", + "conditional_term", "conditional_factor", "conditional_primary", "any_expression", + "in_expression", "in_value", "between_expression", "propertyBetween_expression", + "isNull_expression", "isNotNull_expression", "isEmpty_expression", "isNotEmpty_expression", + "like_expression", "like_op", "comparison_expression", "comparison_operator", + "value_expression", "literal" + }; - private static final String[] _LITERAL_NAMES = { - null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", - "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", - "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", - "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", - "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", - "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", - "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", - "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", - null, null, null, null, null, null, "'0'" - }; - private static final String[] _SYMBOLIC_NAMES = { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", - "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", - "ZERO", "STRING_LITERAL", "WS" - }; - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + private static final String[] _LITERAL_NAMES = { + null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'", + "','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'", + "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'", + "'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'", + "'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'", + "'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'", + "'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'", + "'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'", + null, null, null, null, null, null, "'0'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE", + "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT", + "ZERO", "STRING_LITERAL", "WS" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } - @Override + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } - public Vocabulary getVocabulary() { - return VOCABULARY; - } + @Override - @Override - public String getGrammarFileName() { return "EQL.g4"; } + public Vocabulary getVocabulary() { + return VOCABULARY; + } - @Override - public String[] getRuleNames() { return ruleNames; } + @Override + public String getGrammarFileName() { + return "EQL.g4"; + } - @Override - public String getSerializedATN() { return _serializedATN; } + @Override + public String[] getRuleNames() { + return ruleNames; + } - @Override - public ATN getATN() { return _ATN; } + @Override + public String getSerializedATN() { + return _serializedATN; + } + + @Override + public ATN getATN() { + return _ATN; + } // @Override @@ -126,2354 +147,2633 @@ public class EQLParser extends Parser { // throw new RuntimeException("Error in grammer - " + e.getMessage()); // } - public EQLParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - public static class Select_statementContext extends ParserRuleContext { - public Select_clauseContext select_clause() { - return getRuleContext(Select_clauseContext.class,0); - } - public List fetch_clause() { - return getRuleContexts(Fetch_clauseContext.class); - } - public Fetch_clauseContext fetch_clause(int i) { - return getRuleContext(Fetch_clauseContext.class,i); - } - public Where_clauseContext where_clause() { - return getRuleContext(Where_clauseContext.class,0); - } - public Orderby_clauseContext orderby_clause() { - return getRuleContext(Orderby_clauseContext.class,0); - } - public Limit_clauseContext limit_clause() { - return getRuleContext(Limit_clauseContext.class,0); - } - public Select_statementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_select_statement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterSelect_statement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitSelect_statement(this); - } - } - - public final Select_statementContext select_statement() throws RecognitionException { - Select_statementContext _localctx = new Select_statementContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_select_statement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(81); - _la = _input.LA(1); - if (_la==T__0) { - { - setState(80); - select_clause(); - } - } - - setState(86); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__15) { - { - { - setState(83); - fetch_clause(); - } - } - setState(88); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(90); - _la = _input.LA(1); - if (_la==T__4) { - { - setState(89); - where_clause(); - } - } - - setState(93); - _la = _input.LA(1); - if (_la==T__5) { - { - setState(92); - orderby_clause(); - } - } - - setState(96); - _la = _input.LA(1); - if (_la==T__13) { - { - setState(95); - limit_clause(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Select_clauseContext extends ParserRuleContext { - public Fetch_property_groupContext fetch_property_group() { - return getRuleContext(Fetch_property_groupContext.class,0); - } - public DistinctContext distinct() { - return getRuleContext(DistinctContext.class,0); - } - public Select_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_select_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterSelect_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitSelect_clause(this); - } - } - - public final Select_clauseContext select_clause() throws RecognitionException { - Select_clauseContext _localctx = new Select_clauseContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_select_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(98); - match(T__0); - setState(100); - _la = _input.LA(1); - if (_la==T__3) { - { - setState(99); - distinct(); - } - } - - setState(102); - match(T__1); - setState(103); - fetch_property_group(); - setState(104); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class DistinctContext extends ParserRuleContext { - public DistinctContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_distinct; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterDistinct(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitDistinct(this); - } - } - - public final DistinctContext distinct() throws RecognitionException { - DistinctContext _localctx = new DistinctContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_distinct); - try { - enterOuterAlt(_localctx, 1); - { - setState(106); - match(T__3); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_clauseContext extends ParserRuleContext { - public Fetch_pathContext fetch_path() { - return getRuleContext(Fetch_pathContext.class,0); - } - public Fetch_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_clause(this); - } - } - - public final Fetch_clauseContext fetch_clause() throws RecognitionException { - Fetch_clauseContext _localctx = new Fetch_clauseContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_fetch_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(108); - fetch_path(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Where_clauseContext extends ParserRuleContext { - public Conditional_expressionContext conditional_expression() { - return getRuleContext(Conditional_expressionContext.class,0); - } - public Where_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_where_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterWhere_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitWhere_clause(this); - } - } - - public final Where_clauseContext where_clause() throws RecognitionException { - Where_clauseContext _localctx = new Where_clauseContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_where_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(110); - match(T__4); - setState(111); - conditional_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Orderby_clauseContext extends ParserRuleContext { - public List orderby_property() { - return getRuleContexts(Orderby_propertyContext.class); - } - public Orderby_propertyContext orderby_property(int i) { - return getRuleContext(Orderby_propertyContext.class,i); - } - public Orderby_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_orderby_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOrderby_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOrderby_clause(this); - } - } - - public final Orderby_clauseContext orderby_clause() throws RecognitionException { - Orderby_clauseContext _localctx = new Orderby_clauseContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_orderby_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(113); - match(T__5); - setState(114); - match(T__6); - setState(115); - orderby_property(); - setState(120); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(116); - match(T__7); - setState(117); - orderby_property(); - } - } - setState(122); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Orderby_propertyContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Asc_descContext asc_desc() { - return getRuleContext(Asc_descContext.class,0); - } - public Nulls_firstlastContext nulls_firstlast() { - return getRuleContext(Nulls_firstlastContext.class,0); - } - public Orderby_propertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_orderby_property; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOrderby_property(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOrderby_property(this); - } - } - - public final Orderby_propertyContext orderby_property() throws RecognitionException { - Orderby_propertyContext _localctx = new Orderby_propertyContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_orderby_property); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(123); - match(PATH_VARIABLE); - setState(125); - _la = _input.LA(1); - if (_la==T__11 || _la==T__12) { - { - setState(124); - asc_desc(); - } - } - - setState(128); - _la = _input.LA(1); - if (_la==T__8) { - { - setState(127); - nulls_firstlast(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Nulls_firstlastContext extends ParserRuleContext { - public Nulls_firstlastContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nulls_firstlast; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterNulls_firstlast(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitNulls_firstlast(this); - } - } - - public final Nulls_firstlastContext nulls_firstlast() throws RecognitionException { - Nulls_firstlastContext _localctx = new Nulls_firstlastContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_nulls_firstlast); - try { - setState(134); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(130); - match(T__8); - setState(131); - match(T__9); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(132); - match(T__8); - setState(133); - match(T__10); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Asc_descContext extends ParserRuleContext { - public Asc_descContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_asc_desc; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterAsc_desc(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitAsc_desc(this); - } - } - - public final Asc_descContext asc_desc() throws RecognitionException { - Asc_descContext _localctx = new Asc_descContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_asc_desc); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(136); - _la = _input.LA(1); - if ( !(_la==T__11 || _la==T__12) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Limit_clauseContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Offset_clauseContext offset_clause() { - return getRuleContext(Offset_clauseContext.class,0); - } - public Limit_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_limit_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLimit_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLimit_clause(this); - } - } - - public final Limit_clauseContext limit_clause() throws RecognitionException { - Limit_clauseContext _localctx = new Limit_clauseContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_limit_clause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(138); - match(T__13); - setState(139); - match(NUMBER_LITERAL); - setState(141); - _la = _input.LA(1); - if (_la==T__14) { - { - setState(140); - offset_clause(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Offset_clauseContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Offset_clauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_offset_clause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterOffset_clause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitOffset_clause(this); - } - } - - public final Offset_clauseContext offset_clause() throws RecognitionException { - Offset_clauseContext _localctx = new Offset_clauseContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_offset_clause); - try { - enterOuterAlt(_localctx, 1); - { - setState(143); - match(T__14); - setState(144); - match(NUMBER_LITERAL); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_pathContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Fetch_optionContext fetch_option() { - return getRuleContext(Fetch_optionContext.class,0); - } - public Fetch_property_setContext fetch_property_set() { - return getRuleContext(Fetch_property_setContext.class,0); - } - public Fetch_pathContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_path; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_path(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_path(this); - } - } - - public final Fetch_pathContext fetch_path() throws RecognitionException { - Fetch_pathContext _localctx = new Fetch_pathContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_fetch_path); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(146); - match(T__15); - setState(148); - _la = _input.LA(1); - if (_la==T__17 || _la==T__18) { - { - setState(147); - fetch_option(); - } - } - - setState(150); - match(PATH_VARIABLE); - setState(152); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(151); - fetch_property_set(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_property_setContext extends ParserRuleContext { - public Fetch_property_groupContext fetch_property_group() { - return getRuleContext(Fetch_property_groupContext.class,0); - } - public Fetch_property_setContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property_set; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property_set(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property_set(this); - } - } - - public final Fetch_property_setContext fetch_property_set() throws RecognitionException { - Fetch_property_setContext _localctx = new Fetch_property_setContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_fetch_property_set); - try { - enterOuterAlt(_localctx, 1); - { - setState(154); - match(T__1); - setState(155); - fetch_property_group(); - setState(156); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_property_groupContext extends ParserRuleContext { - public List fetch_property() { - return getRuleContexts(Fetch_propertyContext.class); - } - public Fetch_propertyContext fetch_property(int i) { - return getRuleContext(Fetch_propertyContext.class,i); - } - public Fetch_property_groupContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property_group; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property_group(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property_group(this); - } - } - - public final Fetch_property_groupContext fetch_property_group() throws RecognitionException { - Fetch_property_groupContext _localctx = new Fetch_property_groupContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_fetch_property_group); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(158); - fetch_property(); - setState(163); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(159); - match(T__7); - setState(160); - fetch_property(); - } - } - setState(165); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_propertyContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Fetch_query_hintContext fetch_query_hint() { - return getRuleContext(Fetch_query_hintContext.class,0); - } - public Fetch_lazy_hintContext fetch_lazy_hint() { - return getRuleContext(Fetch_lazy_hintContext.class,0); - } - public Fetch_propertyContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_property; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_property(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_property(this); - } - } - - public final Fetch_propertyContext fetch_property() throws RecognitionException { - Fetch_propertyContext _localctx = new Fetch_propertyContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_fetch_property); - try { - setState(169); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(166); - match(PATH_VARIABLE); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(167); - fetch_query_hint(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(168); - fetch_lazy_hint(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_query_hintContext extends ParserRuleContext { - public Fetch_query_optionContext fetch_query_option() { - return getRuleContext(Fetch_query_optionContext.class,0); - } - public Fetch_query_hintContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_query_hint; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_query_hint(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_query_hint(this); - } - } - - public final Fetch_query_hintContext fetch_query_hint() throws RecognitionException { - Fetch_query_hintContext _localctx = new Fetch_query_hintContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_fetch_query_hint); - try { - enterOuterAlt(_localctx, 1); - { - setState(171); - match(T__16); - setState(172); - fetch_query_option(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_lazy_hintContext extends ParserRuleContext { - public Fetch_lazy_optionContext fetch_lazy_option() { - return getRuleContext(Fetch_lazy_optionContext.class,0); - } - public Fetch_lazy_hintContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_lazy_hint; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_lazy_hint(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_lazy_hint(this); - } - } - - public final Fetch_lazy_hintContext fetch_lazy_hint() throws RecognitionException { - Fetch_lazy_hintContext _localctx = new Fetch_lazy_hintContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_fetch_lazy_hint); - try { - enterOuterAlt(_localctx, 1); - { - setState(174); - match(T__16); - setState(175); - fetch_lazy_option(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_optionContext extends ParserRuleContext { - public Fetch_query_optionContext fetch_query_option() { - return getRuleContext(Fetch_query_optionContext.class,0); - } - public Fetch_lazy_optionContext fetch_lazy_option() { - return getRuleContext(Fetch_lazy_optionContext.class,0); - } - public Fetch_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_option(this); - } - } - - public final Fetch_optionContext fetch_option() throws RecognitionException { - Fetch_optionContext _localctx = new Fetch_optionContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_fetch_option); - try { - setState(179); - switch (_input.LA(1)) { - case T__17: - enterOuterAlt(_localctx, 1); - { - setState(177); - fetch_query_option(); - } - break; - case T__18: - enterOuterAlt(_localctx, 2); - { - setState(178); - fetch_lazy_option(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_query_optionContext extends ParserRuleContext { - public Fetch_batch_sizeContext fetch_batch_size() { - return getRuleContext(Fetch_batch_sizeContext.class,0); - } - public Fetch_query_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_query_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_query_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_query_option(this); - } - } - - public final Fetch_query_optionContext fetch_query_option() throws RecognitionException { - Fetch_query_optionContext _localctx = new Fetch_query_optionContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_fetch_query_option); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(181); - match(T__17); - setState(183); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(182); - fetch_batch_size(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_lazy_optionContext extends ParserRuleContext { - public Fetch_batch_sizeContext fetch_batch_size() { - return getRuleContext(Fetch_batch_sizeContext.class,0); - } - public Fetch_lazy_optionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_lazy_option; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_lazy_option(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_lazy_option(this); - } - } - - public final Fetch_lazy_optionContext fetch_lazy_option() throws RecognitionException { - Fetch_lazy_optionContext _localctx = new Fetch_lazy_optionContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_fetch_lazy_option); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(185); - match(T__18); - setState(187); - _la = _input.LA(1); - if (_la==T__1) { - { - setState(186); - fetch_batch_size(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Fetch_batch_sizeContext extends ParserRuleContext { - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public Fetch_batch_sizeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fetch_batch_size; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterFetch_batch_size(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitFetch_batch_size(this); - } - } - - public final Fetch_batch_sizeContext fetch_batch_size() throws RecognitionException { - Fetch_batch_sizeContext _localctx = new Fetch_batch_sizeContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_fetch_batch_size); - try { - enterOuterAlt(_localctx, 1); - { - setState(189); - match(T__1); - setState(190); - match(NUMBER_LITERAL); - setState(191); - match(T__2); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_expressionContext extends ParserRuleContext { - public List conditional_term() { - return getRuleContexts(Conditional_termContext.class); - } - public Conditional_termContext conditional_term(int i) { - return getRuleContext(Conditional_termContext.class,i); - } - public Conditional_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_expression(this); - } - } - - public final Conditional_expressionContext conditional_expression() throws RecognitionException { - Conditional_expressionContext _localctx = new Conditional_expressionContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_conditional_expression); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(193); - conditional_term(); - setState(198); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__19) { - { - { - setState(194); - match(T__19); - setState(195); - conditional_term(); - } - } - setState(200); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_termContext extends ParserRuleContext { - public List conditional_factor() { - return getRuleContexts(Conditional_factorContext.class); - } - public Conditional_factorContext conditional_factor(int i) { - return getRuleContext(Conditional_factorContext.class,i); - } - public Conditional_termContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_term; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_term(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_term(this); - } - } - - public final Conditional_termContext conditional_term() throws RecognitionException { - Conditional_termContext _localctx = new Conditional_termContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_conditional_term); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(201); - conditional_factor(); - setState(206); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__20) { - { - { - setState(202); - match(T__20); - setState(203); - conditional_factor(); - } - } - setState(208); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_factorContext extends ParserRuleContext { - public Conditional_primaryContext conditional_primary() { - return getRuleContext(Conditional_primaryContext.class,0); - } - public Conditional_factorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_factor; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_factor(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_factor(this); - } - } - - public final Conditional_factorContext conditional_factor() throws RecognitionException { - Conditional_factorContext _localctx = new Conditional_factorContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_conditional_factor); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(210); - _la = _input.LA(1); - if (_la==T__21) { - { - setState(209); - match(T__21); - } - } - - setState(212); - conditional_primary(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Conditional_primaryContext extends ParserRuleContext { - public Any_expressionContext any_expression() { - return getRuleContext(Any_expressionContext.class,0); - } - public Conditional_expressionContext conditional_expression() { - return getRuleContext(Conditional_expressionContext.class,0); - } - public Conditional_primaryContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_conditional_primary; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterConditional_primary(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitConditional_primary(this); - } - } - - public final Conditional_primaryContext conditional_primary() throws RecognitionException { - Conditional_primaryContext _localctx = new Conditional_primaryContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_conditional_primary); - try { - setState(219); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(214); - any_expression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(215); - match(T__1); - setState(216); - conditional_expression(); - setState(217); - match(T__2); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Any_expressionContext extends ParserRuleContext { - public Comparison_expressionContext comparison_expression() { - return getRuleContext(Comparison_expressionContext.class,0); - } - public Like_expressionContext like_expression() { - return getRuleContext(Like_expressionContext.class,0); - } - public Between_expressionContext between_expression() { - return getRuleContext(Between_expressionContext.class,0); - } - public PropertyBetween_expressionContext propertyBetween_expression() { - return getRuleContext(PropertyBetween_expressionContext.class,0); - } - public In_expressionContext in_expression() { - return getRuleContext(In_expressionContext.class,0); - } - public IsNull_expressionContext isNull_expression() { - return getRuleContext(IsNull_expressionContext.class,0); - } - public IsNotNull_expressionContext isNotNull_expression() { - return getRuleContext(IsNotNull_expressionContext.class,0); - } - public IsEmpty_expressionContext isEmpty_expression() { - return getRuleContext(IsEmpty_expressionContext.class,0); - } - public IsNotEmpty_expressionContext isNotEmpty_expression() { - return getRuleContext(IsNotEmpty_expressionContext.class,0); - } - public Any_expressionContext any_expression() { - return getRuleContext(Any_expressionContext.class,0); - } - public Any_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_any_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterAny_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitAny_expression(this); - } - } - - public final Any_expressionContext any_expression() throws RecognitionException { - Any_expressionContext _localctx = new Any_expressionContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_any_expression); - try { - setState(234); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(221); - comparison_expression(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(222); - like_expression(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(223); - between_expression(); - } - break; - case 4: - enterOuterAlt(_localctx, 4); - { - setState(224); - propertyBetween_expression(); - } - break; - case 5: - enterOuterAlt(_localctx, 5); - { - setState(225); - in_expression(); - } - break; - case 6: - enterOuterAlt(_localctx, 6); - { - setState(226); - isNull_expression(); - } - break; - case 7: - enterOuterAlt(_localctx, 7); - { - setState(227); - isNotNull_expression(); - } - break; - case 8: - enterOuterAlt(_localctx, 8); - { - setState(228); - isEmpty_expression(); - } - break; - case 9: - enterOuterAlt(_localctx, 9); - { - setState(229); - isNotEmpty_expression(); - } - break; - case 10: - enterOuterAlt(_localctx, 10); - { - setState(230); - match(T__1); - setState(231); - any_expression(); - setState(232); - match(T__2); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class In_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public In_valueContext in_value() { - return getRuleContext(In_valueContext.class,0); - } - public In_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_in_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIn_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIn_expression(this); - } - } - - public final In_expressionContext in_expression() throws RecognitionException { - In_expressionContext _localctx = new In_expressionContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_in_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(236); - match(PATH_VARIABLE); - setState(237); - match(T__22); - setState(238); - in_value(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class In_valueContext extends ParserRuleContext { - public TerminalNode INPUT_VARIABLE() { return getToken(EQLParser.INPUT_VARIABLE, 0); } - public List value_expression() { - return getRuleContexts(Value_expressionContext.class); - } - public Value_expressionContext value_expression(int i) { - return getRuleContext(Value_expressionContext.class,i); - } - public In_valueContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_in_value; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIn_value(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIn_value(this); - } - } - - public final In_valueContext in_value() throws RecognitionException { - In_valueContext _localctx = new In_valueContext(_ctx, getState()); - enterRule(_localctx, 54, RULE_in_value); - int _la; - try { - setState(252); - switch (_input.LA(1)) { - case INPUT_VARIABLE: - enterOuterAlt(_localctx, 1); - { - setState(240); - match(INPUT_VARIABLE); - } - break; - case T__1: - enterOuterAlt(_localctx, 2); - { - setState(241); - match(T__1); - setState(242); - value_expression(); - setState(247); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__7) { - { - { - setState(243); - match(T__7); - setState(244); - value_expression(); - } - } - setState(249); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(250); - match(T__2); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Between_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public List value_expression() { - return getRuleContexts(Value_expressionContext.class); - } - public Value_expressionContext value_expression(int i) { - return getRuleContext(Value_expressionContext.class,i); - } - public Between_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_between_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterBetween_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitBetween_expression(this); - } - } - - public final Between_expressionContext between_expression() throws RecognitionException { - Between_expressionContext _localctx = new Between_expressionContext(_ctx, getState()); - enterRule(_localctx, 56, RULE_between_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(254); - match(PATH_VARIABLE); - setState(255); - match(T__23); - setState(256); - value_expression(); - setState(257); - match(T__20); - setState(258); - value_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class PropertyBetween_expressionContext extends ParserRuleContext { - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public List PATH_VARIABLE() { return getTokens(EQLParser.PATH_VARIABLE); } - public TerminalNode PATH_VARIABLE(int i) { - return getToken(EQLParser.PATH_VARIABLE, i); - } - public PropertyBetween_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_propertyBetween_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterPropertyBetween_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitPropertyBetween_expression(this); - } - } - - public final PropertyBetween_expressionContext propertyBetween_expression() throws RecognitionException { - PropertyBetween_expressionContext _localctx = new PropertyBetween_expressionContext(_ctx, getState()); - enterRule(_localctx, 58, RULE_propertyBetween_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(260); - value_expression(); - setState(261); - match(T__23); - setState(262); - match(PATH_VARIABLE); - setState(263); - match(T__20); - setState(264); - match(PATH_VARIABLE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNull_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNull_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNull_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNull_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNull_expression(this); - } - } - - public final IsNull_expressionContext isNull_expression() throws RecognitionException { - IsNull_expressionContext _localctx = new IsNull_expressionContext(_ctx, getState()); - enterRule(_localctx, 60, RULE_isNull_expression); - try { - setState(271); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(266); - match(PATH_VARIABLE); - setState(267); - match(T__24); - setState(268); - match(T__25); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(269); - match(PATH_VARIABLE); - setState(270); - match(T__26); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNotNull_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNotNull_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNotNull_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNotNull_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNotNull_expression(this); - } - } - - public final IsNotNull_expressionContext isNotNull_expression() throws RecognitionException { - IsNotNull_expressionContext _localctx = new IsNotNull_expressionContext(_ctx, getState()); - enterRule(_localctx, 62, RULE_isNotNull_expression); - try { - setState(281); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,26,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(273); - match(PATH_VARIABLE); - setState(274); - match(T__24); - setState(275); - match(T__21); - setState(276); - match(T__25); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(277); - match(PATH_VARIABLE); - setState(278); - match(T__27); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(279); - match(PATH_VARIABLE); - setState(280); - match(T__28); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsEmpty_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsEmpty_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isEmpty_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsEmpty_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsEmpty_expression(this); - } - } - - public final IsEmpty_expressionContext isEmpty_expression() throws RecognitionException { - IsEmpty_expressionContext _localctx = new IsEmpty_expressionContext(_ctx, getState()); - enterRule(_localctx, 64, RULE_isEmpty_expression); - try { - setState(288); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(283); - match(PATH_VARIABLE); - setState(284); - match(T__24); - setState(285); - match(T__29); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(286); - match(PATH_VARIABLE); - setState(287); - match(T__30); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class IsNotEmpty_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public IsNotEmpty_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_isNotEmpty_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterIsNotEmpty_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitIsNotEmpty_expression(this); - } - } - - public final IsNotEmpty_expressionContext isNotEmpty_expression() throws RecognitionException { - IsNotEmpty_expressionContext _localctx = new IsNotEmpty_expressionContext(_ctx, getState()); - enterRule(_localctx, 66, RULE_isNotEmpty_expression); - try { - setState(298); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(290); - match(PATH_VARIABLE); - setState(291); - match(T__24); - setState(292); - match(T__21); - setState(293); - match(T__29); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(294); - match(PATH_VARIABLE); - setState(295); - match(T__31); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(296); - match(PATH_VARIABLE); - setState(297); - match(T__32); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Like_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Like_opContext like_op() { - return getRuleContext(Like_opContext.class,0); - } - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public Like_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_like_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLike_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLike_expression(this); - } - } - - public final Like_expressionContext like_expression() throws RecognitionException { - Like_expressionContext _localctx = new Like_expressionContext(_ctx, getState()); - enterRule(_localctx, 68, RULE_like_expression); - try { - enterOuterAlt(_localctx, 1); - { - setState(300); - match(PATH_VARIABLE); - setState(301); - like_op(); - setState(302); - value_expression(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Like_opContext extends ParserRuleContext { - public Like_opContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_like_op; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLike_op(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLike_op(this); - } - } - - public final Like_opContext like_op() throws RecognitionException { - Like_opContext _localctx = new Like_opContext(_ctx, getState()); - enterRule(_localctx, 70, RULE_like_op); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(304); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Comparison_expressionContext extends ParserRuleContext { - public TerminalNode PATH_VARIABLE() { return getToken(EQLParser.PATH_VARIABLE, 0); } - public Comparison_operatorContext comparison_operator() { - return getRuleContext(Comparison_operatorContext.class,0); - } - public Value_expressionContext value_expression() { - return getRuleContext(Value_expressionContext.class,0); - } - public Comparison_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_comparison_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterComparison_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitComparison_expression(this); - } - } - - public final Comparison_expressionContext comparison_expression() throws RecognitionException { - Comparison_expressionContext _localctx = new Comparison_expressionContext(_ctx, getState()); - enterRule(_localctx, 72, RULE_comparison_expression); - try { - setState(314); - switch (_input.LA(1)) { - case PATH_VARIABLE: - enterOuterAlt(_localctx, 1); - { - setState(306); - match(PATH_VARIABLE); - setState(307); - comparison_operator(); - setState(308); - value_expression(); - } - break; - case INPUT_VARIABLE: - case BOOLEAN_LITERAL: - case NUMBER_LITERAL: - case STRING_LITERAL: - enterOuterAlt(_localctx, 2); - { - setState(310); - value_expression(); - setState(311); - comparison_operator(); - setState(312); - match(PATH_VARIABLE); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Comparison_operatorContext extends ParserRuleContext { - public Comparison_operatorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_comparison_operator; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterComparison_operator(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitComparison_operator(this); - } - } - - public final Comparison_operatorContext comparison_operator() throws RecognitionException { - Comparison_operatorContext _localctx = new Comparison_operatorContext(_ctx, getState()); - enterRule(_localctx, 74, RULE_comparison_operator); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(316); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Value_expressionContext extends ParserRuleContext { - public LiteralContext literal() { - return getRuleContext(LiteralContext.class,0); - } - public TerminalNode INPUT_VARIABLE() { return getToken(EQLParser.INPUT_VARIABLE, 0); } - public Value_expressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_value_expression; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterValue_expression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitValue_expression(this); - } - } - - public final Value_expressionContext value_expression() throws RecognitionException { - Value_expressionContext _localctx = new Value_expressionContext(_ctx, getState()); - enterRule(_localctx, 76, RULE_value_expression); - try { - setState(320); - switch (_input.LA(1)) { - case BOOLEAN_LITERAL: - case NUMBER_LITERAL: - case STRING_LITERAL: - enterOuterAlt(_localctx, 1); - { - setState(318); - literal(); - } - break; - case INPUT_VARIABLE: - enterOuterAlt(_localctx, 2); - { - setState(319); - match(INPUT_VARIABLE); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class LiteralContext extends ParserRuleContext { - public TerminalNode STRING_LITERAL() { return getToken(EQLParser.STRING_LITERAL, 0); } - public TerminalNode BOOLEAN_LITERAL() { return getToken(EQLParser.BOOLEAN_LITERAL, 0); } - public TerminalNode NUMBER_LITERAL() { return getToken(EQLParser.NUMBER_LITERAL, 0); } - public LiteralContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_literal; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).enterLiteral(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof EQLListener ) ((EQLListener)listener).exitLiteral(this); - } - } - - public final LiteralContext literal() throws RecognitionException { - LiteralContext _localctx = new LiteralContext(_ctx, getState()); - enterRule(_localctx, 78, RULE_literal); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(322); - _la = _input.LA(1); - if ( !(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (BOOLEAN_LITERAL - 60)) | (1L << (NUMBER_LITERAL - 60)) | (1L << (STRING_LITERAL - 60)))) != 0)) ) { - _errHandler.recoverInline(this); - } else { - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3D\u0147\4\2\t\2\4"+ - "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ - "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\3\2\5\2T\n\2\3"+ - "\2\7\2W\n\2\f\2\16\2Z\13\2\3\2\5\2]\n\2\3\2\5\2`\n\2\3\2\5\2c\n\2\3\3"+ - "\3\3\5\3g\n\3\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3\7"+ - "\3\7\3\7\7\7y\n\7\f\7\16\7|\13\7\3\b\3\b\5\b\u0080\n\b\3\b\5\b\u0083\n"+ - "\b\3\t\3\t\3\t\3\t\5\t\u0089\n\t\3\n\3\n\3\13\3\13\3\13\5\13\u0090\n\13"+ - "\3\f\3\f\3\f\3\r\3\r\5\r\u0097\n\r\3\r\3\r\5\r\u009b\n\r\3\16\3\16\3\16"+ - "\3\16\3\17\3\17\3\17\7\17\u00a4\n\17\f\17\16\17\u00a7\13\17\3\20\3\20"+ - "\3\20\5\20\u00ac\n\20\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23\5\23\u00b6"+ - "\n\23\3\24\3\24\5\24\u00ba\n\24\3\25\3\25\5\25\u00be\n\25\3\26\3\26\3"+ - "\26\3\26\3\27\3\27\3\27\7\27\u00c7\n\27\f\27\16\27\u00ca\13\27\3\30\3"+ - "\30\3\30\7\30\u00cf\n\30\f\30\16\30\u00d2\13\30\3\31\5\31\u00d5\n\31\3"+ - "\31\3\31\3\32\3\32\3\32\3\32\3\32\5\32\u00de\n\32\3\33\3\33\3\33\3\33"+ - "\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\5\33\u00ed\n\33\3\34\3\34"+ - "\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u00f8\n\35\f\35\16\35\u00fb\13"+ - "\35\3\35\3\35\5\35\u00ff\n\35\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37"+ - "\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \5 \u0112\n \3!\3!\3!\3!\3!\3!\3!\3"+ - "!\5!\u011c\n!\3\"\3\"\3\"\3\"\3\"\5\"\u0123\n\"\3#\3#\3#\3#\3#\3#\3#\3"+ - "#\5#\u012d\n#\3$\3$\3$\3$\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\5&\u013d\n&\3"+ - "\'\3\'\3(\3(\5(\u0143\n(\3)\3)\3)\2\2*\2\4\6\b\n\f\16\20\22\24\26\30\32"+ - "\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNP\2\6\3\2\16\17\3\2$+\3\2,;\4\2"+ - ">?CC\u0148\2S\3\2\2\2\4d\3\2\2\2\6l\3\2\2\2\bn\3\2\2\2\np\3\2\2\2\fs\3"+ - "\2\2\2\16}\3\2\2\2\20\u0088\3\2\2\2\22\u008a\3\2\2\2\24\u008c\3\2\2\2"+ - "\26\u0091\3\2\2\2\30\u0094\3\2\2\2\32\u009c\3\2\2\2\34\u00a0\3\2\2\2\36"+ - "\u00ab\3\2\2\2 \u00ad\3\2\2\2\"\u00b0\3\2\2\2$\u00b5\3\2\2\2&\u00b7\3"+ - "\2\2\2(\u00bb\3\2\2\2*\u00bf\3\2\2\2,\u00c3\3\2\2\2.\u00cb\3\2\2\2\60"+ - "\u00d4\3\2\2\2\62\u00dd\3\2\2\2\64\u00ec\3\2\2\2\66\u00ee\3\2\2\28\u00fe"+ - "\3\2\2\2:\u0100\3\2\2\2<\u0106\3\2\2\2>\u0111\3\2\2\2@\u011b\3\2\2\2B"+ - "\u0122\3\2\2\2D\u012c\3\2\2\2F\u012e\3\2\2\2H\u0132\3\2\2\2J\u013c\3\2"+ - "\2\2L\u013e\3\2\2\2N\u0142\3\2\2\2P\u0144\3\2\2\2RT\5\4\3\2SR\3\2\2\2"+ - "ST\3\2\2\2TX\3\2\2\2UW\5\b\5\2VU\3\2\2\2WZ\3\2\2\2XV\3\2\2\2XY\3\2\2\2"+ - "Y\\\3\2\2\2ZX\3\2\2\2[]\5\n\6\2\\[\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^`\5\f"+ - "\7\2_^\3\2\2\2_`\3\2\2\2`b\3\2\2\2ac\5\24\13\2ba\3\2\2\2bc\3\2\2\2c\3"+ - "\3\2\2\2df\7\3\2\2eg\5\6\4\2fe\3\2\2\2fg\3\2\2\2gh\3\2\2\2hi\7\4\2\2i"+ - "j\5\34\17\2jk\7\5\2\2k\5\3\2\2\2lm\7\6\2\2m\7\3\2\2\2no\5\30\r\2o\t\3"+ - "\2\2\2pq\7\7\2\2qr\5,\27\2r\13\3\2\2\2st\7\b\2\2tu\7\t\2\2uz\5\16\b\2"+ - "vw\7\n\2\2wy\5\16\b\2xv\3\2\2\2y|\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\r\3\2\2"+ - "\2|z\3\2\2\2}\177\7=\2\2~\u0080\5\22\n\2\177~\3\2\2\2\177\u0080\3\2\2"+ - "\2\u0080\u0082\3\2\2\2\u0081\u0083\5\20\t\2\u0082\u0081\3\2\2\2\u0082"+ - "\u0083\3\2\2\2\u0083\17\3\2\2\2\u0084\u0085\7\13\2\2\u0085\u0089\7\f\2"+ - "\2\u0086\u0087\7\13\2\2\u0087\u0089\7\r\2\2\u0088\u0084\3\2\2\2\u0088"+ - "\u0086\3\2\2\2\u0089\21\3\2\2\2\u008a\u008b\t\2\2\2\u008b\23\3\2\2\2\u008c"+ - "\u008d\7\20\2\2\u008d\u008f\7?\2\2\u008e\u0090\5\26\f\2\u008f\u008e\3"+ - "\2\2\2\u008f\u0090\3\2\2\2\u0090\25\3\2\2\2\u0091\u0092\7\21\2\2\u0092"+ - "\u0093\7?\2\2\u0093\27\3\2\2\2\u0094\u0096\7\22\2\2\u0095\u0097\5$\23"+ - "\2\u0096\u0095\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u009a"+ - "\7=\2\2\u0099\u009b\5\32\16\2\u009a\u0099\3\2\2\2\u009a\u009b\3\2\2\2"+ - "\u009b\31\3\2\2\2\u009c\u009d\7\4\2\2\u009d\u009e\5\34\17\2\u009e\u009f"+ - "\7\5\2\2\u009f\33\3\2\2\2\u00a0\u00a5\5\36\20\2\u00a1\u00a2\7\n\2\2\u00a2"+ - "\u00a4\5\36\20\2\u00a3\u00a1\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3"+ - "\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\35\3\2\2\2\u00a7\u00a5\3\2\2\2\u00a8"+ - "\u00ac\7=\2\2\u00a9\u00ac\5 \21\2\u00aa\u00ac\5\"\22\2\u00ab\u00a8\3\2"+ - "\2\2\u00ab\u00a9\3\2\2\2\u00ab\u00aa\3\2\2\2\u00ac\37\3\2\2\2\u00ad\u00ae"+ - "\7\23\2\2\u00ae\u00af\5&\24\2\u00af!\3\2\2\2\u00b0\u00b1\7\23\2\2\u00b1"+ - "\u00b2\5(\25\2\u00b2#\3\2\2\2\u00b3\u00b6\5&\24\2\u00b4\u00b6\5(\25\2"+ - "\u00b5\u00b3\3\2\2\2\u00b5\u00b4\3\2\2\2\u00b6%\3\2\2\2\u00b7\u00b9\7"+ - "\24\2\2\u00b8\u00ba\5*\26\2\u00b9\u00b8\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba"+ - "\'\3\2\2\2\u00bb\u00bd\7\25\2\2\u00bc\u00be\5*\26\2\u00bd\u00bc\3\2\2"+ - "\2\u00bd\u00be\3\2\2\2\u00be)\3\2\2\2\u00bf\u00c0\7\4\2\2\u00c0\u00c1"+ - "\7?\2\2\u00c1\u00c2\7\5\2\2\u00c2+\3\2\2\2\u00c3\u00c8\5.\30\2\u00c4\u00c5"+ - "\7\26\2\2\u00c5\u00c7\5.\30\2\u00c6\u00c4\3\2\2\2\u00c7\u00ca\3\2\2\2"+ - "\u00c8\u00c6\3\2\2\2\u00c8\u00c9\3\2\2\2\u00c9-\3\2\2\2\u00ca\u00c8\3"+ - "\2\2\2\u00cb\u00d0\5\60\31\2\u00cc\u00cd\7\27\2\2\u00cd\u00cf\5\60\31"+ - "\2\u00ce\u00cc\3\2\2\2\u00cf\u00d2\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d0\u00d1"+ - "\3\2\2\2\u00d1/\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d3\u00d5\7\30\2\2\u00d4"+ - "\u00d3\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d7\5\62"+ - "\32\2\u00d7\61\3\2\2\2\u00d8\u00de\5\64\33\2\u00d9\u00da\7\4\2\2\u00da"+ - "\u00db\5,\27\2\u00db\u00dc\7\5\2\2\u00dc\u00de\3\2\2\2\u00dd\u00d8\3\2"+ - "\2\2\u00dd\u00d9\3\2\2\2\u00de\63\3\2\2\2\u00df\u00ed\5J&\2\u00e0\u00ed"+ - "\5F$\2\u00e1\u00ed\5:\36\2\u00e2\u00ed\5<\37\2\u00e3\u00ed\5\66\34\2\u00e4"+ - "\u00ed\5> \2\u00e5\u00ed\5@!\2\u00e6\u00ed\5B\"\2\u00e7\u00ed\5D#\2\u00e8"+ - "\u00e9\7\4\2\2\u00e9\u00ea\5\64\33\2\u00ea\u00eb\7\5\2\2\u00eb\u00ed\3"+ - "\2\2\2\u00ec\u00df\3\2\2\2\u00ec\u00e0\3\2\2\2\u00ec\u00e1\3\2\2\2\u00ec"+ - "\u00e2\3\2\2\2\u00ec\u00e3\3\2\2\2\u00ec\u00e4\3\2\2\2\u00ec\u00e5\3\2"+ - "\2\2\u00ec\u00e6\3\2\2\2\u00ec\u00e7\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed"+ - "\65\3\2\2\2\u00ee\u00ef\7=\2\2\u00ef\u00f0\7\31\2\2\u00f0\u00f1\58\35"+ - "\2\u00f1\67\3\2\2\2\u00f2\u00ff\7<\2\2\u00f3\u00f4\7\4\2\2\u00f4\u00f9"+ - "\5N(\2\u00f5\u00f6\7\n\2\2\u00f6\u00f8\5N(\2\u00f7\u00f5\3\2\2\2\u00f8"+ - "\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9\u00fa\3\2\2\2\u00fa\u00fc\3\2"+ - "\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7\5\2\2\u00fd\u00ff\3\2\2\2\u00fe"+ - "\u00f2\3\2\2\2\u00fe\u00f3\3\2\2\2\u00ff9\3\2\2\2\u0100\u0101\7=\2\2\u0101"+ - "\u0102\7\32\2\2\u0102\u0103\5N(\2\u0103\u0104\7\27\2\2\u0104\u0105\5N"+ - "(\2\u0105;\3\2\2\2\u0106\u0107\5N(\2\u0107\u0108\7\32\2\2\u0108\u0109"+ - "\7=\2\2\u0109\u010a\7\27\2\2\u010a\u010b\7=\2\2\u010b=\3\2\2\2\u010c\u010d"+ - "\7=\2\2\u010d\u010e\7\33\2\2\u010e\u0112\7\34\2\2\u010f\u0110\7=\2\2\u0110"+ - "\u0112\7\35\2\2\u0111\u010c\3\2\2\2\u0111\u010f\3\2\2\2\u0112?\3\2\2\2"+ - "\u0113\u0114\7=\2\2\u0114\u0115\7\33\2\2\u0115\u0116\7\30\2\2\u0116\u011c"+ - "\7\34\2\2\u0117\u0118\7=\2\2\u0118\u011c\7\36\2\2\u0119\u011a\7=\2\2\u011a"+ - "\u011c\7\37\2\2\u011b\u0113\3\2\2\2\u011b\u0117\3\2\2\2\u011b\u0119\3"+ - "\2\2\2\u011cA\3\2\2\2\u011d\u011e\7=\2\2\u011e\u011f\7\33\2\2\u011f\u0123"+ - "\7 \2\2\u0120\u0121\7=\2\2\u0121\u0123\7!\2\2\u0122\u011d\3\2\2\2\u0122"+ - "\u0120\3\2\2\2\u0123C\3\2\2\2\u0124\u0125\7=\2\2\u0125\u0126\7\33\2\2"+ - "\u0126\u0127\7\30\2\2\u0127\u012d\7 \2\2\u0128\u0129\7=\2\2\u0129\u012d"+ - "\7\"\2\2\u012a\u012b\7=\2\2\u012b\u012d\7#\2\2\u012c\u0124\3\2\2\2\u012c"+ - "\u0128\3\2\2\2\u012c\u012a\3\2\2\2\u012dE\3\2\2\2\u012e\u012f\7=\2\2\u012f"+ - "\u0130\5H%\2\u0130\u0131\5N(\2\u0131G\3\2\2\2\u0132\u0133\t\3\2\2\u0133"+ - "I\3\2\2\2\u0134\u0135\7=\2\2\u0135\u0136\5L\'\2\u0136\u0137\5N(\2\u0137"+ - "\u013d\3\2\2\2\u0138\u0139\5N(\2\u0139\u013a\5L\'\2\u013a\u013b\7=\2\2"+ - "\u013b\u013d\3\2\2\2\u013c\u0134\3\2\2\2\u013c\u0138\3\2\2\2\u013dK\3"+ - "\2\2\2\u013e\u013f\t\4\2\2\u013fM\3\2\2\2\u0140\u0143\5P)\2\u0141\u0143"+ - "\7<\2\2\u0142\u0140\3\2\2\2\u0142\u0141\3\2\2\2\u0143O\3\2\2\2\u0144\u0145"+ - "\t\5\2\2\u0145Q\3\2\2\2!SX\\_bfz\177\u0082\u0088\u008f\u0096\u009a\u00a5"+ - "\u00ab\u00b5\u00b9\u00bd\u00c8\u00d0\u00d4\u00dd\u00ec\u00f9\u00fe\u0111"+ - "\u011b\u0122\u012c\u013c\u0142"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file + public EQLParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + } + + public static class Select_statementContext extends ParserRuleContext { + public Select_clauseContext select_clause() { + return getRuleContext(Select_clauseContext.class, 0); + } + + public List fetch_clause() { + return getRuleContexts(Fetch_clauseContext.class); + } + + public Fetch_clauseContext fetch_clause(int i) { + return getRuleContext(Fetch_clauseContext.class, i); + } + + public Where_clauseContext where_clause() { + return getRuleContext(Where_clauseContext.class, 0); + } + + public Orderby_clauseContext orderby_clause() { + return getRuleContext(Orderby_clauseContext.class, 0); + } + + public Limit_clauseContext limit_clause() { + return getRuleContext(Limit_clauseContext.class, 0); + } + + public Select_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_select_statement; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterSelect_statement(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitSelect_statement(this); + } + } + + public final Select_statementContext select_statement() throws RecognitionException { + Select_statementContext _localctx = new Select_statementContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_select_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(81); + _la = _input.LA(1); + if (_la == T__0) { + { + setState(80); + select_clause(); + } + } + + setState(86); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__15) { + { + { + setState(83); + fetch_clause(); + } + } + setState(88); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(90); + _la = _input.LA(1); + if (_la == T__4) { + { + setState(89); + where_clause(); + } + } + + setState(93); + _la = _input.LA(1); + if (_la == T__5) { + { + setState(92); + orderby_clause(); + } + } + + setState(96); + _la = _input.LA(1); + if (_la == T__13) { + { + setState(95); + limit_clause(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Select_clauseContext extends ParserRuleContext { + public Fetch_property_groupContext fetch_property_group() { + return getRuleContext(Fetch_property_groupContext.class, 0); + } + + public DistinctContext distinct() { + return getRuleContext(DistinctContext.class, 0); + } + + public Select_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_select_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterSelect_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitSelect_clause(this); + } + } + + public final Select_clauseContext select_clause() throws RecognitionException { + Select_clauseContext _localctx = new Select_clauseContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_select_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(98); + match(T__0); + setState(100); + _la = _input.LA(1); + if (_la == T__3) { + { + setState(99); + distinct(); + } + } + + setState(102); + match(T__1); + setState(103); + fetch_property_group(); + setState(104); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class DistinctContext extends ParserRuleContext { + public DistinctContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_distinct; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterDistinct(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitDistinct(this); + } + } + + public final DistinctContext distinct() throws RecognitionException { + DistinctContext _localctx = new DistinctContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_distinct); + try { + enterOuterAlt(_localctx, 1); + { + setState(106); + match(T__3); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_clauseContext extends ParserRuleContext { + public Fetch_pathContext fetch_path() { + return getRuleContext(Fetch_pathContext.class, 0); + } + + public Fetch_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_clause(this); + } + } + + public final Fetch_clauseContext fetch_clause() throws RecognitionException { + Fetch_clauseContext _localctx = new Fetch_clauseContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_fetch_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(108); + fetch_path(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Where_clauseContext extends ParserRuleContext { + public Conditional_expressionContext conditional_expression() { + return getRuleContext(Conditional_expressionContext.class, 0); + } + + public Where_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_where_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterWhere_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitWhere_clause(this); + } + } + + public final Where_clauseContext where_clause() throws RecognitionException { + Where_clauseContext _localctx = new Where_clauseContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_where_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(110); + match(T__4); + setState(111); + conditional_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Orderby_clauseContext extends ParserRuleContext { + public List orderby_property() { + return getRuleContexts(Orderby_propertyContext.class); + } + + public Orderby_propertyContext orderby_property(int i) { + return getRuleContext(Orderby_propertyContext.class, i); + } + + public Orderby_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_orderby_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOrderby_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOrderby_clause(this); + } + } + + public final Orderby_clauseContext orderby_clause() throws RecognitionException { + Orderby_clauseContext _localctx = new Orderby_clauseContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_orderby_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(113); + match(T__5); + setState(114); + match(T__6); + setState(115); + orderby_property(); + setState(120); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(116); + match(T__7); + setState(117); + orderby_property(); + } + } + setState(122); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Orderby_propertyContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Asc_descContext asc_desc() { + return getRuleContext(Asc_descContext.class, 0); + } + + public Nulls_firstlastContext nulls_firstlast() { + return getRuleContext(Nulls_firstlastContext.class, 0); + } + + public Orderby_propertyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_orderby_property; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOrderby_property(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOrderby_property(this); + } + } + + public final Orderby_propertyContext orderby_property() throws RecognitionException { + Orderby_propertyContext _localctx = new Orderby_propertyContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_orderby_property); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(123); + match(PATH_VARIABLE); + setState(125); + _la = _input.LA(1); + if (_la == T__11 || _la == T__12) { + { + setState(124); + asc_desc(); + } + } + + setState(128); + _la = _input.LA(1); + if (_la == T__8) { + { + setState(127); + nulls_firstlast(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Nulls_firstlastContext extends ParserRuleContext { + public Nulls_firstlastContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_nulls_firstlast; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterNulls_firstlast(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitNulls_firstlast(this); + } + } + + public final Nulls_firstlastContext nulls_firstlast() throws RecognitionException { + Nulls_firstlastContext _localctx = new Nulls_firstlastContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_nulls_firstlast); + try { + setState(134); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 9, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(130); + match(T__8); + setState(131); + match(T__9); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(132); + match(T__8); + setState(133); + match(T__10); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Asc_descContext extends ParserRuleContext { + public Asc_descContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_asc_desc; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterAsc_desc(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitAsc_desc(this); + } + } + + public final Asc_descContext asc_desc() throws RecognitionException { + Asc_descContext _localctx = new Asc_descContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_asc_desc); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(136); + _la = _input.LA(1); + if (!(_la == T__11 || _la == T__12)) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Limit_clauseContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Offset_clauseContext offset_clause() { + return getRuleContext(Offset_clauseContext.class, 0); + } + + public Limit_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_limit_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLimit_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLimit_clause(this); + } + } + + public final Limit_clauseContext limit_clause() throws RecognitionException { + Limit_clauseContext _localctx = new Limit_clauseContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_limit_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(138); + match(T__13); + setState(139); + match(NUMBER_LITERAL); + setState(141); + _la = _input.LA(1); + if (_la == T__14) { + { + setState(140); + offset_clause(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Offset_clauseContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Offset_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_offset_clause; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterOffset_clause(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitOffset_clause(this); + } + } + + public final Offset_clauseContext offset_clause() throws RecognitionException { + Offset_clauseContext _localctx = new Offset_clauseContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_offset_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(143); + match(T__14); + setState(144); + match(NUMBER_LITERAL); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_pathContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Fetch_optionContext fetch_option() { + return getRuleContext(Fetch_optionContext.class, 0); + } + + public Fetch_property_setContext fetch_property_set() { + return getRuleContext(Fetch_property_setContext.class, 0); + } + + public Fetch_pathContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_path; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_path(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_path(this); + } + } + + public final Fetch_pathContext fetch_path() throws RecognitionException { + Fetch_pathContext _localctx = new Fetch_pathContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_fetch_path); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(146); + match(T__15); + setState(148); + _la = _input.LA(1); + if (_la == T__17 || _la == T__18) { + { + setState(147); + fetch_option(); + } + } + + setState(150); + match(PATH_VARIABLE); + setState(152); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(151); + fetch_property_set(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_property_setContext extends ParserRuleContext { + public Fetch_property_groupContext fetch_property_group() { + return getRuleContext(Fetch_property_groupContext.class, 0); + } + + public Fetch_property_setContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property_set; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property_set(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property_set(this); + } + } + + public final Fetch_property_setContext fetch_property_set() throws RecognitionException { + Fetch_property_setContext _localctx = new Fetch_property_setContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_fetch_property_set); + try { + enterOuterAlt(_localctx, 1); + { + setState(154); + match(T__1); + setState(155); + fetch_property_group(); + setState(156); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_property_groupContext extends ParserRuleContext { + public List fetch_property() { + return getRuleContexts(Fetch_propertyContext.class); + } + + public Fetch_propertyContext fetch_property(int i) { + return getRuleContext(Fetch_propertyContext.class, i); + } + + public Fetch_property_groupContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property_group; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property_group(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property_group(this); + } + } + + public final Fetch_property_groupContext fetch_property_group() throws RecognitionException { + Fetch_property_groupContext _localctx = new Fetch_property_groupContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_fetch_property_group); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(158); + fetch_property(); + setState(163); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(159); + match(T__7); + setState(160); + fetch_property(); + } + } + setState(165); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_propertyContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Fetch_query_hintContext fetch_query_hint() { + return getRuleContext(Fetch_query_hintContext.class, 0); + } + + public Fetch_lazy_hintContext fetch_lazy_hint() { + return getRuleContext(Fetch_lazy_hintContext.class, 0); + } + + public Fetch_propertyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_property; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_property(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_property(this); + } + } + + public final Fetch_propertyContext fetch_property() throws RecognitionException { + Fetch_propertyContext _localctx = new Fetch_propertyContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_fetch_property); + try { + setState(169); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 14, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(166); + match(PATH_VARIABLE); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(167); + fetch_query_hint(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(168); + fetch_lazy_hint(); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_query_hintContext extends ParserRuleContext { + public Fetch_query_optionContext fetch_query_option() { + return getRuleContext(Fetch_query_optionContext.class, 0); + } + + public Fetch_query_hintContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_query_hint; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_query_hint(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_query_hint(this); + } + } + + public final Fetch_query_hintContext fetch_query_hint() throws RecognitionException { + Fetch_query_hintContext _localctx = new Fetch_query_hintContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_fetch_query_hint); + try { + enterOuterAlt(_localctx, 1); + { + setState(171); + match(T__16); + setState(172); + fetch_query_option(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_lazy_hintContext extends ParserRuleContext { + public Fetch_lazy_optionContext fetch_lazy_option() { + return getRuleContext(Fetch_lazy_optionContext.class, 0); + } + + public Fetch_lazy_hintContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_lazy_hint; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_lazy_hint(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_lazy_hint(this); + } + } + + public final Fetch_lazy_hintContext fetch_lazy_hint() throws RecognitionException { + Fetch_lazy_hintContext _localctx = new Fetch_lazy_hintContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_fetch_lazy_hint); + try { + enterOuterAlt(_localctx, 1); + { + setState(174); + match(T__16); + setState(175); + fetch_lazy_option(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_optionContext extends ParserRuleContext { + public Fetch_query_optionContext fetch_query_option() { + return getRuleContext(Fetch_query_optionContext.class, 0); + } + + public Fetch_lazy_optionContext fetch_lazy_option() { + return getRuleContext(Fetch_lazy_optionContext.class, 0); + } + + public Fetch_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_option(this); + } + } + + public final Fetch_optionContext fetch_option() throws RecognitionException { + Fetch_optionContext _localctx = new Fetch_optionContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_fetch_option); + try { + setState(179); + switch (_input.LA(1)) { + case T__17: + enterOuterAlt(_localctx, 1); + { + setState(177); + fetch_query_option(); + } + break; + case T__18: + enterOuterAlt(_localctx, 2); + { + setState(178); + fetch_lazy_option(); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_query_optionContext extends ParserRuleContext { + public Fetch_batch_sizeContext fetch_batch_size() { + return getRuleContext(Fetch_batch_sizeContext.class, 0); + } + + public Fetch_query_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_query_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_query_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_query_option(this); + } + } + + public final Fetch_query_optionContext fetch_query_option() throws RecognitionException { + Fetch_query_optionContext _localctx = new Fetch_query_optionContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_fetch_query_option); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(181); + match(T__17); + setState(183); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(182); + fetch_batch_size(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_lazy_optionContext extends ParserRuleContext { + public Fetch_batch_sizeContext fetch_batch_size() { + return getRuleContext(Fetch_batch_sizeContext.class, 0); + } + + public Fetch_lazy_optionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_lazy_option; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_lazy_option(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_lazy_option(this); + } + } + + public final Fetch_lazy_optionContext fetch_lazy_option() throws RecognitionException { + Fetch_lazy_optionContext _localctx = new Fetch_lazy_optionContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_fetch_lazy_option); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(185); + match(T__18); + setState(187); + _la = _input.LA(1); + if (_la == T__1) { + { + setState(186); + fetch_batch_size(); + } + } + + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Fetch_batch_sizeContext extends ParserRuleContext { + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public Fetch_batch_sizeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_fetch_batch_size; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterFetch_batch_size(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitFetch_batch_size(this); + } + } + + public final Fetch_batch_sizeContext fetch_batch_size() throws RecognitionException { + Fetch_batch_sizeContext _localctx = new Fetch_batch_sizeContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_fetch_batch_size); + try { + enterOuterAlt(_localctx, 1); + { + setState(189); + match(T__1); + setState(190); + match(NUMBER_LITERAL); + setState(191); + match(T__2); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_expressionContext extends ParserRuleContext { + public List conditional_term() { + return getRuleContexts(Conditional_termContext.class); + } + + public Conditional_termContext conditional_term(int i) { + return getRuleContext(Conditional_termContext.class, i); + } + + public Conditional_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_expression(this); + } + } + + public final Conditional_expressionContext conditional_expression() throws RecognitionException { + Conditional_expressionContext _localctx = new Conditional_expressionContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_conditional_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(193); + conditional_term(); + setState(198); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__19) { + { + { + setState(194); + match(T__19); + setState(195); + conditional_term(); + } + } + setState(200); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_termContext extends ParserRuleContext { + public List conditional_factor() { + return getRuleContexts(Conditional_factorContext.class); + } + + public Conditional_factorContext conditional_factor(int i) { + return getRuleContext(Conditional_factorContext.class, i); + } + + public Conditional_termContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_term; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_term(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_term(this); + } + } + + public final Conditional_termContext conditional_term() throws RecognitionException { + Conditional_termContext _localctx = new Conditional_termContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_conditional_term); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(201); + conditional_factor(); + setState(206); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__20) { + { + { + setState(202); + match(T__20); + setState(203); + conditional_factor(); + } + } + setState(208); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_factorContext extends ParserRuleContext { + public Conditional_primaryContext conditional_primary() { + return getRuleContext(Conditional_primaryContext.class, 0); + } + + public Conditional_factorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_factor; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_factor(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_factor(this); + } + } + + public final Conditional_factorContext conditional_factor() throws RecognitionException { + Conditional_factorContext _localctx = new Conditional_factorContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_conditional_factor); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(210); + _la = _input.LA(1); + if (_la == T__21) { + { + setState(209); + match(T__21); + } + } + + setState(212); + conditional_primary(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Conditional_primaryContext extends ParserRuleContext { + public Any_expressionContext any_expression() { + return getRuleContext(Any_expressionContext.class, 0); + } + + public Conditional_expressionContext conditional_expression() { + return getRuleContext(Conditional_expressionContext.class, 0); + } + + public Conditional_primaryContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_conditional_primary; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterConditional_primary(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitConditional_primary(this); + } + } + + public final Conditional_primaryContext conditional_primary() throws RecognitionException { + Conditional_primaryContext _localctx = new Conditional_primaryContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_conditional_primary); + try { + setState(219); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 21, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(214); + any_expression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(215); + match(T__1); + setState(216); + conditional_expression(); + setState(217); + match(T__2); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Any_expressionContext extends ParserRuleContext { + public Comparison_expressionContext comparison_expression() { + return getRuleContext(Comparison_expressionContext.class, 0); + } + + public Like_expressionContext like_expression() { + return getRuleContext(Like_expressionContext.class, 0); + } + + public Between_expressionContext between_expression() { + return getRuleContext(Between_expressionContext.class, 0); + } + + public PropertyBetween_expressionContext propertyBetween_expression() { + return getRuleContext(PropertyBetween_expressionContext.class, 0); + } + + public In_expressionContext in_expression() { + return getRuleContext(In_expressionContext.class, 0); + } + + public IsNull_expressionContext isNull_expression() { + return getRuleContext(IsNull_expressionContext.class, 0); + } + + public IsNotNull_expressionContext isNotNull_expression() { + return getRuleContext(IsNotNull_expressionContext.class, 0); + } + + public IsEmpty_expressionContext isEmpty_expression() { + return getRuleContext(IsEmpty_expressionContext.class, 0); + } + + public IsNotEmpty_expressionContext isNotEmpty_expression() { + return getRuleContext(IsNotEmpty_expressionContext.class, 0); + } + + public Any_expressionContext any_expression() { + return getRuleContext(Any_expressionContext.class, 0); + } + + public Any_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_any_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterAny_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitAny_expression(this); + } + } + + public final Any_expressionContext any_expression() throws RecognitionException { + Any_expressionContext _localctx = new Any_expressionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_any_expression); + try { + setState(234); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 22, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(221); + comparison_expression(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(222); + like_expression(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(223); + between_expression(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(224); + propertyBetween_expression(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(225); + in_expression(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(226); + isNull_expression(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(227); + isNotNull_expression(); + } + break; + case 8: + enterOuterAlt(_localctx, 8); + { + setState(228); + isEmpty_expression(); + } + break; + case 9: + enterOuterAlt(_localctx, 9); + { + setState(229); + isNotEmpty_expression(); + } + break; + case 10: + enterOuterAlt(_localctx, 10); + { + setState(230); + match(T__1); + setState(231); + any_expression(); + setState(232); + match(T__2); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class In_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public In_valueContext in_value() { + return getRuleContext(In_valueContext.class, 0); + } + + public In_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_in_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIn_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIn_expression(this); + } + } + + public final In_expressionContext in_expression() throws RecognitionException { + In_expressionContext _localctx = new In_expressionContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_in_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(236); + match(PATH_VARIABLE); + setState(237); + match(T__22); + setState(238); + in_value(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class In_valueContext extends ParserRuleContext { + public TerminalNode INPUT_VARIABLE() { + return getToken(EQLParser.INPUT_VARIABLE, 0); + } + + public List value_expression() { + return getRuleContexts(Value_expressionContext.class); + } + + public Value_expressionContext value_expression(int i) { + return getRuleContext(Value_expressionContext.class, i); + } + + public In_valueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_in_value; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIn_value(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIn_value(this); + } + } + + public final In_valueContext in_value() throws RecognitionException { + In_valueContext _localctx = new In_valueContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_in_value); + int _la; + try { + setState(252); + switch (_input.LA(1)) { + case INPUT_VARIABLE: + enterOuterAlt(_localctx, 1); + { + setState(240); + match(INPUT_VARIABLE); + } + break; + case T__1: + enterOuterAlt(_localctx, 2); + { + setState(241); + match(T__1); + setState(242); + value_expression(); + setState(247); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == T__7) { + { + { + setState(243); + match(T__7); + setState(244); + value_expression(); + } + } + setState(249); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(250); + match(T__2); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Between_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public List value_expression() { + return getRuleContexts(Value_expressionContext.class); + } + + public Value_expressionContext value_expression(int i) { + return getRuleContext(Value_expressionContext.class, i); + } + + public Between_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_between_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterBetween_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitBetween_expression(this); + } + } + + public final Between_expressionContext between_expression() throws RecognitionException { + Between_expressionContext _localctx = new Between_expressionContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_between_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(254); + match(PATH_VARIABLE); + setState(255); + match(T__23); + setState(256); + value_expression(); + setState(257); + match(T__20); + setState(258); + value_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class PropertyBetween_expressionContext extends ParserRuleContext { + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public List PATH_VARIABLE() { + return getTokens(EQLParser.PATH_VARIABLE); + } + + public TerminalNode PATH_VARIABLE(int i) { + return getToken(EQLParser.PATH_VARIABLE, i); + } + + public PropertyBetween_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_propertyBetween_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterPropertyBetween_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitPropertyBetween_expression(this); + } + } + + public final PropertyBetween_expressionContext propertyBetween_expression() throws RecognitionException { + PropertyBetween_expressionContext _localctx = new PropertyBetween_expressionContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_propertyBetween_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(260); + value_expression(); + setState(261); + match(T__23); + setState(262); + match(PATH_VARIABLE); + setState(263); + match(T__20); + setState(264); + match(PATH_VARIABLE); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNull_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNull_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNull_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNull_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNull_expression(this); + } + } + + public final IsNull_expressionContext isNull_expression() throws RecognitionException { + IsNull_expressionContext _localctx = new IsNull_expressionContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_isNull_expression); + try { + setState(271); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 25, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(266); + match(PATH_VARIABLE); + setState(267); + match(T__24); + setState(268); + match(T__25); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(269); + match(PATH_VARIABLE); + setState(270); + match(T__26); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNotNull_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNotNull_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNotNull_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNotNull_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNotNull_expression(this); + } + } + + public final IsNotNull_expressionContext isNotNull_expression() throws RecognitionException { + IsNotNull_expressionContext _localctx = new IsNotNull_expressionContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_isNotNull_expression); + try { + setState(281); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 26, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(273); + match(PATH_VARIABLE); + setState(274); + match(T__24); + setState(275); + match(T__21); + setState(276); + match(T__25); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(277); + match(PATH_VARIABLE); + setState(278); + match(T__27); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(279); + match(PATH_VARIABLE); + setState(280); + match(T__28); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsEmpty_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsEmpty_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isEmpty_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsEmpty_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsEmpty_expression(this); + } + } + + public final IsEmpty_expressionContext isEmpty_expression() throws RecognitionException { + IsEmpty_expressionContext _localctx = new IsEmpty_expressionContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_isEmpty_expression); + try { + setState(288); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 27, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(283); + match(PATH_VARIABLE); + setState(284); + match(T__24); + setState(285); + match(T__29); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(286); + match(PATH_VARIABLE); + setState(287); + match(T__30); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class IsNotEmpty_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public IsNotEmpty_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_isNotEmpty_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterIsNotEmpty_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitIsNotEmpty_expression(this); + } + } + + public final IsNotEmpty_expressionContext isNotEmpty_expression() throws RecognitionException { + IsNotEmpty_expressionContext _localctx = new IsNotEmpty_expressionContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_isNotEmpty_expression); + try { + setState(298); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 28, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(290); + match(PATH_VARIABLE); + setState(291); + match(T__24); + setState(292); + match(T__21); + setState(293); + match(T__29); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(294); + match(PATH_VARIABLE); + setState(295); + match(T__31); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(296); + match(PATH_VARIABLE); + setState(297); + match(T__32); + } + break; + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Like_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Like_opContext like_op() { + return getRuleContext(Like_opContext.class, 0); + } + + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public Like_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_like_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLike_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLike_expression(this); + } + } + + public final Like_expressionContext like_expression() throws RecognitionException { + Like_expressionContext _localctx = new Like_expressionContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_like_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(300); + match(PATH_VARIABLE); + setState(301); + like_op(); + setState(302); + value_expression(); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Like_opContext extends ParserRuleContext { + public Like_opContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_like_op; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLike_op(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLike_op(this); + } + } + + public final Like_opContext like_op() throws RecognitionException { + Like_opContext _localctx = new Like_opContext(_ctx, getState()); + enterRule(_localctx, 70, RULE_like_op); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(304); + _la = _input.LA(1); + if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Comparison_expressionContext extends ParserRuleContext { + public TerminalNode PATH_VARIABLE() { + return getToken(EQLParser.PATH_VARIABLE, 0); + } + + public Comparison_operatorContext comparison_operator() { + return getRuleContext(Comparison_operatorContext.class, 0); + } + + public Value_expressionContext value_expression() { + return getRuleContext(Value_expressionContext.class, 0); + } + + public Comparison_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_comparison_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterComparison_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitComparison_expression(this); + } + } + + public final Comparison_expressionContext comparison_expression() throws RecognitionException { + Comparison_expressionContext _localctx = new Comparison_expressionContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_comparison_expression); + try { + setState(314); + switch (_input.LA(1)) { + case PATH_VARIABLE: + enterOuterAlt(_localctx, 1); + { + setState(306); + match(PATH_VARIABLE); + setState(307); + comparison_operator(); + setState(308); + value_expression(); + } + break; + case INPUT_VARIABLE: + case BOOLEAN_LITERAL: + case NUMBER_LITERAL: + case STRING_LITERAL: + enterOuterAlt(_localctx, 2); + { + setState(310); + value_expression(); + setState(311); + comparison_operator(); + setState(312); + match(PATH_VARIABLE); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Comparison_operatorContext extends ParserRuleContext { + public Comparison_operatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_comparison_operator; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterComparison_operator(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitComparison_operator(this); + } + } + + public final Comparison_operatorContext comparison_operator() throws RecognitionException { + Comparison_operatorContext _localctx = new Comparison_operatorContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_comparison_operator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(316); + _la = _input.LA(1); + if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class Value_expressionContext extends ParserRuleContext { + public LiteralContext literal() { + return getRuleContext(LiteralContext.class, 0); + } + + public TerminalNode INPUT_VARIABLE() { + return getToken(EQLParser.INPUT_VARIABLE, 0); + } + + public Value_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_value_expression; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterValue_expression(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitValue_expression(this); + } + } + + public final Value_expressionContext value_expression() throws RecognitionException { + Value_expressionContext _localctx = new Value_expressionContext(_ctx, getState()); + enterRule(_localctx, 76, RULE_value_expression); + try { + setState(320); + switch (_input.LA(1)) { + case BOOLEAN_LITERAL: + case NUMBER_LITERAL: + case STRING_LITERAL: + enterOuterAlt(_localctx, 1); + { + setState(318); + literal(); + } + break; + case INPUT_VARIABLE: + enterOuterAlt(_localctx, 2); + { + setState(319); + match(INPUT_VARIABLE); + } + break; + default: + throw new NoViableAltException(this); + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static class LiteralContext extends ParserRuleContext { + public TerminalNode STRING_LITERAL() { + return getToken(EQLParser.STRING_LITERAL, 0); + } + + public TerminalNode BOOLEAN_LITERAL() { + return getToken(EQLParser.BOOLEAN_LITERAL, 0); + } + + public TerminalNode NUMBER_LITERAL() { + return getToken(EQLParser.NUMBER_LITERAL, 0); + } + + public LiteralContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override + public int getRuleIndex() { + return RULE_literal; + } + + @Override + public void enterRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).enterLiteral(this); + } + + @Override + public void exitRule(ParseTreeListener listener) { + if (listener instanceof EQLListener) ((EQLListener) listener).exitLiteral(this); + } + } + + public final LiteralContext literal() throws RecognitionException { + LiteralContext _localctx = new LiteralContext(_ctx, getState()); + enterRule(_localctx, 78, RULE_literal); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(322); + _la = _input.LA(1); + if (!(((((_la - 60)) & ~0x3f) == 0 && ((1L << (_la - 60)) & ((1L << (BOOLEAN_LITERAL - 60)) | (1L << (NUMBER_LITERAL - 60)) | (1L << (STRING_LITERAL - 60)))) != 0))) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + } catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3D\u0147\4\2\t\2\4" + + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t" + + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\3\2\5\2T\n\2\3" + + "\2\7\2W\n\2\f\2\16\2Z\13\2\3\2\5\2]\n\2\3\2\5\2`\n\2\3\2\5\2c\n\2\3\3" + + "\3\3\5\3g\n\3\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3\7" + + "\3\7\3\7\7\7y\n\7\f\7\16\7|\13\7\3\b\3\b\5\b\u0080\n\b\3\b\5\b\u0083\n" + + "\b\3\t\3\t\3\t\3\t\5\t\u0089\n\t\3\n\3\n\3\13\3\13\3\13\5\13\u0090\n\13" + + "\3\f\3\f\3\f\3\r\3\r\5\r\u0097\n\r\3\r\3\r\5\r\u009b\n\r\3\16\3\16\3\16" + + "\3\16\3\17\3\17\3\17\7\17\u00a4\n\17\f\17\16\17\u00a7\13\17\3\20\3\20" + + "\3\20\5\20\u00ac\n\20\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23\5\23\u00b6" + + "\n\23\3\24\3\24\5\24\u00ba\n\24\3\25\3\25\5\25\u00be\n\25\3\26\3\26\3" + + "\26\3\26\3\27\3\27\3\27\7\27\u00c7\n\27\f\27\16\27\u00ca\13\27\3\30\3" + + "\30\3\30\7\30\u00cf\n\30\f\30\16\30\u00d2\13\30\3\31\5\31\u00d5\n\31\3" + + "\31\3\31\3\32\3\32\3\32\3\32\3\32\5\32\u00de\n\32\3\33\3\33\3\33\3\33" + + "\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\5\33\u00ed\n\33\3\34\3\34" + + "\3\34\3\34\3\35\3\35\3\35\3\35\3\35\7\35\u00f8\n\35\f\35\16\35\u00fb\13" + + "\35\3\35\3\35\5\35\u00ff\n\35\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37" + + "\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \5 \u0112\n \3!\3!\3!\3!\3!\3!\3!\3" + + "!\5!\u011c\n!\3\"\3\"\3\"\3\"\3\"\5\"\u0123\n\"\3#\3#\3#\3#\3#\3#\3#\3" + + "#\5#\u012d\n#\3$\3$\3$\3$\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\5&\u013d\n&\3" + + "\'\3\'\3(\3(\5(\u0143\n(\3)\3)\3)\2\2*\2\4\6\b\n\f\16\20\22\24\26\30\32" + + "\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNP\2\6\3\2\16\17\3\2$+\3\2,;\4\2" + + ">?CC\u0148\2S\3\2\2\2\4d\3\2\2\2\6l\3\2\2\2\bn\3\2\2\2\np\3\2\2\2\fs\3" + + "\2\2\2\16}\3\2\2\2\20\u0088\3\2\2\2\22\u008a\3\2\2\2\24\u008c\3\2\2\2" + + "\26\u0091\3\2\2\2\30\u0094\3\2\2\2\32\u009c\3\2\2\2\34\u00a0\3\2\2\2\36" + + "\u00ab\3\2\2\2 \u00ad\3\2\2\2\"\u00b0\3\2\2\2$\u00b5\3\2\2\2&\u00b7\3" + + "\2\2\2(\u00bb\3\2\2\2*\u00bf\3\2\2\2,\u00c3\3\2\2\2.\u00cb\3\2\2\2\60" + + "\u00d4\3\2\2\2\62\u00dd\3\2\2\2\64\u00ec\3\2\2\2\66\u00ee\3\2\2\28\u00fe" + + "\3\2\2\2:\u0100\3\2\2\2<\u0106\3\2\2\2>\u0111\3\2\2\2@\u011b\3\2\2\2B" + + "\u0122\3\2\2\2D\u012c\3\2\2\2F\u012e\3\2\2\2H\u0132\3\2\2\2J\u013c\3\2" + + "\2\2L\u013e\3\2\2\2N\u0142\3\2\2\2P\u0144\3\2\2\2RT\5\4\3\2SR\3\2\2\2" + + "ST\3\2\2\2TX\3\2\2\2UW\5\b\5\2VU\3\2\2\2WZ\3\2\2\2XV\3\2\2\2XY\3\2\2\2" + + "Y\\\3\2\2\2ZX\3\2\2\2[]\5\n\6\2\\[\3\2\2\2\\]\3\2\2\2]_\3\2\2\2^`\5\f" + + "\7\2_^\3\2\2\2_`\3\2\2\2`b\3\2\2\2ac\5\24\13\2ba\3\2\2\2bc\3\2\2\2c\3" + + "\3\2\2\2df\7\3\2\2eg\5\6\4\2fe\3\2\2\2fg\3\2\2\2gh\3\2\2\2hi\7\4\2\2i" + + "j\5\34\17\2jk\7\5\2\2k\5\3\2\2\2lm\7\6\2\2m\7\3\2\2\2no\5\30\r\2o\t\3" + + "\2\2\2pq\7\7\2\2qr\5,\27\2r\13\3\2\2\2st\7\b\2\2tu\7\t\2\2uz\5\16\b\2" + + "vw\7\n\2\2wy\5\16\b\2xv\3\2\2\2y|\3\2\2\2zx\3\2\2\2z{\3\2\2\2{\r\3\2\2" + + "\2|z\3\2\2\2}\177\7=\2\2~\u0080\5\22\n\2\177~\3\2\2\2\177\u0080\3\2\2" + + "\2\u0080\u0082\3\2\2\2\u0081\u0083\5\20\t\2\u0082\u0081\3\2\2\2\u0082" + + "\u0083\3\2\2\2\u0083\17\3\2\2\2\u0084\u0085\7\13\2\2\u0085\u0089\7\f\2" + + "\2\u0086\u0087\7\13\2\2\u0087\u0089\7\r\2\2\u0088\u0084\3\2\2\2\u0088" + + "\u0086\3\2\2\2\u0089\21\3\2\2\2\u008a\u008b\t\2\2\2\u008b\23\3\2\2\2\u008c" + + "\u008d\7\20\2\2\u008d\u008f\7?\2\2\u008e\u0090\5\26\f\2\u008f\u008e\3" + + "\2\2\2\u008f\u0090\3\2\2\2\u0090\25\3\2\2\2\u0091\u0092\7\21\2\2\u0092" + + "\u0093\7?\2\2\u0093\27\3\2\2\2\u0094\u0096\7\22\2\2\u0095\u0097\5$\23" + + "\2\u0096\u0095\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\3\2\2\2\u0098\u009a" + + "\7=\2\2\u0099\u009b\5\32\16\2\u009a\u0099\3\2\2\2\u009a\u009b\3\2\2\2" + + "\u009b\31\3\2\2\2\u009c\u009d\7\4\2\2\u009d\u009e\5\34\17\2\u009e\u009f" + + "\7\5\2\2\u009f\33\3\2\2\2\u00a0\u00a5\5\36\20\2\u00a1\u00a2\7\n\2\2\u00a2" + + "\u00a4\5\36\20\2\u00a3\u00a1\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3" + + "\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\35\3\2\2\2\u00a7\u00a5\3\2\2\2\u00a8" + + "\u00ac\7=\2\2\u00a9\u00ac\5 \21\2\u00aa\u00ac\5\"\22\2\u00ab\u00a8\3\2" + + "\2\2\u00ab\u00a9\3\2\2\2\u00ab\u00aa\3\2\2\2\u00ac\37\3\2\2\2\u00ad\u00ae" + + "\7\23\2\2\u00ae\u00af\5&\24\2\u00af!\3\2\2\2\u00b0\u00b1\7\23\2\2\u00b1" + + "\u00b2\5(\25\2\u00b2#\3\2\2\2\u00b3\u00b6\5&\24\2\u00b4\u00b6\5(\25\2" + + "\u00b5\u00b3\3\2\2\2\u00b5\u00b4\3\2\2\2\u00b6%\3\2\2\2\u00b7\u00b9\7" + + "\24\2\2\u00b8\u00ba\5*\26\2\u00b9\u00b8\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba" + + "\'\3\2\2\2\u00bb\u00bd\7\25\2\2\u00bc\u00be\5*\26\2\u00bd\u00bc\3\2\2" + + "\2\u00bd\u00be\3\2\2\2\u00be)\3\2\2\2\u00bf\u00c0\7\4\2\2\u00c0\u00c1" + + "\7?\2\2\u00c1\u00c2\7\5\2\2\u00c2+\3\2\2\2\u00c3\u00c8\5.\30\2\u00c4\u00c5" + + "\7\26\2\2\u00c5\u00c7\5.\30\2\u00c6\u00c4\3\2\2\2\u00c7\u00ca\3\2\2\2" + + "\u00c8\u00c6\3\2\2\2\u00c8\u00c9\3\2\2\2\u00c9-\3\2\2\2\u00ca\u00c8\3" + + "\2\2\2\u00cb\u00d0\5\60\31\2\u00cc\u00cd\7\27\2\2\u00cd\u00cf\5\60\31" + + "\2\u00ce\u00cc\3\2\2\2\u00cf\u00d2\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d0\u00d1" + + "\3\2\2\2\u00d1/\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d3\u00d5\7\30\2\2\u00d4" + + "\u00d3\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d7\5\62" + + "\32\2\u00d7\61\3\2\2\2\u00d8\u00de\5\64\33\2\u00d9\u00da\7\4\2\2\u00da" + + "\u00db\5,\27\2\u00db\u00dc\7\5\2\2\u00dc\u00de\3\2\2\2\u00dd\u00d8\3\2" + + "\2\2\u00dd\u00d9\3\2\2\2\u00de\63\3\2\2\2\u00df\u00ed\5J&\2\u00e0\u00ed" + + "\5F$\2\u00e1\u00ed\5:\36\2\u00e2\u00ed\5<\37\2\u00e3\u00ed\5\66\34\2\u00e4" + + "\u00ed\5> \2\u00e5\u00ed\5@!\2\u00e6\u00ed\5B\"\2\u00e7\u00ed\5D#\2\u00e8" + + "\u00e9\7\4\2\2\u00e9\u00ea\5\64\33\2\u00ea\u00eb\7\5\2\2\u00eb\u00ed\3" + + "\2\2\2\u00ec\u00df\3\2\2\2\u00ec\u00e0\3\2\2\2\u00ec\u00e1\3\2\2\2\u00ec" + + "\u00e2\3\2\2\2\u00ec\u00e3\3\2\2\2\u00ec\u00e4\3\2\2\2\u00ec\u00e5\3\2" + + "\2\2\u00ec\u00e6\3\2\2\2\u00ec\u00e7\3\2\2\2\u00ec\u00e8\3\2\2\2\u00ed" + + "\65\3\2\2\2\u00ee\u00ef\7=\2\2\u00ef\u00f0\7\31\2\2\u00f0\u00f1\58\35" + + "\2\u00f1\67\3\2\2\2\u00f2\u00ff\7<\2\2\u00f3\u00f4\7\4\2\2\u00f4\u00f9" + + "\5N(\2\u00f5\u00f6\7\n\2\2\u00f6\u00f8\5N(\2\u00f7\u00f5\3\2\2\2\u00f8" + + "\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9\u00fa\3\2\2\2\u00fa\u00fc\3\2" + + "\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7\5\2\2\u00fd\u00ff\3\2\2\2\u00fe" + + "\u00f2\3\2\2\2\u00fe\u00f3\3\2\2\2\u00ff9\3\2\2\2\u0100\u0101\7=\2\2\u0101" + + "\u0102\7\32\2\2\u0102\u0103\5N(\2\u0103\u0104\7\27\2\2\u0104\u0105\5N" + + "(\2\u0105;\3\2\2\2\u0106\u0107\5N(\2\u0107\u0108\7\32\2\2\u0108\u0109" + + "\7=\2\2\u0109\u010a\7\27\2\2\u010a\u010b\7=\2\2\u010b=\3\2\2\2\u010c\u010d" + + "\7=\2\2\u010d\u010e\7\33\2\2\u010e\u0112\7\34\2\2\u010f\u0110\7=\2\2\u0110" + + "\u0112\7\35\2\2\u0111\u010c\3\2\2\2\u0111\u010f\3\2\2\2\u0112?\3\2\2\2" + + "\u0113\u0114\7=\2\2\u0114\u0115\7\33\2\2\u0115\u0116\7\30\2\2\u0116\u011c" + + "\7\34\2\2\u0117\u0118\7=\2\2\u0118\u011c\7\36\2\2\u0119\u011a\7=\2\2\u011a" + + "\u011c\7\37\2\2\u011b\u0113\3\2\2\2\u011b\u0117\3\2\2\2\u011b\u0119\3" + + "\2\2\2\u011cA\3\2\2\2\u011d\u011e\7=\2\2\u011e\u011f\7\33\2\2\u011f\u0123" + + "\7 \2\2\u0120\u0121\7=\2\2\u0121\u0123\7!\2\2\u0122\u011d\3\2\2\2\u0122" + + "\u0120\3\2\2\2\u0123C\3\2\2\2\u0124\u0125\7=\2\2\u0125\u0126\7\33\2\2" + + "\u0126\u0127\7\30\2\2\u0127\u012d\7 \2\2\u0128\u0129\7=\2\2\u0129\u012d" + + "\7\"\2\2\u012a\u012b\7=\2\2\u012b\u012d\7#\2\2\u012c\u0124\3\2\2\2\u012c" + + "\u0128\3\2\2\2\u012c\u012a\3\2\2\2\u012dE\3\2\2\2\u012e\u012f\7=\2\2\u012f" + + "\u0130\5H%\2\u0130\u0131\5N(\2\u0131G\3\2\2\2\u0132\u0133\t\3\2\2\u0133" + + "I\3\2\2\2\u0134\u0135\7=\2\2\u0135\u0136\5L\'\2\u0136\u0137\5N(\2\u0137" + + "\u013d\3\2\2\2\u0138\u0139\5N(\2\u0139\u013a\5L\'\2\u013a\u013b\7=\2\2" + + "\u013b\u013d\3\2\2\2\u013c\u0134\3\2\2\2\u013c\u0138\3\2\2\2\u013dK\3" + + "\2\2\2\u013e\u013f\t\4\2\2\u013fM\3\2\2\2\u0140\u0143\5P)\2\u0141\u0143" + + "\7<\2\2\u0142\u0140\3\2\2\2\u0142\u0141\3\2\2\2\u0143O\3\2\2\2\u0144\u0145" + + "\t\5\2\2\u0145Q\3\2\2\2!SX\\_bfz\177\u0082\u0088\u008f\u0096\u009a\u00a5" + + "\u00ab\u00b5\u00b9\u00bd\u00c8\u00d0\u00d4\u00dd\u00ec\u00f9\u00fe\u0111" + + "\u011b\u0122\u012c\u013c\u0142"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html b/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html index 6e97437be..90aa57569 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/idgen/package.html @@ -1,11 +1,11 @@ - - Id Generation + + Id Generation Id Generation (Sequences, UUIDGen etc) - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java index f420e59d2..0e45a8caf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonScheduleThreadPool.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.lib; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + /** * Daemon based ScheduleThreadPool. *

diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java index 70ca67fe5..63dc82944 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/DaemonThreadFactory.java @@ -15,35 +15,35 @@ import java.util.concurrent.atomic.AtomicInteger; * on shutdown or register with the JVM shutdown hook to perform a nice shutdown * of the daemon threads etc. *

- * + * * @author rbygrave */ public class DaemonThreadFactory implements ThreadFactory { - private static final AtomicInteger poolNumber = new AtomicInteger(1); - - private final ThreadGroup group; - - private final AtomicInteger threadNumber = new AtomicInteger(1); - - private final String namePrefix; + private static final AtomicInteger poolNumber = new AtomicInteger(1); - public DaemonThreadFactory(String namePrefix) { - SecurityManager s = System.getSecurityManager(); - this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); - this.namePrefix = namePrefix != null ? namePrefix : "pool-" + poolNumber.getAndIncrement() + "-thread-"; + private final ThreadGroup group; + + private final AtomicInteger threadNumber = new AtomicInteger(1); + + private final String namePrefix; + + public DaemonThreadFactory(String namePrefix) { + SecurityManager s = System.getSecurityManager(); + this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); + this.namePrefix = namePrefix != null ? namePrefix : "pool-" + poolNumber.getAndIncrement() + "-thread-"; + } + + public Thread newThread(Runnable r) { + + Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); + + t.setDaemon(true); + + if (t.getPriority() != Thread.NORM_PRIORITY) { + t.setPriority(Thread.NORM_PRIORITY); } - public Thread newThread(Runnable r) { - - Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); - - t.setDaemon(true); - - if (t.getPriority() != Thread.NORM_PRIORITY) { - t.setPriority(Thread.NORM_PRIORITY); - } - - return t; - } -} \ No newline at end of file + return t; + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java index 33f298554..892a36e9c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/ShutdownManager.java @@ -21,87 +21,87 @@ import java.util.List; */ public final class ShutdownManager { - private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); + private static final Logger logger = LoggerFactory.getLogger(ShutdownManager.class); - static final List servers = new ArrayList<>(); + static final List servers = new ArrayList<>(); - static final ShutdownHook shutdownHook = new ShutdownHook(); + static final ShutdownHook shutdownHook = new ShutdownHook(); - static boolean stopping; + static boolean stopping; - static SpiContainer container; + static SpiContainer container; - static { - // Register the Shutdown hook - registerShutdownHook(); - } + static { + // Register the Shutdown hook + registerShutdownHook(); + } - /** - * Disallow construction. - */ - private ShutdownManager() { - } + /** + * Disallow construction. + */ + private ShutdownManager() { + } - public static void registerContainer(SpiContainer ebeanContainer){ - container = ebeanContainer; - } - - /** - * Make sure the ShutdownManager is activated. - */ - public static void touch() { - // Do nothing - } + public static void registerContainer(SpiContainer ebeanContainer) { + container = ebeanContainer; + } - /** - * Return true if the system is in the process of stopping. - */ - public static boolean isStopping() { - synchronized (servers) { - return stopping; - } - } + /** + * Make sure the ShutdownManager is activated. + */ + public static void touch() { + // Do nothing + } - /** - * Deregister the Shutdown hook. + /** + * Return true if the system is in the process of stopping. + */ + public static boolean isStopping() { + synchronized (servers) { + return stopping; + } + } + + /** + * Deregister the Shutdown hook. *

* In calling this method it is expected that application code will invoke * the shutdown() method. *

- *

- * For running in a Servlet Container a redeploy will cause a shutdown, and - * for that case we need to make sure the shutdown hook is deregistered. - *

- */ - public static void deregisterShutdownHook() { - synchronized (servers) { - try { - Runtime.getRuntime().removeShutdownHook(shutdownHook); - } catch (IllegalStateException ex) { - if (!ex.getMessage().equals("Shutdown in progress")) { - throw ex; - } - } - } - } + *

+ * For running in a Servlet Container a redeploy will cause a shutdown, and + * for that case we need to make sure the shutdown hook is deregistered. + *

+ */ + public static void deregisterShutdownHook() { + synchronized (servers) { + try { + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } catch (IllegalStateException ex) { + if (!ex.getMessage().equals("Shutdown in progress")) { + throw ex; + } + } + } + } - /** - * Register the shutdown hook with the Runtime. - */ - protected static void registerShutdownHook() { - synchronized (servers) { - try { + /** + * Register the shutdown hook with the Runtime. + */ + protected static void registerShutdownHook() { + synchronized (servers) { + try { String value = System.getProperty("ebean.registerShutdownHook"); if (value == null || !value.trim().equalsIgnoreCase("false")) { Runtime.getRuntime().addShutdownHook(shutdownHook); } - } catch (IllegalStateException ex) { - if (!ex.getMessage().equals("Shutdown in progress")) { - throw ex; - } - } - } - } + } catch (IllegalStateException ex) { + if (!ex.getMessage().equals("Shutdown in progress")) { + throw ex; + } + } + } + } /** * Shutdown gracefully cleaning up any resources as required. @@ -134,7 +134,7 @@ public final class ShutdownManager { logger.error("Error running custom shutdown runnable", e); } } - + if (container != null) { // shutdown cluster networking if active container.shutdown(); @@ -150,10 +150,10 @@ public final class ShutdownManager { ex.printStackTrace(); } } - + if ("true".equalsIgnoreCase(System.getProperty("ebean.datasource.deregisterAllDrivers", "false"))) { deregisterAllJdbcDrivers(); - } + } } } @@ -163,29 +163,29 @@ public final class ShutdownManager { while (drivers.hasMoreElements()) { Driver driver = drivers.nextElement(); try { - logger.info("Deregistering jdbc driver: "+driver); + logger.info("Deregistering jdbc driver: " + driver); DriverManager.deregisterDriver(driver); } catch (SQLException e) { - logger.error("Error deregistering driver "+driver, e); + logger.error("Error deregistering driver " + driver, e); } } } - - /** - * Register an ebeanServer to be shutdown when the JVM is shutdown. - */ - public static void registerEbeanServer(SpiEbeanServer server) { - synchronized (servers) { - servers.add(server); - } - } - - /** - * Deregister an ebeanServer. - *

- * This is done when the ebeanServer is shutdown manually. - *

- */ + + /** + * Register an ebeanServer to be shutdown when the JVM is shutdown. + */ + public static void registerEbeanServer(SpiEbeanServer server) { + synchronized (servers) { + servers.add(server); + } + } + + /** + * Deregister an ebeanServer. + *

+ * This is done when the ebeanServer is shutdown manually. + *

+ */ public static void unregisterEbeanServer(SpiEbeanServer server) { synchronized (servers) { servers.remove(server); diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/package.html b/src/main/java/com/avaje/ebeaninternal/server/lib/package.html index 9055f2795..a114cce65 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/package.html @@ -1,13 +1,13 @@ - - AvajeLib + + AvajeLib Core services for an application.

-Core services including Logging, Deployment properties and Background thread for -running frequent tasks. + Core services including Logging, Deployment properties and Background thread for + running frequent tasks.

- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java index 78496bc23..6e7cfce48 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/Str.java @@ -10,7 +10,7 @@ public class Str { /** * Append strings together. */ - public static String add(String s0, String s1, String ... args) { + public static String add(String s0, String s1, String... args) { // determine a decent buffer size int len = 16 + s0.length() + s1.length(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java index 4e5b7667c..ca008eb7c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/StringHelper.java @@ -8,293 +8,285 @@ import java.util.Map; */ public class StringHelper { - /** - * Parses out a list of Name Value pairs that are delimited together. Will - * always return a StringMap. If allNameValuePairs is null, or no name - * values can be parsed out an empty StringMap is returned. - * - * @param allNameValuePairs - * the entire string to be parsed. - * @param listDelimiter - * (typically ';') the delimited between the list - * @param nameValueSeparator - * (typically '=') the separator between the name and value - */ - public static Map delimitedToMap(String allNameValuePairs, - String listDelimiter, String nameValueSeparator) { + /** + * Parses out a list of Name Value pairs that are delimited together. Will + * always return a StringMap. If allNameValuePairs is null, or no name + * values can be parsed out an empty StringMap is returned. + * + * @param allNameValuePairs the entire string to be parsed. + * @param listDelimiter (typically ';') the delimited between the list + * @param nameValueSeparator (typically '=') the separator between the name and value + */ + public static Map delimitedToMap(String allNameValuePairs, + String listDelimiter, String nameValueSeparator) { - HashMap params = new HashMap<>(); - if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { - return params; - } - // trim off any leading listDelimiter... - allNameValuePairs = trimFront(allNameValuePairs, listDelimiter); - return getKeyValue(params, 0, allNameValuePairs, listDelimiter, nameValueSeparator); - } + HashMap params = new HashMap<>(); + if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { + return params; + } + // trim off any leading listDelimiter... + allNameValuePairs = trimFront(allNameValuePairs, listDelimiter); + return getKeyValue(params, 0, allNameValuePairs, listDelimiter, nameValueSeparator); + } - /** - * Trims off recurring strings from the front of a string. - * - * @param source - * the source string - * @param trim - * the string to trim off the front - */ - public static String trimFront(String source, String trim) { - if (source == null) { - return null; - } - if (source.indexOf(trim) == 0) { - // dp("trim ..."); - return trimFront(source.substring(trim.length()), trim); - } else { - return source; - } - } + /** + * Trims off recurring strings from the front of a string. + * + * @param source the source string + * @param trim the string to trim off the front + */ + public static String trimFront(String source, String trim) { + if (source == null) { + return null; + } + if (source.indexOf(trim) == 0) { + // dp("trim ..."); + return trimFront(source.substring(trim.length()), trim); + } else { + return source; + } + } - /** - * Return true if the value is null or an empty string. - */ - public static boolean isNull(String value) { + /** + * Return true if the value is null or an empty string. + */ + public static boolean isNull(String value) { return value == null || value.trim().isEmpty(); } - /** - * Recursively pulls out the key value pairs from a raw string. - */ - private static HashMap getKeyValue(HashMap map, int pos, - String allNameValuePairs, String listDelimiter, String nameValueSeparator) { + /** + * Recursively pulls out the key value pairs from a raw string. + */ + private static HashMap getKeyValue(HashMap map, int pos, + String allNameValuePairs, String listDelimiter, String nameValueSeparator) { - if (pos >= allNameValuePairs.length()) { - // dp("end as "+pos+" >= "+allNameValuePairs.length() ); - return map; - } + if (pos >= allNameValuePairs.length()) { + // dp("end as "+pos+" >= "+allNameValuePairs.length() ); + return map; + } - int equalsPos = allNameValuePairs.indexOf(nameValueSeparator, pos); - int delimPos = allNameValuePairs.indexOf(listDelimiter, pos); + int equalsPos = allNameValuePairs.indexOf(nameValueSeparator, pos); + int delimPos = allNameValuePairs.indexOf(listDelimiter, pos); - if (delimPos == -1) { - delimPos = allNameValuePairs.length(); - } - if (equalsPos == -1) { - // dp("no more equals..."); - return map; - } - if (delimPos == (equalsPos + 1)) { - // dp("Ignoring as nothing between delim and equals... - // delim:"+delimPos+" eq:"+equalsPos); - return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); - } - if (equalsPos > delimPos) { - // there is a key without a value? - String key = allNameValuePairs.substring(pos, delimPos); - key = key.trim(); - if (!key.isEmpty()) { - map.put(key, null); - } - return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + if (delimPos == -1) { + delimPos = allNameValuePairs.length(); + } + if (equalsPos == -1) { + // dp("no more equals..."); + return map; + } + if (delimPos == (equalsPos + 1)) { + // dp("Ignoring as nothing between delim and equals... + // delim:"+delimPos+" eq:"+equalsPos); + return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, + nameValueSeparator); + } + if (equalsPos > delimPos) { + // there is a key without a value? + String key = allNameValuePairs.substring(pos, delimPos); + key = key.trim(); + if (!key.isEmpty()) { + map.put(key, null); + } + return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, + nameValueSeparator); - } - String key = allNameValuePairs.substring(pos, equalsPos); + } + String key = allNameValuePairs.substring(pos, equalsPos); - if (delimPos > -1) { - String value = allNameValuePairs.substring(equalsPos + 1, delimPos); - // dp("cont "+key+","+value+" pos:"+pos+" - // len:"+allNameValuePairs.length()); - key = key.trim(); + if (delimPos > -1) { + String value = allNameValuePairs.substring(equalsPos + 1, delimPos); + // dp("cont "+key+","+value+" pos:"+pos+" + // len:"+allNameValuePairs.length()); + key = key.trim(); - map.put(key, value); - pos = delimPos + 1; + map.put(key, value); + pos = delimPos + 1; - // recurse the rest of the values... - return getKeyValue(map, pos, allNameValuePairs, listDelimiter, nameValueSeparator); - } else { - // dp("ERROR: delimPos < 0 ???"); - return map; - } - } + // recurse the rest of the values... + return getKeyValue(map, pos, allNameValuePairs, listDelimiter, nameValueSeparator); + } else { + // dp("ERROR: delimPos < 0 ???"); + return map; + } + } - /** - * This method takes a String and will replace all occurrences of the match - * String with that of the replace String. - * - * @param source - * the source string - * @param match - * the string used to find a match - * @param replace - * the string used to replace match with - * @return the source string after the search and replace - */ - public static String replaceString(String source, String match, String replace) { - if (source == null){ - return null; - } - if (replace == null){ - return source; - } - if (match == null){ - throw new NullPointerException("match is null?"); - } - if (match.equals(replace)){ - return source; - } - return replaceString(source, match, replace, 30, 0, source.length()); - } + /** + * This method takes a String and will replace all occurrences of the match + * String with that of the replace String. + * + * @param source the source string + * @param match the string used to find a match + * @param replace the string used to replace match with + * @return the source string after the search and replace + */ + public static String replaceString(String source, String match, String replace) { + if (source == null) { + return null; + } + if (replace == null) { + return source; + } + if (match == null) { + throw new NullPointerException("match is null?"); + } + if (match.equals(replace)) { + return source; + } + return replaceString(source, match, replace, 30, 0, source.length()); + } - /** - * Additionally specify the additionalSize to add to the buffer. This will - * make the buffer bigger so that it doesn't have to grow when replacement - * occurs. - */ - public static String replaceString(String source, String match, String replace, - int additionalSize, int startPos, int endPos) { + /** + * Additionally specify the additionalSize to add to the buffer. This will + * make the buffer bigger so that it doesn't have to grow when replacement + * occurs. + */ + public static String replaceString(String source, String match, String replace, + int additionalSize, int startPos, int endPos) { - if (source == null){ - return null; - } - - char match0 = match.charAt(0); - - int matchLength = match.length(); + if (source == null) { + return null; + } - if (matchLength == 1 && replace.length() == 1) { - char replace0 = replace.charAt(0); - return source.replace(match0, replace0); - } - if (matchLength >= replace.length()) { - additionalSize = 0; - } + char match0 = match.charAt(0); + + int matchLength = match.length(); + + if (matchLength == 1 && replace.length() == 1) { + char replace0 = replace.charAt(0); + return source.replace(match0, replace0); + } + if (matchLength >= replace.length()) { + additionalSize = 0; + } - int sourceLength = source.length(); - int lastMatch = endPos - matchLength; + int sourceLength = source.length(); + int lastMatch = endPos - matchLength; - StringBuilder sb = new StringBuilder(sourceLength + additionalSize); + StringBuilder sb = new StringBuilder(sourceLength + additionalSize); - if (startPos > 0) { - sb.append(source.substring(0, startPos)); - } + if (startPos > 0) { + sb.append(source.substring(0, startPos)); + } - char sourceChar; - boolean isMatch; - int sourceMatchPos; + char sourceChar; + boolean isMatch; + int sourceMatchPos; - for (int i = startPos; i < sourceLength; i++) { - sourceChar = source.charAt(i); - if (i > lastMatch || sourceChar != match0) { - sb.append(sourceChar); + for (int i = startPos; i < sourceLength; i++) { + sourceChar = source.charAt(i); + if (i > lastMatch || sourceChar != match0) { + sb.append(sourceChar); - } else { - // check to see if this is a match - isMatch = true; - sourceMatchPos = i; - - // check each following character... - for (int j = 1; j < matchLength; j++) { - sourceMatchPos++; - if (source.charAt(sourceMatchPos) != match.charAt(j)) { - isMatch = false; - break; - } - } - if (isMatch) { - i = i + matchLength - 1; - sb.append(replace); - } else { - // was not a match - sb.append(sourceChar); - } - } - } + } else { + // check to see if this is a match + isMatch = true; + sourceMatchPos = i; - return sb.toString(); - } + // check each following character... + for (int j = 1; j < matchLength; j++) { + sourceMatchPos++; + if (source.charAt(sourceMatchPos) != match.charAt(j)) { + isMatch = false; + break; + } + } + if (isMatch) { + i = i + matchLength - 1; + sb.append(replace); + } else { + // was not a match + sb.append(sourceChar); + } + } + } - /** - * A search and replace with multiple matching strings. - *

- * Useful when converting CRNL CR and NL all to a BR tag for example. - *

- * - *

-	 * String[] multi = { "\r\n", "\r", "\n" };
-	 * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
-	 * 
- */ - public static String replaceStringMulti(String source, String[] match, String replace) { - return replaceStringMulti(source, match, replace, 30, 0, source.length()); - } + return sb.toString(); + } - /** - * Additionally specify an additional size estimate for the buffer plus - * start and end positions. - *

- * The start and end positions can limit the search and replace. Otherwise - * these default to startPos = 0 and endPos = source.length(). - *

- */ - public static String replaceStringMulti(String source, String[] match, String replace, - int additionalSize, int startPos, int endPos) { + /** + * A search and replace with multiple matching strings. + *

+ * Useful when converting CRNL CR and NL all to a BR tag for example. + *

+ *

+ *


+   * String[] multi = { "\r\n", "\r", "\n" };
+   * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
+   * 
+ */ + public static String replaceStringMulti(String source, String[] match, String replace) { + return replaceStringMulti(source, match, replace, 30, 0, source.length()); + } - int shortestMatch = match[0].length(); + /** + * Additionally specify an additional size estimate for the buffer plus + * start and end positions. + *

+ * The start and end positions can limit the search and replace. Otherwise + * these default to startPos = 0 and endPos = source.length(). + *

+ */ + public static String replaceStringMulti(String source, String[] match, String replace, + int additionalSize, int startPos, int endPos) { - char[] match0 = new char[match.length]; - for (int i = 0; i < match0.length; i++) { - match0[i] = match[i].charAt(0); - if (match[i].length() < shortestMatch) { - shortestMatch = match[i].length(); - } - } + int shortestMatch = match[0].length(); - StringBuilder sb = new StringBuilder(source.length() + additionalSize); + char[] match0 = new char[match.length]; + for (int i = 0; i < match0.length; i++) { + match0[i] = match[i].charAt(0); + if (match[i].length() < shortestMatch) { + shortestMatch = match[i].length(); + } + } - char sourceChar; + StringBuilder sb = new StringBuilder(source.length() + additionalSize); - int len = source.length(); - int lastMatch = endPos - shortestMatch; + char sourceChar; - if (startPos > 0) { - sb.append(source.substring(0, startPos)); - } + int len = source.length(); + int lastMatch = endPos - shortestMatch; - int matchCount; + if (startPos > 0) { + sb.append(source.substring(0, startPos)); + } - for (int i = startPos; i < len; i++) { - sourceChar = source.charAt(i); - if (i > lastMatch) { - sb.append(sourceChar); - } else { - matchCount = 0; - for (int k = 0; k < match0.length; k++) { - if (matchCount == 0 && sourceChar == match0[k]) { - if (match[k].length() + i <= len) { + int matchCount; - ++matchCount; - int j = 1; - for (; j < match[k].length(); j++) { - if (source.charAt(i + j) != match[k].charAt(j)) { - --matchCount; - break; - } - } - if (matchCount > 0) { - i = i + j - 1; - sb.append(replace); - break; - } - } - } - } - if (matchCount == 0) { - sb.append(sourceChar); - } - } - } + for (int i = startPos; i < len; i++) { + sourceChar = source.charAt(i); + if (i > lastMatch) { + sb.append(sourceChar); + } else { + matchCount = 0; + for (int k = 0; k < match0.length; k++) { + if (matchCount == 0 && sourceChar == match0[k]) { + if (match[k].length() + i <= len) { - return sb.toString(); - } + ++matchCount; + int j = 1; + for (; j < match[k].length(); j++) { + if (source.charAt(i + j) != match[k].charAt(j)) { + --matchCount; + break; + } + } + if (matchCount > 0) { + i = i + j - 1; + sb.append(replace); + break; + } + } + } + } + if (matchCount == 0) { + sb.append(sourceChar); + } + } + } + + return sb.toString(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html b/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html index 5079d4e5b..4f128ef71 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/util/package.html @@ -1,7 +1,7 @@ - - AvajeLib + + AvajeLib General utility objects. @@ -9,4 +9,4 @@ General utility objects.

Provides general utility objects.

- \ No newline at end of file + From 5cf9d1423707a7ad653480ff69a2450a82013e41 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:21:17 +1300 Subject: [PATCH 71/87] no effective change - format only --- .../server/core/BasicTypeConverter.java | 2 +- .../core/CObjectGraphNodeStatistics.java | 8 +- .../server/core/DatabasePlatformFactory.java | 52 ++-- .../core/DefaultBackgroundExecutor.java | 38 +-- .../server/core/DefaultCallableSql.java | 8 +- .../server/core/DefaultContainer.java | 6 +- .../server/core/DefaultMetaInfoManager.java | 24 +- .../server/core/DefaultServer.java | 98 ++++-- .../server/core/DefaultSqlUpdate.java | 291 +++++++----------- .../ebeaninternal/server/core/DiffHelp.java | 6 +- .../server/core/InternString.java | 48 +-- .../ebeaninternal/server/core/Message.java | 90 +++--- .../server/core/PersistRequest.java | 128 ++++---- .../server/core/PersistRequestBean.java | 1 + .../core/PersistRequestCallableSql.java | 193 ++++++------ .../server/core/PersistRequestOrmUpdate.java | 164 +++++----- .../ebeaninternal/server/core/Persister.java | 6 +- .../server/core/RelationalQueryRequest.java | 3 +- .../server/core/ServletContextListener.java | 25 +- .../server/core/TransWrapper.java | 58 ++-- .../core/bootup/BootupClassPathSearch.java | 3 +- .../server/core/bootup/ManifestReader.java | 4 +- .../ebeaninternal/server/core/package.html | 6 +- .../core/timezone/CloneDataTimeZone.java | 2 +- .../ebeaninternal/server/el/ElFilter.java | 6 +- .../server/el/ElMatchBuilder.java | 2 +- 26 files changed, 623 insertions(+), 649 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java b/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java index d98ad3f65..fa83a4764 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/BasicTypeConverter.java @@ -151,7 +151,7 @@ public final class BasicTypeConverter implements Serializable { return (Boolean) value; } if (value instanceof Number) { - return ((Number)value).intValue() == 1; + return ((Number) value).intValue() == 1; } String s = value.toString(); return s.equalsIgnoreCase(dbTrueValue); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java b/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java index 96fe96d6a..41349515d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/CObjectGraphNodeStatistics.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.core; +import com.avaje.ebean.bean.ObjectGraphNode; +import com.avaje.ebean.meta.MetaObjectGraphNodeStats; + import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.LongAdder; -import com.avaje.ebean.meta.*; -import com.avaje.ebean.bean.ObjectGraphNode; - /** * Helper to collect the query execution statistics for a given node. */ @@ -34,7 +34,7 @@ public class CObjectGraphNodeStatistics { public MetaObjectGraphNodeStats get(boolean reset) { if (reset) { return new Snapshot(node, startTime.getAndSet(System.currentTimeMillis()), count.sumThenReset(), - totalTime.sumThenReset(), totalBeans.sumThenReset()); + totalTime.sumThenReset(), totalBeans.sumThenReset()); } else { return new Snapshot(node, startTime.get(), count.sum(), totalTime.sum(), totalBeans.sum()); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java b/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java index 49c5cac20..d882208b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -1,18 +1,28 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.config.ServerConfig; -import com.avaje.ebean.config.dbplatform.*; +import com.avaje.ebean.config.dbplatform.DB2Platform; +import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import com.avaje.ebean.config.dbplatform.H2Platform; +import com.avaje.ebean.config.dbplatform.HsqldbPlatform; +import com.avaje.ebean.config.dbplatform.MsSqlServer2000Platform; +import com.avaje.ebean.config.dbplatform.MsSqlServer2005Platform; +import com.avaje.ebean.config.dbplatform.MySqlPlatform; +import com.avaje.ebean.config.dbplatform.OraclePlatform; +import com.avaje.ebean.config.dbplatform.Postgres8Platform; +import com.avaje.ebean.config.dbplatform.PostgresPlatform; +import com.avaje.ebean.config.dbplatform.SQLitePlatform; +import com.avaje.ebean.config.dbplatform.SqlAnywherePlatform; import com.avaje.ebean.dbmigration.DbOffline; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; + /** * Create a DatabasePlatform from the configuration. *

@@ -135,37 +145,29 @@ public class DatabasePlatformFactory { if (dbProductName.contains("oracle")) { return new OraclePlatform(); - } - else if (dbProductName.contains("microsoft")) { + } else if (dbProductName.contains("microsoft")) { if (majorVersion > 8) { return new MsSqlServer2005Platform(); } else { return new MsSqlServer2000Platform(); } - } - else if (dbProductName.contains("mysql")) { + } else if (dbProductName.contains("mysql")) { return new MySqlPlatform(); - } - else if (dbProductName.contains("h2")) { + } else if (dbProductName.contains("h2")) { return new H2Platform(); - } - else if (dbProductName.contains("hsql database engine")) { + } else if (dbProductName.contains("hsql database engine")) { return new HsqldbPlatform(); - } - else if (dbProductName.contains("postgres")) { + } else if (dbProductName.contains("postgres")) { return new PostgresPlatform(); - } - else if (dbProductName.contains("sqlite")) { + } else if (dbProductName.contains("sqlite")) { return new SQLitePlatform(); - } - else if (dbProductName.contains("db2")) { + } else if (dbProductName.contains("db2")) { return new DB2Platform(); - } - else if (dbProductName.contains("sql anywhere")) { + } else if (dbProductName.contains("sql anywhere")) { return new SqlAnywherePlatform(); } - // use the standard one + // use the standard one return new DatabasePlatform(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java index e71bc42ef..f32a3d512 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutor.java @@ -11,32 +11,32 @@ import java.util.concurrent.TimeUnit; */ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor { - private final DaemonScheduleThreadPool schedulePool; + private final DaemonScheduleThreadPool schedulePool; private final DaemonExecutorService pool; /** * Construct the default implementation of BackgroundExecutor. */ - public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) { - this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); - this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix+"-periodic-"); - } + public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) { + this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); + this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-"); + } - /** - * Execute a Runnable using a background thread. - */ - public void execute(Runnable r) { - pool.execute(r); - } + /** + * Execute a Runnable using a background thread. + */ + public void execute(Runnable r) { + pool.execute(r); + } - public void executePeriodically(Runnable r, long delay, TimeUnit unit) { - schedulePool.scheduleWithFixedDelay(r, delay, delay, unit); - } + public void executePeriodically(Runnable r, long delay, TimeUnit unit) { + schedulePool.scheduleWithFixedDelay(r, delay, delay, unit); + } + + public void shutdown() { + pool.shutdown(); + schedulePool.shutdown(); + } - public void shutdown() { - pool.shutdown(); - schedulePool.shutdown(); - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java index 85090eb8e..f74b340b6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultCallableSql.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.io.Serializable; -import java.sql.CallableStatement; -import java.sql.SQLException; - import com.avaje.ebean.CallableSql; import com.avaje.ebean.EbeanServer; import com.avaje.ebeaninternal.api.BindParams; @@ -11,6 +7,10 @@ import com.avaje.ebeaninternal.api.BindParams.Param; import com.avaje.ebeaninternal.api.SpiCallableSql; import com.avaje.ebeaninternal.api.TransactionEventTable; +import java.io.Serializable; +import java.sql.CallableStatement; +import java.sql.SQLException; + public class DefaultCallableSql implements Serializable, SpiCallableSql { diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java index e6c9df9dd..87f4a610e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java @@ -14,8 +14,8 @@ import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebean.dbmigration.DbOffline; import com.avaje.ebeaninternal.api.SpiBackgroundExecutor; import com.avaje.ebeaninternal.api.SpiEbeanServer; -import com.avaje.ebeaninternal.server.cache.DefaultServerCachePlugin; import com.avaje.ebeaninternal.server.cache.DefaultServerCacheManager; +import com.avaje.ebeaninternal.server.cache.DefaultServerCachePlugin; import com.avaje.ebeaninternal.server.cluster.ClusterManager; import com.avaje.ebeaninternal.server.core.bootup.BootupClassPathSearch; import com.avaje.ebeaninternal.server.core.bootup.BootupClasses; @@ -286,7 +286,7 @@ public class DefaultContainer implements SpiContainer { DataSourceFactory factory = config.service(DataSourceFactory.class); if (factory == null) { throw new IllegalStateException("No DataSourceFactory service implementation found in class path." - + " Probably missing dependency to avaje-datasource?"); + + " Probably missing dependency to avaje-datasource?"); } DataSourceAlertFactory alertFactory = config.service(DataSourceAlertFactory.class); @@ -306,7 +306,7 @@ public class DefaultContainer implements SpiContainer { if (dsConfig.getListener() == null) { String poolListener = dsConfig.getPoolListener(); if (poolListener != null) { - dsConfig.setListener((DataSourcePoolListener)config.getClassLoadConfig().newInstance(poolListener)); + dsConfig.setListener((DataSourcePoolListener) config.getClassLoadConfig().newInstance(poolListener)); } } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java index 1e4200c7e..b0f7e9bf0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultMetaInfoManager.java @@ -1,24 +1,24 @@ package com.avaje.ebeaninternal.server.core; +import com.avaje.ebean.meta.MetaBeanInfo; +import com.avaje.ebean.meta.MetaInfoManager; +import com.avaje.ebean.meta.MetaObjectGraphNodeStats; +import com.avaje.ebean.meta.MetaQueryPlanStatistic; + import java.util.ArrayList; import java.util.List; -import com.avaje.ebean.meta.MetaBeanInfo; -import com.avaje.ebean.meta.MetaQueryPlanStatistic; -import com.avaje.ebean.meta.MetaInfoManager; -import com.avaje.ebean.meta.MetaObjectGraphNodeStats; - /** * DefaultServer based implementation of MetaInfoManager. */ public class DefaultMetaInfoManager implements MetaInfoManager { private final DefaultServer server; - + public DefaultMetaInfoManager(DefaultServer server) { this.server = server; } - + @Override public MetaBeanInfo getMetaBeanInfo(Class beanClass) { return server.getBeanDescriptor(beanClass); @@ -32,16 +32,14 @@ public class DefaultMetaInfoManager implements MetaInfoManager { @Override public List collectQueryPlanStatistics(boolean reset) { - + List list = new ArrayList<>(); - for (MetaBeanInfo metaBeanInfo : getMetaBeanInfoList()) { list.addAll(metaBeanInfo.collectQueryPlanStatistics(reset)); } - - return list; + return list; } - + public List collectNodeStatistics(boolean reset) { List list = new ArrayList<>(); @@ -55,5 +53,5 @@ public class DefaultMetaInfoManager implements MetaInfoManager { } return list; } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 76c3cb0b8..5b82a9fcd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -1,6 +1,36 @@ package com.avaje.ebeaninternal.server.core; -import com.avaje.ebean.*; +import com.avaje.ebean.AutoTune; +import com.avaje.ebean.BackgroundExecutor; +import com.avaje.ebean.BeanState; +import com.avaje.ebean.CallableSql; +import com.avaje.ebean.DocumentStore; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.Filter; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.SqlQuery; +import com.avaje.ebean.SqlRow; +import com.avaje.ebean.SqlUpdate; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TransactionCallback; +import com.avaje.ebean.TxCallable; +import com.avaje.ebean.TxIsolation; +import com.avaje.ebean.TxRunnable; +import com.avaje.ebean.TxScope; +import com.avaje.ebean.TxType; +import com.avaje.ebean.Update; +import com.avaje.ebean.UpdateQuery; +import com.avaje.ebean.ValuePair; +import com.avaje.ebean.Version; import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.CallStack; import com.avaje.ebean.bean.EntityBean; @@ -538,7 +568,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { * then it will returned that object. *

*/ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public T getReference(Class type, Object id) { if (id == null) { @@ -554,13 +584,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { pc = t.getPersistenceContext(); Object existing = desc.contextGet(pc, id); if (existing != null) { - return (T)existing; + return (T) existing; } } InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo == null) { - return (T)desc.contextRef(pc, null, false, id); + return (T) desc.contextRef(pc, null, false, id); } BeanProperty idProp = desc.getIdProperty(); @@ -652,32 +682,32 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { TxType type = scope.getType(); switch (type) { - case REQUIRED: - return t == null; + case REQUIRED: + return t == null; - case REQUIRES_NEW: - return true; + case REQUIRES_NEW: + return true; - case MANDATORY: - if (t == null) { - throw new PersistenceException("Transaction missing when MANDATORY"); - } - return true; + case MANDATORY: + if (t == null) { + throw new PersistenceException("Transaction missing when MANDATORY"); + } + return true; - case NEVER: - if (t != null) { - throw new PersistenceException("Transaction exists for Transactional NEVER"); - } - return false; + case NEVER: + if (t != null) { + throw new PersistenceException("Transaction exists for Transactional NEVER"); + } + return false; - case SUPPORTS: - return false; + case SUPPORTS: + return false; - case NOT_SUPPORTED: - throw new RuntimeException("NOT_SUPPORTED should already be handled?"); + case NOT_SUPPORTED: + throw new RuntimeException("NOT_SUPPORTED should already be handled?"); - default: - throw new RuntimeException("Should never get here?"); + default: + throw new RuntimeException("Should never get here?"); } } @@ -798,7 +828,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { *

*

* Code example:
- * + *

*

    * <code>
    * Ebean.startTransaction();
@@ -814,7 +844,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
    * }
    * </code>
    * 
- * + *

*

*/ public void endTransaction() { @@ -862,7 +892,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (beanDescriptor == null) { throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?"); } - return ((SpiQuery)query).validate(beanDescriptor); + return ((SpiQuery) query).validate(beanDescriptor); } public Filter filter(Class beanType) { @@ -1056,7 +1086,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { if (SpiQuery.Mode.NORMAL.equals(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()); + T bean = findIdCheckPersistenceContextAndCache(t, spiQuery, spiQuery.getId()); if (bean != null) { return bean; } @@ -1116,7 +1146,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Set findSet(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.SET, query, t); @@ -1135,7 +1165,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public Map findMap(Query query, Transaction t) { SpiOrmQueryRequest request = createQueryRequest(Type.MAP, query, t); @@ -1293,7 +1323,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { @Override public PagedList findPagedList(Query query, Transaction transaction) { - SpiQuery spiQuery = (SpiQuery)query; + SpiQuery spiQuery = (SpiQuery) query; int maxRows = spiQuery.getMaxRows(); if (maxRows == 0) { throw new PersistenceException("maxRows must be specified for findPagedList() query"); @@ -1445,7 +1475,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException("This bean is not an EntityBean?"); } // mark the bean as dirty (so that an update will not get skipped) - ((EntityBean)bean)._ebean_getIntercept().setDirty(true); + ((EntityBean) bean)._ebean_getIntercept().setDirty(true); } /** @@ -1617,9 +1647,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { throw new IllegalArgumentException(Message.msg("bean.isnull")); } if (!(bean instanceof EntityBean)) { - throw new IllegalArgumentException("Was expecting an EntityBean but got a "+bean.getClass()); + throw new IllegalArgumentException("Was expecting an EntityBean but got a " + bean.getClass()); } - return (EntityBean)bean; + return (EntityBean) bean; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java index 98357e1bc..66c025526 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultSqlUpdate.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.io.Serializable; - import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.SqlUpdate; @@ -9,6 +7,8 @@ import com.avaje.ebean.Update; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.SpiSqlUpdate; +import java.io.Serializable; + /** * A SQL Update Delete or Insert statement that can be executed. For the times * when you want to use Sql DML rather than a ORM bean approach. Refer to the @@ -21,159 +21,104 @@ import com.avaje.ebeaninternal.api.SpiSqlUpdate; * SqlUpdate is designed for general DML sql and CallableSql is * designed for use with stored procedures. *

- * - *
- * // String sql = "update f_topic set post_count = :count where id = :topicId";
- * 
- * SqlUpdate update = new SqlUpdate(sql);
- * update.setParameter("count", 1);
- * update.setParameter("topicId", 50);
- * 
- * int modifiedCount = Ebean.execute(update);
- * 
- * - *

- * Note that when the SqlUpdate is executed via Ebean.execute() the sql is - * parsed to determine if it is an update, delete or insert. In addition the - * table modified is deduced. If isAutoTableMod() is true, then this - * is then added to the TransactionEvent and cache invalidation etc is - * maintained. This means you don't need to use the Ebean.externalModification() - * method as this has already been done. - *

- *

- * You can sql.setAutoTableMod(false); to stop the automatic table modification - *

- *

- * EXAMPLE: Using JDBC batching with SqlUpdate - *

- *
- * 
- * String data = "This is a simple test of the batch processing"
- * 		+ " mode and the transaction execute batch method";
- * 
- * String[] da = data.split(" ");
- * 
- * String sql = "insert into junk (word) values (?)";
- * 
- * SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
- * 
- * Transaction t = Ebean.beginTransaction();
- * t.setBatchMode(true);
- * t.setBatchSize(3);
- * try {
- * 	for (int i = 0; i < da.length; i++) {
- * 
- * 		sqlUpdate.setParameter(1, da[i]);
- * 		sqlUpdate.execute();
- * 	}
- * 
- * 	// NB: commit implicitly flushes the batch 
- * 	Ebean.commitTransaction();
- * 
- * } finally {
- * 	Ebean.endTransaction();
- * }
- * 
- * @see com.avaje.ebean.CallableSql - * @see com.avaje.ebean.Ebean#execute(SqlUpdate) */ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate { - private static final long serialVersionUID = -6493829438421253102L; + private static final long serialVersionUID = -6493829438421253102L; - private transient final EbeanServer server; + private transient final EbeanServer server; - /** - * The parameters used to bind to the sql. - */ - private final BindParams bindParams; + /** + * The parameters used to bind to the sql. + */ + private final BindParams bindParams; - /** - * The sql update or delete statement. - */ - private final String sql; + /** + * The sql update or delete statement. + */ + private final String sql; /** * The actual sql with named parameters converted. */ private String generatedSql; - /** - * Some descriptive text that can be put into the transaction log. - */ - private String label = ""; + /** + * Some descriptive text that can be put into the transaction log. + */ + private String label = ""; - /** - * The statement execution timeout. - */ - private int timeout; + /** + * The statement execution timeout. + */ + private int timeout; - /** - * Automatically detect the table being modified by this sql. This will - * register this information so that eBean invalidates cached objects if - * required. - */ - private boolean isAutoTableMod = true; + /** + * Automatically detect the table being modified by this sql. This will + * register this information so that eBean invalidates cached objects if + * required. + */ + private boolean isAutoTableMod = true; - /** - * Helper to add positioned parameters in order. - */ - private int addPos; + /** + * Helper to add positioned parameters in order. + */ + private int addPos; - /** - * Create with server sql and bindParams object. - *

- * Useful if you are building the sql and binding parameters at the - * same time. - *

- */ - public DefaultSqlUpdate(EbeanServer server, String sql, BindParams bindParams) { - this.server = server; - this.sql = sql; - this.bindParams = bindParams; - } - - /** - * Create with a specific server. This means you can use the - * SqlUpdate.execute() method. - */ - public DefaultSqlUpdate(EbeanServer server, String sql) { - this(server, sql, new BindParams()); - } + /** + * Create with server sql and bindParams object. + *

+ * Useful if you are building the sql and binding parameters at the + * same time. + *

+ */ + public DefaultSqlUpdate(EbeanServer server, String sql, BindParams bindParams) { + this.server = server; + this.sql = sql; + this.bindParams = bindParams; + } - /** - * Create with some sql. - */ - public DefaultSqlUpdate(String sql) { - this(null, sql, new BindParams()); - } + /** + * Create with a specific server. This means you can use the + * SqlUpdate.execute() method. + */ + public DefaultSqlUpdate(EbeanServer server, String sql) { + this(server, sql, new BindParams()); + } - public int execute() { - if (server != null) { - return server.execute(this); - } else { - // Hopefully this doesn't catch anyone out... - return Ebean.execute(this); - } - } + /** + * Create with some sql. + */ + public DefaultSqlUpdate(String sql) { + this(null, sql, new BindParams()); + } - public boolean isAutoTableMod() { - return isAutoTableMod; - } + public int execute() { + if (server != null) { + return server.execute(this); + } else { + // Hopefully this doesn't catch anyone out... + return Ebean.execute(this); + } + } - public SqlUpdate setAutoTableMod(boolean isAutoTableMod) { - this.isAutoTableMod = isAutoTableMod; - return this; - } + public boolean isAutoTableMod() { + return isAutoTableMod; + } - public String getLabel() { - return label; - } + public SqlUpdate setAutoTableMod(boolean isAutoTableMod) { + this.isAutoTableMod = isAutoTableMod; + return this; + } - public SqlUpdate setLabel(String label) { - this.label = label; - return this; - } + public String getLabel() { + return label; + } + + public SqlUpdate setLabel(String label) { + this.label = label; + return this; + } public String getGeneratedSql() { return generatedSql; @@ -185,57 +130,57 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate { } public String getSql() { - return sql; - } + return sql; + } - public int getTimeout() { - return timeout; - } + public int getTimeout() { + return timeout; + } - public SqlUpdate setTimeout(int secs) { - this.timeout = secs; - return this; - } + public SqlUpdate setTimeout(int secs) { + this.timeout = secs; + return this; + } public void addParameter(Object value) { setParameter(++addPos, value); } - - public SqlUpdate setParameter(int position, Object value) { - bindParams.setParameter(position, value); - return this; - } - public SqlUpdate setNull(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public SqlUpdate setParameter(int position, Object value) { + bindParams.setParameter(position, value); + return this; + } - public SqlUpdate setNullParameter(int position, int jdbcType) { - bindParams.setNullParameter(position, jdbcType); - return this; - } + public SqlUpdate setNull(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } - public SqlUpdate setParameter(String name, Object param) { - bindParams.setParameter(name, param); - return this; - } + public SqlUpdate setNullParameter(int position, int jdbcType) { + bindParams.setNullParameter(position, jdbcType); + return this; + } - public SqlUpdate setNull(String name, int jdbcType) { - bindParams.setNullParameter(name, jdbcType); - return this; - } + public SqlUpdate setParameter(String name, Object param) { + bindParams.setParameter(name, param); + return this; + } - public SqlUpdate setNullParameter(String name, int jdbcType) { - bindParams.setNullParameter(name, jdbcType); - return this; - } + public SqlUpdate setNull(String name, int jdbcType) { + bindParams.setNullParameter(name, jdbcType); + return this; + } - /** - * Return the bind parameters. - */ - public BindParams getBindParams() { - return bindParams; - } + public SqlUpdate setNullParameter(String name, int jdbcType) { + bindParams.setNullParameter(name, jdbcType); + return this; + } + + /** + * Return the bind parameters. + */ + public BindParams getBindParams() { + return bindParams; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java index 6a237d323..0a0535dd5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DiffHelp.java @@ -71,7 +71,7 @@ public class DiffHelp { iterator.remove(); } else if (beanProperty instanceof BeanPropertyAssocOne) { - BeanPropertyAssocOne assoc = (BeanPropertyAssocOne)beanProperty; + BeanPropertyAssocOne assoc = (BeanPropertyAssocOne) beanProperty; if (!assoc.isEmbedded()) { // flatten for assoc one beans if (flattened == null) { @@ -95,8 +95,8 @@ public class DiffHelp { BeanDescriptor oneDesc = assoc.getTargetDescriptor(); ValuePair value = entry.getValue(); - Object newId = value.getNewValue() == null ? null : oneDesc.getId((EntityBean)value.getNewValue()); - Object oldId = value.getOldValue() == null ? null : oneDesc.getId((EntityBean)value.getOldValue()); + Object newId = value.getNewValue() == null ? null : oneDesc.getId((EntityBean) value.getNewValue()); + Object oldId = value.getOldValue() == null ? null : oneDesc.getId((EntityBean) value.getOldValue()); String propName = beanProperty.getName() + "." + oneDesc.getIdProperty().getName(); flattened.put(propName, new ValuePair(newId, oldId)); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java index f8d6b332a..5bdcb71f0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/InternString.java @@ -5,33 +5,33 @@ import java.util.HashMap; /** * Used to reduce memory consumption of strings used in deployment processing. *

- * Using this for now instead of String.intern() to avoid any unexpected + * Using this for now instead of String.intern() to avoid any unexpected * increase in PermGen space. *

*/ public final class InternString { - private static final HashMap map = new HashMap<>(); - - - /** - * Return the shared instance of this string. - */ - public static String intern(String s){ - - if (s == null){ - return null; - } - - synchronized (map) { - String v = map.get(s); - if (v != null){ - return v; - } else { - map.put(s, s); - return s; - } - - } - } + private static final HashMap map = new HashMap<>(); + + + /** + * Return the shared instance of this string. + */ + public static String intern(String s) { + + if (s == null) { + return null; + } + + synchronized (map) { + String v = map.get(s); + if (v != null) { + return v; + } else { + map.put(s, s); + return s; + } + + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/Message.java b/src/main/java/com/avaje/ebeaninternal/server/core/Message.java index b129864b9..d0f1edd84 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/Message.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/Message.java @@ -9,56 +9,56 @@ import java.util.ResourceBundle; */ public class Message { - private static final String bundle = "com.avaje.ebeaninternal.api.message"; + private static final String bundle = "com.avaje.ebeaninternal.api.message"; - /** - * Return a message that has a single argument. - */ - public static String msg(String key, Object arg) { - Object[] args = new Object[1]; - args[0] = arg; - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has a single argument. + */ + public static String msg(String key, Object arg) { + Object[] args = new Object[1]; + args[0] = arg; + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has a two arguments. - */ - public static String msg(String key, Object arg, Object arg2) { - Object[] args = new Object[2]; - args[0] = arg; - args[1] = arg2; - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has a two arguments. + */ + public static String msg(String key, Object arg, Object arg2) { + Object[] args = new Object[2]; + args[0] = arg; + args[1] = arg2; + return MessageFormat.format(getPattern(key), args); + } - public static String msg(String key, Object arg, Object arg2, Object arg3) { - Object[] args = new Object[3]; - args[0] = arg; - args[1] = arg2; - args[2] = arg3; - return MessageFormat.format(getPattern(key), args); - } + public static String msg(String key, Object arg, Object arg2, Object arg3) { + Object[] args = new Object[3]; + args[0] = arg; + args[1] = arg2; + args[2] = arg3; + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has an array of arguments. - */ - public static String msg(String key, Object[] args) { - return MessageFormat.format(getPattern(key), args); - } + /** + * Return a message that has an array of arguments. + */ + public static String msg(String key, Object[] args) { + return MessageFormat.format(getPattern(key), args); + } - /** - * Return a message that has a no arguments. - */ - public static String msg(String key) { - return MessageFormat.format(getPattern(key), new Object[0]); - } + /** + * Return a message that has a no arguments. + */ + public static String msg(String key) { + return MessageFormat.format(getPattern(key), new Object[0]); + } - private static String getPattern(String key) { - try { - ResourceBundle myResources = ResourceBundle.getBundle(bundle); - return myResources.getString(key); - } catch (MissingResourceException e) { - return "MissingResource " + bundle + ":" + key; - } + private static String getPattern(String key) { + try { + ResourceBundle myResources = ResourceBundle.getBundle(bundle); + return myResources.getString(key); + } catch (MissingResourceException e) { + return "MissingResource " + bundle + ":" + key; } - + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java index faa8d432b..17d9618b4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequest.java @@ -11,36 +11,36 @@ import com.avaje.ebeaninternal.server.persist.PersistExecute; */ public abstract class PersistRequest extends BeanRequest implements BatchPostExecute { - public enum Type { - INSERT, UPDATE, DELETE, SOFT_DELETE, DELETE_PERMANENT, UPDATESQL, CALLABLESQL - } + public enum Type { + INSERT, UPDATE, DELETE, SOFT_DELETE, DELETE_PERMANENT, UPDATESQL, CALLABLESQL + } - protected boolean persistCascade; - - /** - * One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL. - */ - protected Type type; - - protected final PersistExecute persistExecute; + protected boolean persistCascade; /** - * Used by CallableSqlRequest and UpdateSqlRequest. - */ - public PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) { - super(server, t); - this.persistExecute = persistExecute; - } - - /** - * Execute a the request or queue/batch it for later execution. - */ - public abstract int executeOrQueue(); + * One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL. + */ + protected Type type; - /** - * Execute the request right now. - */ - public abstract int executeNow(); + protected final PersistExecute persistExecute; + + /** + * Used by CallableSqlRequest and UpdateSqlRequest. + */ + public PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) { + super(server, t); + this.persistExecute = persistExecute; + } + + /** + * Execute a the request or queue/batch it for later execution. + */ + public abstract int executeOrQueue(); + + /** + * Execute the request right now. + */ + public abstract int executeNow(); public boolean isLogSql() { return transaction.isLogSql(); @@ -58,47 +58,47 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe return transaction.isBatchThisRequest(type); } - /** - * Execute the statement. - */ - public int executeStatement() { - - boolean batch = isBatchThisRequest(); + /** + * Execute the statement. + */ + public int executeStatement() { - int rows; - BatchControl control = transaction.getBatchControl(); - if (control != null) { - rows = control.executeStatementOrBatch(this, batch); - - } else if (batch) { - // need to create the BatchControl - control = persistExecute.createBatchControl(transaction); - rows = control.executeStatementOrBatch(this, true); - } else { - rows = executeNow(); - } - - return rows; - } + boolean batch = isBatchThisRequest(); + + int rows; + BatchControl control = transaction.getBatchControl(); + if (control != null) { + rows = control.executeStatementOrBatch(this, batch); + + } else if (batch) { + // need to create the BatchControl + control = persistExecute.createBatchControl(transaction); + rows = control.executeStatementOrBatch(this, true); + } else { + rows = executeNow(); + } + + return rows; + } public void initTransIfRequired() { - createImplicitTransIfRequired(); - persistCascade = transaction.isPersistCascade(); - } + createImplicitTransIfRequired(); + persistCascade = transaction.isPersistCascade(); + } - /** - * Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL - * or CALLABLESQL. - */ - public Type getType() { - return type; - } + /** + * Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL + * or CALLABLESQL. + */ + public Type getType() { + return type; + } + + /** + * Return true if save and delete should cascade. + */ + public boolean isPersistCascade() { + return persistCascade; + } - /** - * Return true if save and delete should cascade. - */ - public boolean isPersistCascade() { - return persistCascade; - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index 71f29d6d1..23a2e910a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -25,6 +25,7 @@ import com.avaje.ebeaninternal.server.transaction.BeanPersistIdMap; import com.avaje.ebeanservice.docstore.api.DocStoreUpdate; import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext; import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; + import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; import java.io.IOException; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java index 9028d0949..b2db58e0b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java @@ -1,9 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.CallableStatement; -import java.sql.SQLException; -import java.util.List; - import com.avaje.ebean.CallableSql; import com.avaje.ebeaninternal.api.BindParams; import com.avaje.ebeaninternal.api.BindParams.Param; @@ -13,135 +9,138 @@ import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.api.TransactionEventTable; import com.avaje.ebeaninternal.server.persist.PersistExecute; +import java.sql.CallableStatement; +import java.sql.SQLException; +import java.util.List; + /** * Persist request specifically for CallableSql. */ public final class PersistRequestCallableSql extends PersistRequest { - private final SpiCallableSql callableSql; + private final SpiCallableSql callableSql; - private int rowCount; + private int rowCount; - private String bindLog; + private String bindLog; - private CallableStatement cstmt; + private CallableStatement cstmt; - private BindParams bindParam; + private BindParams bindParam; - /** - * Create. - */ - public PersistRequestCallableSql(SpiEbeanServer server, - CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { + /** + * Create. + */ + public PersistRequestCallableSql(SpiEbeanServer server, + CallableSql cs, SpiTransaction t, PersistExecute persistExecute) { - super(server, t, persistExecute); - this.type = PersistRequest.Type.CALLABLESQL; - this.callableSql = (SpiCallableSql)cs; - } + super(server, t, persistExecute); + this.type = PersistRequest.Type.CALLABLESQL; + this.callableSql = (SpiCallableSql) cs; + } - @Override - public int executeOrQueue() { - return executeStatement(); - } + @Override + public int executeOrQueue() { + return executeStatement(); + } - @Override - public int executeNow() { - return persistExecute.executeSqlCallable(this); - } + @Override + public int executeNow() { + return persistExecute.executeSqlCallable(this); + } - /** - * Return the CallableSql. - */ - public SpiCallableSql getCallableSql() { - return callableSql; - } + /** + * Return the CallableSql. + */ + public SpiCallableSql getCallableSql() { + return callableSql; + } - /** - * The the log of bind values. - */ - public void setBindLog(String bindLog) { - this.bindLog = bindLog; - } + /** + * The the log of bind values. + */ + public void setBindLog(String bindLog) { + this.bindLog = bindLog; + } - /** - * Note the rowCount of the execution. - */ - public void checkRowCount(int count) { - this.rowCount = count; - } + /** + * Note the rowCount of the execution. + */ + public void checkRowCount(int count) { + this.rowCount = count; + } - /** - * Only called for insert with generated keys. - */ - public void setGeneratedKey(Object idValue) { - } + /** + * Only called for insert with generated keys. + */ + public void setGeneratedKey(Object idValue) { + } - /** - * Perform post execute processing for the CallableSql. - */ - public void postExecute() { + /** + * Perform post execute processing for the CallableSql. + */ + public void postExecute() { - if (transaction.isLogSummary()) { - String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount+ "]" + " bind[" + bindLog + "]"; - transaction.logSummary(m); - } + if (transaction.isLogSummary()) { + String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount + "]" + " bind[" + bindLog + "]"; + transaction.logSummary(m); + } - // register table modifications with the transaction event - TransactionEventTable tableEvents = callableSql.getTransactionEventTable(); + // register table modifications with the transaction event + TransactionEventTable tableEvents = callableSql.getTransactionEventTable(); - if (tableEvents != null && !tableEvents.isEmpty()) { - transaction.getEvent().add(tableEvents); - } else { - transaction.markNotQueryOnly(); - } + if (tableEvents != null && !tableEvents.isEmpty()) { + transaction.getEvent().add(tableEvents); + } else { + transaction.markNotQueryOnly(); + } - } + } - /** - * These need to be set for use with Non-batch execution. Specifically to - * read registered out parameters and potentially handle the - * executeOverride() method. - */ - public void setBound(BindParams bindParam, CallableStatement cstmt) { - this.bindParam = bindParam; - this.cstmt = cstmt; - } + /** + * These need to be set for use with Non-batch execution. Specifically to + * read registered out parameters and potentially handle the + * executeOverride() method. + */ + public void setBound(BindParams bindParam, CallableStatement cstmt) { + this.bindParam = bindParam; + this.cstmt = cstmt; + } - /** - * Execute the statement in normal non batch mode. - */ - public int executeUpdate() throws SQLException { + /** + * 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)) { - return -1; - // // been overridden so just return the rowCount - // rowCount = callableSql.getRowCount(); - // return rowCount; - } + // check to see if the execution has been overridden + // only works in non-batch mode + if (callableSql.executeOverride(cstmt)) { + return -1; + // // been overridden so just return the rowCount + // rowCount = callableSql.getRowCount(); + // return rowCount; + } - rowCount = cstmt.executeUpdate(); + rowCount = cstmt.executeUpdate(); - // only read in non-batch mode - readOutParams(); + // only read in non-batch mode + readOutParams(); - return rowCount; - } + return rowCount; + } - private void readOutParams() throws SQLException { + private void readOutParams() throws SQLException { - List list = bindParam.positionedParameters(); - int pos = 0; + List list = bindParam.positionedParameters(); + int pos = 0; - for (Param aList : list) { + for (Param param : list) { pos++; - Param param = aList; if (param.isOutParam()) { Object outValue = cstmt.getObject(pos); param.setOutValue(outValue); } } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java index 78c37b9b4..70f7d099e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java @@ -13,98 +13,98 @@ import com.avaje.ebeaninternal.server.persist.PersistExecute; */ public final class PersistRequestOrmUpdate extends PersistRequest { - private final BeanDescriptor beanDescriptor; - - private final SpiUpdate ormUpdate; + private final BeanDescriptor beanDescriptor; - private int rowCount; + private final SpiUpdate ormUpdate; - private String bindLog; + private int rowCount; - /** - * Create. - */ - public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager mgr, SpiUpdate ormUpdate, - SpiTransaction t, PersistExecute persistExecute) { - - super(server, t, persistExecute); - this.beanDescriptor = mgr.getBeanDescriptor(); - this.ormUpdate = ormUpdate; - } - - public BeanDescriptor getBeanDescriptor() { - return beanDescriptor; - } - - @Override - public int executeNow() { - return persistExecute.executeOrmUpdate(this); - } + private String bindLog; - @Override - public int executeOrQueue() { - return executeStatement(); - } + /** + * Create. + */ + public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager mgr, SpiUpdate ormUpdate, + SpiTransaction t, PersistExecute persistExecute) { + + super(server, t, persistExecute); + this.beanDescriptor = mgr.getBeanDescriptor(); + this.ormUpdate = ormUpdate; + } + + public BeanDescriptor getBeanDescriptor() { + return beanDescriptor; + } + + @Override + public int executeNow() { + return persistExecute.executeOrmUpdate(this); + } + + @Override + public int executeOrQueue() { + return executeStatement(); + } - /** - * Return the UpdateSql. - */ - public SpiUpdate getOrmUpdate() { - return ormUpdate; - } + /** + * Return the UpdateSql. + */ + public SpiUpdate getOrmUpdate() { + return ormUpdate; + } - /** - * No concurrency checking so just note the rowCount. - */ - public void checkRowCount(int count) { - this.rowCount = count; - } + /** + * No concurrency checking so just note the rowCount. + */ + public void checkRowCount(int count) { + this.rowCount = count; + } - /** - * Not called for this type of request. - */ - public void setGeneratedKey(Object idValue) { - } + /** + * Not called for this type of request. + */ + public void setGeneratedKey(Object idValue) { + } - /** - * Set the bound values. - */ - public void setBindLog(String bindLog) { - this.bindLog = bindLog; - } + /** + * Set the bound values. + */ + public void setBindLog(String bindLog) { + this.bindLog = bindLog; + } - /** - * Perform post execute processing. - */ - public void postExecute() { + /** + * Perform post execute processing. + */ + public void postExecute() { - 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) { - case INSERT: - transaction.getEvent().add(tableName, true, false, false); - break; - case UPDATE: - transaction.getEvent().add(tableName, false, true, false); - break; - case DELETE: - transaction.getEvent().add(tableName, false, false, true); - break; - default: - break; - } - } - } + 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) { + case INSERT: + transaction.getEvent().add(tableName, true, false, false); + break; + case UPDATE: + transaction.getEvent().add(tableName, false, true, false); + break; + case DELETE: + transaction.getEvent().add(tableName, false, false, true); + break; + default: + break; + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java index 512b62525..89797b8fe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/Persister.java @@ -1,8 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.util.Collection; -import java.util.List; - import com.avaje.ebean.CallableSql; import com.avaje.ebean.Query; import com.avaje.ebean.SqlUpdate; @@ -10,6 +7,9 @@ import com.avaje.ebean.Transaction; import com.avaje.ebean.Update; import com.avaje.ebean.bean.EntityBean; +import java.util.Collection; +import java.util.List; + /** * API for persisting a bean. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java index 95f9e6e12..37018c04b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/RelationalQueryRequest.java @@ -218,8 +218,7 @@ public final class RelationalQueryRequest { int firstRow = query.getFirstRow(); int maxRows = query.getMaxRows(); if (firstRow > 0 || maxRows > 0) { - return ebeanServer.getDatabasePlatform().getBasicSqlLimiter() - .limit(sql, firstRow, maxRows); + return ebeanServer.getDatabasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows); } return sql; } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java b/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java index a00613e1e..f9486be50 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/ServletContextListener.java @@ -6,7 +6,6 @@ import javax.servlet.ServletContextEvent; /** * Listens for webserver server starting and stopping events. - * *

* Register this listener in the web.xml configuration file. This will listen * for startup and shutdown events. @@ -14,18 +13,18 @@ import javax.servlet.ServletContextEvent; */ public class ServletContextListener implements javax.servlet.ServletContextListener { - /** - * The servlet container is stopping. - */ - public void contextDestroyed(ServletContextEvent event) { - ShutdownManager.shutdown(); - } + /** + * The servlet container is stopping. + */ + public void contextDestroyed(ServletContextEvent event) { + ShutdownManager.shutdown(); + } - /** - * Do nothing on startup. - */ - public void contextInitialized(ServletContextEvent event) { + /** + * Do nothing on startup. + */ + public void contextInitialized(ServletContextEvent event) { + + } - } - } diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java b/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java index 36fb3de0f..e1cdf36ac 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/TransWrapper.java @@ -11,17 +11,17 @@ import com.avaje.ebeaninternal.api.SpiTransaction; */ final class TransWrapper { - final SpiTransaction transaction; + final SpiTransaction transaction; - private final boolean wasCreated; + private final boolean wasCreated; - /** - * Wrap the transaction indicating if it was just created. - */ - TransWrapper(SpiTransaction t, boolean created) { - transaction = t; - wasCreated = created; - } + /** + * Wrap the transaction indicating if it was just created. + */ + TransWrapper(SpiTransaction t, boolean created) { + transaction = t; + wasCreated = created; + } void batchEscalateOnCollection() { transaction.checkBatchEscalationOnCollection(); @@ -33,24 +33,24 @@ final class TransWrapper { } } - void commitIfCreated() { - if (wasCreated){ - transaction.commit(); - } - } - - void rollbackIfCreated() { - if (wasCreated){ - transaction.rollbackIfActive(); - } - } - - /** - * Return true if the transaction was just created. If true it should be - * committed after the request has been processed. - */ - boolean wasCreated() { - return wasCreated; - } + void commitIfCreated() { + if (wasCreated) { + transaction.commit(); + } + } -} \ No newline at end of file + void rollbackIfCreated() { + if (wasCreated) { + transaction.rollbackIfActive(); + } + } + + /** + * Return true if the transaction was just created. If true it should be + * committed after the request has been processed. + */ + boolean wasCreated() { + return wasCreated; + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java index a0bd0178c..f5641eed1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/BootupClassPathSearch.java @@ -6,7 +6,8 @@ import org.avaje.classpath.scanner.ClassPathScanner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; +import java.util.List; +import java.util.Set; /** * Searches for interesting classes such as Entities, Embedded and ScalarTypes. diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java index a9ce63945..3acfb8996 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/bootup/ManifestReader.java @@ -24,14 +24,14 @@ class ManifestReader { /** * Read the packages from ebean.mf manifest files found as resources. */ - static Set readManifests(ClassLoader classLoader, String resourcePath) { + static Set readManifests(ClassLoader classLoader, String resourcePath) { return new ManifestReader().read(classLoader, resourcePath); } /** * Read all the specific manifest files and return the set of packages containing type query beans. */ - private Set read(ClassLoader classLoader, String resourcePath) { + private Set read(ClassLoader classLoader, String resourcePath) { try { Enumeration resources = classLoader.getResources(resourcePath); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/package.html b/src/main/java/com/avaje/ebeaninternal/server/core/package.html index 77c14d3f0..a9639f8fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/package.html +++ b/src/main/java/com/avaje/ebeaninternal/server/core/package.html @@ -1,11 +1,11 @@ - - Core implementation objects + + Core implementation objects Core implementation objects - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java b/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java index e0cd52f6c..4f18d653d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/timezone/CloneDataTimeZone.java @@ -17,6 +17,6 @@ public class CloneDataTimeZone extends SimpleDataTimeZone { @Override public Calendar getTimeZone() { // return cloned copy for Oracle to muck around with - return (Calendar)zone.clone(); + return (Calendar) zone.clone(); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java index a37b4dcec..a6f80a0f3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElFilter.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.el; +import com.avaje.ebean.Filter; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; + import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.regex.Pattern; -import com.avaje.ebean.Filter; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; - /** * Default implementation of the Filter interface. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java index f488860e1..b8554445b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/el/ElMatchBuilder.java @@ -224,7 +224,7 @@ class ElMatchBuilder { public boolean isMatch(T value) { return (comparator.compareValue(min, value) <= 0 - && comparator.compareValue(max, value) >= 0); + && comparator.compareValue(max, value) >= 0); } } From 2dceccfa78ba8125bfe4e3fe671690e3fa88df02 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:22:58 +1300 Subject: [PATCH 72/87] no effective change - format only --- .../server/autotune/model/Autotune.java | 203 +++++++--------- .../server/autotune/model/ObjectFactory.java | 98 ++++---- .../server/autotune/model/Origin.java | 227 ++++++++---------- .../server/autotune/model/ProfileDiff.java | 67 +++--- .../server/autotune/model/ProfileEmpty.java | 67 +++--- .../server/autotune/model/ProfileNew.java | 67 +++--- .../service/AutoTuneAllCollection.java | 4 +- .../autotune/service/AutoTuneXmlWriter.java | 2 +- .../service/DefaultAutoTuneService.java | 2 +- .../autotune/service/ProfileOriginQuery.java | 4 +- .../server/cache/CacheChangeSet.java | 4 +- .../server/cache/CachedBeanData.java | 2 +- .../server/cache/CachedBeanDataFromBean.java | 2 +- .../server/cache/DefaultCacheHolder.java | 2 +- .../server/cache/DefaultServerCache.java | 3 +- .../changelog/DefaultChangeLogListener.java | 2 +- .../server/cluster/ClusterManager.java | 2 +- 17 files changed, 347 insertions(+), 411 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java index 6de29008b..c9c67c248 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Autotune.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * + * Java class for anonymous complex type. + *

+ * The following schema fragment specifies the expected content contained within this class. + *

*

  * <complexType>
  *   <complexContent>
@@ -28,123 +27,107 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin", - "profileDiff", - "profileNew", - "profileEmpty" + "origin", + "profileDiff", + "profileNew", + "profileEmpty" }) @XmlRootElement(name = "autotune") public class Autotune { - protected List origin; - protected ProfileDiff profileDiff; - protected ProfileNew profileNew; - protected ProfileEmpty profileEmpty; + protected List origin; + protected ProfileDiff profileDiff; + protected ProfileNew profileNew; + protected ProfileEmpty profileEmpty; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList<>(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } - /** - * Gets the value of the profileDiff property. - * - * @return - * possible object is - * {@link ProfileDiff } - * - */ - public ProfileDiff getProfileDiff() { - return profileDiff; - } + /** + * Gets the value of the profileDiff property. + * + * @return possible object is + * {@link ProfileDiff } + */ + public ProfileDiff getProfileDiff() { + return profileDiff; + } - /** - * Sets the value of the profileDiff property. - * - * @param value - * allowed object is - * {@link ProfileDiff } - * - */ - public void setProfileDiff(ProfileDiff value) { - this.profileDiff = value; - } + /** + * Sets the value of the profileDiff property. + * + * @param value allowed object is + * {@link ProfileDiff } + */ + public void setProfileDiff(ProfileDiff value) { + this.profileDiff = value; + } - /** - * Gets the value of the profileNew property. - * - * @return - * possible object is - * {@link ProfileNew } - * - */ - public ProfileNew getProfileNew() { - return profileNew; - } + /** + * Gets the value of the profileNew property. + * + * @return possible object is + * {@link ProfileNew } + */ + public ProfileNew getProfileNew() { + return profileNew; + } - /** - * Sets the value of the profileNew property. - * - * @param value - * allowed object is - * {@link ProfileNew } - * - */ - public void setProfileNew(ProfileNew value) { - this.profileNew = value; - } + /** + * Sets the value of the profileNew property. + * + * @param value allowed object is + * {@link ProfileNew } + */ + public void setProfileNew(ProfileNew value) { + this.profileNew = value; + } - /** - * Gets the value of the profileEmpty property. - * - * @return - * possible object is - * {@link ProfileEmpty } - * - */ - public ProfileEmpty getProfileEmpty() { - return profileEmpty; - } + /** + * Gets the value of the profileEmpty property. + * + * @return possible object is + * {@link ProfileEmpty } + */ + public ProfileEmpty getProfileEmpty() { + return profileEmpty; + } - /** - * Sets the value of the profileEmpty property. - * - * @param value - * allowed object is - * {@link ProfileEmpty } - * - */ - public void setProfileEmpty(ProfileEmpty value) { - this.profileEmpty = value; - } + /** + * Sets the value of the profileEmpty property. + * + * @param value allowed object is + * {@link ProfileEmpty } + */ + public void setProfileEmpty(ProfileEmpty value) { + this.profileEmpty = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java index effa06fff..26e70bd70 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ObjectFactory.java @@ -1,72 +1,64 @@ - package com.avaje.ebeaninternal.server.autotune.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.server.autotune.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.server.autotune.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autotune.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.server.autotune.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link ProfileNew } - * - */ - public ProfileNew createProfileNew() { - return new ProfileNew(); - } + /** + * Create an instance of {@link ProfileNew } + */ + public ProfileNew createProfileNew() { + return new ProfileNew(); + } - /** - * Create an instance of {@link Origin } - * - */ - public Origin createOrigin() { - return new Origin(); - } + /** + * Create an instance of {@link Origin } + */ + public Origin createOrigin() { + return new Origin(); + } - /** - * Create an instance of {@link ProfileEmpty } - * - */ - public ProfileEmpty createProfileEmpty() { - return new ProfileEmpty(); - } + /** + * Create an instance of {@link ProfileEmpty } + */ + public ProfileEmpty createProfileEmpty() { + return new ProfileEmpty(); + } - /** - * Create an instance of {@link Autotune } - * - */ - public Autotune createAutotune() { - return new Autotune(); - } + /** + * Create an instance of {@link Autotune } + */ + public Autotune createAutotune() { + return new Autotune(); + } - /** - * Create an instance of {@link ProfileDiff } - * - */ - public ProfileDiff createProfileDiff() { - return new ProfileDiff(); - } + /** + * Create an instance of {@link ProfileDiff } + */ + public ProfileDiff createProfileDiff() { + return new ProfileDiff(); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java index 04c9af034..150197c3b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/Origin.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.server.autotune.model; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -28,144 +27,122 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "callStack" + "callStack" }) @XmlRootElement(name = "origin") public class Origin { - protected String callStack; - @XmlAttribute(name = "key", required = true) - protected String key; - @XmlAttribute(name = "beanType") - protected String beanType; - @XmlAttribute(name = "detail") - protected String detail; - @XmlAttribute(name = "original") - protected String original; + protected String callStack; + @XmlAttribute(name = "key", required = true) + protected String key; + @XmlAttribute(name = "beanType") + protected String beanType; + @XmlAttribute(name = "detail") + protected String detail; + @XmlAttribute(name = "original") + protected String original; - /** - * Gets the value of the callStack property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCallStack() { - return callStack; - } + /** + * Gets the value of the callStack property. + * + * @return possible object is + * {@link String } + */ + public String getCallStack() { + return callStack; + } - /** - * Sets the value of the callStack property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCallStack(String value) { - this.callStack = value; - } + /** + * Sets the value of the callStack property. + * + * @param value allowed object is + * {@link String } + */ + public void setCallStack(String value) { + this.callStack = value; + } - /** - * Gets the value of the key property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getKey() { - return key; - } + /** + * Gets the value of the key property. + * + * @return possible object is + * {@link String } + */ + public String getKey() { + return key; + } - /** - * Sets the value of the key property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } + /** + * Sets the value of the key property. + * + * @param value allowed object is + * {@link String } + */ + public void setKey(String value) { + this.key = value; + } - /** - * Gets the value of the beanType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBeanType() { - return beanType; - } + /** + * Gets the value of the beanType property. + * + * @return possible object is + * {@link String } + */ + public String getBeanType() { + return beanType; + } - /** - * Sets the value of the beanType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBeanType(String value) { - this.beanType = value; - } + /** + * Sets the value of the beanType property. + * + * @param value allowed object is + * {@link String } + */ + public void setBeanType(String value) { + this.beanType = value; + } - /** - * Gets the value of the detail property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDetail() { - return detail; - } + /** + * Gets the value of the detail property. + * + * @return possible object is + * {@link String } + */ + public String getDetail() { + return detail; + } - /** - * Sets the value of the detail property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDetail(String value) { - this.detail = value; - } + /** + * Sets the value of the detail property. + * + * @param value allowed object is + * {@link String } + */ + public void setDetail(String value) { + this.detail = value; + } - /** - * Gets the value of the original property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOriginal() { - return original; - } + /** + * Gets the value of the original property. + * + * @return possible object is + * {@link String } + */ + public String getOriginal() { + return original; + } - /** - * Sets the value of the original property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOriginal(String value) { - this.original = value; - } + /** + * Sets the value of the original property. + * + * @param value allowed object is + * {@link String } + */ + public void setOriginal(String value) { + this.original = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java index c8357a41e..5fc587ef0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileDiff.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileDiff") public class ProfileDiff { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList<>(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java index 317d7d431..1a962316c 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileEmpty.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileEmpty") public class ProfileEmpty { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList<>(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java index 416b3e8c4..03f208d6b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/model/ProfileNew.java @@ -1,19 +1,18 @@ - package com.avaje.ebeaninternal.server.autotune.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "origin" + "origin" }) @XmlRootElement(name = "profileNew") public class ProfileNew { - protected List origin; + protected List origin; - /** - * Gets the value of the origin property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the origin property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getOrigin().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Origin } - * - * - */ - public List getOrigin() { - if (origin == null) { - origin = new ArrayList<>(); - } - return this.origin; + /** + * Gets the value of the origin property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the origin property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getOrigin().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Origin } + */ + public List getOrigin() { + if (origin == null) { + origin = new ArrayList<>(); } + return this.origin; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java index 6956f60ab..5f2068842 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneAllCollection.java @@ -7,7 +7,7 @@ import java.util.Collection; /** * Event where all tuned query information is collected. *

- * This is for writing the "all" file on shutdown when using runtime tuning. + * This is for writing the "all" file on shutdown when using runtime tuning. *

*/ public class AutoTuneAllCollection { @@ -53,7 +53,7 @@ public class AutoTuneAllCollection { private void loadAllTuned() { Collection all = queryTuner.getAll(); - for (TunedQueryInfo tuned: all) { + for (TunedQueryInfo tuned : all) { document.getOrigin().add(tuned.getOrigin()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java index a86f9f7ab..552eb9123 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/AutoTuneXmlWriter.java @@ -46,7 +46,7 @@ public class AutoTuneXmlWriter { try { JAXBContext jaxbContext = JAXBContext.newInstance(Autotune.class); Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(profiling, file); } catch (JAXBException e) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java index da8ebf80c..c3ae7f756 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/DefaultAutoTuneService.java @@ -196,7 +196,7 @@ public class DefaultAutoTuneService implements AutoTuneService { File existingTuning = new File(tuningFile); if (existingTuning.exists()) { // rename the existing autotune.xml file (appending 'now') - if (!existingTuning.renameTo(new File(tuningFile+"."+AutoTuneXmlWriter.now()))) { + if (!existingTuning.renameTo(new File(tuningFile + "." + AutoTuneXmlWriter.now()))) { logger.warn("Failed to rename autotune file [{}]", tuningFile); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java index b0a938393..d7f298152 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/server/autotune/service/ProfileOriginQuery.java @@ -30,7 +30,7 @@ public class ProfileOriginQuery implements Serializable { totalMicros.add(micros); } - public AutoTuneCollection.EntryQuery createEntryQuery(boolean reset){ + public AutoTuneCollection.EntryQuery createEntryQuery(boolean reset) { if (reset) { return new AutoTuneCollection.EntryQuery(path, exeCount.sumThenReset(), totalBeanLoaded.sumThenReset(), totalMicros.sumThenReset()); @@ -40,4 +40,4 @@ public class ProfileOriginQuery implements Serializable { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java index 50fb06f46..282c9c8d7 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CacheChangeSet.java @@ -37,7 +37,7 @@ public class CacheChangeSet { /** * Apply the changes to the L2 cache except entity/view invalidation. - * + *

* Return the set of table changes to process invalidation for entities based on views. */ public Set apply() { @@ -139,7 +139,7 @@ public class CacheChangeSet { final List removes = new ArrayList<>(); - final Map puts = new LinkedHashMap<>(); + final Map puts = new LinkedHashMap<>(); boolean clear; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java index b82a4c361..526d56f24 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanData.java @@ -133,7 +133,7 @@ public class CachedBeanData implements Externalizable { /** * Return all the property data. */ - public Map getData() { + public Map getData() { return data; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java index 7927f20bd..3f2dc99bb 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBean.java @@ -15,7 +15,7 @@ public class CachedBeanDataFromBean { EntityBeanIntercept ebi = bean._ebean_getIntercept(); - Map data = new LinkedHashMap<>(); + Map data = new LinkedHashMap<>(); BeanProperty idProperty = desc.getIdProperty(); if (idProperty != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java index 82c58da0b..cae96c6a5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder.java @@ -1,7 +1,7 @@ package com.avaje.ebeaninternal.server.cache; -import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.annotation.CacheBeanTuning; +import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheFactory; import com.avaje.ebean.cache.ServerCacheOptions; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java index da247e70c..0204c677e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache.java @@ -4,7 +4,6 @@ import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheOptions; import com.avaje.ebean.cache.ServerCacheStatistics; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -323,7 +322,7 @@ public class DefaultServerCache implements ServerCache { if (logger.isTraceEnabled()) { logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}]" - , name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU); + , name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java index 1e00c9564..3d6c0bb31 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java +++ b/src/main/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogListener.java @@ -4,8 +4,8 @@ import com.avaje.ebean.event.changelog.BeanChange; import com.avaje.ebean.event.changelog.ChangeLogListener; import com.avaje.ebean.event.changelog.ChangeSet; import com.avaje.ebean.event.changelog.ChangeType; -import com.avaje.ebean.plugin.SpiServer; import com.avaje.ebean.plugin.Plugin; +import com.avaje.ebean.plugin.SpiServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java index f339968da..90f848946 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/cluster/ClusterManager.java @@ -49,7 +49,7 @@ public class ClusterManager { } if (factory == null) { throw new IllegalStateException("No ClusterTransportFactory found in classpath. " - + " Probably need to add the avaje-ebeanorm-cluster dependency"); + + " Probably need to add the avaje-ebeanorm-cluster dependency"); } return factory; } From 002d7d9f275867c39bfd717a449e10c0e190afeb Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:24:38 +1300 Subject: [PATCH 73/87] no effective change - format only --- .../avaje/ebeaninternal/api/BeanIdList.java | 56 +- .../avaje/ebeaninternal/api/BindParams.java | 640 +++++++++--------- .../avaje/ebeaninternal/api/ClassUtil.java | 2 +- .../ebeaninternal/api/ConcurrencyMode.java | 18 +- .../avaje/ebeaninternal/api/HashQuery.java | 6 +- .../ebeaninternal/api/HashQueryPlan.java | 16 +- .../api/HashQueryPlanBuilder.java | 12 +- .../ebeaninternal/api/HelpScopeTrans.java | 49 +- .../ebeaninternal/api/LoadBeanBuffer.java | 8 +- .../ebeaninternal/api/LoadBeanContext.java | 3 +- .../ebeaninternal/api/LoadManyBuffer.java | 8 +- .../ebeaninternal/api/LoadManyContext.java | 2 +- .../ebeaninternal/api/LoadManyRequest.java | 2 +- .../avaje/ebeaninternal/api/LoadRequest.java | 56 +- .../ebeaninternal/api/LoadSecondaryQuery.java | 8 +- .../com/avaje/ebeaninternal/api/Monitor.java | 4 +- .../avaje/ebeaninternal/api/PropertyJoin.java | 4 +- .../ebeaninternal/api/ScopedTransaction.java | 1 + .../api/SpiBackgroundExecutor.java | 8 +- .../ebeaninternal/api/SpiCallableSql.java | 6 +- .../ebeaninternal/api/SpiEbeanServer.java | 2 +- .../ebeaninternal/api/SpiExpression.java | 95 ++- .../ebeaninternal/api/SpiExpressionList.java | 8 +- .../avaje/ebeaninternal/api/SpiSqlQuery.java | 2 - .../avaje/ebeaninternal/api/SpiSqlUpdate.java | 2 +- .../ebeaninternal/api/SpiTransaction.java | 1 + .../api/SpiTransactionScopeManager.java | 2 +- .../avaje/ebeaninternal/api/SpiUpdate.java | 128 ++-- .../ebeaninternal/api/SpiUpdatePlan.java | 66 +- .../ebeaninternal/api/TransactionEvent.java | 2 +- .../api/TransactionEventBeans.java | 44 +- .../api/TransactionEventTable.java | 237 +++---- .../extraddl/model/DdlScript.java | 141 ++-- .../extraddl/model/ExtraDdl.java | 69 +- .../extraddl/model/ExtraDdlXmlReader.java | 3 +- .../extraddl/model/ObjectFactory.java | 59 +- 36 files changed, 873 insertions(+), 897 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java index c1de039bd..95d82e27e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java @@ -7,40 +7,40 @@ import java.util.List; */ public class BeanIdList { - private final List idList; + private final List idList; private boolean hasMore; - public BeanIdList(List idList) { - this.idList = idList; - } + public BeanIdList(List idList) { + this.idList = idList; + } - /** - * Add an Id to the list. - */ - public void add(Object id){ - idList.add(id); - } + /** + * Add an Id to the list. + */ + public void add(Object id) { + idList.add(id); + } - /** - * Return the list of Id's. - */ - public List getIdList() { - return idList; - } + /** + * Return the list of Id's. + */ + public List getIdList() { + return idList; + } - /** - * Return true if max rows was hit and there is more rows to fetch. - */ - public boolean isHasMore() { - return hasMore; - } + /** + * Return true if max rows was hit and there is more rows to fetch. + */ + public boolean isHasMore() { + return hasMore; + } - /** - * Set to true when max rows is hit and there are more rows to fetch. - */ - public void setHasMore(boolean hasMore) { - this.hasMore = hasMore; - } + /** + * Set to true when max rows is hit and there are more rows to fetch. + */ + public void setHasMore(boolean hasMore) { + this.hasMore = hasMore; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java index ecb4c4afe..c2d0a82eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java @@ -1,5 +1,7 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -8,8 +10,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; - /** * Parameters used for binding to a statement. *

@@ -18,18 +18,18 @@ import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; */ public class BindParams implements Serializable { - private static final long serialVersionUID = 4541081933302086285L; + private static final long serialVersionUID = 4541081933302086285L; - private final List positionedParameters = new ArrayList<>(); + private final List positionedParameters = new ArrayList<>(); - private final Map namedParameters = new LinkedHashMap<>(); + private final Map namedParameters = new LinkedHashMap<>(); - /** - * This is the sql. For named parameters this is the sql after the named - * parameters have been replaced with question mark place holders and the - * parameters have been ordered by addNamedParamInOrder(). - */ - private String preparedSql; + /** + * This is the sql. For named parameters this is the sql after the named + * parameters have been replaced with question mark place holders and the + * parameters have been ordered by addNamedParamInOrder(). + */ + private String preparedSql; /** * Bind hash and count used to detect when the bind values have changed such @@ -37,16 +37,16 @@ public class BindParams implements Serializable { */ private int[] bindHash; - public BindParams() { - } + public BindParams() { + } public int queryBindHash() { - int hc = namedParameters.hashCode(); + int hc = namedParameters.hashCode(); for (Param positionedParameter : positionedParameters) { hc = hc * 31 + positionedParameter.hashCode(); } - return hc; - } + return hc; + } /** * Return the hash that should be included with the query plan. @@ -84,136 +84,136 @@ public class BindParams implements Serializable { return new int[]{hc, bc}; } - /** - * Return a deep copy of the BindParams. - */ - public BindParams copy() { - BindParams copy = new BindParams(); - for (Param p : positionedParameters) { - copy.positionedParameters.add(p.copy()); - } - for (Entry entry : namedParameters.entrySet()) { + /** + * Return a deep copy of the BindParams. + */ + public BindParams copy() { + BindParams copy = new BindParams(); + for (Param p : positionedParameters) { + copy.positionedParameters.add(p.copy()); + } + for (Entry entry : namedParameters.entrySet()) { copy.namedParameters.put(entry.getKey(), entry.getValue().copy()); - } - return copy; - } + } + return copy; + } - /** - * Return true if there are no bind parameters. - */ - public boolean isEmpty() { - return positionedParameters.isEmpty() && namedParameters.isEmpty(); - } + /** + * Return true if there are no bind parameters. + */ + public boolean isEmpty() { + return positionedParameters.isEmpty() && namedParameters.isEmpty(); + } - /** - * Return a Natural Key bind param if supported. - */ - public NaturalKeyBindParam getNaturalKeyBindParam() { - if (positionedParameters != null){ - return null; - } - if (namedParameters != null && namedParameters.size() == 1){ - Entry e = namedParameters.entrySet().iterator().next(); - return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); - } - return null; - } + /** + * Return a Natural Key bind param if supported. + */ + public NaturalKeyBindParam getNaturalKeyBindParam() { + if (positionedParameters != null) { + return null; + } + if (namedParameters != null && namedParameters.size() == 1) { + Entry e = namedParameters.entrySet().iterator().next(); + return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); + } + return null; + } - public int size() { - return positionedParameters.size(); - } + public int size() { + return positionedParameters.size(); + } - /** - * Return true if named parameters are being used and they have not yet been - * ordered. The sql needs to be prepared (named replaced with ?) and the - * parameters ordered. - */ - public boolean requiresNamedParamsPrepare() { - return !namedParameters.isEmpty(); - } + /** + * Return true if named parameters are being used and they have not yet been + * ordered. The sql needs to be prepared (named replaced with ?) and the + * parameters ordered. + */ + public boolean requiresNamedParamsPrepare() { + return !namedParameters.isEmpty(); + } - /** - * Set a null parameter using position. - */ - public void setNullParameter(int position, int jdbcType) { - Param p = getParam(position); - p.setInNullType(jdbcType); - } + /** + * Set a null parameter using position. + */ + public void setNullParameter(int position, int jdbcType) { + Param p = getParam(position); + p.setInNullType(jdbcType); + } - /** - * Set an In Out parameter using position. - */ - public void setParameter(int position, Object value, int outType) { + /** + * Set an In Out parameter using position. + */ + public void setParameter(int position, Object value, int outType) { - Param p = getParam(position); - p.setInValue(value); - p.setOutType(outType); - } + Param p = getParam(position); + p.setInValue(value); + p.setOutType(outType); + } - /** - * Using position set the In value of a parameter. Note that for nulls you - * must use setNullParameter. - */ - public void setParameter(int position, Object value) { + /** + * Using position set the In value of a parameter. Note that for nulls you + * must use setNullParameter. + */ + public void setParameter(int position, Object value) { - Param p = getParam(position); - p.setInValue(value); - } + Param p = getParam(position); + p.setInValue(value); + } - /** - * Register the parameter as an Out parameter using position. - */ - public void registerOut(int position, int outType) { - Param p = getParam(position); - p.setOutType(outType); - } + /** + * Register the parameter as an Out parameter using position. + */ + public void registerOut(int position, int outType) { + Param p = getParam(position); + p.setOutType(outType); + } - private Param getParam(String name) { - Param p = namedParameters.get(name); - if (p == null) { - p = new Param(); - namedParameters.put(name, p); - } - return p; - } + private Param getParam(String name) { + Param p = namedParameters.get(name); + if (p == null) { + p = new Param(); + namedParameters.put(name, p); + } + return p; + } - private Param getParam(int position) { - int more = position - positionedParameters.size(); - if (more > 0) { - for (int i = 0; i < more; i++) { - positionedParameters.add(new Param()); - } - } - return positionedParameters.get(position - 1); - } + private Param getParam(int position) { + int more = position - positionedParameters.size(); + if (more > 0) { + for (int i = 0; i < more; i++) { + positionedParameters.add(new Param()); + } + } + return positionedParameters.get(position - 1); + } - /** - * Set a named In Out parameter. - */ - public void setParameter(String name, Object value, int outType) { + /** + * Set a named In Out parameter. + */ + public void setParameter(String name, Object value, int outType) { Param p = getParam(name); - p.setInValue(value); - p.setOutType(outType); - } + p.setInValue(value); + p.setOutType(outType); + } - /** - * Set a named In parameter that is null. - */ - public void setNullParameter(String name, int jdbcType) { - Param p = getParam(name); - p.setInNullType(jdbcType); - } + /** + * Set a named In parameter that is null. + */ + public void setNullParameter(String name, int jdbcType) { + Param p = getParam(name); + p.setInNullType(jdbcType); + } - /** - * Set a named In parameter that is not null. - */ - public Param setParameter(String name, Object value) { + /** + * Set a named In parameter that is not null. + */ + public Param setParameter(String name, Object value) { - Param p = getParam(name); - p.setInValue(value); - return p; - } + Param p = getParam(name); + p.setInValue(value); + return p; + } /** * Set an encryption key as a bind value. @@ -227,50 +227,50 @@ public class BindParams implements Serializable { return p; } - /** - * Register the named parameter as an Out parameter. - */ - public void registerOut(String name, int outType) { - Param p = getParam(name); - p.setOutType(outType); - } + /** + * Register the named parameter as an Out parameter. + */ + public void registerOut(String name, int outType) { + Param p = getParam(name); + p.setOutType(outType); + } - /** - * Return the Parameter for a given position. - */ - public Param getParameter(int position) { - // Used to read Out value by CallableSql - return getParam(position); - } + /** + * Return the Parameter for a given position. + */ + public Param getParameter(int position) { + // Used to read Out value by CallableSql + return getParam(position); + } - /** - * Return the named parameter. - */ - public Param getParameter(String name) { - return getParam(name); - } + /** + * Return the named parameter. + */ + public Param getParameter(String name) { + return getParam(name); + } - /** - * Return the values of ordered parameters. - */ - public List positionedParameters() { - return positionedParameters; - } + /** + * Return the values of ordered parameters. + */ + public List positionedParameters() { + return positionedParameters; + } - /** - * Set the sql with named parameters replaced with place holder ?. - */ - public void setPreparedSql(String preparedSql) { - this.preparedSql = preparedSql; - } + /** + * Set the sql with named parameters replaced with place holder ?. + */ + public void setPreparedSql(String preparedSql) { + this.preparedSql = preparedSql; + } - /** - * Return the sql with ? place holders (named parameters have been processed - * and ordered). - */ - public String getPreparedSql() { - return preparedSql; - } + /** + * Return the sql with ? place holders (named parameters have been processed + * and ordered). + */ + public String getPreparedSql() { + return preparedSql; + } /** * Return true if the bind hash and count has not changed. @@ -295,160 +295,160 @@ public class BindParams implements Serializable { } /** - * The bind parameters in the correct binding order. - *

- * This is the result of converting sql with named parameters - * into sql with ? and ordered parameters. - *

- */ - public static final class OrderedList { + * The bind parameters in the correct binding order. + *

+ * This is the result of converting sql with named parameters + * into sql with ? and ordered parameters. + *

+ */ + public static final class OrderedList { - private final List paramList; + private final List paramList; - private final StringBuilder preparedSql; + private final StringBuilder preparedSql; - public OrderedList() { - this(new ArrayList<>()); - } + public OrderedList() { + this(new ArrayList<>()); + } - public OrderedList(List paramList) { - this.paramList = paramList; - this.preparedSql = new StringBuilder(); - } + public OrderedList(List paramList) { + this.paramList = paramList; + this.preparedSql = new StringBuilder(); + } - /** - * Add a parameter in the correct binding order. - */ - public void add(Param param) { - paramList.add(param); - } + /** + * Add a parameter in the correct binding order. + */ + public void add(Param param) { + paramList.add(param); + } - /** - * Return the number of bind parameters in this list. - */ - public int size() { - return paramList.size(); - } + /** + * Return the number of bind parameters in this list. + */ + public int size() { + return paramList.size(); + } - /** - * Returns the ordered list of bind parameters. - */ - public List list() { - return paramList; - } + /** + * Returns the ordered list of bind parameters. + */ + public List list() { + return paramList; + } - /** - * Append parsedSql that has named parameters converted into ?. - */ - public void appendSql(String parsedSql) { - preparedSql.append(parsedSql); - } + /** + * Append parsedSql that has named parameters converted into ?. + */ + public void appendSql(String parsedSql) { + preparedSql.append(parsedSql); + } - public String getPreparedSql() { - return preparedSql.toString(); - } - } + public String getPreparedSql() { + return preparedSql.toString(); + } + } - /** - * A In Out capable parameter for the CallableStatement. - */ - public static final class Param implements Serializable { + /** + * A In Out capable parameter for the CallableStatement. + */ + public static final class Param implements Serializable { private static final long serialVersionUID = 1L; private boolean encryptionKey; - private boolean isInParam; + private boolean isInParam; - private boolean isOutParam; + private boolean isOutParam; - private int type; + private int type; - private Object inValue; + private Object inValue; - private Object outValue; + private Object outValue; - /** - * Construct a Parameter. - */ - public Param() { - } + /** + * Construct a Parameter. + */ + public Param() { + } - public int queryBindCount() { - if (inValue == null) { - return 0; - } - if (inValue instanceof Collection){ - return ((Collection)inValue).size(); - } - return 1; - } + public int queryBindCount() { + if (inValue == null) { + return 0; + } + if (inValue instanceof Collection) { + return ((Collection) inValue).size(); + } + return 1; + } - /** - * Create a deep copy of the Param. - */ - public Param copy() { - Param copy = new Param(); - copy.isInParam = isInParam; - copy.isOutParam = isOutParam; - copy.type = type; - copy.inValue = inValue; - copy.outValue = outValue; - return copy; - } + /** + * Create a deep copy of the Param. + */ + public Param copy() { + Param copy = new Param(); + copy.isInParam = isInParam; + copy.isOutParam = isOutParam; + copy.type = type; + copy.inValue = inValue; + copy.outValue = outValue; + return copy; + } - public int hashCode() { - int hc = getClass().hashCode(); - hc = hc * 31 + (isInParam ? 0 : 1); - hc = hc * 31 + (isOutParam ? 0 : 1); - hc = hc * 31 + (type); - hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); - return hc; - } + public int hashCode() { + int hc = getClass().hashCode(); + hc = hc * 31 + (isInParam ? 0 : 1); + hc = hc * 31 + (isOutParam ? 0 : 1); + hc = hc * 31 + (type); + hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); + return hc; + } - public boolean equals(Object o) { + public boolean equals(Object o) { return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); } - /** - * Return true if this is an In parameter that needs to be bound before - * execution. - */ - public boolean isInParam() { - return isInParam; - } + /** + * Return true if this is an In parameter that needs to be bound before + * execution. + */ + public boolean isInParam() { + return isInParam; + } - /** - * Return true if this is an out parameter that needs to be registered - * before execution. - */ - public boolean isOutParam() { - return isOutParam; - } + /** + * Return true if this is an out parameter that needs to be registered + * before execution. + */ + public boolean isOutParam() { + return isOutParam; + } - /** - * Return the jdbc type of this parameter. Used for registering Out - * parameters and setting NULL In parameters. - */ - public int getType() { - return type; - } + /** + * Return the jdbc type of this parameter. Used for registering Out + * parameters and setting NULL In parameters. + */ + public int getType() { + return type; + } - /** - * Set the Out parameter type. - */ - public void setOutType(int type) { - this.type = type; - this.isOutParam = true; - } + /** + * Set the Out parameter type. + */ + public void setOutType(int type) { + this.type = type; + this.isOutParam = true; + } - /** - * Set the In value. - */ - public void setInValue(Object in) { - this.inValue = in; - this.isInParam = true; - } + /** + * Set the In value. + */ + public void setInValue(Object in) { + this.inValue = in; + this.isInParam = true; + } /** * Set an encryption key (which can not be logged). @@ -459,39 +459,39 @@ public class BindParams implements Serializable { this.encryptionKey = true; } - /** - * Specify that the In parameter is NULL and the specific type that it - * is. - */ - public void setInNullType(int type) { - this.type = type; - this.inValue = null; - this.isInParam = true; - } + /** + * Specify that the In parameter is NULL and the specific type that it + * is. + */ + public void setInNullType(int type) { + this.type = type; + this.inValue = null; + this.isInParam = true; + } - /** - * Return the OUT value that was retrieved. This value is set after - * CallableStatement was executed. - */ - public Object getOutValue() { - return outValue; - } + /** + * Return the OUT value that was retrieved. This value is set after + * CallableStatement was executed. + */ + public Object getOutValue() { + return outValue; + } - /** - * Return the In value. If this is null, then the type should be used to - * specify the type of the null. - */ - public Object getInValue() { - return inValue; - } + /** + * Return the In value. If this is null, then the type should be used to + * specify the type of the null. + */ + public Object getInValue() { + return inValue; + } - /** - * Set the OUT value returned by a CallableStatement after it has - * executed. - */ - public void setOutValue(Object out) { - this.outValue = out; - } + /** + * Set the OUT value returned by a CallableStatement after it has + * executed. + */ + public void setOutValue(Object out) { + this.outValue = out; + } /** * If true do not include this value in a transaction log. @@ -500,5 +500,5 @@ public class BindParams implements Serializable { return encryptionKey; } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java index 8e3f0679e..aac90be4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java @@ -44,7 +44,7 @@ public class ClassUtil { ClassLoader contextLoader() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return (loader != null) ? loader: callerLoader; + return (loader != null) ? loader : callerLoader; } public Class forName(String name) throws ClassNotFoundException { diff --git a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java index 2fc8613f7..5de101008 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java @@ -5,13 +5,13 @@ package com.avaje.ebeaninternal.api; */ public enum ConcurrencyMode { - /** - * No concurrency checking. - */ - NONE, - - /** - * Use a version column. - */ - VERSION + /** + * No concurrency checking. + */ + NONE, + + /** + * Use a version column. + */ + VERSION } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java index a9422ac14..c885b29e2 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java @@ -6,7 +6,7 @@ package com.avaje.ebeaninternal.api; public class HashQuery { private final CQueryPlanKey planHash; - + private final int bindHash; /** @@ -26,7 +26,7 @@ public class HashQuery { hc = 31 * hc + bindHash; return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -34,7 +34,7 @@ public class HashQuery { if (!(obj instanceof HashQuery)) { return false; } - + HashQuery e = (HashQuery) obj; return e.bindHash == bindHash && e.planHash.equals(planHash); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java index d4c75e05d..d7faa080f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java @@ -6,9 +6,9 @@ package com.avaje.ebeaninternal.api; public class HashQueryPlan { private final String rawSql; - + private final int planHash; - + private final int bindCount; public HashQueryPlan(String rawSql, int planHash, int bindCount) { @@ -18,7 +18,7 @@ public class HashQueryPlan { } public String toString() { - return planHash+":"+bindCount+(rawSql != null ? ":r" : ""); + return planHash + ":" + bindCount + (rawSql != null ? ":r" : ""); } /** @@ -27,7 +27,7 @@ public class HashQueryPlan { * can be used as a shot form proxy for the actual sql. */ public String getPartialKey() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int hashCode() { @@ -36,7 +36,7 @@ public class HashQueryPlan { hc = hc * 31 + (rawSql == null ? 0 : rawSql.hashCode()); return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -44,11 +44,11 @@ public class HashQueryPlan { if (!(obj instanceof HashQueryPlan)) { return false; } - + HashQueryPlan e = (HashQueryPlan) obj; //noinspection StringEquality return e.planHash == planHash - && e.bindCount == bindCount - && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); + && e.bindCount == bindCount + && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java index c1f2ad696..e55962625 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java @@ -8,7 +8,7 @@ import java.util.Set; public class HashQueryPlanBuilder { private int planHash; - + private int bindCount; public HashQueryPlanBuilder() { @@ -16,9 +16,9 @@ public class HashQueryPlanBuilder { } public String toString() { - return planHash+":"+bindCount; + return planHash + ":" + bindCount; } - + /** * Add a class to the hash calculation. */ @@ -57,7 +57,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (hashValue); return this; } - + /** * Add a boolean to the hash calculation. */ @@ -65,7 +65,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (booleanValue ? 92821 : 0); return this; } - + /** * Add a number to the bind count for the hash. */ @@ -83,7 +83,7 @@ public class HashQueryPlanBuilder { * Build and return the calculated HashQueryPlan. */ public String build() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int getPlanHash() { diff --git a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java index abc111d61..2c7978171 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java @@ -9,28 +9,29 @@ import com.avaje.ebean.TxScope; */ public class HelpScopeTrans { - /** - * Create a ScopeTrans for a given methods TxScope. - */ - public static ScopeTrans createScopeTrans(TxScope txScope) { - - EbeanServer server = Ebean.getServer(txScope.getServerName()); - SpiEbeanServer iserver = (SpiEbeanServer)server; - return iserver.createScopeTrans(txScope); - } - - /** - * Exiting the method in an expected fashion. - *

- * That is returning successfully or via a caught exception. - * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. - *

- * @param returnOrThrowable the return or throwable object - * @param opCode the opcode for ATHROW or ARETURN etc - * @param scopeTrans the scoped transaction the method was run with. - */ - public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans){ - - scopeTrans.onExit(returnOrThrowable, opCode); - } + /** + * Create a ScopeTrans for a given methods TxScope. + */ + public static ScopeTrans createScopeTrans(TxScope txScope) { + + EbeanServer server = Ebean.getServer(txScope.getServerName()); + SpiEbeanServer iserver = (SpiEbeanServer) server; + return iserver.createScopeTrans(txScope); + } + + /** + * Exiting the method in an expected fashion. + *

+ * That is returning successfully or via a caught exception. + * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. + *

+ * + * @param returnOrThrowable the return or throwable object + * @param opCode the opcode for ATHROW or ARETURN etc + * @param scopeTrans the scoped transaction the method was run with. + */ + public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans) { + + scopeTrans.onExit(returnOrThrowable, opCode); + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java index 82e26aa9b..4a90fefa9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import java.util.List; + /** * A buffer of beans for batch lazy loading and secondary query loading. */ @@ -14,7 +14,7 @@ public interface LoadBeanBuffer { int getBatchSize(); List getBatch(); - + BeanDescriptor getBeanDescriptor(); PersistenceContext getPersistenceContext(); @@ -23,4 +23,4 @@ public interface LoadBeanBuffer { void configureQuery(SpiQuery query, String lazyLoadProperty); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java index f38b43189..65c9b0ffc 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java @@ -5,6 +5,5 @@ package com.avaje.ebeaninternal.api; * Controls the loading of ManyToOne and OneToOne relationships. */ public interface LoadBeanContext extends LoadSecondaryQuery { - - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java index d067559e9..f8d1a1ce3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import java.util.List; + /** * A buffer of bean collections for batch lazy loading and secondary query loading. */ @@ -16,7 +16,7 @@ public interface LoadManyBuffer { int getBatchSize(); List> getBatch(); - + BeanPropertyAssocMany getBeanProperty(); ObjectGraphNode getObjectGraphNode(); @@ -30,4 +30,4 @@ public interface LoadManyBuffer { void configureQuery(SpiQuery query); boolean isUseDocStore(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java index 4747778af..dd64d2bd9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java @@ -5,5 +5,5 @@ package com.avaje.ebeaninternal.api; * Controls the loading of OneToMany and ManyToMany relationships. */ public interface LoadManyContext extends LoadSecondaryQuery { - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 3f6172422..281939151 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -42,7 +42,7 @@ public class LoadManyRequest extends LoadRequest { this(loadContext, parentRequest, false, false, false); } - private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { + private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { super(parentRequest, lazy); this.loadContext = loadContext; this.batch = loadContext.getBatch(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java index 89c2c7fdf..4220a28f3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java @@ -14,12 +14,12 @@ public abstract class LoadRequest { protected final boolean lazy; - public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { + public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { - this.parentRequest = parentRequest; - this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); - this.lazy = lazy; - } + this.parentRequest = parentRequest; + this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); + this.lazy = lazy; + } /** * Return the associated bean type for this load request. @@ -35,29 +35,29 @@ public abstract class LoadRequest { parentRequest.getQuery().logSecondaryQuery(query); } } - - /** - * Return true if this is a lazy load and false if it is a secondary query. - */ - public boolean isLazy() { - return lazy; - } - /** - * Return the transaction to use if this is a secondary query. - *

- * Lazy loading queries run in their own transaction. - *

- */ - public Transaction getTransaction() { - return transaction; - } + /** + * Return true if this is a lazy load and false if it is a secondary query. + */ + public boolean isLazy() { + return lazy; + } - /** - * Return true if the parent query is a findIterate() type query. - * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). - */ - public boolean isParentFindIterate() { - return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; - } + /** + * Return the transaction to use if this is a secondary query. + *

+ * Lazy loading queries run in their own transaction. + *

+ */ + public Transaction getTransaction() { + return transaction; + } + + /** + * Return true if the parent query is a findIterate() type query. + * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). + */ + public boolean isParentFindIterate() { + return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java index bb97cccca..317409f45 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java @@ -11,8 +11,8 @@ import com.avaje.ebeaninternal.server.core.OrmQueryRequest; */ public interface LoadSecondaryQuery { - /** - * Execute the secondary query with a given batch size. - */ - void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); + /** + * Execute the secondary query with a given batch size. + */ + void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java index 3a2e8221c..86aac0370 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java @@ -7,6 +7,6 @@ import java.io.Serializable; */ public class Monitor implements Serializable { - private static final long serialVersionUID = -2741687226680981940L; - + private static final long serialVersionUID = -2741687226680981940L; + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java index 2b183074c..0b9338ed9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java @@ -11,7 +11,7 @@ public class PropertyJoin { * The property name. */ private final String property; - + /** * Set to true if the property needs to be an outer join. */ @@ -35,5 +35,5 @@ public class PropertyJoin { public SqlJoinType getSqlJoinType() { return joinType; } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java index 0b437b36d..85bc3fd89 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java @@ -10,6 +10,7 @@ import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.BatchControl; + import javax.persistence.PersistenceException; import javax.persistence.RollbackException; import java.io.IOException; diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java index c4bf5f744..3619b9349 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java @@ -7,8 +7,8 @@ import com.avaje.ebean.BackgroundExecutor; */ public interface SpiBackgroundExecutor extends BackgroundExecutor { - /** - * Shutdown any associated thread pools. - */ - void shutdown(); + /** + * Shutdown any associated thread pools. + */ + void shutdown(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java index 152492c26..2afa43159 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java @@ -4,7 +4,7 @@ import com.avaje.ebean.CallableSql; public interface SpiCallableSql extends CallableSql { - BindParams getBindParams(); - - TransactionEventTable getTransactionEventTable(); + BindParams getBindParams(); + + TransactionEventTable getTransactionEventTable(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java index f375d7cab..09e02d717 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java @@ -13,10 +13,10 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebean.event.readaudit.ReadAuditLogger; import com.avaje.ebean.event.readaudit.ReadAuditPrepare; +import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.query.CQuery; import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent; -import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import java.util.List; diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java index 0c996e741..7195d79e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java @@ -13,28 +13,28 @@ import java.io.IOException; */ public interface SpiExpression extends Expression { - /** - * Simplify nested expressions if possible. - */ - void simplify(); + /** + * Simplify nested expressions if possible. + */ + void simplify(); - /** + /** * Write the expression as an elastic search expression. */ void writeDocQuery(DocQueryContext context) throws IOException; - /** - * Return the nested path for this expression. - */ - String nestedPath(BeanDescriptor desc); + /** + * Return the nested path for this expression. + */ + String nestedPath(BeanDescriptor desc); - /** - * Process "Many" properties populating ManyWhereJoins. + /** + * Process "Many" properties populating ManyWhereJoins. *

* Predicates on Many properties require an extra independent join clause. *

*/ - void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); + void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); /** * Prepare the expression. For example, compile sub-query expressions etc. @@ -42,18 +42,18 @@ public interface SpiExpression extends Expression { void prepareExpression(BeanQueryRequest request); /** - * Calculate a hash value used to identify a query for AutoTune tuning. - *

- * That is, if the hash changes then the query will be considered different - * from an AutoTune perspective and get different tuning. - *

- */ - void queryPlanHash(HashQueryPlanBuilder builder); + * Calculate a hash value used to identify a query for AutoTune tuning. + *

+ * That is, if the hash changes then the query will be considered different + * from an AutoTune perspective and get different tuning. + *

+ */ + void queryPlanHash(HashQueryPlanBuilder builder); - /** - * Return the hash value for the values that will be bound. - */ - int queryBindHash(); + /** + * Return the hash value for the values that will be bound. + */ + int queryBindHash(); /** * Return true if the expression is the same without taking into account bind values. @@ -65,29 +65,28 @@ public interface SpiExpression extends Expression { */ boolean isSameByBind(SpiExpression other); - /** - * Add some sql to the query. - *

- * This will contain ? as a place holder for each associated bind values. - *

- *

- * The 'sql' added to the query can contain object property names rather - * than db tables and columns. This 'sql' is later parsed converting the - * logical property names to their full database column names. - *

- * @param request - * the associated request. - */ - void addSql(SpiExpressionRequest request); + /** + * Add some sql to the query. + *

+ * This will contain ? as a place holder for each associated bind values. + *

+ *

+ * The 'sql' added to the query can contain object property names rather + * than db tables and columns. This 'sql' is later parsed converting the + * logical property names to their full database column names. + *

+ * + * @param request the associated request. + */ + void addSql(SpiExpressionRequest request); - /** - * Add the parameter values to be set against query. For each ? place holder - * there should be a corresponding value that is added to the bindList. - * - * @param request - * the associated request. - */ - void addBindValues(SpiExpressionRequest request); + /** + * Add the parameter values to be set against query. For each ? place holder + * there should be a corresponding value that is added to the bindList. + * + * @param request the associated request. + */ + void addBindValues(SpiExpressionRequest request); /** * Validate all the properties/paths associated with this expression. @@ -99,8 +98,8 @@ public interface SpiExpression extends Expression { */ SpiExpression copyForPlanKey(); - /** - * Return the bind Id value if this is a "equal to" expression for the id property. + /** + * Return the bind Id value if this is a "equal to" expression for the id property. */ - Object getIdEqualTo(String idName); + Object getIdEqualTo(String idName); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java index 4c19c61a2..895b81203 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java @@ -27,10 +27,10 @@ public interface SpiExpressionList extends ExpressionList, SpiExpression { */ SpiExpressionList trimPath(int prefixTrim); - /** - * Return true if this list is empty. - */ - boolean isEmpty(); + /** + * Return true if this list is empty. + */ + boolean isEmpty(); /** * Write the top level where expressions taking into account possible extra idEquals expression. diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java index 51a7f1c0e..99c81f2ec 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.api; -import java.sql.PreparedStatement; - import com.avaje.ebean.SqlQuery; /** diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java index 2060a9c9a..b19ce0b9d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java @@ -4,7 +4,7 @@ import com.avaje.ebean.SqlUpdate; public interface SpiSqlUpdate extends SqlUpdate { - BindParams getBindParams(); + BindParams getBindParams(); void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index 5224acf57..e63071432 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -9,6 +9,7 @@ import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.BatchControl; + import java.sql.Connection; /** diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java index 881b32c49..32a316338 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java @@ -2,5 +2,5 @@ package com.avaje.ebeaninternal.api; public interface SpiTransactionScopeManager { - void replace(SpiTransaction t); + void replace(SpiTransaction t); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java index 04d7be2b9..17324e507 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java @@ -7,70 +7,70 @@ import com.avaje.ebean.Update; */ public interface SpiUpdate extends Update { - /** - * The type of the update request. - */ - enum OrmUpdateType { - INSERT { - public String toString() { - return "Insert"; - } - }, - UPDATE { - public String toString() { - return "Update"; - } - }, - DELETE { - public String toString() { - return "Delete"; - } - }, - UNKNOWN { - public String toString() { - return "Unknown"; - } + /** + * The type of the update request. + */ + enum OrmUpdateType { + INSERT { + public String toString() { + return "Insert"; + } + }, + UPDATE { + public String toString() { + return "Update"; + } + }, + DELETE { + public String toString() { + return "Delete"; + } + }, + UNKNOWN { + public String toString() { + return "Unknown"; + } - } - } - - /** - * Return the type of bean being updated. - */ - Class getBeanType(); + } + } - /** - * Return the type of this - insert, update or delete. - */ - OrmUpdateType getOrmUpdateType(); - - /** - * Return the name of the table being modified. - */ - String getBaseTable(); - - /** - * Return the update statement. This could be either sql or an orm update with bean types and property names. - */ - String getUpdateStatement(); - - /** - * Return the timeout in seconds. - */ - int getTimeout(); - - /** - * Return true if the cache should be notified to invalidate objects. - */ - boolean isNotifyCache(); - - /** - * Return the bind parameters. - */ - BindParams getBindParams(); - - /** - * Set the generated sql used. - */ - void setGeneratedSql(String sql); + /** + * Return the type of bean being updated. + */ + Class getBeanType(); + + /** + * Return the type of this - insert, update or delete. + */ + OrmUpdateType getOrmUpdateType(); + + /** + * Return the name of the table being modified. + */ + String getBaseTable(); + + /** + * Return the update statement. This could be either sql or an orm update with bean types and property names. + */ + String getUpdateStatement(); + + /** + * Return the timeout in seconds. + */ + int getTimeout(); + + /** + * Return true if the cache should be notified to invalidate objects. + */ + boolean isNotifyCache(); + + /** + * Return the bind parameters. + */ + BindParams getBindParams(); + + /** + * Set the generated sql used. + */ + void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java index 15551602b..1f634a33f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.sql.SQLException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.persist.dml.DmlHandler; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; +import java.sql.SQLException; + /** * A plan for executing bean updates for a given set of changed properties. *

@@ -26,41 +26,41 @@ public interface SpiUpdatePlan { *

*/ boolean isEmptySetClause(); - - /** - * Bind given the request and bean. The bean could be the oldValues bean - * when binding a update or delete where clause with ALL concurrency mode. - */ - void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was created. - */ - long getTimeCreated(); + /** + * Bind given the request and bean. The bean could be the oldValues bean + * when binding a update or delete where clause with ALL concurrency mode. + */ + void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was last used. - */ - Long getTimeLastUsed(); + /** + * Return the time this plan was created. + */ + long getTimeCreated(); - /** - * Return the hash key for this plan. - */ - Integer getKey(); + /** + * Return the time this plan was last used. + */ + Long getTimeLastUsed(); - /** - * Return the concurrency mode for this plan. - */ - ConcurrencyMode getMode(); + /** + * Return the hash key for this plan. + */ + Integer getKey(); - /** - * Return the update SQL statement. - */ - String getSql(); + /** + * Return the concurrency mode for this plan. + */ + ConcurrencyMode getMode(); - /** - * Return the set of bindable update properties. - */ - Bindable getSet(); + /** + * Return the update SQL statement. + */ + String getSql(); -} \ No newline at end of file + /** + * Return the set of bindable update properties. + */ + Bindable getSet(); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 6f81f9aa1..2f1d0a2f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -1,10 +1,10 @@ package com.avaje.ebeaninternal.api; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.transaction.DeleteByIdMap; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 3b770ce92..608091511 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.cache.CacheChangeSet; import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import java.util.ArrayList; +import java.util.List; + /** * Lists of inserted updated and deleted beans that have a BeanPersistListener. *

@@ -17,28 +17,28 @@ public class TransactionEventBeans { final ArrayList> requests = new ArrayList<>(); - /** - * Return the list of PersistRequests that BeanListeners are interested in. - */ - public List> getRequests() { - return requests; - } - - /** - * Add a bean for BeanListener notification. - */ - public void add(PersistRequestBean request) { - - requests.add(request); - } - - /** - * Collect the cache changes. + /** + * Return the list of PersistRequests that BeanListeners are interested in. */ - public void notifyCache(CacheChangeSet changeSet) { + public List> getRequests() { + return requests; + } + + /** + * Add a bean for BeanListener notification. + */ + public void add(PersistRequestBean request) { + + requests.add(request); + } + + /** + * Collect the cache changes. + */ + public void notifyCache(CacheChangeSet changeSet) { for (PersistRequestBean request : requests) { request.notifyCache(changeSet); } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java index 1922b6bee..c96580f4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebean.event.BulkTableEvent; +import com.avaje.ebeaninternal.server.cluster.BinaryMessage; +import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; + import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; @@ -8,136 +12,133 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import com.avaje.ebean.event.BulkTableEvent; -import com.avaje.ebeaninternal.server.cluster.BinaryMessage; -import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; - public final class TransactionEventTable implements Serializable { - private static final long serialVersionUID = 2236555729767483264L; - - private final Map map = new HashMap<>(); - - public String toString() { - return "TransactionEventTable " + map.values(); + private static final long serialVersionUID = 2236555729767483264L; + + private final Map map = new HashMap<>(); + + public String toString() { + return "TransactionEventTable " + map.values(); + } + + public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { + + for (TableIUD tableIud : map.values()) { + tableIud.writeBinaryMessage(msgList); + } + } + + public void readBinaryMessage(DataInput dataInput) throws IOException { + + TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); + map.put(tableIud.getTableName(), tableIud); + } + + + public void add(TransactionEventTable table) { + + for (TableIUD iud : table.values()) { + add(iud); + } + } + + public void add(String table, boolean insert, boolean update, boolean delete) { + + table = table.toUpperCase(); + + add(new TableIUD(table, insert, update, delete)); + } + + public void add(TableIUD newTableIUD) { + + TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); + if (existingTableIUD != null) { + newTableIUD.add(existingTableIUD); + } + } + + public boolean isEmpty() { + return map.isEmpty(); + } + + public Collection values() { + return map.values(); + } + + public static class TableIUD implements Serializable, BulkTableEvent { + + private static final long serialVersionUID = -1958317571064162089L; + + private final String table; + private boolean insert; + private boolean update; + private boolean delete; + + public TableIUD(String table, boolean insert, boolean update, boolean delete) { + this.table = table; + this.insert = insert; + this.update = update; + this.delete = delete; + } + + public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { + + String table = dataInput.readUTF(); + boolean insert = dataInput.readBoolean(); + boolean update = dataInput.readBoolean(); + boolean delete = dataInput.readBoolean(); + + return new TableIUD(table, insert, update, delete); } public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - for (TableIUD tableIud : map.values()) { - tableIud.writeBinaryMessage(msgList); - } - } - - public void readBinaryMessage(DataInput dataInput) throws IOException { - - TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); - map.put(tableIud.getTableName(), tableIud); + BinaryMessage msg = new BinaryMessage(table.length() + 10); + DataOutputStream os = msg.getOs(); + os.writeInt(BinaryMessage.TYPE_TABLEIUD); + os.writeUTF(table); + os.writeBoolean(insert); + os.writeBoolean(update); + os.writeBoolean(delete); + + msgList.add(msg); } - - public void add(TransactionEventTable table){ - - for (TableIUD iud : table.values()) { - add(iud); - } - } + public String toString() { + return "TableIUD " + table + " i:" + insert + " u:" + update + " d:" + delete; + } - public void add(String table, boolean insert, boolean update, boolean delete){ + private void add(TableIUD other) { + if (other.insert) { + insert = true; + } + if (other.update) { + update = true; + } + if (other.delete) { + delete = true; + } + } - table = table.toUpperCase(); - - add(new TableIUD(table, insert, update, delete)); - } - - public void add(TableIUD newTableIUD){ + public String getTableName() { + return table; + } - TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); - if (existingTableIUD != null){ - newTableIUD.add(existingTableIUD); - } - } - - public boolean isEmpty() { - return map.isEmpty(); - } - - public Collection values() { - return map.values(); - } - - public static class TableIUD implements Serializable, BulkTableEvent { - - private static final long serialVersionUID = -1958317571064162089L; - - private final String table; - private boolean insert; - private boolean update; - private boolean delete; - - public TableIUD(String table, boolean insert, boolean update, boolean delete){ - this.table = table; - this.insert = insert; - this.update = update; - this.delete = delete; - } - - public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { - - String table = dataInput.readUTF(); - boolean insert = dataInput.readBoolean(); - boolean update = dataInput.readBoolean(); - boolean delete = dataInput.readBoolean(); - - return new TableIUD(table, insert, update, delete); - } - - public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - - BinaryMessage msg = new BinaryMessage(table.length()+10); - DataOutputStream os = msg.getOs(); - os.writeInt(BinaryMessage.TYPE_TABLEIUD); - os.writeUTF(table); - os.writeBoolean(insert); - os.writeBoolean(update); - os.writeBoolean(delete); - - msgList.add(msg); - } - - public String toString() { - return "TableIUD "+table+" i:"+insert+" u:"+update+" d:"+delete; - } - - private void add(TableIUD other) { - if (other.insert){ - insert = true; - } - if (other.update){ - update = true; - } - if (other.delete){ - delete = true; - } - } - public String getTableName() { - return table; - } + public boolean isInsert() { + return insert; + } - public boolean isInsert() { - return insert; - } + public boolean isUpdate() { + return update; + } - public boolean isUpdate() { - return update; - } + public boolean isDelete() { + return delete; + } - public boolean isDelete() { - return delete; - } - - public boolean isUpdateOrDelete() { - return update || delete; - } - } + public boolean isUpdateOrDelete() { + return update || delete; + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java index a0020f584..fd104ac5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -24,93 +23,79 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "ddl-script") public class DdlScript { - @XmlValue - protected String value; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "platforms") - protected String platforms; + @XmlValue + protected String value; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "platforms") + protected String platforms; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the platforms property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPlatforms() { - return platforms; - } + /** + * Gets the value of the platforms property. + * + * @return possible object is + * {@link String } + */ + public String getPlatforms() { + return platforms; + } - /** - * Sets the value of the platforms property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPlatforms(String value) { - this.platforms = value; - } + /** + * Sets the value of the platforms property. + * + * @param value allowed object is + * {@link String } + */ + public void setPlatforms(String value) { + this.platforms = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java index 79d532c70..3c7867262 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java @@ -1,20 +1,19 @@ - package com.avaje.ebeaninternal.extraddl.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "ddlScript" + "ddlScript" }) @XmlRootElement(name = "extra-ddl") public class ExtraDdl { - @XmlElement(name = "ddl-script", required = true) - protected List ddlScript; + @XmlElement(name = "ddl-script", required = true) + protected List ddlScript; - /** - * Gets the value of the ddlScript property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ddlScript property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getDdlScript().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link DdlScript } - * - * - */ - public List getDdlScript() { - if (ddlScript == null) { - ddlScript = new ArrayList<>(); - } - return this.ddlScript; + /** + * Gets the value of the ddlScript property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the ddlScript property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getDdlScript().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link DdlScript } + */ + public List getDdlScript() { + if (ddlScript == null) { + ddlScript = new ArrayList<>(); } + return this.ddlScript; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java index 2a3767785..1a5e1fbf0 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java @@ -36,8 +36,9 @@ public class ExtraDdlXmlReader { /** * Return true if the script platforms is a match/supported for the given platform. + * * @param platformName The database platform we are generating/running DDL for - * @param platforms The platforms (comma delimited) this script should run for + * @param platforms The platforms (comma delimited) this script should run for */ public static boolean matchPlatform(String platformName, String platforms) { if (platforms == null || platforms.trim().isEmpty()) { diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java index 07009ef1a..c73abca6f 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java @@ -1,48 +1,43 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.extraddl.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.extraddl.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link DdlScript } - * - */ - public DdlScript createDdlScript() { - return new DdlScript(); - } + /** + * Create an instance of {@link DdlScript } + */ + public DdlScript createDdlScript() { + return new DdlScript(); + } - /** - * Create an instance of {@link ExtraDdl } - * - */ - public ExtraDdl createExtraDdl() { - return new ExtraDdl(); - } + /** + * Create an instance of {@link ExtraDdl } + */ + public ExtraDdl createExtraDdl() { + return new ExtraDdl(); + } } From 60dfe6308e7e2e0346b50d8c37bc860180f9eafe Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:54:54 +1300 Subject: [PATCH 74/87] no effective change - format and javadoc --- .../com/avaje/ebean/BackgroundExecutor.java | 2 +- src/main/java/com/avaje/ebean/BeanState.java | 17 +- .../java/com/avaje/ebean/CallableSql.java | 92 ++++---- .../com/avaje/ebean/DRawSqlColumnsParser.java | 7 +- .../java/com/avaje/ebean/DRawSqlParser.java | 2 +- .../java/com/avaje/ebean/DocumentStore.java | 16 +- src/main/java/com/avaje/ebean/Ebean.java | 213 +++++++----------- .../java/com/avaje/ebean/EbeanServer.java | 14 +- .../com/avaje/ebean/EbeanServerFactory.java | 2 +- .../com/avaje/ebean/ExampleExpression.java | 40 ++-- src/main/java/com/avaje/ebean/Expr.java | 35 ++- .../com/avaje/ebean/ExpressionFactory.java | 30 ++- .../java/com/avaje/ebean/ExpressionList.java | 83 ++++--- .../java/com/avaje/ebean/FetchConfig.java | 62 ++--- src/main/java/com/avaje/ebean/Filter.java | 77 ++++--- src/main/java/com/avaje/ebean/Finder.java | 15 +- src/main/java/com/avaje/ebean/FutureList.java | 19 +- .../java/com/avaje/ebean/FutureRowCount.java | 4 +- src/main/java/com/avaje/ebean/Junction.java | 7 +- src/main/java/com/avaje/ebean/Model.java | 110 ++++----- src/main/java/com/avaje/ebean/OrderBy.java | 2 +- src/main/java/com/avaje/ebean/PagedList.java | 18 +- src/main/java/com/avaje/ebean/Query.java | 4 +- .../com/avaje/ebean/QueryEachConsumer.java | 12 +- .../avaje/ebean/QueryEachWhileConsumer.java | 15 +- .../java/com/avaje/ebean/QueryIterator.java | 8 +- src/main/java/com/avaje/ebean/RawSql.java | 46 ++-- .../java/com/avaje/ebean/RawSqlBuilder.java | 22 +- src/main/java/com/avaje/ebean/SqlQuery.java | 14 +- src/main/java/com/avaje/ebean/SqlUpdate.java | 26 ++- .../java/com/avaje/ebean/Transaction.java | 63 +++--- src/main/java/com/avaje/ebean/TxCallable.java | 22 +- .../java/com/avaje/ebean/TxIsolation.java | 30 +-- src/main/java/com/avaje/ebean/TxRunnable.java | 21 +- src/main/java/com/avaje/ebean/TxScope.java | 3 +- src/main/java/com/avaje/ebean/TxType.java | 2 +- src/main/java/com/avaje/ebean/Update.java | 95 ++++---- .../java/com/avaje/ebean/UpdateQuery.java | 28 +-- src/main/java/com/avaje/ebean/ValuePair.java | 2 +- src/main/java/com/avaje/ebean/overview.html | 74 +++--- src/main/java/com/avaje/ebean/package.html | 6 +- src/main/java/com/avaje/ebean/stylesheet.css | 93 ++++++-- 42 files changed, 680 insertions(+), 773 deletions(-) diff --git a/src/main/java/com/avaje/ebean/BackgroundExecutor.java b/src/main/java/com/avaje/ebean/BackgroundExecutor.java index 12edb0a51..8f2afbf64 100644 --- a/src/main/java/com/avaje/ebean/BackgroundExecutor.java +++ b/src/main/java/com/avaje/ebean/BackgroundExecutor.java @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; * code if you want. It can be useful for some server caching implementations * (background population and trimming of the cache etc). *

- * + * * @author rbygrave */ public interface BackgroundExecutor { diff --git a/src/main/java/com/avaje/ebean/BeanState.java b/src/main/java/com/avaje/ebean/BeanState.java index a6708a783..7972abbd4 100644 --- a/src/main/java/com/avaje/ebean/BeanState.java +++ b/src/main/java/com/avaje/ebean/BeanState.java @@ -45,13 +45,11 @@ public interface BeanState { /** * Set the loaded state of the property given it's name. - * *

- * Typically this would be used to set the loaded state of a property - * to false to ensure that the specific property is excluded from a - * stateless update. + * Typically this would be used to set the loaded state of a property + * to false to ensure that the specific property is excluded from a + * stateless update. *

- * *
{@code
    *
    *   // populate a bean via say JSON
@@ -64,8 +62,7 @@ public interface BeanState {
    *   user.update();
    *
    * }
- * - * + *

* This will throw an IllegalArgumentException if the property is unknown. */ void setPropertyLoaded(String propertyName, boolean loaded); @@ -87,8 +84,8 @@ public interface BeanState { /** * Return a map of the updated properties and their new and old values. */ - Map getDirtyValues(); - + Map getDirtyValues(); + /** * Return true if the bean is readOnly. *

@@ -125,4 +122,4 @@ public interface BeanState { * Reset the bean putting it into NEW state such that a save() results in an insert. */ void resetForInsert(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/CallableSql.java b/src/main/java/com/avaje/ebean/CallableSql.java index fcff6b43b..edeb670a0 100644 --- a/src/main/java/com/avaje/ebean/CallableSql.java +++ b/src/main/java/com/avaje/ebean/CallableSql.java @@ -13,65 +13,66 @@ import java.sql.SQLException; *

* Example 1: *

- * - *
- * String sql = "{call sp_order_mod(?,?)}";
- * 
+ * 
{@code
+ *
+ * String sql = "{call sp_order_mod(?,?)}";
+ *
  * CallableSql cs = Ebean.createCallableSql(sql);
- * cs.setParameter(1, "turbo");
+ * cs.setParameter(1, "turbo");
  * cs.registerOut(2, Types.INTEGER);
- * 
+ *
  * Ebean.execute(cs);
- * 
+ *
  * // read the out parameter
  * Integer returnValue = (Integer) cs.getObject(2);
- * 
- * + * + * }
*

* Example 2:
* Includes batch mode, table modification information and label. Note that the * label is really only to help people reading the transaction logs to identify * the procedure called etc. *

- * - *
- * String sql = "{call sp_insert_order(?,?)}";
- * 
+ *
+ * 
{@code
+ *
+ * String sql = "{call sp_insert_order(?,?)}";
+ *
  * CallableSql cs = Ebean.createCallableSql(sql);
- * 
+ *
  * // Inform Ebean this stored procedure inserts into the
  * // oe_order table and inserts + updates the oe_order_detail table.
  * // this is used to invalidate objects in the cache
- * cs.addModification("oe_order", true, false, false);
- * cs.addModification("oe_order_detail", true, true, false);
- * 
+ * cs.addModification("oe_order", true, false, false);
+ * cs.addModification("oe_order_detail", true, true, false);
+ *
  * Transaction t = Ebean.startTransaction();
- * 
+ *
  * // execute using JDBC batching 10 statements at a time
  * t.setBatchMode(true);
  * t.setBatchSize(10);
  * try {
- *   cs.setParameter(1, "Was");
- *   cs.setParameter(2, "Banana");
+ *   cs.setParameter(1, "Was");
+ *   cs.setParameter(2, "Banana");
  *   Ebean.execute(cs);
- * 
- *   cs.setParameter(1, "Here");
- *   cs.setParameter(2, "Kumera");
+ *
+ *   cs.setParameter(1, "Here");
+ *   cs.setParameter(2, "Kumera");
  *   Ebean.execute(cs);
- * 
- *   cs.setParameter(1, "More");
- *   cs.setParameter(2, "Apple");
+ *
+ *   cs.setParameter(1, "More");
+ *   cs.setParameter(2, "Apple");
  *   Ebean.execute(cs);
- * 
- *   // Ebean.externalModification("oe_order",true,false,false);
- *   // Ebean.externalModification("oe_order_detail",true,true,false);
+ *
+ *   // Ebean.externalModification("oe_order",true,false,false);
+ *   // Ebean.externalModification("oe_order_detail",true,true,false);
  *   Ebean.commitTransaction();
- * 
+ *
  * } finally {
  *   Ebean.endTransaction();
  * }
- * 
- * + * }
+ * * @see com.avaje.ebean.SqlUpdate * @see com.avaje.ebean.Ebean#execute(CallableSql) */ @@ -119,21 +120,17 @@ public interface CallableSql { * This is designed so that you do not need to set params in index order. You * can set/register param 2 before param 1 etc. *

- * - * @param position - * the index position of the parameter. - * @param value - * the value of the parameter. + * + * @param position the index position of the parameter. + * @param value the value of the parameter. */ CallableSql bind(int position, Object value); /** * Bind a positioned parameter (same as bind method). - * - * @param position - * the index position of the parameter. - * @param value - * the value of the parameter. + * + * @param position the index position of the parameter. + * @param value the value of the parameter. */ CallableSql setParameter(int position, Object value); @@ -147,11 +144,9 @@ public interface CallableSql { * This is designed so that you do not need to register params in index order. * You can set/register param 2 before param 1 etc. *

- * - * @param position - * the index position of the parameter (starts with 1). - * @param type - * the jdbc type of the OUT parameter that will be read. + * + * @param position the index position of the parameter (starts with 1). + * @param type the jdbc type of the OUT parameter that will be read. */ CallableSql registerOut(int position, int type); @@ -168,7 +163,6 @@ public interface CallableSql { Object getObject(int position); /** - * * You can extend this object and override this method for more advanced * stored procedure calls. This would be the case when ResultSets are returned * etc. @@ -190,4 +184,4 @@ public interface CallableSql { */ CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java index 43a96a191..6cb9d14ce 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlColumnsParser.java @@ -1,10 +1,9 @@ package com.avaje.ebean; -import java.util.ArrayList; +import com.avaje.ebean.RawSql.ColumnMapping; import javax.persistence.PersistenceException; - -import com.avaje.ebean.RawSql.ColumnMapping; +import java.util.ArrayList; /** * Parses columnMapping (select clause) mapping columns to bean properties. @@ -74,7 +73,7 @@ final class DRawSqlColumnsParser { // build back the 'column formula' that precedes the AS keyword StringBuilder sb = new StringBuilder(); sb.append(split[0]); - for (int i = 1; i < split.length-2; i++) { + for (int i = 1; i < split.length - 2; i++) { sb.append(" ").append(split[i]); } return new ColumnMapping.Column(indexPos++, sb.toString(), split[split.length - 1]); diff --git a/src/main/java/com/avaje/ebean/DRawSqlParser.java b/src/main/java/com/avaje/ebean/DRawSqlParser.java index 1f3b9a560..a212c795c 100644 --- a/src/main/java/com/avaje/ebean/DRawSqlParser.java +++ b/src/main/java/com/avaje/ebean/DRawSqlParser.java @@ -47,7 +47,7 @@ class DRawSqlParser { private DRawSqlParser(String sqlString) { sqlString = sqlString.trim(); - sqlString = sqlString.replace('\n',' '); + sqlString = sqlString.replace('\n', ' '); this.sql = sqlString; this.hasPlaceHolders = findAndRemovePlaceHolders(); this.textParser = new SimpleTextParser(sqlString); diff --git a/src/main/java/com/avaje/ebean/DocumentStore.java b/src/main/java/com/avaje/ebean/DocumentStore.java index 22b30f953..95e0a1134 100644 --- a/src/main/java/com/avaje/ebean/DocumentStore.java +++ b/src/main/java/com/avaje/ebean/DocumentStore.java @@ -93,7 +93,6 @@ public interface DocumentStore { *

* Typically this is called indirectly by findPagedList() on the query that has setUseDocStore(true). *

- * *
{@code
    *
    * PagedList newCustomers =
@@ -104,7 +103,6 @@ public interface DocumentStore {
    *    .findPagedList();
    *
    * }
- * */ PagedList findPagedList(DocQueryRequest request); @@ -117,7 +115,6 @@ public interface DocumentStore { *

* Typically this is called indirectly by findEach() on the query that has setUseDocStore(true). *

- * *
{@code
    *
    *  server.find(Order.class)
@@ -146,8 +143,6 @@ public interface DocumentStore {
    * 

* Typically this is called indirectly by findEachWhile() on the query that has setUseDocStore(true). *

- * - * *
{@code
    *
    *  server.find(Order.class)
@@ -175,7 +170,6 @@ public interface DocumentStore {
 
   /**
    * Drop the index from the document store (similar to DDL drop table).
-   *
    * 
{@code
    *
    *   DocumentStore documentStore = server.docStore();
@@ -183,13 +177,11 @@ public interface DocumentStore {
    *   documentStore.dropIndex("product_copy");
    *
    * }
- * */ void dropIndex(String indexName); /** * Create an index given a mapping file as a resource in the classPath (similar to DDL create table). - * *
{@code
    *
    *   DocumentStore documentStore = server.docStore();
@@ -201,8 +193,8 @@ public interface DocumentStore {
    *
    * }
* - * @param indexName the name of the new index - * @param alias the alias of the index + * @param indexName the name of the new index + * @param alias the alias of the index */ void createIndex(String indexName, String alias); @@ -222,7 +214,6 @@ public interface DocumentStore { * documentStore.indexSettings("product", settings); * * }
- * *
{@code
    *
    *   // refresh_interval 1s ... restore after bulk loading
@@ -244,7 +235,6 @@ public interface DocumentStore {
    * 

* This copy process does not use the database but instead will copy from the source index to a destination index. *

- * *
{@code
    *
    *  long copyCount = documentStore.copyIndex(Product.class, "product_copy");
@@ -263,7 +253,6 @@ public interface DocumentStore {
    * 

* To support this the document needs to have a @WhenModified property. *

- * *
{@code
    *
    *  long copyCount = documentStore.copyIndex(Product.class, "product_copy", sinceMillis);
@@ -279,7 +268,6 @@ public interface DocumentStore {
   /**
    * Copy from a source index to a new index taking only the documents
    * matching the given query.
-   *
    * 
{@code
    *
    *  // predicates to select the source documents to copy
diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java
index 33020f033..e7012913e 100644
--- a/src/main/java/com/avaje/ebean/Ebean.java
+++ b/src/main/java/com/avaje/ebean/Ebean.java
@@ -41,7 +41,6 @@ import java.util.concurrent.ConcurrentHashMap;
  * {@link #find(Class)} that proxy through to the 'default' EbeanServer. This
  * can be useful for applications that use a single database.
  * 
- * 
  * 

* For developer convenience Ebean has static methods that proxy through to the * methods on the 'default' EbeanServer. These methods are provided for @@ -59,7 +58,6 @@ import java.util.concurrent.ConcurrentHashMap; * created automatically they are configured using information in the * ebean.properties file. *

- * *
{@code
  *
  *   // fetch shipped orders (and also their customer)
@@ -76,40 +74,36 @@ import java.util.concurrent.ConcurrentHashMap;
  *   }
  *
  * }
- * *
{@code
  *
  *   // fetch order 10, modify and save
  *   Order order = Ebean.find(Order.class, 10);
- * 
+ *
  *   OrderStatus shipped = Ebean.getReference(OrderStatus.class,"SHIPPED");
  *   order.setStatus(shipped);
  *   order.setShippedDate(shippedDate);
  *   ...
- * 
+ *
  *   // implicitly creates a transaction and commits
  *   Ebean.save(order);
  *
  * }
- * *

* When you have multiple databases and need access to a specific one the * {@link #getServer(String)} method provides access to the EbeanServer for that * specific database. *

- * *
{@code
  *
  *   // Get access to the Human Resources EbeanServer/Database
  *   EbeanServer hrDb = Ebean.getServer("hr");
- * 
- * 
+ *
  *   // fetch contact 3 from the HR database
  *   Contact contact = hrDb.find(Contact.class, 3);
- * 
+ *
  *   contact.setName("I'm going to change");
  *   ...
- * 
+ *
  *   // save the contact back to the HR database
  *   hrDb.save(contact);
  *
@@ -217,7 +211,7 @@ public final class Ebean {
     private void register(EbeanServer server, boolean isDefaultServer) {
       registerWithName(server.getName(), server, isDefaultServer);
     }
-    
+
     private void registerWithName(String name, EbeanServer server, boolean isDefaultServer) {
       synchronized (monitor) {
         concMap.put(name, server);
@@ -242,16 +236,14 @@ public final class Ebean {
    * transactions and the ability to use transactions created externally to
    * Ebean.
    * 

- * *
{@code
    * // use the "hr" database
    * EbeanServer hrDatabase = Ebean.getServer("hr");
-   * 
+   *
    * Person person = hrDatabase.find(Person.class, 10);
    * }
- * - * @param name - * the name of the server, can use null for the 'default server' + * + * @param name the name of the server, can use null for the 'default server' */ public static EbeanServer getServer(String name) { return serverMgr.get(name); @@ -304,7 +296,7 @@ public final class Ebean { serverMgr.registerWithName(name, server, defaultServer); return originalPrimaryServer; } - + /** * Return the next identity value for a given bean type. *

@@ -336,7 +328,6 @@ public final class Ebean { * Example of using a transaction to span multiple calls to find(), save() * etc. *

- * *
{@code
    *
    *   // start a transaction (stored in a ThreadLocal)
@@ -345,9 +336,9 @@ public final class Ebean {
    * 	   Order order = Ebean.find(Order.class,10); ...
    *
    * 	   Ebean.save(order);
-   * 
+   *
    * 	   Ebean.commitTransaction();
-   * 
+   *
    *   } finally {
    * 	   // rollback if we didn't commit
    * 	   // i.e. an exception occurred before commitTransaction().
@@ -355,7 +346,6 @@ public final class Ebean {
    *   }
    *
    * }
- * *

* If you want to externalise the transaction management then you should be * able to do this via EbeanServer. Specifically with EbeanServer you can pass @@ -371,10 +361,8 @@ public final class Ebean { /** * Start a transaction additionally specifying the isolation level. - * - * @param isolation - * the Transaction isolation level - * + * + * @param isolation the Transaction isolation level */ public static Transaction beginTransaction(TxIsolation isolation) { return serverMgr.getDefaultServer().beginTransaction(isolation); @@ -382,12 +370,10 @@ public final class Ebean { /** * Start a transaction typically specifying REQUIRES_NEW or REQUIRED semantics. - * *

* Note that this provides an try finally alternative to using {@link #execute(TxScope, TxCallable)} or * {@link #execute(TxScope, TxRunnable)}. *

- * *

REQUIRES_NEW example:

*
{@code
    * // Start a new transaction. If there is a current transaction
@@ -408,7 +394,6 @@ public final class Ebean {
    * }
    *
    * }
- * *

REQUIRED example:

*
{@code
    *
@@ -431,7 +416,7 @@ public final class Ebean {
    *
    * }
*/ - public static Transaction beginTransaction(TxScope scope){ + public static Transaction beginTransaction(TxScope scope) { return serverMgr.getDefaultServer().beginTransaction(scope); } @@ -449,7 +434,6 @@ public final class Ebean { * If there is no currently active transaction then a PersistenceException is thrown. * * @param transactionCallback the transaction callback to be registered with the current transaction - * * @throws PersistenceException if there is no currently active transaction */ public static void register(TransactionCallback transactionCallback) throws PersistenceException { @@ -480,7 +464,6 @@ public final class Ebean { *

* Code example: *

- * *
{@code
    *   Ebean.beginTransaction();
    *   try {
@@ -488,7 +471,7 @@ public final class Ebean {
    *
    *     // commit at the end
    *     Ebean.commitTransaction();
-   * 
+   *
    *   } finally {
    *     // if commit didn't occur then rollback the transaction
    *     Ebean.endTransaction();
@@ -532,16 +515,14 @@ public final class Ebean {
    * In this example below the details property has a CascadeType.ALL set so
    * saving an order will also save all its details.
    * 

- * *
{@code
    *   public class Order { ...
-   * 	
+   *
    * 	   @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
    * 	   List details;
    * 	   ...
    *   }
    * }
- * *

* When a save cascades via a OneToMany or ManyToMany Ebean will automatically * set the 'parent' object to the 'detail' object. In the example below in @@ -576,16 +557,15 @@ public final class Ebean { *

* An unmodified bean that is saved or updated is normally skipped and this marks the bean as * dirty so that it is not skipped. - * *

{@code
-   * 
+   *
    *   Customer customer = Ebean.find(Customer, id);
-   * 
+   *
    *   // mark the bean as dirty so that a save() or update() will
    *   // increment the version property
    *   Ebean.markAsDirty(customer);
    *   Ebean.save(customer);
-   * 
+   *
    * }
*/ public static void markAsDirty(Object bean) throws OptimisticLockException { @@ -614,17 +594,16 @@ public final class Ebean { * controls if only the changed properties are included in the update or if all the loaded * properties are included instead. *

- * *
{@code
-   * 
+   *
    *   // A 'stateless update' example
    *   Customer customer = new Customer();
    *   customer.setId(7);
    *   customer.setName("ModifiedNameNoOCC");
    *   ebeanServer.update(customer);
-   * 
+   *
    * }
- * + * * @see ServerConfig#setUpdatesDeleteMissingChildren(boolean) * @see ServerConfig#setUpdateChangesOnly(boolean) */ @@ -731,7 +710,6 @@ public final class Ebean { /** * Refresh a 'many' property of a bean. - * *
{@code
    *
    *   Order order = ...;
@@ -740,11 +718,9 @@ public final class Ebean {
    *   Ebean.refreshMany(order, "details");
    *
    * }
- * - * @param bean - * the entity bean containing the List Set or Map to refresh. - * @param manyPropertyName - * the property name of the List Set or Map to refresh. + * + * @param bean the entity bean containing the List Set or Map to refresh. + * @param manyPropertyName the property name of the List Set or Map to refresh. */ public static void refreshMany(Object bean, String manyPropertyName) { serverMgr.getDefaultServer().refreshMany(bean, manyPropertyName); @@ -755,24 +731,21 @@ public final class Ebean { *

* This is sometimes described as a proxy (with lazy loading). *

- * *
{@code
    *
    *   Product product = Ebean.getReference(Product.class, 1);
-   * 
+   *
    *   // You can get the id without causing a fetch/lazy load
    *   Integer productId = product.getId();
-   * 
+   *
    *   // If you try to get any other property a fetch/lazy loading will occur
    *   // This will cause a query to execute...
    *   String name = product.getName();
    *
    * }
- * - * @param beanType - * the type of entity bean - * @param id - * the id value + * + * @param beanType the type of entity bean + * @param id the id value */ public static T getReference(Class beanType, Object id) { return serverMgr.getDefaultServer().getReference(beanType, id); @@ -796,29 +769,26 @@ public final class Ebean { * Note that the sorting uses a Comparator and Collections.sort(); and does * not invoke a DB query. *

- * *
{@code
-   * 
+   *
    *   // find orders and their customers
    *   List list = Ebean.find(Order.class)
    *     .fetch("customer")
    *     .orderBy("id")
    *     .findList();
-   * 
+   *
    *   // sort by customer name ascending, then by order shipDate
    *   // ... then by the order status descending
    *   Ebean.sort(list, "customer.name, shipDate, status desc");
-   * 
+   *
    *   // sort by customer name descending (with nulls low)
    *   // ... then by the order id
    *   Ebean.sort(list, "customer.name desc nullsLow, id");
-   * 
+   *
    * }
- * - * @param list - * the list of entity beans - * @param sortByClause - * the properties to sort the list by + * + * @param list the list of entity beans + * @param sortByClause the properties to sort the list by */ public static void sort(List list, String sortByClause) { serverMgr.getDefaultServer().sort(list, sortByClause); @@ -826,35 +796,35 @@ public final class Ebean { /** * Find a bean using its unique id. This will not use caching. - * *
{@code
+   *
    *   // Fetch order 1
    *   Order order = Ebean.find(Order.class, 1);
+   *
    * }
- * *

* If you want more control over the query then you can use createQuery() and * Query.findUnique(); *

- * *
{@code
+   *
    *   // ... additionally fetching customer, customer shipping address,
    *   // order details, and the product associated with each order detail.
    *   // note: only product id and name is fetch (its a "partial object").
    *   // note: all other objects use "*" and have all their properties fetched.
-   * 
+   *
    *   Query query = Ebean.find(Order.class)
    *     .setId(1)
    *     .fetch("customer")
    *     .fetch("customer.shippingAddress")
    *     .fetch("details")
    *     .query();
-   * 
+   *
    *   // fetch associated products but only fetch their product id and name
    *   query.fetch("details.product", "name");
-   * 
+   *
    *   // traverse the object graph...
-   * 
+   *
    *   Order order = query.findUnique();
    *   Customer customer = order.getCustomer();
    *   Address shippingAddress = customer.getShippingAddress();
@@ -864,11 +834,9 @@ public final class Ebean {
    *   String productName = product.getName();
    *
    * }
- * - * @param beanType - * the type of entity bean to fetch - * @param id - * the id value + * + * @param beanType the type of entity bean to fetch + * @param id the id value */ @Nullable public static T find(Class beanType, Object id) { @@ -903,7 +871,7 @@ public final class Ebean { /** * Create a CallableSql to execute a given stored procedure. - * + * * @see CallableSql */ public static CallableSql createCallableSql(String sql) { @@ -921,19 +889,18 @@ public final class Ebean { *

* An example: *

- * *
{@code
-   * 
+   *
    *   // The bean name and properties - "topic","postCount" and "id"
-   * 
+   *
    *   // will be converted into their associated table and column names
    *   String updStatement = "update topic set postCount = :pc where id = :id";
-   * 
+   *
    *   Update update = Ebean.createUpdate(Topic.class, updStatement);
-   * 
+   *
    *   update.set("pc", 9);
    *   update.set("id", 3);
-   * 
+   *
    *   int rows = update.execute();
    *   System.out.println("rows updated:" + rows);
    *
@@ -983,8 +950,7 @@ public final class Ebean {
    * which is was created.
    * 

* - * @param beanType - * the class of entity to be fetched + * @param beanType the class of entity to be fetched * @return A ORM Query object for this beanType */ public static Query createQuery(Class beanType) { @@ -996,12 +962,10 @@ public final class Ebean { * Parse the Ebean query language statement returning the query which can then * be modified (add expressions, change order by clause, change maxRows, change * fetch and select paths etc). - * + *

*

Example

- * *
{@code
    *
-   *
    *   // Find order additionally fetching the customer, details and details.product name.
    *
    *   String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
@@ -1023,9 +987,8 @@ public final class Ebean {
    * }
* * @param beanType The type of bean to fetch - * @param eql The Ebean query - * @param The type of the entity bean - * + * @param eql The Ebean query + * @param The type of the entity bean * @return The query with expressions defined as per the parsed query statement */ public static Query createQuery(Class beanType, String eql) { @@ -1040,9 +1003,8 @@ public final class Ebean { * exists is that people used to JPA will probably be looking for a * createQuery method (the same as entityManager). *

- * - * @param beanType - * the type of entity bean to find + * + * @param beanType the type of entity bean to find * @return A ORM Query object for this beanType */ public static Query find(Class beanType) { @@ -1103,28 +1065,24 @@ public final class Ebean { *

* Example: *

- * *
{@code
    *
    *   // example that uses 'named' parameters
    *   String s = "UPDATE f_topic set post_count = :count where id = :id"
-   * 
+   *
    *   SqlUpdate update = Ebean.createSqlUpdate(s);
-   * 
+   *
    *   update.setParameter("id", 1);
    *   update.setParameter("count", 50);
-   * 
+   *
    *   int modifiedCount = Ebean.execute(update);
-   * 
+   *
    *   String msg = "There where " + modifiedCount + "rows updated";
    *
    * }
- * - * @param sqlUpdate - * the update sql potentially with bind values - * + * + * @param sqlUpdate the update sql potentially with bind values * @return the number of rows updated or deleted. -1 if executed in batch. - * * @see SqlUpdate * @see CallableSql * @see Ebean#execute(CallableSql) @@ -1138,23 +1096,22 @@ public final class Ebean { *

* Example: *

- * *
{@code
    *
    *   String sql = "{call sp_order_modify(?,?,?)}";
-   * 
+   *
    *   CallableSql cs = Ebean.createCallableSql(sql);
    *   cs.setParameter(1, 27);
    *   cs.setParameter(2, "SHIPPED");
    *   cs.registerOut(3, Types.INTEGER);
-   * 
+   *
    *   Ebean.execute(cs);
-   * 
+   *
    *   // read the out parameter
    *   Integer returnValue = (Integer) cs.getObject(3);
    *
    * }
- * + * * @see CallableSql * @see Ebean#execute(SqlUpdate) */ @@ -1168,7 +1125,6 @@ public final class Ebean { * The scope can control the transaction type, isolation and rollback * semantics. *

- * *
{@code
    *
    *   // set specific transactional scope settings
@@ -1193,17 +1149,16 @@ public final class Ebean {
    * The default scope runs with REQUIRED and by default will rollback on any
    * exception (checked or runtime).
    * 

- * *
{@code
    *
    *   Ebean.execute(new TxRunnable() {
    *     public void run() {
    *       User u1 = Ebean.find(User.class, 1);
    *       User u2 = Ebean.find(User.class, 2);
-   * 
+   *
    *       u1.setName("u1 mod");
    *       u2.setName("u2 mod");
-   * 
+   *
    *       Ebean.save(u1);
    *       Ebean.save(u2);
    *     }
@@ -1221,7 +1176,6 @@ public final class Ebean {
    * The scope can control the transaction type, isolation and rollback
    * semantics.
    * 

- * *
{@code
    *
    *   // set specific transactional scope settings
@@ -1236,7 +1190,6 @@ public final class Ebean {
    *   });
    *
    * }
- * */ public static T execute(TxScope scope, TxCallable c) { return serverMgr.getDefaultServer().execute(scope, c); @@ -1252,20 +1205,19 @@ public final class Ebean { * This is basically the same as TxRunnable except that it returns an Object * (and you specify the return type via generics). *

- * *
{@code
    *
    *   Ebean.execute(new TxCallable() {
    *     public String call() {
    *       User u1 = Ebean.find(User.class, 1);
    *       User u2 = Ebean.find(User.class, 2);
-   * 
+   *
    *       u1.setName("u1 mod");
    *       u2.setName("u2 mod");
-   * 
+   *
    *       Ebean.save(u1);
    *       Ebean.save(u2);
-   * 
+   *
    *       return u1.getEmail();
    *     }
    *   });
@@ -1300,15 +1252,11 @@ public final class Ebean {
    * If there is NO current transaction when you call this method then this
    * information is registered immediately (with the transaction manager).
    * 

- * - * @param tableName - * the name of the table that was modified - * @param inserts - * true if rows where inserted into the table - * @param updates - * true if rows on the table where updated - * @param deletes - * true if rows on the table where deleted + * + * @param tableName the name of the table that was modified + * @param inserts true if rows where inserted into the table + * @param updates true if rows on the table where updated + * @param deletes true if rows on the table where deleted */ public static void externalModification(String tableName, boolean inserts, boolean updates, boolean deletes) { @@ -1327,7 +1275,6 @@ public final class Ebean { /** * Return the manager of the server cache ("L2" cache). - * */ public static ServerCacheManager getServerCacheManager() { return serverMgr.getDefaultServer().getServerCacheManager(); diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java index f09304f87..269625ce5 100644 --- a/src/main/java/com/avaje/ebean/EbeanServer.java +++ b/src/main/java/com/avaje/ebean/EbeanServer.java @@ -169,7 +169,7 @@ public interface EbeanServer { *

* Useful if you use BeanPostConstructListeners or @PostConstruct Annotations. * In this case you should not use "new Bean...()". Making all bean construtors protected - * could be a good idea here. + * could be a good idea here. *

*/ T createEntityBean(Class type); @@ -224,9 +224,8 @@ public interface EbeanServer { * Parse the Ebean query language statement returning the query which can then * be modified (add expressions, change order by clause, change maxRows, change * fetch and select paths etc). - * + *

*

Example

- * *
{@code
    *
    *   // Find order additionally fetching the customer, details and details.product name.
@@ -250,9 +249,8 @@ public interface EbeanServer {
    * }
* * @param beanType The type of bean to fetch - * @param eql The Ebean query - * @param The type of the entity bean - * + * @param eql The Ebean query + * @param The type of the entity bean * @return The query with expressions defined as per the parsed query statement */ Query createQuery(Class beanType, String eql); @@ -994,7 +992,7 @@ public interface EbeanServer { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -1005,7 +1003,6 @@ public interface EbeanServer {
    *      .findSingleAttributeList();
    *
    * }
- * *

Example 2:

*
{@code
    *
@@ -1021,7 +1018,6 @@ public interface EbeanServer {
    * }
* * @return the list of values for the selected property - * * @see Query#findSingleAttributeList() */ List findSingleAttributeList(Query query, Transaction transaction); diff --git a/src/main/java/com/avaje/ebean/EbeanServerFactory.java b/src/main/java/com/avaje/ebean/EbeanServerFactory.java index d6326b5ea..bcc9a2062 100644 --- a/src/main/java/com/avaje/ebean/EbeanServerFactory.java +++ b/src/main/java/com/avaje/ebean/EbeanServerFactory.java @@ -36,7 +36,7 @@ public class EbeanServerFactory { /** * Initialise the container with clustering configuration. - * + *

* Call this prior to creating any EbeanServer instances or alternatively set the * ContainerConfig on the ServerConfig when creating the first EbeanServer instance. */ diff --git a/src/main/java/com/avaje/ebean/ExampleExpression.java b/src/main/java/com/avaje/ebean/ExampleExpression.java index e8fcf366a..6561ed76f 100644 --- a/src/main/java/com/avaje/ebean/ExampleExpression.java +++ b/src/main/java/com/avaje/ebean/ExampleExpression.java @@ -14,44 +14,44 @@ package com.avaje.ebean; * To get control over the options you can create an ExampleExpression and set * those options such as case insensitive etc. *

- * - *
+ *
+ * 
{@code
  * // create an example bean and set the properties
  * // with the query parameters you want
  * Customer example = new Customer();
- * example.setName("Rob%");
- * example.setNotes("%something%");
- * 
+ * example.setName("Rob%");
+ * example.setNotes("%something%");
+ *
  * List<Customer> list =
  *     Ebean.find(Customer.class)
  *         .where()
  *         // pass the bean into the where() clause
  *         .exampleLike(example)
  *         // you can add other expressions to the same query
- *         .gt("id", 2)
+ *         .gt("id", 2)
  *         .findList();
- * 
- * 
- * + * + * }
+ * * Similarly you can create an ExampleExpression - * - *
+ *
+ * 
{@code
+ *
  * Customer example = new Customer();
- * example.setName("Rob%");
- * example.setNotes("%something%");
- * 
+ * example.setName("Rob%");
+ * example.setNotes("%something%");
+ *
  * // create a ExampleExpression with more control
  * ExampleExpression qbe = new ExampleExpression(example, true, LikeType.EQUAL_TO)
  *     .includeZeros();
- * 
- * List<Customer> list =
+ *
+ * List list =
  *     Ebean.find(Customer.class)
  *         .where()
  *         .add(qbe)
  *         .findList();
- * 
- * - * @author Rob Bygrave + * + * }
*/ public interface ExampleExpression extends Expression { @@ -90,4 +90,4 @@ public interface ExampleExpression extends Expression { */ ExampleExpression useEqualTo(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/Expr.java b/src/main/java/com/avaje/ebean/Expr.java index a6a9e8b7c..41718174e 100644 --- a/src/main/java/com/avaje/ebean/Expr.java +++ b/src/main/java/com/avaje/ebean/Expr.java @@ -23,20 +23,19 @@ import java.util.Map; * Creates standard common expressions for using in a Query Where or Having * clause. *

- * - *
- *  // Example: Using an Expr.or() method
- * Query<Order> query = Ebean.createQuery(Order.class);
- * query.where( 
- * 		Expr.or(Expr.eq("status", Order.NEW),
- *     		    Expr.gt("orderDate", lastWeek));
- *     
- * List<Order> list = query.findList();
+ * 
{@code
+ *
+ * // Example: Using an Expr.or() method
+ * Query query = Ebean.createQuery(Order.class);
+ * query.where(
+ *     Expr.or(Expr.eq("status", Order.NEW),
+ *             Expr.gt("orderDate", lastWeek));
+ *
+ * List list = query.findList();
  * ...
- * 
- * + * }
+ * * @see Query#where() - * @author Rob Bygrave */ public class Expr { @@ -77,10 +76,10 @@ public class Expr { * Between - value between two given properties. */ public static Expression between(String lowProperty, String highProperty, Object value) { - + return Ebean.getExpressionFactory().betweenProperties(lowProperty, highProperty, value); } - + /** * Greater Than - property greater than the given value. */ @@ -142,8 +141,7 @@ public class Expr { /** * Create the query by Example expression specifying more options. */ - public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, - LikeType likeType) { + public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) { return Ebean.getExpressionFactory().exampleLike(example, caseInsensitive, likeType); } @@ -257,9 +255,8 @@ public class Expr { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ public static Expression allEq(Map propertyMap) { return Ebean.getExpressionFactory().allEq(propertyMap); diff --git a/src/main/java/com/avaje/ebean/ExpressionFactory.java b/src/main/java/com/avaje/ebean/ExpressionFactory.java index 2fb89e9b2..afa89b7b8 100644 --- a/src/main/java/com/avaje/ebean/ExpressionFactory.java +++ b/src/main/java/com/avaje/ebean/ExpressionFactory.java @@ -24,20 +24,19 @@ import java.util.Map; *

* The ExpressionList is returned from {@link Query#where()}. *

- * - *
- *  // Example: fetch orders where status equals new or orderDate > lastWeek.
- *  
- * Expression newOrLastWeek = 
- *   Expr.or(Expr.eq("status", Order.Status.NEW), 
- *           Expr.gt("orderDate", lastWeek));
- * 
- * Query<Order> query = Ebean.createQuery(Order.class);
+ * 
{@code
+ * // Example: fetch orders where status equals new or orderDate > lastWeek.
+ *
+ * Expression newOrLastWeek =
+ *     Expr.or(Expr.eq("status", Order.Status.NEW),
+ *             Expr.gt("orderDate", lastWeek));
+ *
+ * Query query = Ebean.createQuery(Order.class);
  * query.where().add(newOrLastWeek);
- * List<Order> list = query.findList();
+ * List list = query.findList();
  * ...
- * 
- * + * }
+ * * @see Query#where() */ public interface ExpressionFactory { @@ -282,7 +281,7 @@ public interface ExpressionFactory { * Exists expression */ Expression exists(Query subQuery); - + /** * Not exists expression */ @@ -319,9 +318,8 @@ public interface ExpressionFactory { * Expression where all the property names in the map are equal to the * corresponding value. *

- * - * @param propertyMap - * a map keyed by property names. + * + * @param propertyMap a map keyed by property names. */ Expression allEq(Map propertyMap); diff --git a/src/main/java/com/avaje/ebean/ExpressionList.java b/src/main/java/com/avaje/ebean/ExpressionList.java index 1d123899c..4164d5d2e 100644 --- a/src/main/java/com/avaje/ebean/ExpressionList.java +++ b/src/main/java/com/avaje/ebean/ExpressionList.java @@ -104,7 +104,7 @@ public interface ExpressionList { * Perform an 'As of' query using history tables to return the object graph * as of a time in the past. *

- * To perform this query the DB must have underlying history tables. + * To perform this query the DB must have underlying history tables. *

* * @param asOf the date time in the past at which you want to view the data @@ -201,7 +201,7 @@ public interface ExpressionList { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -212,7 +212,7 @@ public interface ExpressionList {
    *      .findSingleAttributeList();
    *
    * }
- * + *

*

Example 2:

*
{@code
    *
@@ -240,7 +240,6 @@ public interface ExpressionList {
    * 

* * @throws NonUniqueResultException if more than one result was found - * * @see Query#findUnique() */ @Nullable @@ -292,7 +291,7 @@ public interface ExpressionList { * If maxRows is not set on the query prior to calling findPagedList() then a * PersistenceException is thrown. *

- * + *

*

{@code
    *
    *  PagedList pagedList = Ebean.find(Order.class)
@@ -309,7 +308,6 @@ public interface ExpressionList {
    * }
* * @return The PagedList - * * @see Query#findPagedList() */ PagedList findPagedList(); @@ -317,8 +315,8 @@ public interface ExpressionList { /** * Return versions of a @History entity bean. *

- * Generally this query is expected to be a find by id or unique predicates query. - * It will execute the query against the history returning the versions of the bean. + * Generally this query is expected to be a find by id or unique predicates query. + * It will execute the query against the history returning the versions of the bean. *

*/ List> findVersions(); @@ -326,8 +324,8 @@ public interface ExpressionList { /** * Return versions of a @History entity bean between the 2 timestamps. *

- * Generally this query is expected to be a find by id or unique predicates query. - * It will execute the query against the history returning the versions of the bean. + * Generally this query is expected to be a find by id or unique predicates query. + * It will execute the query against the history returning the versions of the bean. *

*/ List> findVersionsBetween(Timestamp start, Timestamp end); @@ -440,7 +438,6 @@ public interface ExpressionList { /** * Path exists - for the given path in a JSON document. - * *
{@code
    *
    *   where().jsonExists("content", "path.other")
@@ -448,13 +445,12 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation + * @param path the nested path in the JSON document in dot notation */ ExpressionList jsonExists(String propertyName, String path); /** * Path does not exist - for the given path in a JSON document. - * *
{@code
    *
    *   where().jsonNotExists("content", "path.other")
@@ -462,13 +458,13 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation + * @param path the nested path in the JSON document in dot notation */ ExpressionList jsonNotExists(String propertyName, String path); /** * Equal to expression for the value at the given path in the JSON document. - * + *

*

{@code
    *
    *   where().jsonEqualTo("content", "path.other", 34)
@@ -476,14 +472,14 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation - * @param value the value used to test against the document path's value + * @param path the nested path in the JSON document in dot notation + * @param value the value used to test against the document path's value */ ExpressionList jsonEqualTo(String propertyName, String path, Object value); /** * Not Equal to - for the given path in a JSON document. - * + *

*

{@code
    *
    *   where().jsonNotEqualTo("content", "path.other", 34)
@@ -491,14 +487,14 @@ public interface ExpressionList {
    * }
* * @param propertyName the property that holds a JSON document - * @param path the nested path in the JSON document in dot notation - * @param value the value used to test against the document path's value + * @param path the nested path in the JSON document in dot notation + * @param value the value used to test against the document path's value */ ExpressionList jsonNotEqualTo(String propertyName, String path, Object value); /** * Greater than - for the given path in a JSON document. - * + *

*

{@code
    *
    *   where().jsonGreaterThan("content", "path.other", 34)
@@ -509,7 +505,7 @@ public interface ExpressionList {
 
   /**
    * Greater than or equal to - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonGreaterOrEqual("content", "path.other", 34)
@@ -520,7 +516,7 @@ public interface ExpressionList {
 
   /**
    * Less than - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonLessThan("content", "path.other", 34)
@@ -531,7 +527,7 @@ public interface ExpressionList {
 
   /**
    * Less than or equal to - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonLessOrEqualTo("content", "path.other", 34)
@@ -542,7 +538,7 @@ public interface ExpressionList {
 
   /**
    * Between - for the given path in a JSON document.
-   *
+   * 

*

{@code
    *
    *   where().jsonBetween("content", "orderDate", lowerDateTime, upperDateTime)
@@ -556,7 +552,7 @@ public interface ExpressionList {
    * 

* This returns the list so that add() can be chained. *

- * + *

*

{@code
    *
    * Query query = Ebean.find(Customer.class);
@@ -647,7 +643,7 @@ public interface ExpressionList {
    * To get control over the options you can create an ExampleExpression and set
    * those options such as case insensitive etc.
    * 

- * + *

*

{@code
    *
    * // create an example bean and set the properties
@@ -663,9 +659,9 @@ public interface ExpressionList {
    *     .gt("id", 2).findList();
    *
    * }
- * + *

* Similarly you can create an ExampleExpression - * + *

*

{@code
    *
    * Customer example = new Customer();
@@ -804,8 +800,7 @@ public interface ExpressionList {
    * corresponding value.
    * 

* - * @param propertyMap - * a map keyed by property names. + * @param propertyMap a map keyed by property names. */ ExpressionList allEq(Map propertyMap); @@ -849,7 +844,7 @@ public interface ExpressionList { * then they are not translated. logical property name names (not fully * qualified) will still be translated to their physical name. *

- * + *

*

Example:

*
{@code
    *
@@ -881,7 +876,7 @@ public interface ExpressionList {
    * then they are not translated. logical property name names (not fully
    * qualified) will still be translated to their physical name.
    * 

- * + *

*

{@code
    *
    *   raw("orderQty < shipQty")
@@ -894,7 +889,7 @@ public interface ExpressionList {
    * Add a match expression.
    *
    * @param propertyName The property name for the match
-   * @param search The search value
+   * @param search       The search value
    */
   ExpressionList match(String propertyName, String search);
 
@@ -902,14 +897,14 @@ public interface ExpressionList {
    * Add a match expression with options.
    *
    * @param propertyName The property name for the match
-   * @param search The search value
+   * @param search       The search value
    */
   ExpressionList match(String propertyName, String search, Match options);
 
   /**
    * Add a multi-match expression.
    */
-  ExpressionList  multiMatch(String search, String... properties);
+  ExpressionList multiMatch(String search, String... properties);
 
   /**
    * Add a multi-match expression using options.
@@ -960,7 +955,7 @@ public interface ExpressionList {
    * typically you only explicitly need to use the and() junction
    * when it is nested inside an or() or not() junction.
    * 

- * + *

*

{@code
    *
    *  // Example: Nested and()
@@ -985,11 +980,11 @@ public interface ExpressionList {
   /**
    * Return a list of expressions that will be joined by OR's.
    * This is exactly the same as disjunction();
-   *
    * 

- * Use endOr() or endJunction() to end the OR junction. + *

+ * Use endOr() or endJunction() to end the OR junction. *

- * + *

*

{@code
    *
    *  // Example: Use or() to join
@@ -1016,10 +1011,10 @@ public interface ExpressionList {
   /**
    * Return a list of expressions that will be wrapped by NOT.
    * 

- * Use endNot() or endJunction() to end expressions being added to the - * NOT expression list. + * Use endNot() or endJunction() to end expressions being added to the + * NOT expression list. *

- * + *

*

@{code
    *
    *    .where()
@@ -1029,7 +1024,7 @@ public interface ExpressionList {
    *        .endNot()
    *
    * }
- * + *

*

@{code
    *
    * // Example: nested not()
diff --git a/src/main/java/com/avaje/ebean/FetchConfig.java b/src/main/java/com/avaje/ebean/FetchConfig.java
index fc4f3de11..fad86a69c 100644
--- a/src/main/java/com/avaje/ebean/FetchConfig.java
+++ b/src/main/java/com/avaje/ebean/FetchConfig.java
@@ -21,47 +21,52 @@ import java.io.Serializable;
  * is high (a lot of "Many" beans per "One" bean) then this can be more
  * efficient loaded as 2 SQL queries.
  * 

- * + *

*

{@code
  * // Normal fetch join results in a single SQL query
  * List list = Ebean.find(Order.class).fetch("details").findList();
- * 
+ *
  * // Find Orders join details using a single SQL query
  * }
*

* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries *

- * + *

*

{@code
+ *
  * // This will use 2 SQL queries to build this object graph
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("details", new FetchConfig().query())
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
+ *
  * }
*

* Example: Using 2 "query joins" *

- * + *

*

{@code
+ *
  * // This will use 3 SQL queries to build this object graph
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("details", new FetchConfig().query())
  *         .fetch("customer", new FetchConfig().queryFirst(5))
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
  * // query 3) find customer where id in (?,?,?,?,?) // first 5 customers
+ *
  * }
*

* Example: Using "query joins" and partial objects *

- * + *

+ * *

{@code
  * // This will use 3 SQL queries to build this object graph
  * List list =
@@ -73,13 +78,13 @@ import java.io.Serializable;
  *         .fetch("customer.contacts")
  *         .fetch("customer.shippingAddress")
  *         .findList();
- * 
+ *
  * // query 1) find order (status, shipDate)
  * // query 2) find orderDetail (quantity, price) fetch product (sku, name) where
  * // order.id in (?,? ...)
  * // query 3) find customer (name) fetch contacts (*) fetch shippingAddress (*)
  * // where id in (?,?,?,?,?)
- * 
+ *
  * // Note: the fetch of "details.product" is automatically included into the
  * // fetch of "details"
  * //
@@ -91,20 +96,21 @@ import java.io.Serializable;
  * immediately and the lazy defines the batch size to use for further lazy
  * loading (if lazy loading is invoked).
  * 

- * + *

*

{@code
+ *
  * List list =
  *     Ebean.find(Order.class)
  *         .fetch("customer", new FetchConfig().query(10).lazy(5))
  *         .findList();
- * 
+ *
  * // query 1) find order
  * // query 2) find customer where id in (?,?,?,?,?,?,?,?,?,?) // first 10 customers
  * // .. then if lazy loading of customers is invoked
  * // .. use a batch size of 5 to load the customers
- * 
+ *
  * }
- * + *

*

* Example of controlling the lazy loading query: *

@@ -112,22 +118,23 @@ import java.io.Serializable; * This gives us the ability to optimise the lazy loading query for a given use * case. *

- * + *

*

{@code
+ *
  * List list = Ebean.find(Order.class)
  *   .fetch("customer","name", new FetchConfig().lazy(5))
  *   .fetch("customer.contacts","contactName, phone, email")
  *   .fetch("customer.shippingAddress")
  *   .where().eq("status",Order.Status.NEW)
  *   .findList();
- * 
+ *
  * // query 1) find order where status = Order.Status.NEW
- * //  
- * // .. if lazy loading of customers is invoked 
+ * //
+ * // .. if lazy loading of customers is invoked
  * // .. use a batch size of 5 to load the customers
- * 
+ *
  * }
- * + * * @author mario * @author rbygrave */ @@ -159,9 +166,8 @@ public class FetchConfig implements Serializable { /** * Specify that this path should be lazy loaded with a specified batch size. - * - * @param lazyBatchSize - * the batch size for lazy loading + * + * @param lazyBatchSize the batch size for lazy loading */ public FetchConfig lazy(int lazyBatchSize) { this.lazyBatchSize = lazyBatchSize; @@ -193,9 +199,8 @@ public class FetchConfig implements Serializable { * This will load all beans on this path eagerly unless a {@link #lazy(int)} * is also used. *

- * - * @param queryBatchSize - * the batch size used to load beans on this path + * + * @param queryBatchSize the batch size used to load beans on this path */ public FetchConfig query(int queryBatchSize) { this.queryBatchSize = queryBatchSize; @@ -211,9 +216,8 @@ public class FetchConfig implements Serializable { * If there are more parent beans than the batch size then they will not be * loaded eagerly but instead use lazy loading. *

- * - * @param queryBatchSize - * the number of parent beans this path is populated for + * + * @param queryBatchSize the number of parent beans this path is populated for */ public FetchConfig queryFirst(int queryBatchSize) { this.queryBatchSize = queryBatchSize; @@ -227,7 +231,7 @@ public class FetchConfig implements Serializable { public int getLazyBatchSize() { return lazyBatchSize; } - + /** * Return the batch size for separate query load. */ diff --git a/src/main/java/com/avaje/ebean/Filter.java b/src/main/java/com/avaje/ebean/Filter.java index f5055123c..f8e1aab16 100644 --- a/src/main/java/com/avaje/ebean/Filter.java +++ b/src/main/java/com/avaje/ebean/Filter.java @@ -19,64 +19,63 @@ import java.util.Set; * The result of the filter method will leave the original list unmodified and * return a new List instance. *

- * - *
- * 
+ * 

+ *

{@code
+ *
  * // get a list of entities (query execution statistics in this case)
- * 
- * List<MetaQueryStatistic> list =
+ *
+ * List list =
  *     Ebean.find(MetaQueryStatistic.class).findList();
- * 
+ *
  * long nowMinus24Hrs = System.currentTimeMillis() - 24 * (1000 * 60 * 60);
- * 
+ *
  * // sort and filter the list returning a filtered list...
- * 
- * List<MetaQueryStatistic> filteredList =
+ *
+ * List filteredList =
  *     Ebean.filter(MetaQueryStatistic.class)
- *         .sort("avgTimeMicros desc")
- *         .gt("executionCount", 0)
- *         .gt("lastQueryTime", nowMinus24Hrs)
- *         .eq("autoTuned", true)
+ *         .sort("avgTimeMicros desc")
+ *         .gt("executionCount", 0)
+ *         .gt("lastQueryTime", nowMinus24Hrs)
+ *         .eq("autoTuned", true)
  *         .maxRows(10)
  *         .filter(list);
- * 
- * 
+ * + * }
*

* The propertyNames can traverse the object graph (e.g. customer.name) by using * dot notation. If any point during the object graph traversal to get a * property value is null then null is returned. *

- * - *
- * // examples of property names that 
+ * 

+ *

{@code
+ *
+ * // examples of property names that
  * // ... will traverse the object graph
  * // ... where customer is a property of our bean
- * 
+ *
  * customer.name
  * customer.shippingAddress.city
- * 
- * - *

- * - *
- * 
+ *
+ * }
+ *

+ *

{@code
+ *
  * // get a list of entities (query execution statistics)
- * 
- * List<Order> orders =
+ *
+ * List orders =
  *     Ebean.find(Order.class).findList();
- * 
+ *
  * // Apply a filter...
- * 
- * List<Order> filteredOrders =
+ *
+ * List filteredOrders =
  *     Ebean.filter(Order.class)
- *         .startsWith("customer.name", "Rob")
- *         .eq("customer.shippingAddress.city", "Auckland")
+ *         .startsWith("customer.name", "Rob")
+ *         .eq("customer.shippingAddress.city", "Auckland")
  *         .filter(orders);
- * 
- * 
- * - * @param - * the entity bean type + * + * }
+ * + * @param the entity bean type */ public interface Filter { @@ -189,9 +188,9 @@ public interface Filter { *

* The sourceList will remain unmodified. *

- * + * * @return Returns a new list with the sorting and filters applied. */ List filter(List sourceList); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/Finder.java b/src/main/java/com/avaje/ebean/Finder.java index beacbea49..6cd7cf1bd 100644 --- a/src/main/java/com/avaje/ebean/Finder.java +++ b/src/main/java/com/avaje/ebean/Finder.java @@ -11,11 +11,10 @@ import java.util.List; * These 'finders' are a place to organise all the finder methods for that bean type * and specific finder methods are expected to be added (find by unique properties etc). *

- * *

Testing

*

- * For testing the mocki-ebean project has the ability to replace the finder implementation - * + * For testing the mocki-ebean project has the ability to replace the finder implementation + *

*

*
{@code
  *
@@ -61,7 +60,6 @@ public class Finder {
 
   /**
    * Create with the type of the entity bean.
-   *
    * 
{@code
    *
    * public class CustomerFinder extends Finder {
@@ -96,10 +94,8 @@ public class Finder {
 
   /**
    * Return the underlying 'default' EbeanServer.
-   *
    * 

* This provides full access to the API such as explicit transaction demarcation etc. - * */ public EbeanServer db() { return Ebean.getServer(serverName); @@ -110,9 +106,8 @@ public class Finder { *

* This is equivalent to {@link Ebean#getServer(String)} * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is - * returned. + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is + * returned. */ public EbeanServer db(String server) { return Ebean.getServer(server); @@ -120,7 +115,6 @@ public class Finder { /** * Creates an entity reference for this ID. - * *

* Equivalent to {@link EbeanServer#getReference(Class, Object)} */ @@ -130,7 +124,6 @@ public class Finder { /** * Retrieves an entity by ID. - * *

* Equivalent to {@link EbeanServer#find(Class, Object)} */ diff --git a/src/main/java/com/avaje/ebean/FutureList.java b/src/main/java/com/avaje/ebean/FutureList.java index 105a8c411..34301d446 100644 --- a/src/main/java/com/avaje/ebean/FutureList.java +++ b/src/main/java/com/avaje/ebean/FutureList.java @@ -17,31 +17,30 @@ import java.util.concurrent.TimeoutException; *

* A simple example: *

- * *
{@code
+ *
  *  // create a query to find all orders
  * Query query = Ebean.find(Order.class);
- * 
+ *
  *  // execute the query in a background thread
  *  // immediately returning the futureList
  * FutureList futureList = query.findFutureList();
- * 
- *  // do something else ... 
- * 
+ *
+ *  // do something else ...
+ *
  * if (!futureList.isDone()){
  * 	// we can cancel the query execution. This will cancel
  * // the underlying query if that is supported by the JDBC
  * // driver and database
  * 	futureList.cancel(true);
  * }
- * 
- * 
+ *
  * if (!futureList.isCancelled()){
  * 	// wait for the query to finish and return the list
  * 	List list = futureList.get();
  * 	...
  * }
- * 
+ *
  * }
*/ public interface FutureList extends Future> { @@ -56,7 +55,6 @@ public interface FutureList extends Future> { * unchecked PersistenceException. * * @return The query list result - * * @throws PersistenceException when a InterruptedException or ExecutionException occurs. */ List getUnchecked(); @@ -66,8 +64,7 @@ public interface FutureList extends Future> { * and ExecutionException in the unchecked PersistenceException. * * @return The query list result - * - * @throws TimeoutException if the wait timed out + * @throws TimeoutException if the wait timed out * @throws PersistenceException if a InterruptedException or ExecutionException occurs. */ List getUnchecked(long timeout, TimeUnit unit) throws TimeoutException; diff --git a/src/main/java/com/avaje/ebean/FutureRowCount.java b/src/main/java/com/avaje/ebean/FutureRowCount.java index 7c9bc747c..959846796 100644 --- a/src/main/java/com/avaje/ebean/FutureRowCount.java +++ b/src/main/java/com/avaje/ebean/FutureRowCount.java @@ -8,8 +8,8 @@ import java.util.concurrent.Future; *

* It extends the java.util.concurrent.Future. *

- * - * @param the BeanType + * + * @param the BeanType * @author rbygrave */ public interface FutureRowCount extends Future { diff --git a/src/main/java/com/avaje/ebean/Junction.java b/src/main/java/com/avaje/ebean/Junction.java index 5d2121882..8437f53e6 100644 --- a/src/main/java/com/avaje/ebean/Junction.java +++ b/src/main/java/com/avaje/ebean/Junction.java @@ -9,7 +9,6 @@ package com.avaje.ebean; *

* Note: where() always takes you to the top level WHERE expression list. *

- * *
{@code
  * Query q =
  *     Ebean.find(Person.class)
@@ -23,13 +22,13 @@ package com.avaje.ebean;
  *
  * // read as...
  * // where ( ((name like Rob%) or (status = NEW)) AND (id > 10) )
- * }
* + * }
*

* Note: endJunction() takes you to the parent expression list *

- * *
{@code
+ *
  * Query q =
  *     Ebean.find(Person.class)
  *       .where()
@@ -46,11 +45,9 @@ package com.avaje.ebean;
  * // read as...
  * // where ( ((name like Rob%) or (status = NEW)) AND (id > 10) )
  * }
- * *

* Example of a nested disjunction. *

- * *
{@code
  * Query q =
  *  Ebean.find(Customer.class)
diff --git a/src/main/java/com/avaje/ebean/Model.java b/src/main/java/com/avaje/ebean/Model.java
index d4553a528..af8fa20c6 100644
--- a/src/main/java/com/avaje/ebean/Model.java
+++ b/src/main/java/com/avaje/ebean/Model.java
@@ -13,31 +13,26 @@ import java.util.UUID;
 /**
  * A MappedSuperclass base class that provides convenience methods for inserting, updating and
  * deleting beans.
- * 
  * 

* By having your entity beans extend this it provides a 'Active Record' style programming model for * Ebean users. - * *

* Note that there is a avaje-ebeanorm-mocker project that enables you to use Mockito or similar * tools to still mock out the underlying 'default EbeanServer' for testing purposes. - * *

* You may choose not use this Model mapped superclass if you don't like the 'Active Record' style * or if you believe it 'pollutes' your entity beans. - * *

* You can use Dependency Injection like Guice or Spring to construct and wire a EbeanServer instance * and have that same instance used with this Model and Finder. The way that works is that when the * DI container creates the EbeanServer instance it can be registered with the Ebean singleton. In this * way the EbeanServer instance can be injected as per normal Guice / Spring dependency injection and * that same instance also used to support the Model and Finder active record style. - * *

* If you choose to use the Model mapped superclass you will probably also chose to additionally add * a {@link Find} as a public static field to complete the active record pattern and provide a * relatively nice clean way to write queries. - * + *

*

Typical common @MappedSuperclass

*
{@code
  *
@@ -58,7 +53,7 @@ import java.util.UUID;
  *       ...
  *
  * }
- * + *

*

Extend the Model

*
{@code
  *
@@ -78,7 +73,7 @@ import java.util.UUID;
  *     }
  *
  * }
- * + *

*

Modal: save()

*
{@code
  *
@@ -90,7 +85,7 @@ import java.util.UUID;
  *     customer.save();
  *
  * }
- * + *

*

Find byId

*
{@code
  *
@@ -98,7 +93,7 @@ import java.util.UUID;
  *     Customer customer = Customer.find.byId(42);
  *
  * }
- * + *

*

Find where

*
{@code
  *
@@ -115,39 +110,37 @@ public abstract class Model {
 
   /**
    * Return the underlying 'default' EbeanServer.
-   * 
    * 

* This provides full access to the API such as explicit transaction demarcation etc. - * *

* Example: *

{@code
    *
    * Transaction transaction = Customer.db().beginTransaction();
    * try {
-   * 
+   *
    *   // turn off cascade persist for this transaction
    *   transaction.setPersistCascade(false);
-   * 
+   *
    *   // extra control over jdbc batching for this transaction
    *   transaction.setBatchGetGeneratedKeys(false);
    *   transaction.setBatchMode(true);
    *   transaction.setBatchSize(20);
-   * 
+   *
    *   Customer customer = new Customer();
    *   customer.setName("Roberto");
    *   customer.save();
-   * 
+   *
    *   Customer otherCustomer = new Customer();
    *   otherCustomer.setName("Franko");
    *   otherCustomer.save();
-   * 
+   *
    *   transaction.commit();
-   * 
+   *
    * } finally {
    *   transaction.end();
    * }
-   * 
+   *
    * }
*/ public static EbeanServer db() { @@ -156,13 +149,11 @@ public abstract class Model { /** * Return a named EbeanServer that is typically different to the default server. - * *

* If you are using multiple databases then each database has a name and maps to a single * EbeanServer. You can use this method to get an EbeanServer for another database. - * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is returned. + * + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is returned. */ public static EbeanServer db(String server) { return Ebean.getServer(server); @@ -176,16 +167,16 @@ public abstract class Model { *

* An unmodified bean that is saved or updated is normally skipped and this marks the bean as * dirty so that it is not skipped. - * + *

*

{@code
-   * 
+   *
    * Customer customer = Customer.find.byId(id);
-   * 
+   *
    * // mark the bean as dirty so that a save() or update() will
    * // increment the version property
    * customer.markAsDirty();
    * customer.save();
-   * 
+   *
    * }
* * @see EbeanServer#markAsDirty(Object) @@ -197,7 +188,7 @@ public abstract class Model { /** * Mark the property as unset or 'not loaded'. *

- * This would be used to specify a property that we did not wish to include in a stateless update. + * This would be used to specify a property that we did not wish to include in a stateless update. *

*
{@code
    *
@@ -215,12 +206,11 @@ public abstract class Model {
    * @param propertyName the name of the property on the bean to be marked as 'unset'
    */
   public void markPropertyUnset(String propertyName) {
-    ((EntityBean)this)._ebean_getIntercept().setPropertyLoaded(propertyName, false);
+    ((EntityBean) this)._ebean_getIntercept().setPropertyLoaded(propertyName, false);
   }
 
   /**
    * Insert or update this entity depending on its state.
-   * 
    * 

* Ebean will detect if this is a new bean or a previously fetched bean and perform either an * insert or an update based on that. @@ -319,6 +309,7 @@ public abstract class Model { * It should be preferred to use {@link Find} instead of Finder as that can use reflection to determine the class * literal type of the entity bean. *

+ * * @param type of the Id property * @param type of the entity bean */ @@ -326,7 +317,7 @@ public abstract class Model { /** * Create with the type of the entity bean. - * + *

*

{@code
      *
      * @Entity
@@ -336,11 +327,11 @@ public abstract class Model {
      *   ...
      *
      * }
- * + *

*

* The preferred approach is to instead use Find as below. This approach is more DRY in that it does * not require the class literal Customer.class to be passed into the constructor. - * + *

*

{@code
      *
      * @Entity
@@ -366,13 +357,13 @@ public abstract class Model {
 
   /**
    * Helper object for performing queries.
-   * 
+   * 

*

* Typically a Find instance is defined as a public static field on an entity bean class to provide a * nice way to write queries. - * + *

*

Example use:

- * + *

*

{@code
    *
    * @Entity
@@ -395,7 +386,7 @@ public abstract class Model {
    *         .findList();
    *
    * }
- * + *

*

Kotlin

* In Kotlin you would typically create Find as a companion object. *
{@code
@@ -404,12 +395,10 @@ public abstract class Model {
    *   companion object : Model.Find() {}
    *
    * }
- * @param - * The Id type. This is most often a {@link Long} but is also often a {@link UUID} or - * {@link String}. * - * @param - * The entity bean type + * @param The Id type. This is most often a {@link Long} but is also often a {@link UUID} or + * {@link String}. + * @param The entity bean type */ public static abstract class Find { @@ -427,11 +416,11 @@ public abstract class Model { * Creates a finder for entity of type T with ID of type I. *

* Typically you create Find as a public static field on each entity bean as the example below. - * + *

*

* Note that Find is an abstract class and hence {} is required. This is done so * that the type (class literal) of the entity bean can be derived from the generics parameter. - * + *

*

{@code
      *
      * @Entity
@@ -456,10 +445,10 @@ public abstract class Model {
      *        .findList();
      *
      * }
- * + *

*

Kotlin

* In Kotlin you would typically create it as a companion object. - * + *

*

{@code
      *
      *   // kotlin
@@ -470,7 +459,7 @@ public abstract class Model {
     @SuppressWarnings("unchecked")
     public Find() {
       this.serverName = null;
-      this.type = (Class)ClassUtil.getSecondArgumentType(getClass());
+      this.type = (Class) ClassUtil.getSecondArgumentType(getClass());
     }
 
     /**
@@ -483,10 +472,9 @@ public abstract class Model {
 
     /**
      * Return the underlying 'default' EbeanServer.
-     * 
+     * 

*

* This provides full access to the API such as explicit transaction demarcation etc. - * */ public EbeanServer db() { return Ebean.getServer(serverName); @@ -496,10 +484,9 @@ public abstract class Model { * Return typically a different EbeanServer to the default. *

* This is equivalent to {@link Ebean#getServer(String)} - * - * @param server - * The name of the EbeanServer. If this is null then the default EbeanServer is - * returned. + * + * @param server The name of the EbeanServer. If this is null then the default EbeanServer is + * returned. */ public EbeanServer db(String server) { return Ebean.getServer(server); @@ -507,7 +494,7 @@ public abstract class Model { /** * Creates a Finder for the named EbeanServer. - * + *

*

* Create and return a new Finder for a different server. */ @@ -526,7 +513,7 @@ public abstract class Model { /** * Retrieves all entities of the given type. - * + *

*

* This is the same as (synonym for) {@link #findList()} */ @@ -536,7 +523,7 @@ public abstract class Model { /** * Retrieves an entity by ID. - * + *

*

* Equivalent to {@link EbeanServer#find(Class, Object)} */ @@ -547,7 +534,7 @@ public abstract class Model { /** * Creates an entity reference for this ID. - * + *

*

* Equivalent to {@link EbeanServer#getReference(Class, Object)} */ @@ -585,7 +572,7 @@ public abstract class Model { /** * Returns the next identity value. - * + * * @see EbeanServer#nextId(Class) */ @SuppressWarnings("unchecked") @@ -693,6 +680,7 @@ public abstract class Model { /** * Deprecated in favor of findCount(). + * * @deprecated */ public int findRowCount() { @@ -829,7 +817,7 @@ public abstract class Model { /** * Sets the ID value to query. - * + *

*

* Use this to perform a find byId query but with additional control over the query such as * using select and fetch to control what parts of the object graph are returned. @@ -858,7 +846,7 @@ public abstract class Model { /** * Create a query with the select with "for update" specified. - * + *

*

* This will typically create row level database locks on the selected rows. */ @@ -895,4 +883,4 @@ public abstract class Model { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/OrderBy.java b/src/main/java/com/avaje/ebean/OrderBy.java index b342fb23a..b62041cbf 100644 --- a/src/main/java/com/avaje/ebean/OrderBy.java +++ b/src/main/java/com/avaje/ebean/OrderBy.java @@ -294,7 +294,7 @@ public final class OrderBy implements Serializable { sb.append(" ").append("desc"); } sb.append(" ").append(nulls).append(" ").append(highLow); - return sb.toString(); + return sb.toString(); } } diff --git a/src/main/java/com/avaje/ebean/PagedList.java b/src/main/java/com/avaje/ebean/PagedList.java index 2b93872cc..253641784 100644 --- a/src/main/java/com/avaje/ebean/PagedList.java +++ b/src/main/java/com/avaje/ebean/PagedList.java @@ -16,8 +16,7 @@ import java.util.concurrent.Future; * the query. This translates into SQL that uses limit offset, rownum or row_number function to * limit the result set. *

- * - * + *

*

Example: typical use including total row count

*
{@code
  *
@@ -43,8 +42,7 @@ import java.util.concurrent.Future;
  *     int totalRowCount = pagedList.getTotalRowCount();
  *
  * }
- * - * + *

*

Example: No total row count required

*
{@code
  *
@@ -57,9 +55,7 @@ import java.util.concurrent.Future;
  *
  * }
* - * @param - * the entity bean type - * + * @param the entity bean type * @see Query#findPagedList() */ public interface PagedList { @@ -79,7 +75,6 @@ public interface PagedList { * int totalRowCount = pagedList.getTotalRowCount(); * * }
- * *

* Also note that using loadRowCount() and getTotalRowCount() rather than getFutureRowCount() * means that exceptions ExecutionException, InterruptedException, TimeoutException are instead @@ -192,11 +187,8 @@ public interface PagedList { * the total row count query if it has not already been invoked. *

* - * @param to - * String to put between the first and last row - * @param of - * String to put between the last row and the total row count - * + * @param to String to put between the first and last row + * @param of String to put between the last row and the total row count * @return String of the format XtoYofZ. */ String getDisplayXtoYofZ(String to, String of); diff --git a/src/main/java/com/avaje/ebean/Query.java b/src/main/java/com/avaje/ebean/Query.java index a3fc51e58..d09d53af8 100644 --- a/src/main/java/com/avaje/ebean/Query.java +++ b/src/main/java/com/avaje/ebean/Query.java @@ -724,7 +724,7 @@ public interface Query { /** * Execute the query returning a list of values for a single property. - * + *

*

Example 1:

*
{@code
    *
@@ -735,7 +735,7 @@ public interface Query {
    *      .findSingleAttributeList();
    *
    * }
- * + *

*

Example 2:

*
{@code
    *
diff --git a/src/main/java/com/avaje/ebean/QueryEachConsumer.java b/src/main/java/com/avaje/ebean/QueryEachConsumer.java
index f7de39953..6aa3f54fa 100644
--- a/src/main/java/com/avaje/ebean/QueryEachConsumer.java
+++ b/src/main/java/com/avaje/ebean/QueryEachConsumer.java
@@ -11,7 +11,7 @@ package com.avaje.ebean;
  * all the beans in the query result to be held in memory at once. This makes
  * QueryResultVisitor useful for processing large queries.
  * 

- * + *

*

{@code
  *
  * Query query = server.find(Customer.class)
@@ -25,17 +25,15 @@ package com.avaje.ebean;
  * });
  *
  * }
- * - * @param - * the type of entity bean being queried. + * + * @param the type of entity bean being queried. */ public interface QueryEachConsumer { /** * Process the bean. - * - * @param bean - * the entity bean to process + * + * @param bean the entity bean to process */ void accept(T bean); } diff --git a/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java b/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java index 251fd4326..54dfb9597 100644 --- a/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java +++ b/src/main/java/com/avaje/ebean/QueryEachWhileConsumer.java @@ -12,23 +12,24 @@ package com.avaje.ebean; * QueryResultVisitor useful for processing large queries. *

*

- *

+ * 
{@code
  *
- * Query<Customer> query = server.find(Customer.class)
- *     .fetch("contacts", new FetchConfig().query(2))
- *     .where().gt("id", 0)
- *     .orderBy("id")
+ * Query query = server.find(Customer.class)
+ *     .fetchQuery("contacts")
+ *     .where().gt("id", 0)
+ *     .orderBy("id")
  *     .setMaxRows(2);
  *
  * query.findEachWhile((Customer customer) -> {
  *
  *     // do something with customer
- *     System.out.println("-- visit " + customer);
+ *     System.out.println("-- visit " + customer);
  *
  *     // return true to continue processing or false to stop
  *     return (customer.getId() < 40);
  * });
- * 
+ * + * }
* * @param the type of entity bean being queried. */ diff --git a/src/main/java/com/avaje/ebean/QueryIterator.java b/src/main/java/com/avaje/ebean/QueryIterator.java index 23bfaea55..96787bd3f 100644 --- a/src/main/java/com/avaje/ebean/QueryIterator.java +++ b/src/main/java/com/avaje/ebean/QueryIterator.java @@ -19,9 +19,8 @@ import java.util.Iterator; * Remember that with {@link QueryIterator} you must call {@link QueryIterator#close()} * when you have finished iterating the results (typically in a finally block). *

- * *
{@code
- * 
+ *
  *  Query query = server.find(Customer.class)
  *     .where().gt("id", 0)
  *     .orderBy("id")
@@ -39,9 +38,8 @@ import java.util.Iterator;
  *  }
  *
  * }
- * - * @param - * the type of entity bean in the iteration + * + * @param the type of entity bean in the iteration */ public interface QueryIterator extends Iterator, java.io.Closeable { diff --git a/src/main/java/com/avaje/ebean/RawSql.java b/src/main/java/com/avaje/ebean/RawSql.java index f2727e398..b5ca778d2 100644 --- a/src/main/java/com/avaje/ebean/RawSql.java +++ b/src/main/java/com/avaje/ebean/RawSql.java @@ -1,10 +1,15 @@ package com.avaje.ebean; +import com.avaje.ebean.util.CamelCaseHelper; + import java.io.Serializable; import java.sql.ResultSet; -import java.util.*; - -import com.avaje.ebean.util.CamelCaseHelper; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * Used to build object graphs based on a raw SQL statement (rather than @@ -51,9 +56,8 @@ import com.avaje.ebean.util.CamelCaseHelper; * to hold the values for the aggregate functions (sum etc) and a @OneToOne * to Order. *

- * + *

*

Example OrderAggregate

- * *
{@code
  *  ...
  *  // @Sql indicates to that this bean
@@ -74,9 +78,9 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *  ...
  *
  * }
- * + *

*

Example 1:

- * + *

*

{@code
  *
  *   String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
@@ -102,15 +106,14 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *
  *
  * }
- * + *

*

Example 2:

- * *

* The following example uses a FetchConfig().query() so that after the initial * RawSql query is executed Ebean executes a secondary query to fetch the * associated order status, orderDate along with the customer name. *

- * + *

*

{@code
  *
  *  String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
@@ -133,11 +136,10 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *     .findList();
  *
  * }
- * - * + *

*

Example 3: tableAliasMapping

*

- * Instead of mapping each column you can map each table alias to a path using tableAliasMapping(). + * Instead of mapping each column you can map each table alias to a path using tableAliasMapping(). *

*
{@code
  *
@@ -162,12 +164,10 @@ import com.avaje.ebean.util.CamelCaseHelper;
  *       .findList();
  *
  * }
- * - * + *

*

* Note that lazy loading also works with object graphs built with RawSql. *

- * */ public final class RawSql implements Serializable { @@ -278,7 +278,7 @@ public final class RawSql implements Serializable { * Construct for parsed SQL. */ protected Sql(String unparsedSql, String preFrom, String preWhere, boolean andWhereExpr, - String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) { + String preHaving, boolean andHavingExpr, String orderByPrefix, String orderBy, boolean distinct) { this.unparsedSql = unparsedSql; this.parsed = true; @@ -296,8 +296,7 @@ public final class RawSql implements Serializable { if (!parsed) { return "unparsed[" + unparsedSql + "]"; } - return "select[" + preFrom + "] preWhere[" + preWhere + "] preHaving[" + preHaving - + "] orderBy[" + orderBy + "]"; + return "select[" + preFrom + "] preWhere[" + preWhere + "] preHaving[" + preHaving + "] orderBy[" + orderBy + "]"; } public boolean isDistinct() { @@ -476,8 +475,7 @@ public final class RawSql implements Serializable { /** * Creates an immutable copy of this ColumnMapping. * - * @throws IllegalStateException - * when a propertyName has not been defined for a column. + * @throws IllegalStateException when a propertyName has not been defined for a column. */ protected ColumnMapping createImmutableCopy() { @@ -566,7 +564,7 @@ public final class RawSql implements Serializable { */ public void tableAliasMapping(String tableAlias, String path) { - String startMatch = tableAlias+"."; + String startMatch = tableAlias + "."; for (Map.Entry entry : dbColumnMap.entrySet()) { if (entry.getKey().startsWith(startMatch)) { entry.getValue().tableAliasMapping(path); @@ -719,8 +717,8 @@ public final class RawSql implements Serializable { Key that = (Key) o; return parsed == that.parsed - && columnMapping.equals(that.columnMapping) - && unParsedSql.equals(that.unParsedSql); + && columnMapping.equals(that.columnMapping) + && unParsedSql.equals(that.unParsedSql); } @Override diff --git a/src/main/java/com/avaje/ebean/RawSqlBuilder.java b/src/main/java/com/avaje/ebean/RawSqlBuilder.java index 45ab6880c..0c4e1ed3c 100644 --- a/src/main/java/com/avaje/ebean/RawSqlBuilder.java +++ b/src/main/java/com/avaje/ebean/RawSqlBuilder.java @@ -1,17 +1,17 @@ package com.avaje.ebean; -import java.sql.ResultSet; - import com.avaje.ebean.RawSql.ColumnMapping; import com.avaje.ebean.RawSql.Sql; +import java.sql.ResultSet; + /** * Builds RawSql instances from a SQL string and column mappings. *

* Note that RawSql can also be defined in ebean-orm.xml files and be used as a * named query. *

- * + * * @see RawSql */ public class RawSqlBuilder { @@ -22,7 +22,7 @@ public class RawSqlBuilder { public static final String IGNORE_COLUMN = "$$_IGNORE_COLUMN_$$"; private final ResultSet resultSet; - + private final Sql sql; private final ColumnMapping columnMapping; @@ -37,7 +37,7 @@ public class RawSqlBuilder { public static RawSql resultSet(ResultSet resultSet, String... propertyNames) { return new RawSql(resultSet, propertyNames); } - + /** * Return an unparsed RawSqlBuilder. Unlike a parsed one this query can not be * modified - so no additional WHERE or HAVING expressions can be added to @@ -70,7 +70,7 @@ public class RawSqlBuilder { ColumnMapping mapping = DRawSqlColumnsParser.parse(select); return new RawSqlBuilder(sql2, mapping); } - + private RawSqlBuilder(Sql sql, ColumnMapping columnMapping) { this.sql = sql; this.columnMapping = columnMapping; @@ -83,11 +83,9 @@ public class RawSqlBuilder { * For Unparsed SQL the columnMapping MUST be defined in the same order that * the columns appear in the SQL statement. *

- * - * @param dbColumn - * the DB column that we are mapping to a bean property - * @param propertyName - * the bean property that we are mapping the DB column to. + * + * @param dbColumn the DB column that we are mapping to a bean property + * @param propertyName the bean property that we are mapping the DB column to. */ public RawSqlBuilder columnMapping(String dbColumn, String propertyName) { columnMapping.columnMapping(dbColumn, propertyName); @@ -130,6 +128,4 @@ public class RawSqlBuilder { return sql; } - - } diff --git a/src/main/java/com/avaje/ebean/SqlQuery.java b/src/main/java/com/avaje/ebean/SqlQuery.java index 58e4b721d..5a817bc16 100644 --- a/src/main/java/com/avaje/ebean/SqlQuery.java +++ b/src/main/java/com/avaje/ebean/SqlQuery.java @@ -18,23 +18,22 @@ import java.util.List; * The returned SqlRow objects are similar to a LinkedHashMap with some type * conversion support added. *

- * + *

*

{@code
  *
  *   // its typically a good idea to use a named query
  *   // and put the sql in the orm.xml instead of in your code
- * 
+ *
  *   String sql = "select id, name from customer where name like :name and status_code = :status";
- * 
+ *
  *   SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
  *   sqlQuery.setParameter("name", "Acme%");
  *   sqlQuery.setParameter("status", "ACTIVE");
- * 
+ *
  *   // execute the query returning a List of MapBean objects
  *   List list = sqlQuery.findList();
  *
  * }
- * */ public interface SqlQuery extends Serializable { @@ -98,9 +97,8 @@ public interface SqlQuery extends Serializable { * preparedStatement. If the timeout occurs an exception will be thrown - this * will be a SQLException wrapped up in a PersistenceException. *

- * - * @param secs - * the query timeout limit in seconds. Zero means there is no limit. + * + * @param secs the query timeout limit in seconds. Zero means there is no limit. */ SqlQuery setTimeout(int secs); diff --git a/src/main/java/com/avaje/ebean/SqlUpdate.java b/src/main/java/com/avaje/ebean/SqlUpdate.java index c02e89485..720d74159 100644 --- a/src/main/java/com/avaje/ebean/SqlUpdate.java +++ b/src/main/java/com/avaje/ebean/SqlUpdate.java @@ -16,19 +16,21 @@ package com.avaje.ebean; * notify Ebean of external changes and enable Ebean to maintain it's "L2" * server cache. *

- * - *
- * // example that uses 'named' parameters 
- * String s = "UPDATE f_topic set post_count = :count where id = :id"
+ * 

+ *

{@code
+ *
+ * // example that uses 'named' parameters
+ * String s = "UPDATE f_topic set post_count = :count where id = :id";
  * SqlUpdate update = Ebean.createSqlUpdate(s);
- * update.setParameter("id", 1);
- * update.setParameter("count", 50);
- * 
+ * update.setParameter("id", 1);
+ * update.setParameter("count", 50);
+ *
  * int modifiedCount = Ebean.execute(update);
- * 
- * String msg = "There were " + modifiedCount + " rows updated"
- * 
- * + * + * String msg = "There were " + modifiedCount + " rows updated"; + * + * }
+ * * @see Update * @see SqlQuery * @see CallableSql @@ -47,7 +49,7 @@ public interface SqlUpdate { * {@link Transaction#setBatchMode(boolean)} and * {@link Transaction#setBatchSize(int)}. *

- * + * * @see com.avaje.ebean.Ebean#execute(SqlUpdate) */ int execute(); diff --git a/src/main/java/com/avaje/ebean/Transaction.java b/src/main/java/com/avaje/ebean/Transaction.java index c05434b5c..ee453f159 100644 --- a/src/main/java/com/avaje/ebean/Transaction.java +++ b/src/main/java/com/avaje/ebean/Transaction.java @@ -62,10 +62,10 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Flush the JDBC batch buffer
  • - *
  • Call commit on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • + *
  • Flush the JDBC batch buffer
  • + *
  • Call commit on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • *
*/ void commitAndContinue() throws RollbackException; @@ -78,12 +78,12 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Flush the JDBC batch buffer
  • - *
  • Call commit on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • - *
  • Close any underlying resources, closing the underlying JDBC connection
  • - *
  • Mark the transaction as "Inactive"
  • + *
  • Flush the JDBC batch buffer
  • + *
  • Call commit on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Perform post-commit processing updating L2 cache, ElasticSearch etc
  • + *
  • Close any underlying resources, closing the underlying JDBC connection
  • + *
  • Mark the transaction as "Inactive"
  • *
*/ void commit() throws RollbackException; @@ -95,10 +95,10 @@ public interface Transaction extends Closeable { *

*

Functions/h3> *
    - *
  • Call rollback on the underlying JDBC connection
  • - *
  • Trigger any registered TransactionCallbacks
  • - *
  • Close any underlying resources, closing the underlying JDBC connection
  • - *
  • Mark the transaction as "Inactive"
  • + *
  • Call rollback on the underlying JDBC connection
  • + *
  • Trigger any registered TransactionCallbacks
  • + *
  • Close any underlying resources, closing the underlying JDBC connection
  • + *
  • Mark the transaction as "Inactive"
  • *
*/ void rollback() throws PersistenceException; @@ -136,10 +136,10 @@ public interface Transaction extends Closeable { /** * Set the behavior for document store updates on this transaction. *

- * For example, set the mode to DocStoreEvent.IGNORE for this transaction and - * then any changes via this transaction are not sent to the doc store. This - * would be used when doing large bulk inserts into the database and we want - * to control how that is sent to the document store. + * For example, set the mode to DocStoreEvent.IGNORE for this transaction and + * then any changes via this transaction are not sent to the doc store. This + * would be used when doing large bulk inserts into the database and we want + * to control how that is sent to the document store. *

*/ void setDocStoreMode(DocStoreMode mode); @@ -147,11 +147,11 @@ public interface Transaction extends Closeable { /** * Set the batch size to use for sending messages to the document store. *

- * You might set this if you know the changes in this transaction result in especially large or - * especially small payloads and want to adjust the batch size to match. + * You might set this if you know the changes in this transaction result in especially large or + * especially small payloads and want to adjust the batch size to match. *

*

- * Setting this overrides the default of {@link DocStoreConfig#getBulkBatchSize()} + * Setting this overrides the default of {@link DocStoreConfig#getBulkBatchSize()} *

*/ void setDocStoreBatchSize(int batchSize); @@ -197,7 +197,7 @@ public interface Transaction extends Closeable { * Refer to {@link ServerConfig#setSkipCacheAfterWrite(boolean)} for configuring the default behavior * for using the L2 bean cache in transactions spanning multiple query/persist requests. *

- * + *

*

{@code
    *
    *   // assume Customer has L2 bean caching enabled ...
@@ -279,23 +279,23 @@ public interface Transaction extends Closeable {
    * 

* Example: batch processing executing every 3 rows *

- * + *

*

{@code
    *
    * String data = "This is a simple test of the batch processing"
    *             + " mode and the transaction execute batch method";
-   * 
+   *
    * String[] da = data.split(" ");
-   * 
+   *
    * String sql = "{call sp_t3(?,?)}";
-   * 
+   *
    * CallableSql cs = new CallableSql(sql);
    * cs.registerOut(2, Types.INTEGER);
-   * 
+   *
    * // (optional) inform eBean this stored procedure
    * // inserts into a table called sp_test
    * cs.addModification("sp_test", true, false, false);
-   * 
+   *
    * Transaction txn = ebeanServer.beginTransaction();
    * txn.setBatchMode(true);
    * txn.setBatchSize(3);
@@ -304,16 +304,15 @@ public interface Transaction extends Closeable {
    *     cs.setParameter(1, da[i]);
    *     ebeanServer.execute(cs);
    *   }
-   * 
+   *
    *   // NB: commit implicitly flushes
    *   txn.commit();
-   * 
+   *
    * } finally {
    *   txn.end();
    * }
    *
    * }
- * */ void setBatchMode(boolean useBatch); @@ -325,7 +324,6 @@ public interface Transaction extends Closeable { *

* * @param persistBatchMode the batch mode to use for this transaction - * * @see com.avaje.ebean.config.ServerConfig#setPersistBatch(com.avaje.ebean.config.PersistBatch) */ void setBatch(PersistBatch persistBatchMode); @@ -347,7 +345,6 @@ public interface Transaction extends Closeable { *

* * @param batchOnCascadeMode the batch mode to use per save(), insert(), update() or delete() - * * @see com.avaje.ebean.config.ServerConfig#setPersistBatchOnCascade(com.avaje.ebean.config.PersistBatch) */ void setBatchOnCascade(PersistBatch batchOnCascadeMode); diff --git a/src/main/java/com/avaje/ebean/TxCallable.java b/src/main/java/com/avaje/ebean/TxCallable.java index 204b1774a..3e4128b7a 100644 --- a/src/main/java/com/avaje/ebean/TxCallable.java +++ b/src/main/java/com/avaje/ebean/TxCallable.java @@ -12,24 +12,26 @@ package com.avaje.ebean; *

* See also {@link TxRunnable}. *

- * - *
- * Ebean.execute(new TxCallable<String>() {
+ * 

+ *

{@code
+ *
+ * Ebean.execute(new TxCallable() {
  *   public String call() {
  *     User u1 = Ebean.find(User.class, 1);
  *     User u2 = Ebean.find(User.class, 2);
- * 
- *     u1.setName("u1 mod");
- *     u2.setName("u2 mod");
- * 
+ *
+ *     u1.setName("u1 mod");
+ *     u2.setName("u2 mod");
+ *
  *     Ebean.save(u1);
  *     Ebean.save(u2);
- * 
+ *
  *     return u1.getEmail();
  *   }
  * });
- * 
- * + * + * }
+ * * @see TxRunnable */ public interface TxCallable { diff --git a/src/main/java/com/avaje/ebean/TxIsolation.java b/src/main/java/com/avaje/ebean/TxIsolation.java index 8c0394c29..754959bbf 100644 --- a/src/main/java/com/avaje/ebean/TxIsolation.java +++ b/src/main/java/com/avaje/ebean/TxIsolation.java @@ -12,7 +12,7 @@ import java.sql.Connection; * This can be used with TxScope to define transactional scopes to execute * method within. *

- * + * * @see TxScope */ public enum TxIsolation { @@ -74,26 +74,26 @@ public enum TxIsolation { public static TxIsolation fromLevel(int connectionIsolationLevel) { switch (connectionIsolationLevel) { - case Connection.TRANSACTION_READ_UNCOMMITTED: - return TxIsolation.READ_UNCOMMITTED; + case Connection.TRANSACTION_READ_UNCOMMITTED: + return TxIsolation.READ_UNCOMMITTED; - case Connection.TRANSACTION_READ_COMMITTED: - return TxIsolation.READ_COMMITED; + case Connection.TRANSACTION_READ_COMMITTED: + return TxIsolation.READ_COMMITED; - case Connection.TRANSACTION_REPEATABLE_READ: - return TxIsolation.REPEATABLE_READ; + case Connection.TRANSACTION_REPEATABLE_READ: + return TxIsolation.REPEATABLE_READ; - case Connection.TRANSACTION_SERIALIZABLE: - return TxIsolation.SERIALIZABLE; + case Connection.TRANSACTION_SERIALIZABLE: + return TxIsolation.SERIALIZABLE; - case Connection.TRANSACTION_NONE: - return TxIsolation.NONE; + case Connection.TRANSACTION_NONE: + return TxIsolation.NONE; - case -1: - return TxIsolation.DEFAULT; + case -1: + return TxIsolation.DEFAULT; - default: - throw new RuntimeException("Unknown isolation level " + connectionIsolationLevel); + default: + throw new RuntimeException("Unknown isolation level " + connectionIsolationLevel); } } diff --git a/src/main/java/com/avaje/ebean/TxRunnable.java b/src/main/java/com/avaje/ebean/TxRunnable.java index f3bc724cc..2ae3009a2 100644 --- a/src/main/java/com/avaje/ebean/TxRunnable.java +++ b/src/main/java/com/avaje/ebean/TxRunnable.java @@ -8,26 +8,27 @@ package com.avaje.ebean; *

* See also {@link TxCallable}. *

- * - *
- * 
+ * 

+ *

{@code
+ *
  * // this run method runs in a transaction scope
  * // which by default is TxScope.REQUIRED
- * 
+ *
  * Ebean.execute(new TxRunnable() {
  *   public void run() {
  *     User u1 = Ebean.find(User.class, 1);
  *     User u2 = Ebean.find(User.class, 2);
- * 
- *     u1.setName("u1 mod");
- *     u2.setName("u2 mod");
- * 
+ *
+ *     u1.setName("u1 mod");
+ *     u2.setName("u2 mod");
+ *
  *     Ebean.save(u1);
  *     Ebean.save(u2);
  *   }
  * });
- * 
- * + * + * }
+ * * @see TxCallable */ public interface TxRunnable { diff --git a/src/main/java/com/avaje/ebean/TxScope.java b/src/main/java/com/avaje/ebean/TxScope.java index cd8ac0c50..300e7b696 100644 --- a/src/main/java/com/avaje/ebean/TxScope.java +++ b/src/main/java/com/avaje/ebean/TxScope.java @@ -105,8 +105,7 @@ public final class TxScope { */ public String toString() { return "TxScope[" + type + "] readOnly[" + readOnly + "] isolation[" + isolation - + "] serverName[" + serverName - + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]"; + + "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]"; } /** diff --git a/src/main/java/com/avaje/ebean/TxType.java b/src/main/java/com/avaje/ebean/TxType.java index e1cb19511..08d724d24 100644 --- a/src/main/java/com/avaje/ebean/TxType.java +++ b/src/main/java/com/avaje/ebean/TxType.java @@ -8,7 +8,7 @@ package com.avaje.ebean; * {@link Ebean#execute(TxScope, TxCallable)} and * {@link Ebean#execute(TxScope, TxRunnable)}. *

- * + * * @see TxScope */ public enum TxType { diff --git a/src/main/java/com/avaje/ebean/Update.java b/src/main/java/com/avaje/ebean/Update.java index d58fb8575..cbebb6c2c 100644 --- a/src/main/java/com/avaje/ebean/Update.java +++ b/src/main/java/com/avaje/ebean/Update.java @@ -11,43 +11,43 @@ package com.avaje.ebean; *

* The following is an example of named updates on an entity bean. *

- * - *
+ * 
{@code
  *  ...
- * @NamedUpdates(value = {
- *   @NamedUpdate(
- *      name = "setTitle", 
- *      notifyCache = false, 
- *      update = "update topic set title = :title, postCount = :count where id = :id"),
- *  @NamedUpdate(
- *      name = "setPostCount", 
- *      notifyCache = false, 
- *      update = "update f_topic set post_count = :postCount where id = :id"),
- *  @NamedUpdate(
- *      name = "incrementPostCount", 
- *      notifyCache = false, 
- *      update = "update Topic set postCount = postCount + 1 where id = :id") 
- *      //update = "update f_topic set post_count = post_count + 1 where id = :id") 
+ * @NamedUpdates(value = {
+ *   @NamedUpdate(
+ *      name = "setTitle",
+ *      notifyCache = false,
+ *      update = "update topic set title = :title, postCount = :count where id = :id"),
+ *  @NamedUpdate(
+ *      name = "setPostCount",
+ *      notifyCache = false,
+ *      update = "update f_topic set post_count = :postCount where id = :id"),
+ *  @NamedUpdate(
+ *      name = "incrementPostCount",
+ *      notifyCache = false,
+ *      update = "update Topic set postCount = postCount + 1 where id = :id")
+ *      //update = "update f_topic set post_count = post_count + 1 where id = :id")
  *  })
- * @Entity
- * @Table(name = "f_topic")
+ * @Entity
+ * @Table(name = "f_topic")
  * public class Topic {
  *  ...
- * 
- * + * }
+ * *

* The following show code that would use a named update on the Topic entity * bean. *

- * - *
- * Update<Topic> update = Ebean.createUpdate(Topic.class, "incrementPostCount");
- * update.setParameter("id", 1);
+ * 

+ *

{@code
+ *
+ * Update update = Ebean.createUpdate(Topic.class, "incrementPostCount");
+ * update.setParameter("id", 1);
  * int rows = update.execute();
- * 
- * - * @param - * the type of entity beans inserted updated or deleted + * + * }
+ * + * @param the type of entity beans inserted updated or deleted */ public interface Update { @@ -73,9 +73,8 @@ public interface Update { * preparedStatement. If the timeout occurs an exception will be thrown - this * will be a SQLException wrapped up in a PersistenceException. *

- * - * @param secs - * the timeout in seconds. Zero implies unlimited. + * + * @param secs the timeout in seconds. Zero implies unlimited. */ Update setTimeout(int secs); @@ -92,21 +91,17 @@ public interface Update { *

* Set a value for each ? you have in the sql. *

- * - * @param position - * the index position of the parameter starting with 1. - * @param value - * the parameter value to bind. + * + * @param position the index position of the parameter starting with 1. + * @param value the parameter value to bind. */ Update set(int position, Object value); /** * Set and ordered bind parameter (same as bind). - * - * @param position - * the index position of the parameter starting with 1. - * @param value - * the parameter value to bind. + * + * @param position the index position of the parameter starting with 1. + * @param value the parameter value to bind. */ Update setParameter(int position, Object value); @@ -129,11 +124,9 @@ public interface Update { *

* A more succinct version of setParameter() to be consistent with Query. *

- * - * @param name - * the parameter name. - * @param value - * the parameter value. + * + * @param name the parameter name. + * @param value the parameter value. */ Update set(String name, Object value); @@ -148,11 +141,9 @@ public interface Update { *

* A more succinct version of setNullParameter(). *

- * - * @param name - * the parameter name. - * @param jdbcType - * the type of the property being bound. + * + * @param name the parameter name. + * @param jdbcType the type of the property being bound. */ Update setNull(String name, int jdbcType); @@ -166,4 +157,4 @@ public interface Update { */ String getGeneratedSql(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/UpdateQuery.java b/src/main/java/com/avaje/ebean/UpdateQuery.java index 3760d57f6..1245644cd 100644 --- a/src/main/java/com/avaje/ebean/UpdateQuery.java +++ b/src/main/java/com/avaje/ebean/UpdateQuery.java @@ -7,9 +7,9 @@ package com.avaje.ebean; * This UpdateQuery is more for the cases where we want to build the where expression of the update using the * {@link ExpressionList} "Criteria API" that is used with a normal ORM query. *

- * + *

*

Example: Simple update

- * + *

*

{@code
  *
  *  int rows = ebeanServer
@@ -26,18 +26,17 @@ package com.avaje.ebean;
  *   update o_customer set status=?, updtime=? where id > ?
  *
  * }
- * *

* Note that if the where() clause contains a join then the SQL update changes to use a * WHERE ID IN () form. *

- * + *

*

Example: Update with a JOIN

*

- * In this example the expression .eq("billingAddress.country", nz) requires a join - * to the address table. + * In this example the expression .eq("billingAddress.country", nz) requires a join + * to the address table. *

- * + *

*

{@code
  *
  *   int rows = ebeanServer
@@ -50,7 +49,7 @@ package com.avaje.ebean;
  *         .gt("id", 1000)
  *         .update();
  * }
- * + *

*

{@code sql
  *
  *   update o_customer set status=?, updtime=?
@@ -65,15 +64,13 @@ package com.avaje.ebean;
  * }
* * @param The type of entity bean being updated - * * @see SqlUpdate */ public interface UpdateQuery { /** * Set the value of a property. - * - * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -87,13 +84,13 @@ public interface UpdateQuery {
    * }
* * @param property The bean property to be set - * @param value The value to set the property to + * @param value The value to set the property to */ UpdateQuery set(String property, Object value); /** * Set the property to be null. - * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -110,12 +107,11 @@ public interface UpdateQuery {
   UpdateQuery setNull(String property);
 
   /**
-   *
    * Set using a property expression that does not need any bind values.
    * 

* The property expression typically contains database functions. *

- * + *

*

{@code
    *
    *   int rows = ebeanServer
@@ -148,7 +144,7 @@ public interface UpdateQuery {
    * }
* * @param propertyExpression A raw property expression - * @param values The values to bind with the property expression + * @param values The values to bind with the property expression */ UpdateQuery setRaw(String propertyExpression, Object... values); diff --git a/src/main/java/com/avaje/ebean/ValuePair.java b/src/main/java/com/avaje/ebean/ValuePair.java index e9a49eb75..8b3480449 100644 --- a/src/main/java/com/avaje/ebean/ValuePair.java +++ b/src/main/java/com/avaje/ebean/ValuePair.java @@ -29,7 +29,7 @@ public class ValuePair { public Object getNewValue() { return newValue; } - + /** * Return the old value. */ diff --git a/src/main/java/com/avaje/ebean/overview.html b/src/main/java/com/avaje/ebean/overview.html index 4ce74e843..7f85d3c41 100644 --- a/src/main/java/com/avaje/ebean/overview.html +++ b/src/main/java/com/avaje/ebean/overview.html @@ -1,6 +1,6 @@ - Ebean API + Ebean API Ebean Object Relational Mapping (start at @@ -9,48 +9,48 @@ Ebean Object Relational Mapping (start at

Ebean

-Provides the main API for fetching and persisting beans with Ebean. + Provides the main API for fetching and persisting beans with Ebean.

-For a full description of the query language refer to Query. + For a full description of the query language refer to Query.

-  +  

-

-EXAMPLE 1: Simple fetch -

-
{@code
+  

+ EXAMPLE 1: Simple fetch +

+
{@code
 // fetch order 10
 Order order = Ebean.find(Order.class, 10);
 }
-

-EXAMPLE 2: Fetch an Object with associations -

-
{@code
+  

+ EXAMPLE 2: Fetch an Object with associations +

+
{@code
 // fetch Customer 7 including their billing and shipping addresses
 Customer customer = Ebean.find(Customer.class)
     .fetch("billingAddress");
     .fetch("shippingAddress");
     .setId(7)
     .findUnique();
-	
-		
+
+
 Address billAddr = customer.getBillingAddress();
 Address shipAddr = customer.getShippingAddress();
 }
-

-EXAMPLE 3: Fetch a list of Objects with associations -

-
{@code
+  

+ EXAMPLE 3: Fetch a list of Objects with associations +

+
{@code
 // Note: This example shows a "Partial Object".
-//       For the product objects associated with the 
+//       For the product objects associated with the
 //       order details only the product id and name is
 //       fetched (the product objects are partially populated).
-		
+
 // fetch orders for customer.id = 2
 List orderList = Ebean.find(Order.class);
     .fetch("customer")
@@ -62,14 +62,14 @@ List orderList = Ebean.find(Order.class);
 
 
 // Note: Only the product id and name is fetched for the
-//       product details. This is referred to as a 
-//       "Partial Object" (one that is partially populated).  
+//       product details. This is referred to as a
+//       "Partial Object" (one that is partially populated).
 
 
 // code that traverses the object graph...
 
 Order order = orderList.get(0);
-Customer customer = order.getCustomer();	
+Customer customer = order.getCustomer();
 Address shipAddr = customer.getShippingAddress();
 
 List details = order.getDetails();
@@ -79,10 +79,10 @@ String productName = product.getName();
 
 }
-

-EXAMPLE 4: Create and save an Order -

-
{@code
+  

+ EXAMPLE 4: Create and save an Order +

+
{@code
 // get a Customer reference so we don't hit the database
 Customer custRef = Ebean.getReference(Customer.class, 7);
 
@@ -109,25 +109,25 @@ Ebean.save(newOrder);
 
 }
-

-EXAMPLE 5: Use another database -

-
{@code
+  

+ EXAMPLE 5: Use another database +

+
{@code
 // Get access to the Human Resources EbeanServer/Database
 EbeanServer hrServer = Ebean.getServer("HR");
-                                    
-                              
+
+
 // fetch contact 3 from the HR database
 Contact contact = hrServer.find(Contact.class, 3);
-                                    
+
 contact.setStatus(Contact.Status.INACTIVE);
 ...
-                                    
+
 // save the contact back to the HR database
-hrServer.save(contact); 	
+hrServer.save(contact);
 }
- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/package.html b/src/main/java/com/avaje/ebean/package.html index 3f1155af5..0c825cc56 100644 --- a/src/main/java/com/avaje/ebean/package.html +++ b/src/main/java/com/avaje/ebean/package.html @@ -1,13 +1,13 @@ - Ebean core API + Ebean core API Core API (see
EbeanServer and Ebean).

Ebean

-Provides the main API for fetching and persisting beans with eBean. + Provides the main API for fetching and persisting beans with eBean.

{@code
@@ -83,4 +83,4 @@ hrServer.save(contact);
 }
- \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/stylesheet.css b/src/main/java/com/avaje/ebean/stylesheet.css index 634ca5705..21caf36d8 100644 --- a/src/main/java/com/avaje/ebean/stylesheet.css +++ b/src/main/java/com/avaje/ebean/stylesheet.css @@ -3,40 +3,89 @@ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ -body { -background-color: #FFFFFF; -font-family: Arial, Helvetica, sans-serif; -font-size:10pt; +body { + background-color: #FFFFFF; + font-family: Arial, Helvetica, sans-serif; + font-size: 10pt; } pre.code { - padding:1em; - margin-left:2em; - border: 1px solid #ccc; - background-color: #eee; + padding: 1em; + margin-left: 2em; + border: 1px solid #ccc; + background-color: #eee; } /* Headings */ -h1 { font-size: 14pt } +h1 { + font-size: 14pt +} -#overviewexamples h3 {font-size:10pt } +#overviewexamples h3 { + font-size: 10pt +} /* Table colors */ -.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ -.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ -.TableRowColor { background: #FFFFFF } /* White */ +.TableHeadingColor { + background: #CCCCFF +} + +/* Dark mauve */ +.TableSubHeadingColor { + background: #EEEEFF +} + +/* Light mauve */ +.TableRowColor { + background: #FFFFFF +} + +/* White */ /* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: 12pt; font-family: Helvetica, Arial, sans-serif } -.FrameHeadingFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } -.FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } +.FrameTitleFont { + font-size: 12pt; + font-family: Helvetica, Arial, sans-serif +} + +.FrameHeadingFont { + font-size: 10pt; + font-family: Helvetica, Arial, sans-serif +} + +.FrameItemFont { + font-size: 10pt; + font-family: Helvetica, Arial, sans-serif +} /* Navigation bar fonts and colors */ -.NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ -.NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ -.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} -.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} +.NavBarCell1 { + background-color: #EEEEFF; +} -.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +/* Light mauve */ +.NavBarCell1Rev { + background-color: #00008B; +} + +/* Dark Blue */ +.NavBarFont1 { + font-family: Arial, Helvetica, sans-serif; + color: #000000; +} + +.NavBarFont1Rev { + font-family: Arial, Helvetica, sans-serif; + color: #FFFFFF; +} + +.NavBarCell2 { + font-family: Arial, Helvetica, sans-serif; + background-color: #FFFFFF; +} + +.NavBarCell3 { + font-family: Arial, Helvetica, sans-serif; + background-color: #FFFFFF; +} From 697e4dd0dada36bd67ce3605bac4a4ff20f0532b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 19:58:37 +1300 Subject: [PATCH 75/87] no effective change - format and javadoc --- .../avaje/ebean/annotation/Aggregation.java | 4 +-- .../com/avaje/ebean/annotation/Cache.java | 2 +- .../ebean/annotation/CacheBeanTuning.java | 2 +- .../ebean/annotation/CacheQueryTuning.java | 2 +- .../ebean/annotation/CreatedTimestamp.java | 4 +-- .../com/avaje/ebean/annotation/DbArray.java | 2 +- .../com/avaje/ebean/annotation/DbHstore.java | 4 +-- .../com/avaje/ebean/annotation/DbJson.java | 4 +-- .../com/avaje/ebean/annotation/DbJsonB.java | 8 ++--- .../avaje/ebean/annotation/DocEmbedded.java | 3 +- .../avaje/ebean/annotation/DocMapping.java | 2 +- .../avaje/ebean/annotation/DocProperty.java | 2 +- .../avaje/ebean/annotation/DocSortable.java | 2 +- .../com/avaje/ebean/annotation/DocStore.java | 3 +- .../avaje/ebean/annotation/DocStoreMode.java | 6 ++-- .../ebean/annotation/EmbeddedColumns.java | 2 +- .../com/avaje/ebean/annotation/Encrypted.java | 2 +- .../com/avaje/ebean/annotation/EnumValue.java | 9 +++--- .../com/avaje/ebean/annotation/Formula.java | 30 +++++++++---------- .../com/avaje/ebean/annotation/History.java | 2 +- .../ebean/annotation/HistoryExclude.java | 2 +- .../com/avaje/ebean/annotation/Index.java | 2 +- .../com/avaje/ebean/annotation/Indices.java | 3 +- .../avaje/ebean/annotation/JsonIgnore.java | 6 ++-- .../avaje/ebean/annotation/PrivateOwned.java | 2 +- .../java/com/avaje/ebean/annotation/Sql.java | 2 +- .../avaje/ebean/annotation/Transactional.java | 18 +++++------ .../avaje/ebean/annotation/UpdateMode.java | 4 +-- .../ebean/annotation/UpdatedTimestamp.java | 2 +- .../avaje/ebean/annotation/WhenCreated.java | 4 +-- .../avaje/ebean/annotation/WhenModified.java | 2 +- .../com/avaje/ebean/annotation/Where.java | 10 ++----- .../avaje/ebean/annotation/WhoCreated.java | 5 ++-- .../avaje/ebean/annotation/WhoModified.java | 1 - .../com/avaje/ebean/annotation/package.html | 8 ++--- 35 files changed, 78 insertions(+), 88 deletions(-) diff --git a/src/main/java/com/avaje/ebean/annotation/Aggregation.java b/src/main/java/com/avaje/ebean/annotation/Aggregation.java index 7fb6589cc..aeb4147c1 100644 --- a/src/main/java/com/avaje/ebean/annotation/Aggregation.java +++ b/src/main/java/com/avaje/ebean/annotation/Aggregation.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * included in a query. To populate the aggregation property it must be * explicitly included in the select(). *

- * + *

*

Example:

*
{@code
  *
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
  * Long totalAmount;
  *
  * }
- * + *

*

Example query

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/Cache.java b/src/main/java/com/avaje/ebean/annotation/Cache.java
index ea1a50f2a..59be62ef3 100644
--- a/src/main/java/com/avaje/ebean/annotation/Cache.java
+++ b/src/main/java/com/avaje/ebean/annotation/Cache.java
@@ -8,7 +8,7 @@ import java.lang.annotation.Target;
 /**
  * Specify the default cache use specific entity type.
  */
-@Target({ ElementType.TYPE })
+@Target({ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Cache {
 
diff --git a/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java b/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
index 546f50d5f..b1a299f51 100644
--- a/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
+++ b/src/main/java/com/avaje/ebean/annotation/CacheBeanTuning.java
@@ -12,7 +12,7 @@ import java.lang.annotation.Target;
  * ElasticSearch, Hazelcast, Ignite etc.
  * 

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheBeanTuning { diff --git a/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java b/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java index 2fd1464e5..bf43ef9fc 100644 --- a/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java +++ b/src/main/java/com/avaje/ebean/annotation/CacheQueryTuning.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * If this is not specified then the system default settings are used. *

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheQueryTuning { diff --git a/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java b/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java index 49b5bc6a1..d53e62baf 100644 --- a/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java +++ b/src/main/java/com/avaje/ebean/annotation/CreatedTimestamp.java @@ -22,7 +22,7 @@ import java.lang.annotation.Target; * timestamp value after the insert has occurred. You need to fetch the entity * back to get the inserted timestamp if you want to used it. *

- * + *

*

Example:

*
{@code
  *
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface CreatedTimestamp { diff --git a/src/main/java/com/avaje/ebean/annotation/DbArray.java b/src/main/java/com/avaje/ebean/annotation/DbArray.java index 5c81651d5..8d3fd5d24 100644 --- a/src/main/java/com/avaje/ebean/annotation/DbArray.java +++ b/src/main/java/com/avaje/ebean/annotation/DbArray.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * If the target database does not support ARRAY type (so not Postgres) * then the collection will be stored in JSON format into a VARCHAR column. *

- * + *

*

Example:

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/DbHstore.java b/src/main/java/com/avaje/ebean/annotation/DbHstore.java
index 9ffd29760..87ede7183 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbHstore.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbHstore.java
@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
  * 

* The Map property should have keys and values of type String. *

- * + *

*

Example:

*
{@code
  *
@@ -27,4 +27,4 @@ public @interface DbHstore {
    * For VARCHAR storage specify the column length (defaults to 1000).
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DbJson.java b/src/main/java/com/avaje/ebean/annotation/DbJson.java
index d5bf2b059..07cf1564e 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbJson.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbJson.java
@@ -18,7 +18,7 @@ import java.lang.annotation.Target;
  * Map content;
  *
  * }
- * + *

*

Example with JSONB storage

*
{@code
  *
@@ -41,4 +41,4 @@ public @interface DbJson {
    * For VARCHAR storage specify the column length (defaults to 3000).
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DbJsonB.java b/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
index ebfaf9270..418294006 100644
--- a/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
+++ b/src/main/java/com/avaje/ebean/annotation/DbJsonB.java
@@ -11,9 +11,9 @@ import java.lang.annotation.Target;
  * The content will be stored on Postgres using it's JSONB type and as Clob for other databases.
  * 

*

- * This is equivalent to using @DbJson(storage = DbJsonType.JSONB) + * This is equivalent to using @DbJson(storage = DbJsonType.JSONB) *

- * + *

*

Example:

*
{@code
  *
@@ -22,7 +22,7 @@ import java.lang.annotation.Target;
  * Map content;
  *
  * }
- * + *

*

Equivalent to:

*
{@code
  *
@@ -40,4 +40,4 @@ public @interface DbJsonB {
    * For VARCHAR storage specify the column length.
    */
   int length() default 0;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java b/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
index f0e258287..5cfd92ce7 100644
--- a/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
+++ b/src/main/java/com/avaje/ebean/annotation/DocEmbedded.java
@@ -7,7 +7,6 @@ import java.lang.annotation.Target;
 
 /**
  * Specify the property is included in the parent document store index.
- *
  * 
{@code
  *
  *
@@ -25,7 +24,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocEmbedded { diff --git a/src/main/java/com/avaje/ebean/annotation/DocMapping.java b/src/main/java/com/avaje/ebean/annotation/DocMapping.java index b95a1ec74..10c1fc857 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocMapping.java +++ b/src/main/java/com/avaje/ebean/annotation/DocMapping.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface DocMapping { diff --git a/src/main/java/com/avaje/ebean/annotation/DocProperty.java b/src/main/java/com/avaje/ebean/annotation/DocProperty.java index 4cc5ad262..ee4aaa21b 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocProperty.java +++ b/src/main/java/com/avaje/ebean/annotation/DocProperty.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocProperty { diff --git a/src/main/java/com/avaje/ebean/annotation/DocSortable.java b/src/main/java/com/avaje/ebean/annotation/DocSortable.java index f0b87b450..ba554c1c5 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocSortable.java +++ b/src/main/java/com/avaje/ebean/annotation/DocSortable.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * For example, customer name and product name are good candidates for marking with @DocSortable. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface DocSortable { diff --git a/src/main/java/com/avaje/ebean/annotation/DocStore.java b/src/main/java/com/avaje/ebean/annotation/DocStore.java index be116b799..808c35977 100644 --- a/src/main/java/com/avaje/ebean/annotation/DocStore.java +++ b/src/main/java/com/avaje/ebean/annotation/DocStore.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify the entity type maps to a document store (like ElasticSearch). */ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface DocStore { @@ -73,7 +73,6 @@ public @interface DocStore { * Note that typically DocStoreEmbedded is used on @ManyToOne and @OneToMany * properties to indicate what part of the nested document should be included. *

- * *

Example:

*
{@code
    *
diff --git a/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java b/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
index b4805ee75..03297dbc6 100644
--- a/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
+++ b/src/main/java/com/avaje/ebean/annotation/DocStoreMode.java
@@ -23,9 +23,9 @@ public enum DocStoreMode {
   /**
    * Ignore the event and not update the document store.
    * 

- * This can be used on a index or for a transaction where you want to have more - * manual programmatic control over the updating of the document store. Say you want to - * IGNORE on a particular transaction and instead manually queue a bulk update. + * This can be used on a index or for a transaction where you want to have more + * manual programmatic control over the updating of the document store. Say you want to + * IGNORE on a particular transaction and instead manually queue a bulk update. *

*/ IGNORE, diff --git a/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java b/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java index 5a68edbac..b63ecfebf 100644 --- a/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java +++ b/src/main/java/com/avaje/ebean/annotation/EmbeddedColumns.java @@ -12,7 +12,7 @@ import java.lang.annotation.Target; * standard JPA. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface EmbeddedColumns { diff --git a/src/main/java/com/avaje/ebean/annotation/Encrypted.java b/src/main/java/com/avaje/ebean/annotation/Encrypted.java index a803ddc0a..25c1697c0 100644 --- a/src/main/java/com/avaje/ebean/annotation/Encrypted.java +++ b/src/main/java/com/avaje/ebean/annotation/Encrypted.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * Specify that the property is stored in encrypted form. */ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface Encrypted { diff --git a/src/main/java/com/avaje/ebean/annotation/EnumValue.java b/src/main/java/com/avaje/ebean/annotation/EnumValue.java index 8dce61fdc..d34294327 100644 --- a/src/main/java/com/avaje/ebean/annotation/EnumValue.java +++ b/src/main/java/com/avaje/ebean/annotation/EnumValue.java @@ -7,21 +7,20 @@ import java.lang.annotation.Target; /** * Enables you to specify a value to use to persist for an enum value. - * *
{@code
  *
  * public enum Status {
  *
  *   @EnumValue("N")
  *   NEW,
- * 
+ *
  *   @EnumValue("A")
  *   ACTIVE,
- * 
+ *
  *   @EnumValue("I")
  *   INACTIVE,
  * }
- * 
+ *
  * }
*

* This is an alternative to using the JPA standard approach or Ebean's @@ -33,7 +32,7 @@ import java.lang.annotation.Target; * and fetched as strings. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface EnumValue { diff --git a/src/main/java/com/avaje/ebean/annotation/Formula.java b/src/main/java/com/avaje/ebean/annotation/Formula.java index 647edcfd1..35b24c60e 100644 --- a/src/main/java/com/avaje/ebean/annotation/Formula.java +++ b/src/main/java/com/avaje/ebean/annotation/Formula.java @@ -1,12 +1,12 @@ package com.avaje.ebean.annotation; +import com.avaje.ebean.Query; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.avaje.ebean.Query; - /** * Assign to a property to be based on a SQL formula. *

@@ -24,28 +24,27 @@ import com.avaje.ebean.Query; * You may want to do this if the Formula is relatively expensive and only want * it included in the query when you explicitly state it. *

- * - *
- * // On the Order "master" bean
+ * 

+ *

{@code
+ * // On the Order "master" bean
  * // ... a formula using the Order details
  * // ... sum(order_qty*unit_price)
- * @Transient
- * @Formula(select = "_b${ta}.total_amount", join = "join (select order_id, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) as _b${ta} on _b${ta}.order_id = ${ta}.id")
+ * @Transient
+ * @Formula(select = "_b${ta}.total_amount", join = "join (select order_id, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) as _b${ta} on _b${ta}.order_id = ${ta}.id")
  * Double totalAmount;
- * 
- * 
+ * + * }
*

* As the totalAmount formula is also Transient it is not included by default in * queries - it needs to be explicitly included. *

- * *
{@code
  *
  * // find by Id
  * Order o1 = Ebean.find(Order.class)
  *     .select("id, totalAmount")
  *     .setId(1).findUnique();
- * 
+ *
  * // find list ... using totalAmount in the where clause
  * List list = Ebean.find(Order.class)
  *     .select("id, totalAmount")
@@ -53,7 +52,7 @@ import com.avaje.ebean.Query;
  *     .eq("status", Order.Status.NEW)
  *     .gt("totalAmount", 10)
  *     .findList();
- * 
+ *
  * // as a join from customer
  * List l0 = Ebean.find(Customer.class)
  *     .select("id, name")
@@ -62,10 +61,10 @@ import com.avaje.ebean.Query;
  *     .gt("id", 0)
  *     .gt("orders.totalAmount", 10)
  *     .findList();
- * 
+ *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Formula { @@ -84,7 +83,6 @@ public @interface Formula { *

* The join string should start with either "left join" or "join". *

- * *

* You will almost certainly use the "${ta}" as a place holder for the table * alias of the table you are joining back to (the "base table" of the entity @@ -94,7 +92,7 @@ public @interface Formula { * The example below is used to support a total count of topics created by a * user. *

- * + *

*

{@code
    *
    * join (select user_id, count(*) as topic_count from f_topic group by user_id) as _tc on _tc.user_id = ${ta}.id
diff --git a/src/main/java/com/avaje/ebean/annotation/History.java b/src/main/java/com/avaje/ebean/annotation/History.java
index 36888086d..9548b3cf1 100644
--- a/src/main/java/com/avaje/ebean/annotation/History.java
+++ b/src/main/java/com/avaje/ebean/annotation/History.java
@@ -12,7 +12,7 @@ import java.lang.annotation.Target;
  * typically automatically populated via database triggers.
  * 

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface History { diff --git a/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java b/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java index a41dfe1d9..bae53aa35 100644 --- a/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java +++ b/src/main/java/com/avaje/ebean/annotation/HistoryExclude.java @@ -18,7 +18,7 @@ import java.lang.annotation.Target; * support. *

*/ -@Target({ ElementType.FIELD }) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface HistoryExclude { diff --git a/src/main/java/com/avaje/ebean/annotation/Index.java b/src/main/java/com/avaje/ebean/annotation/Index.java index ae82a8802..426320f5f 100644 --- a/src/main/java/com/avaje/ebean/annotation/Index.java +++ b/src/main/java/com/avaje/ebean/annotation/Index.java @@ -29,7 +29,7 @@ public @interface Index { /** * When placed on the class (rather than field) you can specify the columns * to include in the index in order. - * + *

* Wnen placed on a field, and columnNames are specified, the field-column has to be included. * You can use "${fa}" for alias */ diff --git a/src/main/java/com/avaje/ebean/annotation/Indices.java b/src/main/java/com/avaje/ebean/annotation/Indices.java index 0886482ed..0e74559f7 100644 --- a/src/main/java/com/avaje/ebean/annotation/Indices.java +++ b/src/main/java/com/avaje/ebean/annotation/Indices.java @@ -4,9 +4,10 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + /** * An annotation for declaring multiple indices at class or field level. - * + * * @author Roland Praml, FOCONIS AG */ @Target({ElementType.TYPE, ElementType.FIELD}) diff --git a/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java b/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java index 79635ddc1..822882a0c 100644 --- a/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java +++ b/src/main/java/com/avaje/ebean/annotation/JsonIgnore.java @@ -8,8 +8,8 @@ import java.lang.annotation.Target; /** * Similar to Jackson JsonIgnore but provides the option to just ignore serialize or deserialize. *

- * This provides the same features as Expose but from the opposite perspective which is probably - * more common and more familiar to Jackson users. + * This provides the same features as Expose but from the opposite perspective which is probably + * more common and more familiar to Jackson users. *

*/ @Retention(RetentionPolicy.RUNTIME) @@ -29,4 +29,4 @@ public @interface JsonIgnore { * Defaults to {@code false}. */ boolean deserialize() default false; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java b/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java index 684f5a416..a7d58f978 100644 --- a/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java +++ b/src/main/java/com/avaje/ebean/annotation/PrivateOwned.java @@ -18,7 +18,7 @@ import java.lang.annotation.Target; * in that they are no longer associated/linked to their parent bean. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface PrivateOwned { diff --git a/src/main/java/com/avaje/ebean/annotation/Sql.java b/src/main/java/com/avaje/ebean/annotation/Sql.java index 223db95c5..a37c70d96 100644 --- a/src/main/java/com/avaje/ebean/annotation/Sql.java +++ b/src/main/java/com/avaje/ebean/annotation/Sql.java @@ -11,7 +11,7 @@ import java.lang.annotation.Target; * This means the entity bean has no base table specified (via @Table). *

*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Sql { diff --git a/src/main/java/com/avaje/ebean/annotation/Transactional.java b/src/main/java/com/avaje/ebean/annotation/Transactional.java index 5de7f8b6c..db998ad94 100644 --- a/src/main/java/com/avaje/ebean/annotation/Transactional.java +++ b/src/main/java/com/avaje/ebean/annotation/Transactional.java @@ -1,14 +1,14 @@ package com.avaje.ebean.annotation; +import com.avaje.ebean.TxIsolation; +import com.avaje.ebean.TxType; +import com.avaje.ebean.config.PersistBatch; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.avaje.ebean.TxIsolation; -import com.avaje.ebean.TxType; -import com.avaje.ebean.config.PersistBatch; - /** * Specify transaction scoping for a method. *

@@ -33,22 +33,22 @@ import com.avaje.ebean.config.PersistBatch; * to set the default behaviour to rollback on any exception and optionally * change the setting to be consistent with EJB/Spring if people wish to do so. *

- * + *

*

{@code
  *
  *  // a normal class
  *  public class MySimpleUserService {
- * 
+ *
  *    // this method is transactional automatically handling
  *    // transaction begin, commit and rollback etc
  *    @Transactional
  *    public void runInTrans() throws IOException {
- * 
+ *
  *      // tasks performed within the transaction
  *      ...
  *      // find some objects
  *      Customer cust = ebeanServer.find(Customer.class, 42);
- *    
+ *
  *      Order order = ...;
  *      ...
  *      // save some objects
@@ -58,7 +58,7 @@ import com.avaje.ebean.config.PersistBatch;
  *
  * }
*/ -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Transactional { diff --git a/src/main/java/com/avaje/ebean/annotation/UpdateMode.java b/src/main/java/com/avaje/ebean/annotation/UpdateMode.java index f051262a8..0353737bc 100644 --- a/src/main/java/com/avaje/ebean/annotation/UpdateMode.java +++ b/src/main/java/com/avaje/ebean/annotation/UpdateMode.java @@ -14,13 +14,13 @@ import java.lang.annotation.Target; *

* Note that the default can be set via ebean.properties. *

- * + *

*

  * ## Set to update all loaded properties
  * ebean.updateChangesOnly=false
  * 
*/ -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface UpdateMode { diff --git a/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java b/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java index b93a5ab37..8a181369e 100644 --- a/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java +++ b/src/main/java/com/avaje/ebean/annotation/UpdatedTimestamp.java @@ -13,7 +13,7 @@ import java.lang.annotation.Target; * towards a better naming convention (WhenCreated, WhenModified). *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface UpdatedTimestamp { diff --git a/src/main/java/com/avaje/ebean/annotation/WhenCreated.java b/src/main/java/com/avaje/ebean/annotation/WhenCreated.java index 0d20fdc7a..6779254d1 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhenCreated.java +++ b/src/main/java/com/avaje/ebean/annotation/WhenCreated.java @@ -22,7 +22,7 @@ import java.lang.annotation.Target; * timestamp value after the insert has occurred. You need to fetch the entity * back to get the inserted timestamp if you want to used it. *

- * + *

*

Example:

*
{@code
  *
@@ -31,7 +31,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhenCreated { diff --git a/src/main/java/com/avaje/ebean/annotation/WhenModified.java b/src/main/java/com/avaje/ebean/annotation/WhenModified.java index 1dbfd674e..3e9838816 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhenModified.java +++ b/src/main/java/com/avaje/ebean/annotation/WhenModified.java @@ -12,7 +12,7 @@ import java.lang.annotation.Target; * towards a better naming convention (WhenCreated, WhenModified). *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhenModified { diff --git a/src/main/java/com/avaje/ebean/annotation/Where.java b/src/main/java/com/avaje/ebean/annotation/Where.java index 5fc586593..46ecc25ea 100644 --- a/src/main/java/com/avaje/ebean/annotation/Where.java +++ b/src/main/java/com/avaje/ebean/annotation/Where.java @@ -8,37 +8,33 @@ import java.lang.annotation.Target; /** * Add an Literal to add to the where clause when a many property (List, Set or * Map) is loaded or refreshed. - * *
{@code
  *
  * // on a OneToMany property...
- * 
+ *
  * @OneToMany
  * @Where(clause = "deleted='y'")
  * List topics;
  *
  * }
- * *

* Note that you can include "${ta}" as a place holder for the table alias if * you need to include the table alias in the clause. *

- * *
{@code
  * // ... including the ${ta} table alias placeholder...
- * 
+ *
  * @OneToMany
  * @Where(clause = "${ta}.deleted='y'")
  * List topics;
  *
  * }
- * *

* This will be added to the where clause when lazy loading the OneToMany * property or when there is a join to that OneToMany property. *

*/ -@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Where { diff --git a/src/main/java/com/avaje/ebean/annotation/WhoCreated.java b/src/main/java/com/avaje/ebean/annotation/WhoCreated.java index c9dcfdfae..8bb199834 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhoCreated.java +++ b/src/main/java/com/avaje/ebean/annotation/WhoCreated.java @@ -12,8 +12,7 @@ import java.lang.annotation.Target; * To use this annotation you need to implement CurrentUserProvider. * The type of the bean property should match the type returned by * CurrentUserProvider. - *

- + *

*

Example:

*
{@code
  *
@@ -22,7 +21,7 @@ import java.lang.annotation.Target;
  *
  * }
*/ -@Target({ ElementType.FIELD, ElementType.METHOD }) +@Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WhoCreated { diff --git a/src/main/java/com/avaje/ebean/annotation/WhoModified.java b/src/main/java/com/avaje/ebean/annotation/WhoModified.java index 1ef57e298..5bd2c9de0 100644 --- a/src/main/java/com/avaje/ebean/annotation/WhoModified.java +++ b/src/main/java/com/avaje/ebean/annotation/WhoModified.java @@ -13,7 +13,6 @@ import java.lang.annotation.Target; * The type of the bean property should match the type returned by * CurrentUserProvider. *

- * *

Example:

*
{@code
  *
diff --git a/src/main/java/com/avaje/ebean/annotation/package.html b/src/main/java/com/avaje/ebean/annotation/package.html
index c39eed7aa..a3cb62253 100644
--- a/src/main/java/com/avaje/ebean/annotation/package.html
+++ b/src/main/java/com/avaje/ebean/annotation/package.html
@@ -1,14 +1,14 @@
 
 
-	
-	Extra deployment annotations
+  
+  Extra deployment annotations
 
 
 Extra deployment annotations
 
 

-Extra deployment annotations for entity beans. + Extra deployment annotations for entity beans.

- \ No newline at end of file + From c41070043311564cbc8537aa3ff4e07f38ef4796 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:00:01 +1300 Subject: [PATCH 76/87] no effective change - format --- .../com/avaje/ebean/bean/BeanCollection.java | 16 ++++++--- .../java/com/avaje/ebean/bean/CallStack.java | 12 +++---- .../java/com/avaje/ebean/bean/EntityBean.java | 4 +-- .../avaje/ebean/bean/EntityBeanIntercept.java | 34 +++++++++---------- .../com/avaje/ebean/bean/ObjectGraphNode.java | 12 +++---- .../avaje/ebean/bean/ObjectGraphOrigin.java | 12 +++---- .../java/com/avaje/ebean/bean/package.html | 7 ++-- .../com/avaje/ebean/cache/ServerCache.java | 7 ++-- .../avaje/ebean/cache/ServerCacheOptions.java | 2 +- .../ebean/cache/ServerCacheStatistics.java | 2 +- .../java/com/avaje/ebean/cache/package.html | 6 ++-- 11 files changed, 59 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/avaje/ebean/bean/BeanCollection.java b/src/main/java/com/avaje/ebean/bean/BeanCollection.java index 59470843e..aec02a5d3 100644 --- a/src/main/java/com/avaje/ebean/bean/BeanCollection.java +++ b/src/main/java/com/avaje/ebean/bean/BeanCollection.java @@ -1,11 +1,11 @@ package com.avaje.ebean.bean; +import com.avaje.ebean.ExpressionList; + import java.io.Serializable; import java.util.Collection; import java.util.Set; -import com.avaje.ebean.ExpressionList; - /** * Lazy loading capable Maps, Lists and Sets. *

@@ -23,11 +23,17 @@ import com.avaje.ebean.ExpressionList; public interface BeanCollection extends Serializable { enum ModifyListenMode { - /** The common mode */ + /** + * The common mode + */ NONE, - /** Mode used for PrivateOwned */ + /** + * Mode used for PrivateOwned + */ REMOVALS, - /** Mode used for ManyToMany relationships */ + /** + * Mode used for ManyToMany relationships + */ ALL } diff --git a/src/main/java/com/avaje/ebean/bean/CallStack.java b/src/main/java/com/avaje/ebean/bean/CallStack.java index bc93b7206..54f625e83 100644 --- a/src/main/java/com/avaje/ebean/bean/CallStack.java +++ b/src/main/java/com/avaje/ebean/bean/CallStack.java @@ -95,7 +95,7 @@ public final class CallStack implements Serializable { } public String getOriginKey(int queryHash) { - return enc(queryHash)+ "." + zeroHash + "." + pathHash; + return enc(queryHash) + "." + zeroHash + "." + pathHash; } private static final int radix = 1 << 6; @@ -116,10 +116,10 @@ public final class CallStack implements Serializable { } private static final char intToBase64[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; } diff --git a/src/main/java/com/avaje/ebean/bean/EntityBean.java b/src/main/java/com/avaje/ebean/bean/EntityBean.java index f4b0c12d1..4fd4f226a 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBean.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBean.java @@ -15,9 +15,9 @@ import java.io.Serializable; public interface EntityBean extends Serializable { String[] _ebean_getPropertyNames(); - + String _ebean_getPropertyName(int pos); - + /** * Return the enhancement marker value. *

diff --git a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java index 0025abfb1..2ff325daa 100644 --- a/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/com/avaje/ebean/bean/EntityBeanIntercept.java @@ -311,7 +311,7 @@ public final class EntityBeanIntercept implements Serializable { if (idPos > -1) { // For cases where properties are set on constructor // set every non Id property to unloaded (for lazy loading) - for (int i=0; i< loadedProps.length; i++) { + for (int i = 0; i < loadedProps.length; i++) { if (i != idPos) { loadedProps[i] = false; } @@ -486,7 +486,7 @@ public final class EntityBeanIntercept implements Serializable { public void setPropertyLoaded(String propertyName, boolean loaded) { int position = findProperty(propertyName); if (position == -1) { - throw new IllegalArgumentException("Property "+propertyName+" not found"); + throw new IllegalArgumentException("Property " + propertyName + " not found"); } loadedProps[position] = loaded; } @@ -526,7 +526,7 @@ public final class EntityBeanIntercept implements Serializable { */ public boolean isDirtyProperty(int propertyIndex) { return (changedProps != null && changedProps[propertyIndex] - || embeddedDirty != null && embeddedDirty[propertyIndex]); + || embeddedDirty != null && embeddedDirty[propertyIndex]); } /** @@ -572,7 +572,7 @@ public final class EntityBeanIntercept implements Serializable { changedProps = new boolean[owner._ebean_getPropertyNames().length]; } - for (int i=0; i< loadedProps.length; i++) { + for (int i = 0; i < loadedProps.length; i++) { if (loadedProps[i]) { changedProps[i] = true; } @@ -588,7 +588,7 @@ public final class EntityBeanIntercept implements Serializable { return null; } Set props = new LinkedHashSet<>(); - for (int i=0; i getDirtyValues() { - Map dirtyValues = new LinkedHashMap<>(); + public Map getDirtyValues() { + Map dirtyValues = new LinkedHashMap<>(); addDirtyPropertyValues(dirtyValues, null); return dirtyValues; } @@ -674,7 +674,7 @@ public final class EntityBeanIntercept implements Serializable { /** * Recursively add dirty properties. */ - public void addDirtyPropertyValues(Map dirtyValues, String prefix) { + public void addDirtyPropertyValues(Map dirtyValues, String prefix) { int len = getPropertyLength(); for (int i = 0; i < len; i++) { if (changedProps != null && changedProps[i]) { @@ -687,7 +687,7 @@ public final class EntityBeanIntercept implements Serializable { } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse - EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); + EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i); embeddedBean._ebean_getIntercept().addDirtyPropertyValues(dirtyValues, getProperty(i) + "."); } } @@ -708,10 +708,10 @@ public final class EntityBeanIntercept implements Serializable { for (int i = 0; i < len; i++) { if (changedProps != null && changedProps[i]) { // the property has been changed on this bean - hash = hash * 31 + (i+1); + hash = hash * 31 + (i + 1); } else if (embeddedDirty != null && embeddedDirty[i]) { // an embedded property has been changed - recurse - EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i); + EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i); hash = hash * 31 + embeddedBean._ebean_getIntercept().addDirtyPropertyHash(hash); } } @@ -726,7 +726,7 @@ public final class EntityBeanIntercept implements Serializable { int len = getPropertyLength(); for (int i = 0; i < len; i++) { if (isLoadedProperty(i)) { - hash = hash * 31 + (i+1); + hash = hash * 31 + (i + 1); } } return hash; @@ -821,7 +821,7 @@ public final class EntityBeanIntercept implements Serializable { /** * Helper method to check if two objects are equal. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) protected boolean areEqual(Object obj1, Object obj2) { if (obj1 == null) { return (obj2 == null); @@ -1044,7 +1044,7 @@ public final class EntityBeanIntercept implements Serializable { } else { return null; } - return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } /** @@ -1104,7 +1104,7 @@ public final class EntityBeanIntercept implements Serializable { } else { return null; } - return (pcs == null) ? null: new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); + return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue); } /** diff --git a/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java b/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java index ef75d3c3c..54344e3ee 100644 --- a/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java +++ b/src/main/java/com/avaje/ebean/bean/ObjectGraphNode.java @@ -64,15 +64,15 @@ public final class ObjectGraphNode implements Serializable { } public String toString() { - return "origin:" + originQueryPoint + " path[" + path+"]"; + return "origin:" + originQueryPoint + " path[" + path + "]"; } - + public int hashCode() { int hc = 31 * originQueryPoint.hashCode(); hc = 31 * hc + (path == null ? 0 : path.hashCode()); return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -80,10 +80,10 @@ public final class ObjectGraphNode implements Serializable { if (!(obj instanceof ObjectGraphNode)) { return false; } - + ObjectGraphNode e = (ObjectGraphNode) obj; //noinspection StringEquality - return ((e.path == path) || (e.path != null && e.path.equals(path))) - && e.originQueryPoint.equals(originQueryPoint); + return ((e.path == path) || (e.path != null && e.path.equals(path))) + && e.originQueryPoint.equals(originQueryPoint); } } diff --git a/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java b/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java index 1ed7710fb..2b6dd8882 100644 --- a/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java +++ b/src/main/java/com/avaje/ebean/bean/ObjectGraphOrigin.java @@ -58,7 +58,7 @@ public final class ObjectGraphOrigin implements Serializable { } public String toString() { - return "key["+ key + "] type[" + beanType + "] " + callStack.getFirstStackTraceElement()+" "; + return "key[" + key + "] type[" + beanType + "] " + callStack.getFirstStackTraceElement() + " "; } public int hashCode() { @@ -67,7 +67,7 @@ public final class ObjectGraphOrigin implements Serializable { hc = 31 * hc + queryHash; return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -75,10 +75,10 @@ public final class ObjectGraphOrigin implements Serializable { if (!(obj instanceof ObjectGraphOrigin)) { return false; } - + ObjectGraphOrigin e = (ObjectGraphOrigin) obj; - return e.queryHash == queryHash - && e.beanType.equals(beanType) - && e.callStack.equals(callStack); + return e.queryHash == queryHash + && e.beanType.equals(beanType) + && e.callStack.equals(callStack); } } diff --git a/src/main/java/com/avaje/ebean/bean/package.html b/src/main/java/com/avaje/ebean/bean/package.html index 6abde55f5..93554710f 100644 --- a/src/main/java/com/avaje/ebean/bean/package.html +++ b/src/main/java/com/avaje/ebean/bean/package.html @@ -1,12 +1,11 @@ - - Enhanced beans API and Support objects + + Enhanced beans API and Support objects Enhanced beans API and Support objects - - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/cache/ServerCache.java b/src/main/java/com/avaje/ebean/cache/ServerCache.java index e3c64a326..40439ac0f 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCache.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCache.java @@ -10,7 +10,7 @@ package com.avaje.ebean.cache; * which holds beans of a given type. The other is the 'query cache' holding * query results for a given type. *

- * + * * @author rbygrave */ public interface ServerCache { @@ -52,9 +52,8 @@ public interface ServerCache { /** * Return statistics for the cache. - * - * @param reset - * if true the statistics are reset. + * + * @param reset if true the statistics are reset. */ ServerCacheStatistics getStatistics(boolean reset); } diff --git a/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java b/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java index 35c3443f2..1da6527c1 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCacheOptions.java @@ -1,7 +1,7 @@ package com.avaje.ebean.cache; -import com.avaje.ebean.annotation.CacheQueryTuning; import com.avaje.ebean.annotation.CacheBeanTuning; +import com.avaje.ebean.annotation.CacheQueryTuning; /** * Options for controlling a cache. diff --git a/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java b/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java index a2f290916..56a2a412a 100644 --- a/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java +++ b/src/main/java/com/avaje/ebean/cache/ServerCacheStatistics.java @@ -71,7 +71,7 @@ public class ServerCacheStatistics { if (totalCount == 0) { return 0; } else { - return (int)(hitCount * 100 / totalCount); + return (int) (hitCount * 100 / totalCount); } } diff --git a/src/main/java/com/avaje/ebean/cache/package.html b/src/main/java/com/avaje/ebean/cache/package.html index e69e39f09..78e2479a2 100644 --- a/src/main/java/com/avaje/ebean/cache/package.html +++ b/src/main/java/com/avaje/ebean/cache/package.html @@ -1,10 +1,10 @@ - - Server Cache Service + + Server Cache Service Server Cache Service - \ No newline at end of file + From 57813179b250ba7f558903d02bb38a96c49e7817 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:05:04 +1300 Subject: [PATCH 77/87] no effective change - format --- .../avaje/ebean/config/AutoTuneConfig.java | 2 +- .../avaje/ebean/config/ClassLoadConfig.java | 2 +- .../com/avaje/ebean/config/CompoundType.java | 8 +--- .../ebean/config/CompoundTypeProperty.java | 20 ++++------ .../ebean/config/CurrentUserProvider.java | 4 +- .../avaje/ebean/config/DbMigrationConfig.java | 13 +++---- .../com/avaje/ebean/config/EncryptDeploy.java | 17 +++----- .../ebean/config/EncryptDeployManager.java | 3 -- .../com/avaje/ebean/config/EncryptKey.java | 3 -- .../avaje/ebean/config/EncryptKeyManager.java | 2 - .../com/avaje/ebean/config/Encryptor.java | 4 -- .../config/MatchingNamingConvention.java | 8 ++-- .../avaje/ebean/config/NamingConvention.java | 39 +++++++------------ .../com/avaje/ebean/config/PersistBatch.java | 1 - .../ebean/config/PropertyExpression.java | 7 ++-- .../avaje/ebean/config/PropertyMapLoader.java | 22 +++++------ .../ebean/config/ScalarTypeConverter.java | 20 ++++------ .../com/avaje/ebean/config/ServerConfig.java | 3 +- .../com/avaje/ebean/config/TableName.java | 37 ++++++++++-------- .../config/UnderscoreNamingConvention.java | 2 +- .../config/dbplatform/AbstractDbEncrypt.java | 30 +++++++------- .../ebean/config/dbplatform/DB2Platform.java | 7 ++-- .../dbplatform/DB2SequenceIdGenerator.java | 4 +- .../config/dbplatform/DbDefaultValue.java | 2 +- .../ebean/config/dbplatform/DbEncrypt.java | 4 +- .../config/dbplatform/DbPlatformType.java | 18 ++++----- .../ebean/config/dbplatform/H2DbEncrypt.java | 8 ++-- .../ebean/config/dbplatform/H2Platform.java | 2 - .../dbplatform/H2SequenceIdGenerator.java | 4 +- .../dbplatform/LimitOffsetSqlLimiter.java | 2 +- .../config/dbplatform/MySqlDbEncrypt.java | 2 +- .../config/dbplatform/OracleDbEncrypt.java | 34 ++++++++-------- .../dbplatform/OracleSequenceIdGenerator.java | 10 ++--- .../config/dbplatform/PostgresDbEncrypt.java | 2 - .../config/dbplatform/PostgresPlatform.java | 14 +++---- .../PostgresSequenceIdGenerator.java | 10 ++--- .../dbplatform/RowNumberSqlLimiter.java | 2 +- .../config/dbplatform/RownumSqlLimiter.java | 2 +- .../dbplatform/SequenceIdGenerator.java | 19 +++++---- .../dbplatform/SimpleSequenceIdGenerator.java | 15 ++++--- .../config/dbplatform/SqlAnywhereLimiter.java | 2 +- .../ebean/config/dbplatform/package.html | 6 +-- .../java/com/avaje/ebean/config/package.html | 6 +-- 43 files changed, 180 insertions(+), 242 deletions(-) diff --git a/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java b/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java index 85e5306b1..71373c575 100644 --- a/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java +++ b/src/main/java/com/avaje/ebean/config/AutoTuneConfig.java @@ -24,7 +24,7 @@ public class AutoTuneConfig { private int profilingUpdateFrequency; private int garbageCollectionWait = 100; - + private boolean skipGarbageCollectionOnShutdown; private boolean skipProfileReportingOnShutdown; diff --git a/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java b/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java index 1adf6d32c..a76547c4f 100644 --- a/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java +++ b/src/main/java/com/avaje/ebean/config/ClassLoadConfig.java @@ -137,7 +137,7 @@ public class ClassLoadConfig { ClassLoader contextLoader() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return (loader != null) ? loader: callerLoader; + return (loader != null) ? loader : callerLoader; } Enumeration getResources(String name) throws IOException { diff --git a/src/main/java/com/avaje/ebean/config/CompoundType.java b/src/main/java/com/avaje/ebean/config/CompoundType.java index 59e704a40..c0ffcbda6 100644 --- a/src/main/java/com/avaje/ebean/config/CompoundType.java +++ b/src/main/java/com/avaje/ebean/config/CompoundType.java @@ -3,7 +3,6 @@ package com.avaje.ebean.config; /** * API from creating and getting property values from an Immutable Compound * Value Object. - * *

* A Compound Value object should contain multiple properties that are stored * separately. If you only have a single scalar value you should instead look to @@ -24,12 +23,9 @@ package com.avaje.ebean.config; * implementations of this interface (along with detecting the entity classes * etc). *

- * + * + * @param The type of the Value Object * @author rbygrave - * - * @param - * The type of the Value Object - * * @see ScalarTypeConverter */ public interface CompoundType { diff --git a/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java b/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java index 30075b328..b7a22fb7c 100644 --- a/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java +++ b/src/main/java/com/avaje/ebean/config/CompoundTypeProperty.java @@ -5,16 +5,11 @@ package com.avaje.ebean.config; *

* For each property in a {@link CompoundType} you need an implementation of * this CompoundTypeProperty interface. - * *

- * + * + * @param The type of the Compound value object + * @param

The type of the property * @author rbygrave - * - * @param - * The type of the Compound value object - * @param

- * The type of the property - * * @see CompoundType * @see ScalarTypeConverter */ @@ -27,9 +22,8 @@ public interface CompoundTypeProperty { /** * Return the property value from the containing compound value object. - * - * @param valueObject - * the compound value object + * + * @param valueObject the compound value object * @return the property value. */ P getValue(V valueObject); @@ -43,9 +37,9 @@ public interface CompoundTypeProperty { * persistence type is java.sql.Timestamp. In this case return * java.sql.Types.TIMESTAMP (rather than 0). *

- * + * * @return Return the java.sql.Type that you want to use to persist this - * property or 0 and Ebean will use the logical type. + * property or 0 and Ebean will use the logical type. */ int getDbType(); } diff --git a/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java b/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java index 3980cd163..7de4a361f 100644 --- a/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java +++ b/src/main/java/com/avaje/ebean/config/CurrentUserProvider.java @@ -8,8 +8,8 @@ public interface CurrentUserProvider { /** * Return the current user id. *

- * The type returned should match the type of the properties annotated - * with @WhoCreated and @WhoModified. These are typically String, Long or UUID. + * The type returned should match the type of the properties annotated + * with @WhoCreated and @WhoModified. These are typically String, Long or UUID. *

*/ Object currentUser(); diff --git a/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java b/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java index 5e4155289..d3b7dccc6 100644 --- a/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java +++ b/src/main/java/com/avaje/ebean/config/DbMigrationConfig.java @@ -93,7 +93,7 @@ public class DbMigrationConfig { /** * Map of key/value placeholders to replace in DDL scripts. */ - protected Map runPlaceholderMap; + protected Map runPlaceholderMap; /** * DB user used to run the DB migration. @@ -107,7 +107,7 @@ public class DbMigrationConfig { /** * Return the DB platform to generate migration DDL for. - * + *

* We typically need to explicitly specify this as migration can often be generated * when running against H2. */ @@ -375,12 +375,12 @@ public class DbMigrationConfig { metaTable = properties.get("migration.metaTable", metaTable); runPlaceholders = properties.get("migration.placeholders", runPlaceholders); - String adminUser = properties.get("datasource."+serverName+".username", dbUsername); - adminUser = properties.get("datasource."+serverName+".adminusername", adminUser); + String adminUser = properties.get("datasource." + serverName + ".username", dbUsername); + adminUser = properties.get("datasource." + serverName + ".adminusername", adminUser); dbUsername = properties.get("migration.dbusername", adminUser); - String adminPwd = properties.get("datasource."+serverName+".password", dbPassword); - adminPwd = properties.get("datasource."+serverName+".adminpassword", adminPwd); + String adminPwd = properties.get("datasource." + serverName + ".password", dbPassword); + adminPwd = properties.get("datasource." + serverName + ".adminpassword", adminPwd); dbPassword = properties.get("migration.dbpassword", adminPwd); } @@ -403,7 +403,6 @@ public class DbMigrationConfig { /** * Called by EbeanServer on start. - * *

* If enabled this generates the migration xml and DDL scripts. *

diff --git a/src/main/java/com/avaje/ebean/config/EncryptDeploy.java b/src/main/java/com/avaje/ebean/config/EncryptDeploy.java index f19dc4d14..a6a776289 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptDeploy.java +++ b/src/main/java/com/avaje/ebean/config/EncryptDeploy.java @@ -6,9 +6,7 @@ package com.avaje.ebean.config; * You can define the encryption options for a Bean property via the Encrypt * annotation and programmatically via {@link EncryptDeployManager}. *

- * - * @author rbygrave - * + * * @see EncryptDeployManager#getEncryptDeploy(TableName, String) */ public class EncryptDeploy { @@ -67,14 +65,11 @@ public class EncryptDeploy { /** * Construct with all options for Encryption including the dbLength. - * - * @param mode - * the Encryption mode - * @param dbEncrypt - * set to false if you want to use Java client side encryption rather - * than DB encryption. - * @param dbLength - * set the DB length to use. + * + * @param mode the Encryption mode + * @param dbEncrypt set to false if you want to use Java client side encryption rather + * than DB encryption. + * @param dbLength set the DB length to use. */ public EncryptDeploy(Mode mode, boolean dbEncrypt, int dbLength) { this.mode = mode; diff --git a/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java b/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java index dfe800928..38d702f98 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java +++ b/src/main/java/com/avaje/ebean/config/EncryptDeployManager.java @@ -2,9 +2,6 @@ package com.avaje.ebean.config; /** * Programmatically define which database columns are encrypted. - * - * @author rbygrave - * */ public interface EncryptDeployManager { diff --git a/src/main/java/com/avaje/ebean/config/EncryptKey.java b/src/main/java/com/avaje/ebean/config/EncryptKey.java index 3318b8387..5fd142152 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptKey.java +++ b/src/main/java/com/avaje/ebean/config/EncryptKey.java @@ -5,9 +5,6 @@ package com.avaje.ebean.config; *

* For simple cases this often represent a simple String key but depending on * the encryption method this could contain other details. - *

- * - * @author rbygrave */ public interface EncryptKey { diff --git a/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java b/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java index 8c785db59..43dd90ab8 100644 --- a/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java +++ b/src/main/java/com/avaje/ebean/config/EncryptKeyManager.java @@ -2,8 +2,6 @@ package com.avaje.ebean.config; /** * Determine keys used for encryption and decryption. - * - * @author rbygrave */ public interface EncryptKeyManager { diff --git a/src/main/java/com/avaje/ebean/config/Encryptor.java b/src/main/java/com/avaje/ebean/config/Encryptor.java index d2aa540c8..e696e544c 100644 --- a/src/main/java/com/avaje/ebean/config/Encryptor.java +++ b/src/main/java/com/avaje/ebean/config/Encryptor.java @@ -4,10 +4,6 @@ package com.avaje.ebean.config; * Used for Java side encryption of properties when DB encryption is not used. *

* By default this is used on non-varchar types such as Blobs. - *

- * - * @author rbygrave - * */ public interface Encryptor { diff --git a/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java b/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java index a505f99ce..bf871e4b4 100644 --- a/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/MatchingNamingConvention.java @@ -3,13 +3,12 @@ package com.avaje.ebean.config; /** * The JPA naming convention where column names match property names and table * names match entity names. - * *

* The JPA specification states that the in the case of no annotations the name * of the class will be take as the table name and the name of a property will * be taken as the name of the column. *

- * + * * @author emcgreal */ public class MatchingNamingConvention extends AbstractNamingConvention { @@ -23,9 +22,8 @@ public class MatchingNamingConvention extends AbstractNamingConvention { /** * Instantiates with a specific format for DB sequences. - * - * @param sequenceFormat - * the sequence format + * + * @param sequenceFormat the sequence format */ public MatchingNamingConvention(String sequenceFormat) { super(sequenceFormat); diff --git a/src/main/java/com/avaje/ebean/config/NamingConvention.java b/src/main/java/com/avaje/ebean/config/NamingConvention.java index c20854cb3..d86733112 100644 --- a/src/main/java/com/avaje/ebean/config/NamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/NamingConvention.java @@ -26,9 +26,8 @@ public interface NamingConvention { * The purpose of this is to enable NamingConvention to be able to support * database platform specific configuration. *

- * - * @param databasePlatform - * the database platform + * + * @param databasePlatform the database platform */ void setDatabasePlatform(DatabasePlatform databasePlatform); @@ -39,29 +38,24 @@ public interface NamingConvention { * annotations etc. This means you can choose to override the settings defined * by @Table if you wish. *

- * - * @param beanClass - * the bean class - * + * + * @param beanClass the bean class * @return the table name for the entity class */ TableName getTableName(Class beanClass); /** * Returns the ManyToMany join table name (aka the intersection table). - * - * @param lhsTable - * the left hand side bean table - * @param rhsTable - * the right hand side bean table - * + * + * @param lhsTable the left hand side bean table + * @param rhsTable the right hand side bean table * @return the many to many join table name */ TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable); /** * Return the column name given the property name. - * + * * @return the column name for a given property */ String getColumnFromProperty(Class beanClass, String propertyName); @@ -71,12 +65,9 @@ public interface NamingConvention { *

* This is used to help mapping of raw SQL queries onto bean properties. *

- * - * @param beanClass - * the bean class - * @param dbColumnName - * the db column name - * + * + * @param beanClass the bean class + * @param dbColumnName the db column name * @return the property name from the column name */ String getPropertyFromColumn(Class beanClass, String dbColumnName); @@ -86,10 +77,8 @@ public interface NamingConvention { *

* Typically you might append "_seq" to the table name as an example. *

- * - * @param tableName - * the table name - * + * + * @param tableName the table name * @return the sequence name */ String getSequenceName(String tableName, String pkColumn); @@ -116,4 +105,4 @@ public interface NamingConvention { */ void loadFromProperties(PropertiesWrapper properties); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/PersistBatch.java b/src/main/java/com/avaje/ebean/config/PersistBatch.java index 305372d95..b49e1d9b4 100644 --- a/src/main/java/com/avaje/ebean/config/PersistBatch.java +++ b/src/main/java/com/avaje/ebean/config/PersistBatch.java @@ -8,7 +8,6 @@ package com.avaje.ebean.config; * * @see com.avaje.ebean.config.ServerConfig#setPersistBatch(PersistBatch) * @see com.avaje.ebean.config.ServerConfig#setPersistBatchOnCascade(PersistBatch) - * * @see com.avaje.ebean.Transaction#setBatch(PersistBatch) * @see com.avaje.ebean.Transaction#setBatchOnCascade(PersistBatch) */ diff --git a/src/main/java/com/avaje/ebean/config/PropertyExpression.java b/src/main/java/com/avaje/ebean/config/PropertyExpression.java index 67c5bc1df..64c9f88c9 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyExpression.java +++ b/src/main/java/com/avaje/ebean/config/PropertyExpression.java @@ -149,9 +149,8 @@ final class PropertyExpression { /** * Returns null if JNDI is not setup or if the property is not found. - * - * @param key - * the key of the JNDI Environment property including a JNDI: prefix. + * + * @param key the key of the JNDI Environment property including a JNDI: prefix. */ private static String getJndiProperty(String key) { @@ -176,4 +175,4 @@ final class PropertyExpression { return ctx.lookup(JAVA_COMP_ENV + key); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java b/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java index 2532786c2..b237b38c4 100644 --- a/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java +++ b/src/main/java/com/avaje/ebean/config/PropertyMapLoader.java @@ -3,7 +3,11 @@ package com.avaje.ebean.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.Map; import java.util.Properties; @@ -49,11 +53,9 @@ final class PropertyMapLoader { /** * Load the file returning the property map. - * - * @param p - * an existing property map to load into. - * @param fileName - * the name of the properties file to load. + * + * @param p an existing property map to load into. + * @param fileName the name of the properties file to load. */ public static PropertyMap load(PropertyMap p, String fileName) { @@ -67,11 +69,9 @@ final class PropertyMapLoader { /** * Load the InputStream returning the property map. - * - * @param p - * an existing property map to load into. - * @param in - * the InputStream of the properties file to load. + * + * @param p an existing property map to load into. + * @param in the InputStream of the properties file to load. */ public static PropertyMap load(PropertyMap p, InputStream in) { diff --git a/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java b/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java index 1e61f5a71..a0fbb1d47 100644 --- a/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java +++ b/src/main/java/com/avaje/ebean/config/ScalarTypeConverter.java @@ -26,14 +26,10 @@ package com.avaje.ebean.config; * If you want to support a Compound Type rather than a Scalar Type refer to * {@link CompoundType}. *

- * + * + * @param The value object type. + * @param The scalar object type that is used to persist the value object. * @author rbygrave - * - * @param - * The value object type. - * @param - * The scalar object type that is used to persist the value object. - * * @see CompoundType * @see CompoundTypeProperty */ @@ -52,9 +48,8 @@ public interface ScalarTypeConverter { * This typically occurs when Ebean reads the value from a resultSet or other * data source. *

- * - * @param scalarType - * the value from the data source + * + * @param scalarType the value from the data source */ B wrapValue(S scalarType); @@ -65,9 +60,8 @@ public interface ScalarTypeConverter { * This typically occurs when Ebean is persisting the value object to the data * store. *

- * - * @param beanType - * the value object + * + * @param beanType the value object */ S unwrapValue(B beanType); diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index 7bc138f82..374b4083e 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -46,7 +46,6 @@ import java.util.ServiceLoader; * includes searching the class path and automatically registering any entity * classes and listeners etc. *

- * *
{@code
  *
  * ServerConfig c = new ServerConfig();
@@ -2103,6 +2102,7 @@ public class ServerConfig {
   public void add(BeanPostConstructListener listener) {
     postConstructListeners.add(listener);
   }
+
   /**
    * Return the list of BeanFindController instances.
    */
@@ -2144,6 +2144,7 @@ public class ServerConfig {
   public void setPostConstructListeners(List listeners) {
     this.postConstructListeners = listeners;
   }
+
   /**
    * Return the BeanPersistController instances.
    */
diff --git a/src/main/java/com/avaje/ebean/config/TableName.java b/src/main/java/com/avaje/ebean/config/TableName.java
index 2dbe5d023..8d3007011 100644
--- a/src/main/java/com/avaje/ebean/config/TableName.java
+++ b/src/main/java/com/avaje/ebean/config/TableName.java
@@ -2,18 +2,24 @@ package com.avaje.ebean.config;
 
 /**
  * TableName holds catalog, schema and table name.
- * 
+ *
  * @author emcgreal
  */
 public final class TableName {
 
-  /** The catalog. */
+  /**
+   * The catalog.
+   */
   private String catalog;
 
-  /** The schema. */
+  /**
+   * The schema.
+   */
   private String schema;
 
-  /** The name. */
+  /**
+   * The name.
+   */
   private String name;
 
   /**
@@ -36,10 +42,9 @@ public final class TableName {
    * The qualifiedTableName can take the form of catalog.schema.tableName and is
    * split on the '.' period character. The catalog and schema are optional.
    * 

- * - * @param qualifiedTableName - * the fully qualified table name using '.' between schema and table - * name etc (with catalog and schema optional). + * + * @param qualifiedTableName the fully qualified table name using '.' between schema and table + * name etc (with catalog and schema optional). */ public TableName(String qualifiedTableName) { String[] split = qualifiedTableName.split("\\."); @@ -63,14 +68,14 @@ public final class TableName { public static String parse(String qualifiedTableName) { return new TableName(qualifiedTableName).getName(); } - + public String toString() { return getQualifiedName(); } /** * Gets the catalog. - * + * * @return the catalog */ public String getCatalog() { @@ -79,7 +84,7 @@ public final class TableName { /** * Gets the schema. - * + * * @return the schema */ public String getSchema() { @@ -88,7 +93,7 @@ public final class TableName { /** * Gets the name. - * + * * @return the name */ public String getName() { @@ -100,7 +105,7 @@ public final class TableName { *

* Catalog and schema are optional. *

- * + * * @return the qualified name */ public String getQualifiedName() { @@ -139,13 +144,13 @@ public final class TableName { buffer.append(schema).append("."); } } - + /** * Checks if is table name is valid i.e. it has at least a name. - * + * * @return true, if is valid */ public boolean isValid() { return name != null && !name.isEmpty(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java b/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java index 1abe2bc28..b44c6f140 100644 --- a/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java +++ b/src/main/java/com/avaje/ebean/config/UnderscoreNamingConvention.java @@ -106,7 +106,7 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention { protected String toUnderscoreFromCamel(String camelCase) { int lastUpper = -1; - StringBuilder sb = new StringBuilder(camelCase.length()+4); + StringBuilder sb = new StringBuilder(camelCase.length() + 4); for (int i = 0; i < camelCase.length(); i++) { char c = camelCase.charAt(i); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java index b65d1cabd..2c23a3b42 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java @@ -10,7 +10,7 @@ import java.sql.Types; * treated as though that data type can not be encrypted in the DB and will * instead use java client encryption. *

- * + * * @author rbygrave */ public abstract class AbstractDbEncrypt implements DbEncrypt { @@ -41,23 +41,23 @@ public abstract class AbstractDbEncrypt implements DbEncrypt { */ public DbEncryptFunction getDbEncryptFunction(int jdbcType) { switch (jdbcType) { - case Types.VARCHAR: - return varcharEncryptFunction; - case Types.CLOB: - return varcharEncryptFunction; - case Types.CHAR: - return varcharEncryptFunction; - case Types.LONGVARCHAR: - return varcharEncryptFunction; + case Types.VARCHAR: + return varcharEncryptFunction; + case Types.CLOB: + return varcharEncryptFunction; + case Types.CHAR: + return varcharEncryptFunction; + case Types.LONGVARCHAR: + return varcharEncryptFunction; - case Types.DATE: - return dateEncryptFunction; + case Types.DATE: + return dateEncryptFunction; - case Types.TIMESTAMP: - return timestampEncryptFunction; + case Types.TIMESTAMP: + return timestampEncryptFunction; - default: - return null; + default: + return null; } } diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java index 9c0261481..ed30fa2f4 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java @@ -1,12 +1,11 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Types; - -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.dbmigration.ddlgeneration.platform.DB2Ddl; +import javax.sql.DataSource; +import java.sql.Types; + /** * DB2 specific platform. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java index d19e0b7c6..fdc24a0f6 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DB2SequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * DB2 specific sequence Id Generator. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java index 2a5aa82d2..049e699bc 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbDefaultValue.java @@ -23,7 +23,7 @@ public class DbDefaultValue { */ public static final String NOW = "now"; - protected Map map = new LinkedHashMap<>(); + protected Map map = new LinkedHashMap<>(); /** * Set the DB now function. diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java index ab7671889..129bc2c0b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java @@ -8,7 +8,7 @@ package com.avaje.ebean.config.dbplatform; * a special ScalarType but this has the limitation that you can't include that * property in query where clauses. *

- * + * * @author rbygrave */ public interface DbEncrypt { @@ -38,4 +38,4 @@ public interface DbEncrypt { * Return true if the DB encrypt function binds the data before the key. */ boolean isBindEncryptDataFirst(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java index c2599d7aa..aec57b745 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbPlatformType.java @@ -65,11 +65,9 @@ public class DbPlatformType implements ExtraDbTypes { /** * Use with canHaveLength=false for types that should never have a length. - * - * @param name - * the type name - * @param canHaveLength - * set this to false for type that should never have a length + * + * @param name the type name + * @param canHaveLength set this to false for type that should never have a length */ public DbPlatformType(String name, boolean canHaveLength) { this.name = name; @@ -106,12 +104,10 @@ public class DbPlatformType implements ExtraDbTypes { * The deployLength and deployScale are for the property we are rendering the * DB type for. *

- * - * @param deployLength - * the length or precision defined by deployment on a specific - * property. - * @param deployScale - * the scale defined by deployment on a specific property. + * + * @param deployLength the length or precision defined by deployment on a specific + * property. + * @param deployScale the scale defined by deployment on a specific property. */ public String renderType(int deployLength, int deployScale) { return renderType(deployLength, deployScale, true); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java index 589a7f8cc..8641b159e 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; /** * H2 encryption support via encrypt decrypt function. - * + * * @author rbygrave */ public class H2DbEncrypt extends AbstractDbEncrypt { @@ -23,8 +23,7 @@ public class H2DbEncrypt extends AbstractDbEncrypt { public String getDecryptSql(String columnWithTableAlias) { // Hmmm, this looks ugly - checking with H2 Database folks. - return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " - + columnWithTableAlias + ")))"; + return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + ")))"; } public String getEncryptBindSql() { @@ -36,8 +35,7 @@ public class H2DbEncrypt extends AbstractDbEncrypt { private static class H2DateFunction implements DbEncryptFunction { public String getDecryptSql(String columnWithTableAlias) { - return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " - + columnWithTableAlias + "))),'yyyyMMdd')"; + return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + "))),'yyyyMMdd')"; } public String getEncryptBindSql() { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java index a1e0949fe..05d841088 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java @@ -1,11 +1,9 @@ package com.avaje.ebean.config.dbplatform; import com.avaje.ebean.BackgroundExecutor; -import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.dbmigration.ddlgeneration.platform.H2Ddl; import javax.sql.DataSource; -import java.util.Properties; /** * H2 specific platform. diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java index 7547746f3..4b234bb8b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2SequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * H2 specific sequence Id Generator. */ diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java index 1daa75286..de60acc86 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/LimitOffsetSqlLimiter.java @@ -18,7 +18,7 @@ public class LimitOffsetSqlLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(50 + dbSql.length()); sb.append("select "); if (request.isDistinct()) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java index c8bf68ca2..474d06b0a 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; /** * MySql aes_encrypt aes_decrypt based encryption support. - * + * * @author rbygrave */ public class MySqlDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java index 90ab9eab2..01208bf15 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/OracleDbEncrypt.java @@ -2,46 +2,44 @@ package com.avaje.ebean.config.dbplatform; /** * Oracle encryption support. - * + * *

* You will typically need to create your own encryption and decryption * functions similar to the example ones below. *

- * + * *
- * 
- *  // Remember your DB user needs execute privilege on DBMS_CRYPTO 
+ *
+ *  // Remember your DB user needs execute privilege on DBMS_CRYPTO
  *  // as well as your encryption and decryption functions
- *  
- *  
+ *
+ *
  *  // This is an Example Encryption function only - please create your own.
- * 
+ *
  * CREATE OR REPLACE FUNCTION eb_encrypt(data IN VARCHAR, key in VARCHAR) RETURN RAW IS
- * 
+ *
  *     encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC  + DBMS_CRYPTO.PAD_PKCS5;
- * 
+ *
  *     BEGIN
- *          RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'), 
+ *          RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'),
  *            encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8') );
  *     END;
  *     /
- *     
- *     
- *     
+ *
+ *
+ *
  *  // This is an Example Decryption function only - please create your own.
- *     
+ *
  * CREATE OR REPLACE FUNCTION eb_decrypt(data IN RAW, key IN VARCHAR) RETURN VARCHAR IS
- * 
+ *
  *     encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC  + DBMS_CRYPTO.PAD_PKCS5;
- * 
+ *
  *     BEGIN
  *          RETURN UTL_RAW.CAST_TO_VARCHAR2(DBMS_CRYPTO.DECRYPT
  *            (data, encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8')));
  *     END;
  *     /
  * 
- * - * @author rbygrave */ public class OracleDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java index 52436bb30..67992900b 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/OracleSequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * Oracle specific sequence Id Generator. */ @@ -14,11 +14,9 @@ public class OracleSequenceIdGenerator extends SequenceIdGenerator { /** * Construct given a dataSource and sql to return the next sequence value. */ - public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, - int batchSize) { + public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) { super(be, ds, seqName, batchSize); - this.baseSql = "select " + seqName - + ".nextval, a from (select level as a FROM dual CONNECT BY level <= "; + this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= "; } public String getSql(int batchSize) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java index e74111934..ad53ef00d 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java @@ -2,8 +2,6 @@ package com.avaje.ebean.config.dbplatform; /** * Postgres pgp_sym_encrypt pgp_sym_decrypt based encryption support. - * - * @author rbygrave */ public class PostgresDbEncrypt extends AbstractDbEncrypt { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java index 97a6323ec..4c66e09db 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java @@ -64,16 +64,16 @@ public class PostgresPlatform extends DatabasePlatform { } protected void addGeoTypes(int srid) { - dbTypeMap.put(DbType.POINT, geoType("point",srid)); - dbTypeMap.put(DbType.POLYGON, geoType("polygon",srid)); - dbTypeMap.put(DbType.LINESTRING, geoType("linestring",srid)); - dbTypeMap.put(DbType.MULTIPOINT, geoType("multipoint",srid)); - dbTypeMap.put(DbType.MULTILINESTRING, geoType("multilinestring",srid)); - dbTypeMap.put(DbType.MULTIPOLYGON, geoType("multipolygon",srid)); + dbTypeMap.put(DbType.POINT, geoType("point", srid)); + dbTypeMap.put(DbType.POLYGON, geoType("polygon", srid)); + dbTypeMap.put(DbType.LINESTRING, geoType("linestring", srid)); + dbTypeMap.put(DbType.MULTIPOINT, geoType("multipoint", srid)); + dbTypeMap.put(DbType.MULTILINESTRING, geoType("multilinestring", srid)); + dbTypeMap.put(DbType.MULTIPOLYGON, geoType("multipolygon", srid)); } private DbPlatformType geoType(String type, int srid) { - return new DbPlatformType("geometry("+type+","+srid+")"); + return new DbPlatformType("geometry(" + type + "," + srid + ")"); } /** diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java index eb7af2632..20942eb0f 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresSequenceIdGenerator.java @@ -1,9 +1,9 @@ package com.avaje.ebean.config.dbplatform; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; +import javax.sql.DataSource; + /** * Postgres specific sequence Id Generator. */ @@ -14,11 +14,9 @@ public class PostgresSequenceIdGenerator extends SequenceIdGenerator { /** * Construct given a dataSource and sql to return the next sequence value. */ - public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, - int batchSize) { + public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) { super(be, ds, seqName, batchSize); - this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (" - + "select generate_series from generate_series(1,"; + this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (select generate_series from generate_series(1,"; } public String getSql(int batchSize) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java index bd46b3831..43bfbcd56 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/RowNumberSqlLimiter.java @@ -31,7 +31,7 @@ public class RowNumberSqlLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java index 71fb5c99d..e24c07a19 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/RownumSqlLimiter.java @@ -36,7 +36,7 @@ public class RownumSqlLimiter implements SqlLimiter { // where rnum >= :MIN_ROW_TO_FETCH; String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java index 6724d35fd..0f5053bca 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SequenceIdGenerator.java @@ -1,19 +1,18 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.BackgroundExecutor; import com.avaje.ebean.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + /** * Database sequence based IdGenerator. */ @@ -220,7 +219,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator { rset.close(); } } catch (SQLException e) { - logger.error( "Error closing ResultSet", e); + logger.error("Error closing ResultSet", e); } try { if (pstmt != null) { diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java index ead28d3fc..1ddbbee15 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SimpleSequenceIdGenerator.java @@ -1,17 +1,16 @@ package com.avaje.ebean.config.dbplatform; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - import com.avaje.ebean.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.PersistenceException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + /** * A very simple Database sequence based IdGenerator. *

diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java b/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java index d5e0994ab..069fa05ec 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java +++ b/src/main/java/com/avaje/ebean/config/dbplatform/SqlAnywhereLimiter.java @@ -8,7 +8,7 @@ public class SqlAnywhereLimiter implements SqlLimiter { public SqlLimitResponse limit(SqlLimitRequest request) { String dbSql = request.getDbSql(); - + StringBuilder sb = new StringBuilder(60 + dbSql.length()); int firstRow = request.getFirstRow(); diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/package.html b/src/main/java/com/avaje/ebean/config/dbplatform/package.html index cf8b5e070..5e3df5b2d 100644 --- a/src/main/java/com/avaje/ebean/config/dbplatform/package.html +++ b/src/main/java/com/avaje/ebean/config/dbplatform/package.html @@ -1,10 +1,10 @@ - - Database platform specific support + + Database platform specific support Database platform specific support - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/config/package.html b/src/main/java/com/avaje/ebean/config/package.html index a3be4d069..f89a304ff 100644 --- a/src/main/java/com/avaje/ebean/config/package.html +++ b/src/main/java/com/avaje/ebean/config/package.html @@ -1,10 +1,10 @@ - - Configuration settings for EbeanServer construction + + Configuration settings for EbeanServer construction Configuration settings for EbeanServer construction - \ No newline at end of file + From d3bf2191298f762252cc03bc293352734829022c Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:06:58 +1300 Subject: [PATCH 78/87] no effective change - format --- .../avaje/ebean/dbmigration/DbMigration.java | 2 +- .../avaje/ebean/dbmigration/DdlGenerator.java | 2 +- .../dbmigration/ddlgeneration/DdlWrite.java | 6 +- .../ddlgeneration/platform/BaseTableDdl.java | 46 +- .../platform/DbTriggerBasedHistoryDdl.java | 12 +- .../ddlgeneration/platform/H2HistoryDdl.java | 4 +- .../platform/HistoryTableUpdate.java | 2 +- .../platform/MsSqlServerDdl.java | 2 +- .../ddlgeneration/platform/MySqlDdl.java | 2 +- .../platform/MySqlHistoryDdl.java | 16 +- .../ddlgeneration/platform/Oracle10Ddl.java | 2 +- .../ddlgeneration/platform/PlatformDdl.java | 10 +- .../platform/PostgresHistoryDdl.java | 38 +- .../platform/util/IndexColumns.java | 2 +- .../dbmigration/migration/AddColumn.java | 157 ++- .../migration/AddHistoryTable.java | 51 +- .../migration/AddTableComment.java | 95 +- .../dbmigration/migration/AlterColumn.java | 975 ++++++++---------- .../migration/AlterHistoryTable.java | 51 +- .../dbmigration/migration/Application.java | 95 +- .../dbmigration/migration/Applications.java | 67 +- .../ebean/dbmigration/migration/Apply.java | 53 +- .../dbmigration/migration/ChangeSet.java | 389 ++++--- .../dbmigration/migration/ChangeSetType.java | 44 +- .../ebean/dbmigration/migration/Column.java | 713 ++++++------- .../dbmigration/migration/Configuration.java | 53 +- .../dbmigration/migration/CreateIndex.java | 139 ++- .../dbmigration/migration/CreateTable.java | 671 ++++++------ .../migration/DefaultTablespace.java | 139 ++- .../dbmigration/migration/DropColumn.java | 139 ++- .../migration/DropHistoryTable.java | 51 +- .../dbmigration/migration/DropIndex.java | 95 +- .../dbmigration/migration/DropTable.java | 51 +- .../dbmigration/migration/ForeignKey.java | 227 ++-- .../dbmigration/migration/IdentityType.java | 52 +- .../dbmigration/migration/Migration.java | 69 +- .../dbmigration/migration/ObjectFactory.java | 332 +++--- .../dbmigration/migration/RenameColumn.java | 183 ++-- .../dbmigration/migration/RenameTable.java | 95 +- .../ebean/dbmigration/migration/Rollback.java | 53 +- .../ebean/dbmigration/migration/Sql.java | 99 +- .../migration/UniqueConstraint.java | 95 +- .../migrationreader/MigrationXmlReader.java | 5 +- .../ebean/dbmigration/model/CurrentModel.java | 2 +- .../model/MCompoundUniqueConstraint.java | 4 +- .../dbmigration/model/MConfiguration.java | 4 +- .../avaje/ebean/dbmigration/model/MTable.java | 2 +- .../dbmigration/model/MigrationModel.java | 5 +- .../dbmigration/model/ModelContainer.java | 2 +- .../ebean/dbmigration/model/PendingDrops.java | 10 +- .../dbmigration/model/PlatformDdlWriter.java | 2 +- .../model/build/ModelBuildContext.java | 6 +- .../build/ModelBuildIntersectionTable.java | 72 +- .../build/ModelBuildPropertyVisitor.java | 4 +- .../model/visitor/BeanVisitor.java | 6 +- 55 files changed, 2504 insertions(+), 2999 deletions(-) diff --git a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java index 20d112b57..e4fda0461 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/DbMigration.java @@ -4,10 +4,10 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.config.DbConstraintNaming; import com.avaje.ebean.config.DbMigrationConfig; +import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.DB2Platform; import com.avaje.ebean.config.dbplatform.DatabasePlatform; -import com.avaje.ebean.config.Platform; import com.avaje.ebean.config.dbplatform.H2Platform; import com.avaje.ebean.config.dbplatform.MsSqlServer2005Platform; import com.avaje.ebean.config.dbplatform.MySqlPlatform; diff --git a/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java b/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java index c7426989a..2f995fce2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java +++ b/src/main/java/com/avaje/ebean/dbmigration/DdlGenerator.java @@ -21,7 +21,7 @@ import java.sql.SQLException; /** * Controls the generation and execution of "Create All" and "Drop All" DDL scripts. - * + *

* Typically the "Create All" DDL is executed for running tests etc and has nothing to do * with DB Migration (diff based) DDL. */ diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java index e0a6bae94..40a8208a5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/DdlWrite.java @@ -60,9 +60,9 @@ public class DdlWrite { */ public boolean isApplyEmpty() { return apply.getBuffer().isEmpty() - && applyForeignKeys.getBuffer().isEmpty() - && applyHistory.getBuffer().isEmpty() - && applyDropDependencies.getBuffer().isEmpty(); + && applyForeignKeys.getBuffer().isEmpty() + && applyHistory.getBuffer().isEmpty() + && applyDropDependencies.getBuffer().isEmpty(); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java index 1cb4a9818..344ba3320 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -206,12 +206,12 @@ public class BaseTableDdl implements TableDdl { String uqName = col.getUniqueOneToOne(); String[] columnNames = {col.getName()}; write.apply() - .append(platformDdl.alterTableAddUniqueConstraint(tableName, uqName, columnNames)) - .endOfStatement(); + .append(platformDdl.alterTableAddUniqueConstraint(tableName, uqName, columnNames)) + .endOfStatement(); write.dropAllForeignKeys() - .append(platformDdl.dropIndex(uqName, tableName)) - .endOfStatement(); + .append(platformDdl.dropIndex(uqName, tableName)) + .endOfStatement(); } } @@ -338,11 +338,11 @@ public class BaseTableDdl implements TableDdl { fkeyBuffer.end(); write.dropAllForeignKeys() - .append(platformDdl.alterTableDropForeignKey(tableName, fkName)).endOfStatement(); + .append(platformDdl.alterTableDropForeignKey(tableName, fkName)).endOfStatement(); if (indexName != null) { write.dropAllForeignKeys() - .append(platformDdl.dropIndex(indexName, tableName)).endOfStatement(); + .append(platformDdl.dropIndex(indexName, tableName)).endOfStatement(); } write.dropAllForeignKeys().end(); @@ -513,20 +513,20 @@ public class BaseTableDdl implements TableDdl { String[] cols = toColumnNamesSplit(createIndex.getColumns()); writer.apply() - .append(platformDdl.createIndex(createIndex.getIndexName(), createIndex.getTableName(), cols)) - .endOfStatement(); + .append(platformDdl.createIndex(createIndex.getIndexName(), createIndex.getTableName(), cols)) + .endOfStatement(); writer.dropAll() - .append(platformDdl.dropIndex(createIndex.getIndexName(), createIndex.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(createIndex.getIndexName(), createIndex.getTableName())) + .endOfStatement(); } @Override public void generate(DdlWrite writer, DropIndex dropIndex) throws IOException { writer.apply() - .append(platformDdl.dropIndex(dropIndex.getIndexName(), dropIndex.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(dropIndex.getIndexName(), dropIndex.getTableName())) + .endOfStatement(); } /** @@ -793,16 +793,16 @@ public class BaseTableDdl implements TableDdl { protected void alterColumnDropForeignKey(DdlWrite writer, AlterColumn alter) throws IOException { writer.apply() - .append(platformDdl.alterTableDropForeignKey(alter.getTableName(), alter.getDropForeignKey())) - .endOfStatement(); + .append(platformDdl.alterTableDropForeignKey(alter.getTableName(), alter.getDropForeignKey())) + .endOfStatement(); } protected void alterColumnDropUniqueConstraint(DdlWrite writer, AlterColumn alter) throws IOException { writer.apply() - .append(platformDdl.alterTableDropUniqueConstraint(alter.getTableName(), alter.getDropUnique())) - .endOfStatement(); + .append(platformDdl.alterTableDropUniqueConstraint(alter.getTableName(), alter.getDropUnique())) + .endOfStatement(); } protected void alterColumnAddUniqueOneToOneConstraint(DdlWrite writer, AlterColumn alter) throws IOException { @@ -820,27 +820,27 @@ public class BaseTableDdl implements TableDdl { String[] cols = {alter.getColumnName()}; writer.apply() - .append(platformDdl.alterTableAddUniqueConstraint(alter.getTableName(), uqName, cols)) - .endOfStatement(); + .append(platformDdl.alterTableAddUniqueConstraint(alter.getTableName(), uqName, cols)) + .endOfStatement(); writer.dropAllForeignKeys() - .append(platformDdl.dropIndex(uqName, alter.getTableName())) - .endOfStatement(); + .append(platformDdl.dropIndex(uqName, alter.getTableName())) + .endOfStatement(); } protected void alterTableDropColumn(DdlBuffer buffer, String tableName, String columnName) throws IOException { buffer.append("alter table ").append(tableName).append(" drop column ").append(columnName) - .endOfStatement(); + .endOfStatement(); } protected void alterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable) throws IOException { String convertedType = platformDdl.convert(column.getType(), false); buffer.append("alter table ").append(tableName) - .append(" add column ").append(column.getName()) - .append(" ").append(convertedType); + .append(" add column ").append(column.getName()) + .append(" ").append(convertedType); if (!onHistoryTable) { if (isTrue(column.isNotnull())) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java index 4ea033ef7..9d3e844ee 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java @@ -164,9 +164,9 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl { protected void addSysPeriodColumns(DdlBuffer apply, String baseTableName, String whenCreatedColumn) throws IOException { apply.append("alter table ").append(baseTableName).append(" add column ") - .append(sysPeriodStart).append(" ").append(sysPeriodType).append(" default ").append(currentTimestamp).endOfStatement(); + .append(sysPeriodStart).append(" ").append(sysPeriodType).append(" default ").append(currentTimestamp).endOfStatement(); apply.append("alter table ").append(baseTableName).append(" add column ") - .append(sysPeriodEnd).append(" ").append(sysPeriodType).endOfStatement(); + .append(sysPeriodEnd).append(" ").append(sysPeriodType).endOfStatement(); if (whenCreatedColumn != null) { apply.append("update ").append(baseTableName).append(" set ").append(sysPeriodStart).append(" = ").append(whenCreatedColumn).endOfStatement(); @@ -204,10 +204,10 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl { protected void createWithHistoryView(DdlBuffer apply, String baseTableName) throws IOException { apply - .append("create view ").append(baseTableName).append(viewSuffix) - .append(" as select * from ").append(baseTableName) - .append(" union all select * from ").append(baseTableName).append(historySuffix) - .endOfStatement().end(); + .append("create view ").append(baseTableName).append(viewSuffix) + .append(" as select * from ").append(baseTableName) + .append(" union all select * from ").append(baseTableName).append(historySuffix) + .endOfStatement().end(); } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java index 1072e1eba..dde2ed843 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdl.java @@ -45,8 +45,8 @@ public class H2HistoryDdl extends DbTriggerBasedHistoryDdl { // Note that this does not take into account the historyTable name (excepts _history suffix) and // does not take into account excluded columns (all columns included in history) apply - .append("create trigger ").append(triggerName).append(" before update,delete on ").append(baseTable) - .append(" for each row call \"" + TRIGGER_CLASS + "\";").newLine(); + .append("create trigger ").append(triggerName).append(" before update,delete on ").append(baseTable) + .append(" for each row call \"" + TRIGGER_CLASS + "\";").newLine(); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java index dc3505f4b..c72e18f7a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/HistoryTableUpdate.java @@ -36,7 +36,7 @@ public class HistoryTableUpdate { } public String description() { - return change.name().toLowerCase()+" "+column; + return change.name().toLowerCase() + " " + column; } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java index d8cf688d4..73eca28c5 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MsSqlServerDdl.java @@ -37,7 +37,7 @@ public class MsSqlServerDdl extends PlatformDdl { public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns) { // issues#233 - String start = "create unique nonclustered index " + uqName + " on " + tableName+ "("; + String start = "create unique nonclustered index " + uqName + " on " + tableName + "("; StringBuilder sb = new StringBuilder(start); for (int i = 0; i < columns.length; i++) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java index 545b5ba43..df23acd9d 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlDdl.java @@ -15,7 +15,7 @@ public class MySqlDdl extends PlatformDdl { public MySqlDdl(DatabasePlatform platform) { super(platform); - this.alterColumn = "modify"; + this.alterColumn = "modify"; this.dropUniqueConstraint = "drop index"; this.historyDdl = new MySqlHistoryDdl(); this.inlineComments = true; diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java index 9de3ccf49..81f727a66 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/MySqlHistoryDdl.java @@ -48,22 +48,22 @@ public class MySqlHistoryDdl extends DbTriggerBasedHistoryDdl { DdlBuffer apply = update.historyBuffer(); apply - .append("delimiter $$").newLine() - .append("create trigger ").append(triggerName).append(" before update on ").append(update.getBaseTable()) - .append(" for each row begin").newLine(); + .append("delimiter $$").newLine() + .append("create trigger ").append(triggerName).append(" before update on ").append(update.getBaseTable()) + .append(" for each row begin").newLine(); appendInsertIntoHistory(apply, update.getHistoryTable(), update.getColumns()); apply - .append(" set NEW.").append(sysPeriod).append("_start = now(6)").endOfStatement() - .append("end$$").newLine(); + .append(" set NEW.").append(sysPeriod).append("_start = now(6)").endOfStatement() + .append("end$$").newLine(); } private void addBeforeDelete(String triggerName, DbTriggerUpdate update) throws IOException { DdlBuffer apply = update.historyBuffer(); apply - .append("delimiter $$").newLine() - .append("create trigger ").append(triggerName).append(" before delete on ").append(update.getBaseTable()) - .append(" for each row begin").newLine(); + .append("delimiter $$").newLine() + .append("create trigger ").append(triggerName).append(" before delete on ").append(update.getBaseTable()) + .append(" for each row begin").newLine(); appendInsertIntoHistory(apply, update.getHistoryTable(), update.getColumns()); apply.append("end$$").newLine(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java index c4f93b8f9..8037459fe 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/Oracle10Ddl.java @@ -15,7 +15,7 @@ public class Oracle10Ddl extends PlatformDdl { this.dropIndexIfExists = "drop index "; this.dropTableCascade = " cascade constraints purge"; this.foreignKeyRestrict = ""; - this.alterColumn = "modify"; + this.alterColumn = "modify"; this.columnSetNotnull = "not null"; this.columnSetNull = "null"; this.columnSetDefault = "default"; diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java index 460300bf6..6e177483c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -320,13 +320,13 @@ public class PlatformDdl { StringBuilder buffer = new StringBuilder(90); buffer - .append("alter table ").append(tableName) - .append(" add constraint ").append(fkName) - .append(" foreign key"); + .append("alter table ").append(tableName) + .append(" add constraint ").append(fkName) + .append(" foreign key"); appendColumns(columns, buffer); buffer - .append(" references ") - .append(lowerTableName(refTable)); + .append(" references ") + .append(lowerTableName(refTable)); appendColumns(refColumns, buffer); appendWithSpace(foreignKeyRestrict, buffer); diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java index 037756905..ccb026e8c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/PostgresHistoryDdl.java @@ -25,8 +25,8 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { String baseTable = table.getName(); apply - .append("create table ").append(baseTable).append(historySuffix) - .append("(like ").append(baseTable).append(")").endOfStatement(); + .append("create table ").append(baseTable).append(historySuffix) + .append("(like ").append(baseTable).append(")").endOfStatement(); } /** @@ -35,13 +35,13 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { @Override protected void addSysPeriodColumns(DdlBuffer apply, String baseTableName, String whenCreatedColumn) throws IOException { apply - .append("alter table ").append(baseTableName) - .append(" add column ").append(sysPeriod).append(" tstzrange not null default tstzrange(").append(currentTimestamp).append(", null)") - .endOfStatement(); + .append("alter table ").append(baseTableName) + .append(" add column ").append(sysPeriod).append(" tstzrange not null default tstzrange(").append(currentTimestamp).append(", null)") + .endOfStatement(); if (whenCreatedColumn != null) { apply.append("update ").append(baseTableName).append(" set ") - .append(sysPeriod).append(" = tstzrange(").append(whenCreatedColumn).append(", null)").endOfStatement(); + .append(sysPeriod).append(" = tstzrange(").append(whenCreatedColumn).append(", null)").endOfStatement(); } } @@ -64,9 +64,9 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { DdlBuffer apply = writer.applyHistory(); apply - .append("create trigger ").append(triggerName).newLine() - .append(" before update or delete on ").append(baseTableName).newLine() - .append(" for each row execute procedure ").append(procedureName).append("();").newLine().newLine(); + .append("create trigger ").append(triggerName).newLine() + .append(" before update or delete on ").append(baseTableName).newLine() + .append(" for each row execute procedure ").append(procedureName).append("();").newLine().newLine(); } @Override @@ -79,23 +79,23 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl { protected void createOrReplaceFunction(DdlBuffer apply, String procedureName, String historyTable, List includedColumns) throws IOException { apply - .append("create or replace function ").append(procedureName).append("() returns trigger as $$").newLine() - .append("begin").newLine(); + .append("create or replace function ").append(procedureName).append("() returns trigger as $$").newLine() + .append("begin").newLine(); apply - .append(" if (TG_OP = 'UPDATE') then").newLine(); + .append(" if (TG_OP = 'UPDATE') then").newLine(); appendInsertIntoHistory(apply, historyTable, includedColumns); apply - .append(" NEW.").append(sysPeriod).append(" = tstzrange(").append(currentTimestamp).append(",null);").newLine() - .append(" return new;").newLine(); + .append(" NEW.").append(sysPeriod).append(" = tstzrange(").append(currentTimestamp).append(",null);").newLine() + .append(" return new;").newLine(); apply - .append(" elsif (TG_OP = 'DELETE') then").newLine(); + .append(" elsif (TG_OP = 'DELETE') then").newLine(); appendInsertIntoHistory(apply, historyTable, includedColumns); apply - .append(" return old;").newLine(); + .append(" return old;").newLine(); apply - .append(" end if;").newLine() - .append("end;").newLine() - .append("$$ LANGUAGE plpgsql;").newLine(); + .append(" end if;").newLine() + .append("end;").newLine() + .append("$$ LANGUAGE plpgsql;").newLine(); apply.end(); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java index de9db9012..bc99b0701 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java +++ b/src/main/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/IndexColumns.java @@ -39,7 +39,7 @@ public class IndexColumns { if (columns.size() != columnNames.size()) { return false; } - for (int i = 0; i Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -29,98 +28,86 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "column" + "column" }) @XmlRootElement(name = "addColumn") public class AddColumn { - @XmlElement(required = true) - protected List column; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; + @XmlElement(required = true) + protected List column; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; - /** - * Gets the value of the column property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the column property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getColumn().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Column } - * - * - */ - public List getColumn() { - if (column == null) { - column = new ArrayList<>(); - } - return this.column; + /** + * Gets the value of the column property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the column property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getColumn().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Column } + */ + public List getColumn() { + if (column == null) { + column = new ArrayList<>(); } + return this.column; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java index 1ea167f4e..d48f1ae9a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "addHistoryTable") public class AddHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java index 40d50c625..a5e81e26e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AddTableComment.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "addTableComment") public class AddTableComment { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "comment", required = true) - protected String comment; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "comment", required = true) + protected String comment; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java index 7f8c683ca..a0676e33e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -43,585 +42,495 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "alterColumn") public class AlterColumn { - @XmlAttribute(name = "columnName", required = true) - protected String columnName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; - @XmlAttribute(name = "type") - protected String type; - @XmlAttribute(name = "currentType") - protected String currentType; - @XmlAttribute(name = "defaultValue") - protected String defaultValue; - @XmlAttribute(name = "currentDefaultValue") - protected String currentDefaultValue; - @XmlAttribute(name = "notnull") - protected Boolean notnull; - @XmlAttribute(name = "currentNotnull") - protected Boolean currentNotnull; - @XmlAttribute(name = "comment") - protected String comment; - @XmlAttribute(name = "historyExclude") - protected Boolean historyExclude; - @XmlAttribute(name = "checkConstraint") - protected String checkConstraint; - @XmlAttribute(name = "checkConstraintName") - protected String checkConstraintName; - @XmlAttribute(name = "dropCheckConstraint") - protected String dropCheckConstraint; - @XmlAttribute(name = "unique") - protected String unique; - @XmlAttribute(name = "uniqueOneToOne") - protected String uniqueOneToOne; - @XmlAttribute(name = "dropUnique") - protected String dropUnique; - @XmlAttribute(name = "references") - protected String references; - @XmlAttribute(name = "foreignKeyName") - protected String foreignKeyName; - @XmlAttribute(name = "foreignKeyIndex") - protected String foreignKeyIndex; - @XmlAttribute(name = "dropForeignKey") - protected String dropForeignKey; - @XmlAttribute(name = "dropForeignKeyIndex") - protected String dropForeignKeyIndex; + @XmlAttribute(name = "columnName", required = true) + protected String columnName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; + @XmlAttribute(name = "type") + protected String type; + @XmlAttribute(name = "currentType") + protected String currentType; + @XmlAttribute(name = "defaultValue") + protected String defaultValue; + @XmlAttribute(name = "currentDefaultValue") + protected String currentDefaultValue; + @XmlAttribute(name = "notnull") + protected Boolean notnull; + @XmlAttribute(name = "currentNotnull") + protected Boolean currentNotnull; + @XmlAttribute(name = "comment") + protected String comment; + @XmlAttribute(name = "historyExclude") + protected Boolean historyExclude; + @XmlAttribute(name = "checkConstraint") + protected String checkConstraint; + @XmlAttribute(name = "checkConstraintName") + protected String checkConstraintName; + @XmlAttribute(name = "dropCheckConstraint") + protected String dropCheckConstraint; + @XmlAttribute(name = "unique") + protected String unique; + @XmlAttribute(name = "uniqueOneToOne") + protected String uniqueOneToOne; + @XmlAttribute(name = "dropUnique") + protected String dropUnique; + @XmlAttribute(name = "references") + protected String references; + @XmlAttribute(name = "foreignKeyName") + protected String foreignKeyName; + @XmlAttribute(name = "foreignKeyIndex") + protected String foreignKeyIndex; + @XmlAttribute(name = "dropForeignKey") + protected String dropForeignKey; + @XmlAttribute(name = "dropForeignKeyIndex") + protected String dropForeignKeyIndex; - /** - * Gets the value of the columnName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnName() { - return columnName; - } + /** + * Gets the value of the columnName property. + * + * @return possible object is + * {@link String } + */ + public String getColumnName() { + return columnName; + } - /** - * Sets the value of the columnName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnName(String value) { - this.columnName = value; - } + /** + * Sets the value of the columnName property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnName(String value) { + this.columnName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) { + this.type = value; + } - /** - * Gets the value of the currentType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCurrentType() { - return currentType; - } + /** + * Gets the value of the currentType property. + * + * @return possible object is + * {@link String } + */ + public String getCurrentType() { + return currentType; + } - /** - * Sets the value of the currentType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCurrentType(String value) { - this.currentType = value; - } + /** + * Sets the value of the currentType property. + * + * @param value allowed object is + * {@link String } + */ + public void setCurrentType(String value) { + this.currentType = value; + } - /** - * Gets the value of the defaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDefaultValue() { - return defaultValue; - } + /** + * Gets the value of the defaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getDefaultValue() { + return defaultValue; + } - /** - * Sets the value of the defaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDefaultValue(String value) { - this.defaultValue = value; - } + /** + * Sets the value of the defaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setDefaultValue(String value) { + this.defaultValue = value; + } - /** - * Gets the value of the currentDefaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCurrentDefaultValue() { - return currentDefaultValue; - } + /** + * Gets the value of the currentDefaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getCurrentDefaultValue() { + return currentDefaultValue; + } - /** - * Sets the value of the currentDefaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCurrentDefaultValue(String value) { - this.currentDefaultValue = value; - } + /** + * Sets the value of the currentDefaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setCurrentDefaultValue(String value) { + this.currentDefaultValue = value; + } - /** - * Gets the value of the notnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isNotnull() { - return notnull; - } + /** + * Gets the value of the notnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isNotnull() { + return notnull; + } - /** - * Sets the value of the notnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setNotnull(Boolean value) { - this.notnull = value; - } + /** + * Sets the value of the notnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setNotnull(Boolean value) { + this.notnull = value; + } - /** - * Gets the value of the currentNotnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isCurrentNotnull() { - return currentNotnull; - } + /** + * Gets the value of the currentNotnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isCurrentNotnull() { + return currentNotnull; + } - /** - * Sets the value of the currentNotnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setCurrentNotnull(Boolean value) { - this.currentNotnull = value; - } + /** + * Sets the value of the currentNotnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setCurrentNotnull(Boolean value) { + this.currentNotnull = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } - /** - * Gets the value of the historyExclude property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isHistoryExclude() { - return historyExclude; - } + /** + * Gets the value of the historyExclude property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isHistoryExclude() { + return historyExclude; + } - /** - * Sets the value of the historyExclude property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setHistoryExclude(Boolean value) { - this.historyExclude = value; - } + /** + * Sets the value of the historyExclude property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setHistoryExclude(Boolean value) { + this.historyExclude = value; + } - /** - * Gets the value of the checkConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraint() { - return checkConstraint; - } + /** + * Gets the value of the checkConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraint() { + return checkConstraint; + } - /** - * Sets the value of the checkConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraint(String value) { - this.checkConstraint = value; - } + /** + * Sets the value of the checkConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraint(String value) { + this.checkConstraint = value; + } - /** - * Gets the value of the checkConstraintName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraintName() { - return checkConstraintName; - } + /** + * Gets the value of the checkConstraintName property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraintName() { + return checkConstraintName; + } - /** - * Sets the value of the checkConstraintName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraintName(String value) { - this.checkConstraintName = value; - } + /** + * Sets the value of the checkConstraintName property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraintName(String value) { + this.checkConstraintName = value; + } - /** - * Gets the value of the dropCheckConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropCheckConstraint() { - return dropCheckConstraint; - } + /** + * Gets the value of the dropCheckConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getDropCheckConstraint() { + return dropCheckConstraint; + } - /** - * Sets the value of the dropCheckConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropCheckConstraint(String value) { - this.dropCheckConstraint = value; - } + /** + * Sets the value of the dropCheckConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropCheckConstraint(String value) { + this.dropCheckConstraint = value; + } - /** - * Gets the value of the unique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUnique() { - return unique; - } + /** + * Gets the value of the unique property. + * + * @return possible object is + * {@link String } + */ + public String getUnique() { + return unique; + } - /** - * Sets the value of the unique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUnique(String value) { - this.unique = value; - } + /** + * Sets the value of the unique property. + * + * @param value allowed object is + * {@link String } + */ + public void setUnique(String value) { + this.unique = value; + } - /** - * Gets the value of the uniqueOneToOne property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUniqueOneToOne() { - return uniqueOneToOne; - } + /** + * Gets the value of the uniqueOneToOne property. + * + * @return possible object is + * {@link String } + */ + public String getUniqueOneToOne() { + return uniqueOneToOne; + } - /** - * Sets the value of the uniqueOneToOne property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUniqueOneToOne(String value) { - this.uniqueOneToOne = value; - } + /** + * Sets the value of the uniqueOneToOne property. + * + * @param value allowed object is + * {@link String } + */ + public void setUniqueOneToOne(String value) { + this.uniqueOneToOne = value; + } - /** - * Gets the value of the dropUnique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropUnique() { - return dropUnique; - } + /** + * Gets the value of the dropUnique property. + * + * @return possible object is + * {@link String } + */ + public String getDropUnique() { + return dropUnique; + } - /** - * Sets the value of the dropUnique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropUnique(String value) { - this.dropUnique = value; - } + /** + * Sets the value of the dropUnique property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropUnique(String value) { + this.dropUnique = value; + } - /** - * Gets the value of the references property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReferences() { - return references; - } + /** + * Gets the value of the references property. + * + * @return possible object is + * {@link String } + */ + public String getReferences() { + return references; + } - /** - * Sets the value of the references property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReferences(String value) { - this.references = value; - } + /** + * Sets the value of the references property. + * + * @param value allowed object is + * {@link String } + */ + public void setReferences(String value) { + this.references = value; + } - /** - * Gets the value of the foreignKeyName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyName() { - return foreignKeyName; - } + /** + * Gets the value of the foreignKeyName property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyName() { + return foreignKeyName; + } - /** - * Sets the value of the foreignKeyName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyName(String value) { - this.foreignKeyName = value; - } + /** + * Sets the value of the foreignKeyName property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyName(String value) { + this.foreignKeyName = value; + } - /** - * Gets the value of the foreignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyIndex() { - return foreignKeyIndex; - } + /** + * Gets the value of the foreignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyIndex() { + return foreignKeyIndex; + } - /** - * Sets the value of the foreignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyIndex(String value) { - this.foreignKeyIndex = value; - } + /** + * Sets the value of the foreignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyIndex(String value) { + this.foreignKeyIndex = value; + } - /** - * Gets the value of the dropForeignKey property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropForeignKey() { - return dropForeignKey; - } + /** + * Gets the value of the dropForeignKey property. + * + * @return possible object is + * {@link String } + */ + public String getDropForeignKey() { + return dropForeignKey; + } - /** - * Sets the value of the dropForeignKey property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropForeignKey(String value) { - this.dropForeignKey = value; - } + /** + * Sets the value of the dropForeignKey property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropForeignKey(String value) { + this.dropForeignKey = value; + } - /** - * Gets the value of the dropForeignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropForeignKeyIndex() { - return dropForeignKeyIndex; - } + /** + * Gets the value of the dropForeignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getDropForeignKeyIndex() { + return dropForeignKeyIndex; + } - /** - * Sets the value of the dropForeignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropForeignKeyIndex(String value) { - this.dropForeignKeyIndex = value; - } + /** + * Sets the value of the dropForeignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropForeignKeyIndex(String value) { + this.dropForeignKeyIndex = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java index e57b52add..431188bdc 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/AlterHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "alterHistoryTable") public class AlterHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java index 31b8a130c..2063ffaf6 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Application.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "application") public class Application { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "resourcePath", required = true) - protected String resourcePath; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "resourcePath", required = true) + protected String resourcePath; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the resourcePath property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getResourcePath() { - return resourcePath; - } + /** + * Gets the value of the resourcePath property. + * + * @return possible object is + * {@link String } + */ + public String getResourcePath() { + return resourcePath; + } - /** - * Sets the value of the resourcePath property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setResourcePath(String value) { - this.resourcePath = value; - } + /** + * Sets the value of the resourcePath property. + * + * @param value allowed object is + * {@link String } + */ + public void setResourcePath(String value) { + this.resourcePath = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java index 262bd6ecc..68c898b31 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Applications.java @@ -1,19 +1,18 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,45 +24,41 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "application" + "application" }) @XmlRootElement(name = "applications") public class Applications { - protected List application; + protected List application; - /** - * Gets the value of the application property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the application property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getApplication().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Application } - * - * - */ - public List getApplication() { - if (application == null) { - application = new ArrayList<>(); - } - return this.application; + /** + * Gets the value of the application property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the application property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getApplication().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Application } + */ + public List getApplication() { + if (application == null) { + application = new ArrayList<>(); } + return this.application; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java index 3ca1a3fca..b43954ace 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Apply.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -21,41 +20,35 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "apply") public class Apply { - @XmlValue - protected String value; + @XmlValue + protected String value; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java index df76e2d0a..6ed514c10 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSet.java @@ -1,8 +1,5 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -10,13 +7,15 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -36,230 +35,202 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "changeSetChildren" + "changeSetChildren" }) @XmlRootElement(name = "changeSet") public class ChangeSet { - @XmlElements({ - @XmlElement(name = "configuration", type = Configuration.class), - @XmlElement(name = "sql", type = Sql.class), - @XmlElement(name = "createTable", type = CreateTable.class), - @XmlElement(name = "dropTable", type = DropTable.class), - @XmlElement(name = "renameTable", type = RenameTable.class), - @XmlElement(name = "addTableComment", type = AddTableComment.class), - @XmlElement(name = "addHistoryTable", type = AddHistoryTable.class), - @XmlElement(name = "dropHistoryTable", type = DropHistoryTable.class), - @XmlElement(name = "addColumn", type = AddColumn.class), - @XmlElement(name = "dropColumn", type = DropColumn.class), - @XmlElement(name = "alterColumn", type = AlterColumn.class), - @XmlElement(name = "renameColumn", type = RenameColumn.class), - @XmlElement(name = "createIndex", type = CreateIndex.class), - @XmlElement(name = "dropIndex", type = DropIndex.class) - }) - protected List changeSetChildren; - @XmlAttribute(name = "type", required = true) - protected ChangeSetType type; - @XmlAttribute(name = "dropsFor") - protected String dropsFor; - @XmlAttribute(name = "suppressDropsForever") - protected Boolean suppressDropsForever; - @XmlAttribute(name = "generated") - protected Boolean generated; - @XmlAttribute(name = "author") - protected String author; - @XmlAttribute(name = "comment") - protected String comment; + @XmlElements({ + @XmlElement(name = "configuration", type = Configuration.class), + @XmlElement(name = "sql", type = Sql.class), + @XmlElement(name = "createTable", type = CreateTable.class), + @XmlElement(name = "dropTable", type = DropTable.class), + @XmlElement(name = "renameTable", type = RenameTable.class), + @XmlElement(name = "addTableComment", type = AddTableComment.class), + @XmlElement(name = "addHistoryTable", type = AddHistoryTable.class), + @XmlElement(name = "dropHistoryTable", type = DropHistoryTable.class), + @XmlElement(name = "addColumn", type = AddColumn.class), + @XmlElement(name = "dropColumn", type = DropColumn.class), + @XmlElement(name = "alterColumn", type = AlterColumn.class), + @XmlElement(name = "renameColumn", type = RenameColumn.class), + @XmlElement(name = "createIndex", type = CreateIndex.class), + @XmlElement(name = "dropIndex", type = DropIndex.class) + }) + protected List changeSetChildren; + @XmlAttribute(name = "type", required = true) + protected ChangeSetType type; + @XmlAttribute(name = "dropsFor") + protected String dropsFor; + @XmlAttribute(name = "suppressDropsForever") + protected Boolean suppressDropsForever; + @XmlAttribute(name = "generated") + protected Boolean generated; + @XmlAttribute(name = "author") + protected String author; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the changeSetChildren property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the changeSetChildren property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getChangeSetChildren().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Configuration } - * {@link Sql } - * {@link CreateTable } - * {@link DropTable } - * {@link RenameTable } - * {@link AddTableComment } - * {@link AddHistoryTable } - * {@link DropHistoryTable } - * {@link AddColumn } - * {@link DropColumn } - * {@link AlterColumn } - * {@link RenameColumn } - * {@link CreateIndex } - * {@link DropIndex } - * - * - */ - public List getChangeSetChildren() { - if (changeSetChildren == null) { - changeSetChildren = new ArrayList<>(); - } - return this.changeSetChildren; + /** + * Gets the value of the changeSetChildren property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the changeSetChildren property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getChangeSetChildren().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Configuration } + * {@link Sql } + * {@link CreateTable } + * {@link DropTable } + * {@link RenameTable } + * {@link AddTableComment } + * {@link AddHistoryTable } + * {@link DropHistoryTable } + * {@link AddColumn } + * {@link DropColumn } + * {@link AlterColumn } + * {@link RenameColumn } + * {@link CreateIndex } + * {@link DropIndex } + */ + public List getChangeSetChildren() { + if (changeSetChildren == null) { + changeSetChildren = new ArrayList<>(); } + return this.changeSetChildren; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link ChangeSetType } - * - */ - public ChangeSetType getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link ChangeSetType } + */ + public ChangeSetType getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link ChangeSetType } - * - */ - public void setType(ChangeSetType value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link ChangeSetType } + */ + public void setType(ChangeSetType value) { + this.type = value; + } - /** - * Gets the value of the dropsFor property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDropsFor() { - return dropsFor; - } + /** + * Gets the value of the dropsFor property. + * + * @return possible object is + * {@link String } + */ + public String getDropsFor() { + return dropsFor; + } - /** - * Sets the value of the dropsFor property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDropsFor(String value) { - this.dropsFor = value; - } + /** + * Sets the value of the dropsFor property. + * + * @param value allowed object is + * {@link String } + */ + public void setDropsFor(String value) { + this.dropsFor = value; + } - /** - * Gets the value of the suppressDropsForever property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isSuppressDropsForever() { - return suppressDropsForever; - } + /** + * Gets the value of the suppressDropsForever property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isSuppressDropsForever() { + return suppressDropsForever; + } - /** - * Sets the value of the suppressDropsForever property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setSuppressDropsForever(Boolean value) { - this.suppressDropsForever = value; - } + /** + * Sets the value of the suppressDropsForever property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setSuppressDropsForever(Boolean value) { + this.suppressDropsForever = value; + } - /** - * Gets the value of the generated property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isGenerated() { - return generated; - } + /** + * Gets the value of the generated property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isGenerated() { + return generated; + } - /** - * Sets the value of the generated property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setGenerated(Boolean value) { - this.generated = value; - } + /** + * Sets the value of the generated property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setGenerated(Boolean value) { + this.generated = value; + } - /** - * Gets the value of the author property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAuthor() { - return author; - } + /** + * Gets the value of the author property. + * + * @return possible object is + * {@link String } + */ + public String getAuthor() { + return author; + } - /** - * Sets the value of the author property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAuthor(String value) { - this.author = value; - } + /** + * Sets the value of the author property. + * + * @param value allowed object is + * {@link String } + */ + public void setAuthor(String value) { + this.author = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java index b87dffebb..b7708a362 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ChangeSetType.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlEnum; @@ -8,7 +7,7 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for changeSetType. - * + *

*

The following schema fragment specifies the expected content contained within this class. *

*

@@ -20,35 +19,34 @@ import javax.xml.bind.annotation.XmlType;
  *   </restriction>
  * </simpleType>
  * 
- * */ @XmlType(name = "changeSetType") @XmlEnum public enum ChangeSetType { - @XmlEnumValue("apply") - APPLY("apply"), - @XmlEnumValue("pendingDrops") - PENDING_DROPS("pendingDrops"), - @XmlEnumValue("baseline") - BASELINE("baseline"); - private final String value; + @XmlEnumValue("apply") + APPLY("apply"), + @XmlEnumValue("pendingDrops") + PENDING_DROPS("pendingDrops"), + @XmlEnumValue("baseline") + BASELINE("baseline"); + private final String value; - ChangeSetType(String v) { - value = v; - } + ChangeSetType(String v) { + value = v; + } - public String value() { - return value; - } + public String value() { + return value; + } - public static ChangeSetType fromValue(String v) { - for (ChangeSetType c: ChangeSetType.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + public static ChangeSetType fromValue(String v) { + for (ChangeSetType c : ChangeSetType.values()) { + if (c.value.equals(v)) { + return c; + } } + throw new IllegalArgumentException(v); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java index e99569ebe..2e2aecfc7 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Column.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -37,431 +36,365 @@ import javax.xml.bind.annotation.XmlValue;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "content" + "content" }) @XmlRootElement(name = "column") public class Column { - @XmlValue - protected String content; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "type", required = true) - protected String type; - @XmlAttribute(name = "defaultValue") - protected String defaultValue; - @XmlAttribute(name = "notnull") - protected Boolean notnull; - @XmlAttribute(name = "historyExclude") - protected Boolean historyExclude; - @XmlAttribute(name = "primaryKey") - protected Boolean primaryKey; - @XmlAttribute(name = "identity") - protected Boolean identity; - @XmlAttribute(name = "checkConstraint") - protected String checkConstraint; - @XmlAttribute(name = "checkConstraintName") - protected String checkConstraintName; - @XmlAttribute(name = "unique") - protected String unique; - @XmlAttribute(name = "uniqueOneToOne") - protected String uniqueOneToOne; - @XmlAttribute(name = "references") - protected String references; - @XmlAttribute(name = "foreignKeyName") - protected String foreignKeyName; - @XmlAttribute(name = "foreignKeyIndex") - protected String foreignKeyIndex; - @XmlAttribute(name = "comment") - protected String comment; + @XmlValue + protected String content; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "type", required = true) + protected String type; + @XmlAttribute(name = "defaultValue") + protected String defaultValue; + @XmlAttribute(name = "notnull") + protected Boolean notnull; + @XmlAttribute(name = "historyExclude") + protected Boolean historyExclude; + @XmlAttribute(name = "primaryKey") + protected Boolean primaryKey; + @XmlAttribute(name = "identity") + protected Boolean identity; + @XmlAttribute(name = "checkConstraint") + protected String checkConstraint; + @XmlAttribute(name = "checkConstraintName") + protected String checkConstraintName; + @XmlAttribute(name = "unique") + protected String unique; + @XmlAttribute(name = "uniqueOneToOne") + protected String uniqueOneToOne; + @XmlAttribute(name = "references") + protected String references; + @XmlAttribute(name = "foreignKeyName") + protected String foreignKeyName; + @XmlAttribute(name = "foreignKeyIndex") + protected String foreignKeyIndex; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the content property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getContent() { - return content; - } + /** + * Gets the value of the content property. + * + * @return possible object is + * {@link String } + */ + public String getContent() { + return content; + } - /** - * Sets the value of the content property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setContent(String value) { - this.content = value; - } + /** + * Sets the value of the content property. + * + * @param value allowed object is + * {@link String } + */ + public void setContent(String value) { + this.content = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() { + return type; + } - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) { + this.type = value; + } - /** - * Gets the value of the defaultValue property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDefaultValue() { - return defaultValue; - } + /** + * Gets the value of the defaultValue property. + * + * @return possible object is + * {@link String } + */ + public String getDefaultValue() { + return defaultValue; + } - /** - * Sets the value of the defaultValue property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDefaultValue(String value) { - this.defaultValue = value; - } + /** + * Sets the value of the defaultValue property. + * + * @param value allowed object is + * {@link String } + */ + public void setDefaultValue(String value) { + this.defaultValue = value; + } - /** - * Gets the value of the notnull property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isNotnull() { - return notnull; - } + /** + * Gets the value of the notnull property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isNotnull() { + return notnull; + } - /** - * Sets the value of the notnull property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setNotnull(Boolean value) { - this.notnull = value; - } + /** + * Sets the value of the notnull property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setNotnull(Boolean value) { + this.notnull = value; + } - /** - * Gets the value of the historyExclude property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isHistoryExclude() { - return historyExclude; - } + /** + * Gets the value of the historyExclude property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isHistoryExclude() { + return historyExclude; + } - /** - * Sets the value of the historyExclude property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setHistoryExclude(Boolean value) { - this.historyExclude = value; - } + /** + * Sets the value of the historyExclude property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setHistoryExclude(Boolean value) { + this.historyExclude = value; + } - /** - * Gets the value of the primaryKey property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isPrimaryKey() { - return primaryKey; - } + /** + * Gets the value of the primaryKey property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isPrimaryKey() { + return primaryKey; + } - /** - * Sets the value of the primaryKey property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setPrimaryKey(Boolean value) { - this.primaryKey = value; - } + /** + * Sets the value of the primaryKey property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setPrimaryKey(Boolean value) { + this.primaryKey = value; + } - /** - * Gets the value of the identity property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isIdentity() { - return identity; - } + /** + * Gets the value of the identity property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isIdentity() { + return identity; + } - /** - * Sets the value of the identity property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setIdentity(Boolean value) { - this.identity = value; - } + /** + * Sets the value of the identity property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setIdentity(Boolean value) { + this.identity = value; + } - /** - * Gets the value of the checkConstraint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraint() { - return checkConstraint; - } + /** + * Gets the value of the checkConstraint property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraint() { + return checkConstraint; + } - /** - * Sets the value of the checkConstraint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraint(String value) { - this.checkConstraint = value; - } + /** + * Sets the value of the checkConstraint property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraint(String value) { + this.checkConstraint = value; + } - /** - * Gets the value of the checkConstraintName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCheckConstraintName() { - return checkConstraintName; - } + /** + * Gets the value of the checkConstraintName property. + * + * @return possible object is + * {@link String } + */ + public String getCheckConstraintName() { + return checkConstraintName; + } - /** - * Sets the value of the checkConstraintName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCheckConstraintName(String value) { - this.checkConstraintName = value; - } + /** + * Sets the value of the checkConstraintName property. + * + * @param value allowed object is + * {@link String } + */ + public void setCheckConstraintName(String value) { + this.checkConstraintName = value; + } - /** - * Gets the value of the unique property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUnique() { - return unique; - } + /** + * Gets the value of the unique property. + * + * @return possible object is + * {@link String } + */ + public String getUnique() { + return unique; + } - /** - * Sets the value of the unique property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUnique(String value) { - this.unique = value; - } + /** + * Sets the value of the unique property. + * + * @param value allowed object is + * {@link String } + */ + public void setUnique(String value) { + this.unique = value; + } - /** - * Gets the value of the uniqueOneToOne property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getUniqueOneToOne() { - return uniqueOneToOne; - } + /** + * Gets the value of the uniqueOneToOne property. + * + * @return possible object is + * {@link String } + */ + public String getUniqueOneToOne() { + return uniqueOneToOne; + } - /** - * Sets the value of the uniqueOneToOne property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setUniqueOneToOne(String value) { - this.uniqueOneToOne = value; - } + /** + * Sets the value of the uniqueOneToOne property. + * + * @param value allowed object is + * {@link String } + */ + public void setUniqueOneToOne(String value) { + this.uniqueOneToOne = value; + } - /** - * Gets the value of the references property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getReferences() { - return references; - } + /** + * Gets the value of the references property. + * + * @return possible object is + * {@link String } + */ + public String getReferences() { + return references; + } - /** - * Sets the value of the references property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setReferences(String value) { - this.references = value; - } + /** + * Sets the value of the references property. + * + * @param value allowed object is + * {@link String } + */ + public void setReferences(String value) { + this.references = value; + } - /** - * Gets the value of the foreignKeyName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyName() { - return foreignKeyName; - } + /** + * Gets the value of the foreignKeyName property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyName() { + return foreignKeyName; + } - /** - * Sets the value of the foreignKeyName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyName(String value) { - this.foreignKeyName = value; - } + /** + * Sets the value of the foreignKeyName property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyName(String value) { + this.foreignKeyName = value; + } - /** - * Gets the value of the foreignKeyIndex property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getForeignKeyIndex() { - return foreignKeyIndex; - } + /** + * Gets the value of the foreignKeyIndex property. + * + * @return possible object is + * {@link String } + */ + public String getForeignKeyIndex() { + return foreignKeyIndex; + } - /** - * Sets the value of the foreignKeyIndex property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setForeignKeyIndex(String value) { - this.foreignKeyIndex = value; - } + /** + * Sets the value of the foreignKeyIndex property. + * + * @param value allowed object is + * {@link String } + */ + public void setForeignKeyIndex(String value) { + this.foreignKeyIndex = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java index 54c2c3162..9fe8c3f57 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Configuration.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,41 +23,35 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "defaultTablespace" + "defaultTablespace" }) @XmlRootElement(name = "configuration") public class Configuration { - @XmlElement(required = true) - protected DefaultTablespace defaultTablespace; + @XmlElement(required = true) + protected DefaultTablespace defaultTablespace; - /** - * Gets the value of the defaultTablespace property. - * - * @return - * possible object is - * {@link DefaultTablespace } - * - */ - public DefaultTablespace getDefaultTablespace() { - return defaultTablespace; - } + /** + * Gets the value of the defaultTablespace property. + * + * @return possible object is + * {@link DefaultTablespace } + */ + public DefaultTablespace getDefaultTablespace() { + return defaultTablespace; + } - /** - * Sets the value of the defaultTablespace property. - * - * @param value - * allowed object is - * {@link DefaultTablespace } - * - */ - public void setDefaultTablespace(DefaultTablespace value) { - this.defaultTablespace = value; - } + /** + * Sets the value of the defaultTablespace property. + * + * @param value allowed object is + * {@link DefaultTablespace } + */ + public void setDefaultTablespace(DefaultTablespace value) { + this.defaultTablespace = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java index 0a17ea99b..efdebd503 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateIndex.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "createIndex") public class CreateIndex { - @XmlAttribute(name = "indexName", required = true) - protected String indexName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "columns", required = true) - protected String columns; + @XmlAttribute(name = "indexName", required = true) + protected String indexName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "columns", required = true) + protected String columns; - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the columns property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumns() { - return columns; - } + /** + * Gets the value of the columns property. + * + * @return possible object is + * {@link String } + */ + public String getColumns() { + return columns; + } - /** - * Sets the value of the columns property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumns(String value) { - this.columns = value; - } + /** + * Sets the value of the columns property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumns(String value) { + this.columns = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java index f5a470a89..58012e99c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/CreateTable.java @@ -1,9 +1,5 @@ - package com.avaje.ebean.dbmigration.migration; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -11,13 +7,16 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -40,396 +39,344 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "column", - "uniqueConstraint", - "foreignKey" + "column", + "uniqueConstraint", + "foreignKey" }) @XmlRootElement(name = "createTable") public class CreateTable { - @XmlElement(required = true) - protected List column; - protected List uniqueConstraint; - protected List foreignKey; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; - @XmlAttribute(name = "draft") - protected Boolean draft; - @XmlAttribute(name = "identityType") - protected IdentityType identityType; - @XmlAttribute(name = "sequenceName") - protected String sequenceName; - @XmlAttribute(name = "sequenceInitial") - @XmlSchemaType(name = "positiveInteger") - protected BigInteger sequenceInitial; - @XmlAttribute(name = "sequenceAllocate") - @XmlSchemaType(name = "positiveInteger") - protected BigInteger sequenceAllocate; - @XmlAttribute(name = "pkName") - protected String pkName; - @XmlAttribute(name = "tablespace") - protected String tablespace; - @XmlAttribute(name = "indexTablespace") - protected String indexTablespace; - @XmlAttribute(name = "comment") - protected String comment; + @XmlElement(required = true) + protected List column; + protected List uniqueConstraint; + protected List foreignKey; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; + @XmlAttribute(name = "draft") + protected Boolean draft; + @XmlAttribute(name = "identityType") + protected IdentityType identityType; + @XmlAttribute(name = "sequenceName") + protected String sequenceName; + @XmlAttribute(name = "sequenceInitial") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceInitial; + @XmlAttribute(name = "sequenceAllocate") + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequenceAllocate; + @XmlAttribute(name = "pkName") + protected String pkName; + @XmlAttribute(name = "tablespace") + protected String tablespace; + @XmlAttribute(name = "indexTablespace") + protected String indexTablespace; + @XmlAttribute(name = "comment") + protected String comment; - /** - * Gets the value of the column property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the column property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getColumn().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Column } - * - * - */ - public List getColumn() { - if (column == null) { - column = new ArrayList<>(); - } - return this.column; + /** + * Gets the value of the column property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the column property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getColumn().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link Column } + */ + public List getColumn() { + if (column == null) { + column = new ArrayList<>(); } + return this.column; + } - /** - * Gets the value of the uniqueConstraint property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the uniqueConstraint property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getUniqueConstraint().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link UniqueConstraint } - * - * - */ - public List getUniqueConstraint() { - if (uniqueConstraint == null) { - uniqueConstraint = new ArrayList<>(); - } - return this.uniqueConstraint; + /** + * Gets the value of the uniqueConstraint property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the uniqueConstraint property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getUniqueConstraint().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link UniqueConstraint } + */ + public List getUniqueConstraint() { + if (uniqueConstraint == null) { + uniqueConstraint = new ArrayList<>(); } + return this.uniqueConstraint; + } - /** - * Gets the value of the foreignKey property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the foreignKey property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getForeignKey().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link ForeignKey } - * - * - */ - public List getForeignKey() { - if (foreignKey == null) { - foreignKey = new ArrayList<>(); - } - return this.foreignKey; + /** + * Gets the value of the foreignKey property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the foreignKey property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getForeignKey().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link ForeignKey } + */ + public List getForeignKey() { + if (foreignKey == null) { + foreignKey = new ArrayList<>(); } + return this.foreignKey; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } - /** - * Gets the value of the draft property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isDraft() { - return draft; - } + /** + * Gets the value of the draft property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isDraft() { + return draft; + } - /** - * Sets the value of the draft property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setDraft(Boolean value) { - this.draft = value; - } + /** + * Sets the value of the draft property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setDraft(Boolean value) { + this.draft = value; + } - /** - * Gets the value of the identityType property. - * - * @return - * possible object is - * {@link IdentityType } - * - */ - public IdentityType getIdentityType() { - return identityType; - } + /** + * Gets the value of the identityType property. + * + * @return possible object is + * {@link IdentityType } + */ + public IdentityType getIdentityType() { + return identityType; + } - /** - * Sets the value of the identityType property. - * - * @param value - * allowed object is - * {@link IdentityType } - * - */ - public void setIdentityType(IdentityType value) { - this.identityType = value; - } + /** + * Sets the value of the identityType property. + * + * @param value allowed object is + * {@link IdentityType } + */ + public void setIdentityType(IdentityType value) { + this.identityType = value; + } - /** - * Gets the value of the sequenceName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSequenceName() { - return sequenceName; - } + /** + * Gets the value of the sequenceName property. + * + * @return possible object is + * {@link String } + */ + public String getSequenceName() { + return sequenceName; + } - /** - * Sets the value of the sequenceName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSequenceName(String value) { - this.sequenceName = value; - } + /** + * Sets the value of the sequenceName property. + * + * @param value allowed object is + * {@link String } + */ + public void setSequenceName(String value) { + this.sequenceName = value; + } - /** - * Gets the value of the sequenceInitial property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getSequenceInitial() { - return sequenceInitial; - } + /** + * Gets the value of the sequenceInitial property. + * + * @return possible object is + * {@link BigInteger } + */ + public BigInteger getSequenceInitial() { + return sequenceInitial; + } - /** - * Sets the value of the sequenceInitial property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setSequenceInitial(BigInteger value) { - this.sequenceInitial = value; - } + /** + * Sets the value of the sequenceInitial property. + * + * @param value allowed object is + * {@link BigInteger } + */ + public void setSequenceInitial(BigInteger value) { + this.sequenceInitial = value; + } - /** - * Gets the value of the sequenceAllocate property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getSequenceAllocate() { - return sequenceAllocate; - } + /** + * Gets the value of the sequenceAllocate property. + * + * @return possible object is + * {@link BigInteger } + */ + public BigInteger getSequenceAllocate() { + return sequenceAllocate; + } - /** - * Sets the value of the sequenceAllocate property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setSequenceAllocate(BigInteger value) { - this.sequenceAllocate = value; - } + /** + * Sets the value of the sequenceAllocate property. + * + * @param value allowed object is + * {@link BigInteger } + */ + public void setSequenceAllocate(BigInteger value) { + this.sequenceAllocate = value; + } - /** - * Gets the value of the pkName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPkName() { - return pkName; - } + /** + * Gets the value of the pkName property. + * + * @return possible object is + * {@link String } + */ + public String getPkName() { + return pkName; + } - /** - * Sets the value of the pkName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPkName(String value) { - this.pkName = value; - } + /** + * Sets the value of the pkName property. + * + * @param value allowed object is + * {@link String } + */ + public void setPkName(String value) { + this.pkName = value; + } - /** - * Gets the value of the tablespace property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTablespace() { - return tablespace; - } + /** + * Gets the value of the tablespace property. + * + * @return possible object is + * {@link String } + */ + public String getTablespace() { + return tablespace; + } - /** - * Sets the value of the tablespace property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTablespace(String value) { - this.tablespace = value; - } + /** + * Sets the value of the tablespace property. + * + * @param value allowed object is + * {@link String } + */ + public void setTablespace(String value) { + this.tablespace = value; + } - /** - * Gets the value of the indexTablespace property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexTablespace() { - return indexTablespace; - } + /** + * Gets the value of the indexTablespace property. + * + * @return possible object is + * {@link String } + */ + public String getIndexTablespace() { + return indexTablespace; + } - /** - * Sets the value of the indexTablespace property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexTablespace(String value) { - this.indexTablespace = value; - } + /** + * Sets the value of the indexTablespace property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexTablespace(String value) { + this.indexTablespace = value; + } - /** - * Gets the value of the comment property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getComment() { - return comment; - } + /** + * Gets the value of the comment property. + * + * @return possible object is + * {@link String } + */ + public String getComment() { + return comment; + } - /** - * Sets the value of the comment property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setComment(String value) { - this.comment = value; - } + /** + * Sets the value of the comment property. + * + * @param value allowed object is + * {@link String } + */ + public void setComment(String value) { + this.comment = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java index 5beaf7555..f90124787 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DefaultTablespace.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "defaultTablespace") public class DefaultTablespace { - @XmlAttribute(name = "tables") - protected String tables; - @XmlAttribute(name = "indexes") - protected String indexes; - @XmlAttribute(name = "history") - protected String history; + @XmlAttribute(name = "tables") + protected String tables; + @XmlAttribute(name = "indexes") + protected String indexes; + @XmlAttribute(name = "history") + protected String history; - /** - * Gets the value of the tables property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTables() { - return tables; - } + /** + * Gets the value of the tables property. + * + * @return possible object is + * {@link String } + */ + public String getTables() { + return tables; + } - /** - * Sets the value of the tables property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTables(String value) { - this.tables = value; - } + /** + * Sets the value of the tables property. + * + * @param value allowed object is + * {@link String } + */ + public void setTables(String value) { + this.tables = value; + } - /** - * Gets the value of the indexes property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexes() { - return indexes; - } + /** + * Gets the value of the indexes property. + * + * @return possible object is + * {@link String } + */ + public String getIndexes() { + return indexes; + } - /** - * Sets the value of the indexes property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexes(String value) { - this.indexes = value; - } + /** + * Sets the value of the indexes property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexes(String value) { + this.indexes = value; + } - /** - * Gets the value of the history property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getHistory() { - return history; - } + /** + * Gets the value of the history property. + * + * @return possible object is + * {@link String } + */ + public String getHistory() { + return history; + } - /** - * Sets the value of the history property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setHistory(String value) { - this.history = value; - } + /** + * Sets the value of the history property. + * + * @param value allowed object is + * {@link String } + */ + public void setHistory(String value) { + this.history = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java index 03d42b2bf..f4c9d1ae2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -24,91 +23,77 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropColumn") public class DropColumn { - @XmlAttribute(name = "columnName", required = true) - protected String columnName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "withHistory") - protected Boolean withHistory; + @XmlAttribute(name = "columnName", required = true) + protected String columnName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "withHistory") + protected Boolean withHistory; - /** - * Gets the value of the columnName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnName() { - return columnName; - } + /** + * Gets the value of the columnName property. + * + * @return possible object is + * {@link String } + */ + public String getColumnName() { + return columnName; + } - /** - * Sets the value of the columnName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnName(String value) { - this.columnName = value; - } + /** + * Sets the value of the columnName property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnName(String value) { + this.columnName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the withHistory property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isWithHistory() { - return withHistory; - } + /** + * Gets the value of the withHistory property. + * + * @return possible object is + * {@link Boolean } + */ + public Boolean isWithHistory() { + return withHistory; + } - /** - * Sets the value of the withHistory property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setWithHistory(Boolean value) { - this.withHistory = value; - } + /** + * Sets the value of the withHistory property. + * + * @param value allowed object is + * {@link Boolean } + */ + public void setWithHistory(Boolean value) { + this.withHistory = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java index e2ad3f4b8..e50ba686c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropHistoryTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropHistoryTable") public class DropHistoryTable { - @XmlAttribute(name = "baseTable", required = true) - protected String baseTable; + @XmlAttribute(name = "baseTable", required = true) + protected String baseTable; - /** - * Gets the value of the baseTable property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBaseTable() { - return baseTable; - } + /** + * Gets the value of the baseTable property. + * + * @return possible object is + * {@link String } + */ + public String getBaseTable() { + return baseTable; + } - /** - * Sets the value of the baseTable property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBaseTable(String value) { - this.baseTable = value; - } + /** + * Sets the value of the baseTable property. + * + * @param value allowed object is + * {@link String } + */ + public void setBaseTable(String value) { + this.baseTable = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java index 14e97d3a2..c3ffeb583 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropIndex.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropIndex") public class DropIndex { - @XmlAttribute(name = "indexName", required = true) - protected String indexName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; + @XmlAttribute(name = "indexName", required = true) + protected String indexName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java index fe24e36af..47330c14b 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/DropTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -22,39 +21,33 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "dropTable") public class DropTable { - @XmlAttribute(name = "name", required = true) - protected String name; + @XmlAttribute(name = "name", required = true) + protected String name; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java index 7963c73d6..63a1f1ea2 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ForeignKey.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,143 +25,121 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "foreignKey") public class ForeignKey { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "columnNames", required = true) - protected String columnNames; - @XmlAttribute(name = "refColumnNames", required = true) - protected String refColumnNames; - @XmlAttribute(name = "refTableName", required = true) - protected String refTableName; - @XmlAttribute(name = "indexName") - protected String indexName; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "columnNames", required = true) + protected String columnNames; + @XmlAttribute(name = "refColumnNames", required = true) + protected String refColumnNames; + @XmlAttribute(name = "refTableName", required = true) + protected String refTableName; + @XmlAttribute(name = "indexName") + protected String indexName; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the columnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnNames() { - return columnNames; - } + /** + * Gets the value of the columnNames property. + * + * @return possible object is + * {@link String } + */ + public String getColumnNames() { + return columnNames; + } - /** - * Sets the value of the columnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnNames(String value) { - this.columnNames = value; - } + /** + * Sets the value of the columnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnNames(String value) { + this.columnNames = value; + } - /** - * Gets the value of the refColumnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRefColumnNames() { - return refColumnNames; - } + /** + * Gets the value of the refColumnNames property. + * + * @return possible object is + * {@link String } + */ + public String getRefColumnNames() { + return refColumnNames; + } - /** - * Sets the value of the refColumnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRefColumnNames(String value) { - this.refColumnNames = value; - } + /** + * Sets the value of the refColumnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setRefColumnNames(String value) { + this.refColumnNames = value; + } - /** - * Gets the value of the refTableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRefTableName() { - return refTableName; - } + /** + * Gets the value of the refTableName property. + * + * @return possible object is + * {@link String } + */ + public String getRefTableName() { + return refTableName; + } - /** - * Sets the value of the refTableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRefTableName(String value) { - this.refTableName = value; - } + /** + * Sets the value of the refTableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setRefTableName(String value) { + this.refTableName = value; + } - /** - * Gets the value of the indexName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIndexName() { - return indexName; - } + /** + * Gets the value of the indexName property. + * + * @return possible object is + * {@link String } + */ + public String getIndexName() { + return indexName; + } - /** - * Sets the value of the indexName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIndexName(String value) { - this.indexName = value; - } + /** + * Sets the value of the indexName property. + * + * @param value allowed object is + * {@link String } + */ + public void setIndexName(String value) { + this.indexName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java b/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java index 042346cc8..97b2a542a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/IdentityType.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlEnum; @@ -8,7 +7,7 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for identityType. - * + *

*

The following schema fragment specifies the expected content contained within this class. *

*

@@ -22,39 +21,38 @@ import javax.xml.bind.annotation.XmlType;
  *   </restriction>
  * </simpleType>
  * 
- * */ @XmlType(name = "identityType") @XmlEnum public enum IdentityType { - @XmlEnumValue("identity") - IDENTITY("identity"), - @XmlEnumValue("sequence") - SEQUENCE("sequence"), - @XmlEnumValue("generator") - GENERATOR("generator"), - @XmlEnumValue("external") - EXTERNAL("external"), - @XmlEnumValue("default") - DEFAULT("default"); - private final String value; + @XmlEnumValue("identity") + IDENTITY("identity"), + @XmlEnumValue("sequence") + SEQUENCE("sequence"), + @XmlEnumValue("generator") + GENERATOR("generator"), + @XmlEnumValue("external") + EXTERNAL("external"), + @XmlEnumValue("default") + DEFAULT("default"); + private final String value; - IdentityType(String v) { - value = v; - } + IdentityType(String v) { + value = v; + } - public String value() { - return value; - } + public String value() { + return value; + } - public static IdentityType fromValue(String v) { - for (IdentityType c: IdentityType.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + public static IdentityType fromValue(String v) { + for (IdentityType c : IdentityType.values()) { + if (c.value.equals(v)) { + return c; + } } + throw new IllegalArgumentException(v); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java index 611987e0d..0277a79c0 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Migration.java @@ -1,20 +1,19 @@ - package com.avaje.ebean.dbmigration.migration; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "changeSet" + "changeSet" }) @XmlRootElement(name = "migration") public class Migration { - @XmlElement(required = true) - protected List changeSet; + @XmlElement(required = true) + protected List changeSet; - /** - * Gets the value of the changeSet property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the changeSet property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getChangeSet().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link ChangeSet } - * - * - */ - public List getChangeSet() { - if (changeSet == null) { - changeSet = new ArrayList<>(); - } - return this.changeSet; + /** + * Gets the value of the changeSet property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the changeSet property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getChangeSet().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link ChangeSet } + */ + public List getChangeSet() { + if (changeSet == null) { + changeSet = new ArrayList<>(); } + return this.changeSet; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java index 632e62006..0f064b3a6 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/ObjectFactory.java @@ -1,216 +1,190 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebean.dbmigration.migration package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebean.dbmigration.migration package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebean.dbmigration.migration - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebean.dbmigration.migration + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link Rollback } - * - */ - public Rollback createRollback() { - return new Rollback(); - } + /** + * Create an instance of {@link Rollback } + */ + public Rollback createRollback() { + return new Rollback(); + } - /** - * Create an instance of {@link AddColumn } - * - */ - public AddColumn createAddColumn() { - return new AddColumn(); - } + /** + * Create an instance of {@link AddColumn } + */ + public AddColumn createAddColumn() { + return new AddColumn(); + } - /** - * Create an instance of {@link Column } - * - */ - public Column createColumn() { - return new Column(); - } + /** + * Create an instance of {@link Column } + */ + public Column createColumn() { + return new Column(); + } - /** - * Create an instance of {@link CreateTable } - * - */ - public CreateTable createCreateTable() { - return new CreateTable(); - } + /** + * Create an instance of {@link CreateTable } + */ + public CreateTable createCreateTable() { + return new CreateTable(); + } - /** - * Create an instance of {@link UniqueConstraint } - * - */ - public UniqueConstraint createUniqueConstraint() { - return new UniqueConstraint(); - } + /** + * Create an instance of {@link UniqueConstraint } + */ + public UniqueConstraint createUniqueConstraint() { + return new UniqueConstraint(); + } - /** - * Create an instance of {@link ForeignKey } - * - */ - public ForeignKey createForeignKey() { - return new ForeignKey(); - } + /** + * Create an instance of {@link ForeignKey } + */ + public ForeignKey createForeignKey() { + return new ForeignKey(); + } - /** - * Create an instance of {@link Apply } - * - */ - public Apply createApply() { - return new Apply(); - } + /** + * Create an instance of {@link Apply } + */ + public Apply createApply() { + return new Apply(); + } - /** - * Create an instance of {@link Configuration } - * - */ - public Configuration createConfiguration() { - return new Configuration(); - } + /** + * Create an instance of {@link Configuration } + */ + public Configuration createConfiguration() { + return new Configuration(); + } - /** - * Create an instance of {@link DefaultTablespace } - * - */ - public DefaultTablespace createDefaultTablespace() { - return new DefaultTablespace(); - } + /** + * Create an instance of {@link DefaultTablespace } + */ + public DefaultTablespace createDefaultTablespace() { + return new DefaultTablespace(); + } - /** - * Create an instance of {@link AddTableComment } - * - */ - public AddTableComment createAddTableComment() { - return new AddTableComment(); - } + /** + * Create an instance of {@link AddTableComment } + */ + public AddTableComment createAddTableComment() { + return new AddTableComment(); + } - /** - * Create an instance of {@link RenameTable } - * - */ - public RenameTable createRenameTable() { - return new RenameTable(); - } + /** + * Create an instance of {@link RenameTable } + */ + public RenameTable createRenameTable() { + return new RenameTable(); + } - /** - * Create an instance of {@link DropHistoryTable } - * - */ - public DropHistoryTable createDropHistoryTable() { - return new DropHistoryTable(); - } + /** + * Create an instance of {@link DropHistoryTable } + */ + public DropHistoryTable createDropHistoryTable() { + return new DropHistoryTable(); + } - /** - * Create an instance of {@link AlterColumn } - * - */ - public AlterColumn createAlterColumn() { - return new AlterColumn(); - } + /** + * Create an instance of {@link AlterColumn } + */ + public AlterColumn createAlterColumn() { + return new AlterColumn(); + } - /** - * Create an instance of {@link DropColumn } - * - */ - public DropColumn createDropColumn() { - return new DropColumn(); - } + /** + * Create an instance of {@link DropColumn } + */ + public DropColumn createDropColumn() { + return new DropColumn(); + } - /** - * Create an instance of {@link CreateIndex } - * - */ - public CreateIndex createCreateIndex() { - return new CreateIndex(); - } + /** + * Create an instance of {@link CreateIndex } + */ + public CreateIndex createCreateIndex() { + return new CreateIndex(); + } - /** - * Create an instance of {@link ChangeSet } - * - */ - public ChangeSet createChangeSet() { - return new ChangeSet(); - } + /** + * Create an instance of {@link ChangeSet } + */ + public ChangeSet createChangeSet() { + return new ChangeSet(); + } - /** - * Create an instance of {@link Sql } - * - */ - public Sql createSql() { - return new Sql(); - } + /** + * Create an instance of {@link Sql } + */ + public Sql createSql() { + return new Sql(); + } - /** - * Create an instance of {@link DropTable } - * - */ - public DropTable createDropTable() { - return new DropTable(); - } + /** + * Create an instance of {@link DropTable } + */ + public DropTable createDropTable() { + return new DropTable(); + } - /** - * Create an instance of {@link AddHistoryTable } - * - */ - public AddHistoryTable createAddHistoryTable() { - return new AddHistoryTable(); - } + /** + * Create an instance of {@link AddHistoryTable } + */ + public AddHistoryTable createAddHistoryTable() { + return new AddHistoryTable(); + } - /** - * Create an instance of {@link RenameColumn } - * - */ - public RenameColumn createRenameColumn() { - return new RenameColumn(); - } + /** + * Create an instance of {@link RenameColumn } + */ + public RenameColumn createRenameColumn() { + return new RenameColumn(); + } - /** - * Create an instance of {@link DropIndex } - * - */ - public DropIndex createDropIndex() { - return new DropIndex(); - } + /** + * Create an instance of {@link DropIndex } + */ + public DropIndex createDropIndex() { + return new DropIndex(); + } - /** - * Create an instance of {@link AlterHistoryTable } - * - */ - public AlterHistoryTable createAlterHistoryTable() { - return new AlterHistoryTable(); - } + /** + * Create an instance of {@link AlterHistoryTable } + */ + public AlterHistoryTable createAlterHistoryTable() { + return new AlterHistoryTable(); + } - /** - * Create an instance of {@link Migration } - * - */ - public Migration createMigration() { - return new Migration(); - } + /** + * Create an instance of {@link Migration } + */ + public Migration createMigration() { + return new Migration(); + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java index 00e1b30f4..0b9711f51 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameColumn.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,117 +24,99 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "renameColumn") public class RenameColumn { - @XmlAttribute(name = "oldName", required = true) - protected String oldName; - @XmlAttribute(name = "newName", required = true) - protected String newName; - @XmlAttribute(name = "tableName", required = true) - protected String tableName; - @XmlAttribute(name = "dataType") - protected String dataType; + @XmlAttribute(name = "oldName", required = true) + protected String oldName; + @XmlAttribute(name = "newName", required = true) + protected String newName; + @XmlAttribute(name = "tableName", required = true) + protected String tableName; + @XmlAttribute(name = "dataType") + protected String dataType; - /** - * Gets the value of the oldName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOldName() { - return oldName; - } + /** + * Gets the value of the oldName property. + * + * @return possible object is + * {@link String } + */ + public String getOldName() { + return oldName; + } - /** - * Sets the value of the oldName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOldName(String value) { - this.oldName = value; - } + /** + * Sets the value of the oldName property. + * + * @param value allowed object is + * {@link String } + */ + public void setOldName(String value) { + this.oldName = value; + } - /** - * Gets the value of the newName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNewName() { - return newName; - } + /** + * Gets the value of the newName property. + * + * @return possible object is + * {@link String } + */ + public String getNewName() { + return newName; + } - /** - * Sets the value of the newName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNewName(String value) { - this.newName = value; - } + /** + * Sets the value of the newName property. + * + * @param value allowed object is + * {@link String } + */ + public void setNewName(String value) { + this.newName = value; + } - /** - * Gets the value of the tableName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTableName() { - return tableName; - } + /** + * Gets the value of the tableName property. + * + * @return possible object is + * {@link String } + */ + public String getTableName() { + return tableName; + } - /** - * Sets the value of the tableName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTableName(String value) { - this.tableName = value; - } + /** + * Sets the value of the tableName property. + * + * @param value allowed object is + * {@link String } + */ + public void setTableName(String value) { + this.tableName = value; + } - /** - * Gets the value of the dataType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDataType() { - return dataType; - } + /** + * Gets the value of the dataType property. + * + * @return possible object is + * {@link String } + */ + public String getDataType() { + return dataType; + } - /** - * Sets the value of the dataType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDataType(String value) { - this.dataType = value; - } + /** + * Sets the value of the dataType property. + * + * @param value allowed object is + * {@link String } + */ + public void setDataType(String value) { + this.dataType = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java index aca4f7f88..3a4c83623 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/RenameTable.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "renameTable") public class RenameTable { - @XmlAttribute(name = "oldName", required = true) - protected String oldName; - @XmlAttribute(name = "newName", required = true) - protected String newName; + @XmlAttribute(name = "oldName", required = true) + protected String oldName; + @XmlAttribute(name = "newName", required = true) + protected String newName; - /** - * Gets the value of the oldName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOldName() { - return oldName; - } + /** + * Gets the value of the oldName property. + * + * @return possible object is + * {@link String } + */ + public String getOldName() { + return oldName; + } - /** - * Sets the value of the oldName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOldName(String value) { - this.oldName = value; - } + /** + * Sets the value of the oldName property. + * + * @param value allowed object is + * {@link String } + */ + public void setOldName(String value) { + this.oldName = value; + } - /** - * Gets the value of the newName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNewName() { - return newName; - } + /** + * Gets the value of the newName property. + * + * @return possible object is + * {@link String } + */ + public String getNewName() { + return newName; + } - /** - * Sets the value of the newName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNewName(String value) { - this.newName = value; - } + /** + * Sets the value of the newName property. + * + * @param value allowed object is + * {@link String } + */ + public void setNewName(String value) { + this.newName = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java index 9779712a9..3d9c18d32 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Rollback.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -21,41 +20,35 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "rollback") public class Rollback { - @XmlValue - protected String value; + @XmlValue + protected String value; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java b/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java index 534536ddc..f2a951d7c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/Sql.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -25,68 +24,58 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "apply", - "rollback" + "apply", + "rollback" }) @XmlRootElement(name = "sql") public class Sql { - @XmlElement(required = true) - protected Apply apply; - @XmlElement(required = true) - protected Rollback rollback; + @XmlElement(required = true) + protected Apply apply; + @XmlElement(required = true) + protected Rollback rollback; - /** - * Gets the value of the apply property. - * - * @return - * possible object is - * {@link Apply } - * - */ - public Apply getApply() { - return apply; - } + /** + * Gets the value of the apply property. + * + * @return possible object is + * {@link Apply } + */ + public Apply getApply() { + return apply; + } - /** - * Sets the value of the apply property. - * - * @param value - * allowed object is - * {@link Apply } - * - */ - public void setApply(Apply value) { - this.apply = value; - } + /** + * Sets the value of the apply property. + * + * @param value allowed object is + * {@link Apply } + */ + public void setApply(Apply value) { + this.apply = value; + } - /** - * Gets the value of the rollback property. - * - * @return - * possible object is - * {@link Rollback } - * - */ - public Rollback getRollback() { - return rollback; - } + /** + * Gets the value of the rollback property. + * + * @return possible object is + * {@link Rollback } + */ + public Rollback getRollback() { + return rollback; + } - /** - * Sets the value of the rollback property. - * - * @param value - * allowed object is - * {@link Rollback } - * - */ - public void setRollback(Rollback value) { - this.rollback = value; - } + /** + * Sets the value of the rollback property. + * + * @param value allowed object is + * {@link Rollback } + */ + public void setRollback(Rollback value) { + this.rollback = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java b/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java index f560218cc..0301e9a4a 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migration/UniqueConstraint.java @@ -1,4 +1,3 @@ - package com.avaje.ebean.dbmigration.migration; import javax.xml.bind.annotation.XmlAccessType; @@ -10,9 +9,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -23,65 +22,55 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "uniqueConstraint") public class UniqueConstraint { - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "columnNames", required = true) - protected String columnNames; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "columnNames", required = true) + protected String columnNames; - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the columnNames property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getColumnNames() { - return columnNames; - } + /** + * Gets the value of the columnNames property. + * + * @return possible object is + * {@link String } + */ + public String getColumnNames() { + return columnNames; + } - /** - * Sets the value of the columnNames property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setColumnNames(String value) { - this.columnNames = value; - } + /** + * Sets the value of the columnNames property. + * + * @param value allowed object is + * {@link String } + */ + public void setColumnNames(String value) { + this.columnNames = value; + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java index 68e67323f..055ae7918 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java +++ b/src/main/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlReader.java @@ -16,8 +16,9 @@ import java.io.InputStream; */ public class MigrationXmlReader { - private MigrationXmlReader() {} - + private MigrationXmlReader() { + } + /** * Read and return a Migration from an xml document at the given resource path. */ diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java index 99dd89acf..1b3949a5e 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/CurrentModel.java @@ -85,7 +85,7 @@ public class CurrentModel { } public void setChangeSet(ChangeSet changeSet) { - this.changeSet = changeSet; + this.changeSet = changeSet; } /** diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java index 2bd087eb1..3d13e20ef 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MCompoundUniqueConstraint.java @@ -3,8 +3,8 @@ package com.avaje.ebean.dbmigration.model; /** * A unique constraint for multiple columns. *

- * Note that unique constraint on a single column is instead - * a boolean flag on the associated MColumn. + * Note that unique constraint on a single column is instead + * a boolean flag on the associated MColumn. *

*/ public class MCompoundUniqueConstraint { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java b/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java index f6165a670..1c24a7650 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MConfiguration.java @@ -27,8 +27,8 @@ public class MConfiguration { /** * Apply the migration configuration. *

- * It is expected that these are applied in the correct chronological order - * from earliest to latest. + * It is expected that these are applied in the correct chronological order + * from earliest to latest. *

*/ public void apply(Configuration configuration) { diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java index f23614ead..8c1eeea99 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MTable.java @@ -126,7 +126,7 @@ public class MTable { /** * Create a copy of this table structure as a 'draft' table. - * + *

* Note that both tables contain @DraftOnly MColumns and these are filtered out * later when creating the CreateTable object. */ diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java index 17b27e751..ba4bccaa3 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/MigrationModel.java @@ -4,7 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.FileFilter; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -46,14 +45,14 @@ public class MigrationModel { List resources = new ArrayList<>(); - for (File xmlFile: xmlFiles) { + for (File xmlFile : xmlFiles) { resources.add(new MigrationResource(xmlFile, createVersion(xmlFile))); } // sort into version order before applying Collections.sort(resources); - for (MigrationResource migrationResource: resources) { + for (MigrationResource migrationResource : resources) { logger.debug("read {}", migrationResource); model.apply(migrationResource.read(), migrationResource.getVersion()); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java index 1870ff332..1b0dbadf3 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/ModelContainer.java @@ -307,7 +307,7 @@ public class ModelContainer { MTable table = getTable(dropColumn.getTableName()); if (table == null) { - throw new IllegalArgumentException("Table ["+dropColumn.getTableName()+"] not found?"); + throw new IllegalArgumentException("Table [" + dropColumn.getTableName() + "] not found?"); } table.registerPendingDropColumn(dropColumn.getColumnName()); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java index 5a2875487..456202cec 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/PendingDrops.java @@ -86,7 +86,7 @@ public class PendingDrops { } if (migration.getChangeSet().isEmpty()) { - throw new IllegalArgumentException("The remaining pendingDrops changeSets in migration ["+pendingVersion+"] are suppressDropsForever=true and can't be applied"); + throw new IllegalArgumentException("The remaining pendingDrops changeSets in migration [" + pendingVersion + "] are suppressDropsForever=true and can't be applied"); } if (!entry.containsSuppressForever()) { @@ -206,10 +206,10 @@ public class PendingDrops { Iterator iterator = pending.iterator(); while (iterator.hasNext()) { Object pendingDrop = iterator.next(); - if (pendingDrop instanceof DropColumn && dropColumnIn((DropColumn)pendingDrop, appliedDrops)) { + if (pendingDrop instanceof DropColumn && dropColumnIn((DropColumn) pendingDrop, appliedDrops)) { iterator.remove(); - } else if (pendingDrop instanceof DropTable && dropTableIn((DropTable)pendingDrop, appliedDrops)) { + } else if (pendingDrop instanceof DropTable && dropTableIn((DropTable) pendingDrop, appliedDrops)) { iterator.remove(); } } @@ -220,7 +220,7 @@ public class PendingDrops { */ private boolean dropTableIn(DropTable pendingDrop, ChangeSet appliedDrops) { for (Object o : appliedDrops.getChangeSetChildren()) { - if (o instanceof DropTable && sameTable(pendingDrop, (DropTable)o)) { + if (o instanceof DropTable && sameTable(pendingDrop, (DropTable) o)) { return true; } } @@ -251,7 +251,7 @@ public class PendingDrops { */ private boolean sameColumn(DropColumn pending, DropColumn o) { return pending.getColumnName().equals(o.getColumnName()) - && pending.getTableName().equals(o.getTableName()); + && pending.getTableName().equals(o.getTableName()); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java b/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java index 1a6f3f965..3c65d0920 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/PlatformDdlWriter.java @@ -83,7 +83,7 @@ public class PlatformDdlWriter { protected FileWriter createWriter(File path, String fullVersion, String suffix) throws IOException { - File applyFile = new File(path, fullVersion + suffix); + File applyFile = new File(path, fullVersion + suffix); return new FileWriter(applyFile); } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java index e18c53356..f891798ab 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildContext.java @@ -165,7 +165,7 @@ public class ModelBuildContext { int ixCount = 0; int uqCount = 0; Collection cols = draftTable.allColumns(); - for (MColumn col: cols) { + for (MColumn col : cols) { if (col.getForeignKeyName() != null) { // Note that we adjust the 'references' table later in a second pass // after we know all the tables that are 'draftable' @@ -176,10 +176,10 @@ public class ModelBuildContext { col.setForeignKeyIndex(foreignKeyIndexName(draftTable.getName(), indexCols, ++ixCount)); } // adjust the unique constraint names - if (col.getUnique() != null){ + if (col.getUnique() != null) { col.setUnique(uniqueConstraintName(draftTable.getName(), col.getName(), ++uqCount)); } - if (col.getUniqueOneToOne() != null){ + if (col.getUniqueOneToOne() != null) { col.setUniqueOneToOne(uniqueConstraintName(draftTable.getName(), col.getName(), ++uqCount)); } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java index 27f38d287..4dde64375 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildIntersectionTable.java @@ -15,22 +15,22 @@ import com.avaje.ebeaninternal.server.deploy.TableJoinColumn; */ public class ModelBuildIntersectionTable { - private final ModelBuildContext ctx; + private final ModelBuildContext ctx; - private final BeanPropertyAssocMany manyProp; - private final TableJoin intersectionTableJoin; - private final TableJoin tableJoin; + private final BeanPropertyAssocMany manyProp; + private final TableJoin intersectionTableJoin; + private final TableJoin tableJoin; private MTable intersectionTable; private int countForeignKey; - public ModelBuildIntersectionTable(ModelBuildContext ctx, BeanPropertyAssocMany manyProp) { - this.ctx = ctx; - this.manyProp = manyProp; - this.intersectionTableJoin = manyProp.getIntersectionTableJoin(); - this.tableJoin = manyProp.getTableJoin(); - } + public ModelBuildIntersectionTable(ModelBuildContext ctx, BeanPropertyAssocMany manyProp) { + this.ctx = ctx; + this.manyProp = manyProp; + this.intersectionTableJoin = manyProp.getIntersectionTableJoin(); + this.tableJoin = manyProp.getTableJoin(); + } public void build() { @@ -38,7 +38,7 @@ public class ModelBuildIntersectionTable { MTable existingTable = ctx.addTable(intersectionTable); if (existingTable != null) { throw new IllegalStateException("Property " + manyProp.getFullBeanName() + " has duplicate ManyToMany intersection table " + intersectionTable.getName() - + ". Please use @JoinTable to define unique table to use"); + + ". Please use @JoinTable to define unique table to use"); } buildFkConstraints(); @@ -47,21 +47,21 @@ public class ModelBuildIntersectionTable { ctx.createDraft(intersectionTable, false); } - } + } - private void buildFkConstraints() { + private void buildFkConstraints() { - BeanDescriptor localDesc = manyProp.getBeanDescriptor(); - buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); + BeanDescriptor localDesc = manyProp.getBeanDescriptor(); + buildFkConstraints(localDesc, intersectionTableJoin.columns(), true); - BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); - buildFkConstraints(targetDesc, tableJoin.columns(), false); + BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); + buildFkConstraints(targetDesc, tableJoin.columns(), false); intersectionTable.checkDuplicateForeignKeys(); - } + } - private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { + private void buildFkConstraints(BeanDescriptor desc, TableJoinColumn[] columns, boolean direction) { String tableName = intersectionTableJoin.getTable(); String baseTable = ctx.normaliseTable(desc.getBaseTable()); @@ -78,43 +78,43 @@ public class ModelBuildIntersectionTable { } } - private MTable createTable() { + private MTable createTable() { - BeanDescriptor localDesc = manyProp.getBeanDescriptor(); - BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); + BeanDescriptor localDesc = manyProp.getBeanDescriptor(); + BeanDescriptor targetDesc = manyProp.getTargetDescriptor(); String tableName = intersectionTableJoin.getTable(); MTable table = new MTable(tableName); - if (!manyProp.isExcludedFromHistory()) { - if (localDesc.isHistorySupport()) { - table.setWithHistory(true); - } - } + if (!manyProp.isExcludedFromHistory()) { + if (localDesc.isHistorySupport()) { + table.setWithHistory(true); + } + } table.setPkName(ctx.primaryKeyName(tableName)); - TableJoinColumn[] columns = intersectionTableJoin.columns(); + TableJoinColumn[] columns = intersectionTableJoin.columns(); for (TableJoinColumn column : columns) { addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn()); } - TableJoinColumn[] otherColumns = tableJoin.columns(); + TableJoinColumn[] otherColumns = tableJoin.columns(); for (TableJoinColumn otherColumn : otherColumns) { addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn()); } return table; - } + } - private void addColumn(MTable table, BeanDescriptor desc, String column, String findPropColumn) { + private void addColumn(MTable table, BeanDescriptor desc, String column, String findPropColumn) { - BeanProperty p = desc.getIdBinder().findBeanProperty(findPropColumn); - if (p == null) { - throw new RuntimeException("Could not find id property for " + findPropColumn); - } + BeanProperty p = desc.getIdBinder().findBeanProperty(findPropColumn); + if (p == null) { + throw new RuntimeException("Could not find id property for " + findPropColumn); + } MColumn col = new MColumn(column, ctx.getColumnDefn(p, true), true); col.setPrimaryKey(true); table.addColumn(col); - } + } } diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java index 339bec4c5..7fb97ec5c 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/build/ModelBuildPropertyVisitor.java @@ -222,7 +222,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { } @Override - public void visitScalar(BeanProperty p) { + public void visitScalar(BeanProperty p) { if (p.isSecondaryTable()) { lastColumn = null; @@ -262,7 +262,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor { lastColumn = col; table.addColumn(col); - } + } /** * Build the check constraint clause given the db column and values. diff --git a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java index 3483c88d0..44f0fb8c8 100644 --- a/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java +++ b/src/main/java/com/avaje/ebean/dbmigration/model/visitor/BeanVisitor.java @@ -9,10 +9,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; */ public interface BeanVisitor { - /** - * Visit a BeanDescriptor and return a PropertyVisitor to use to visit each + /** + * Visit a BeanDescriptor and return a PropertyVisitor to use to visit each * property on the entity bean (return null to skip visiting this bean). - */ + */ ModelBuildPropertyVisitor visitBean(BeanDescriptor descriptor); } From 99f3bc8c54e7bd7bb4d3c6e6fdf75b70d8fd0c0a Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:14:35 +1300 Subject: [PATCH 79/87] no effective change - format and javadoc --- .../avaje/ebean/event/BeanFindController.java | 4 +- .../ebean/event/BeanPersistController.java | 23 ++- .../ebean/event/BeanPersistListener.java | 32 ++-- .../event/BeanPostConstructListener.java | 8 +- .../com/avaje/ebean/event/BulkTableEvent.java | 2 - .../ebean/event/BulkTableEventListener.java | 8 +- .../ebean/event/ServerConfigStartup.java | 3 - .../ebean/event/changelog/BeanChange.java | 2 +- .../ebean/event/changelog/ChangeSet.java | 6 +- .../java/com/avaje/ebean/event/package.html | 6 +- .../com/avaje/ebean/meta/MetaBeanInfo.java | 4 +- .../com/avaje/ebean/meta/MetaInfoManager.java | 5 +- .../ebean/meta/MetaObjectGraphNodeStats.java | 4 +- .../ebean/meta/MetaQueryPlanOriginCount.java | 4 +- .../ebean/meta/MetaQueryPlanStatistic.java | 2 +- .../avaje/ebean/search/TextCommonTerms.java | 2 - .../avaje/ebean/search/TextQueryString.java | 5 +- .../com/avaje/ebean/search/TextSimple.java | 1 - .../com/avaje/ebean/text/StringFormatter.java | 2 - .../com/avaje/ebean/text/StringParser.java | 3 - .../com/avaje/ebean/text/TextException.java | 2 - .../avaje/ebean/text/TimeStringParser.java | 7 +- .../com/avaje/ebean/text/csv/CsvCallback.java | 30 ++-- .../com/avaje/ebean/text/csv/CsvReader.java | 42 +++-- .../ebean/text/csv/DefaultCsvCallback.java | 8 +- .../java/com/avaje/ebean/text/json/EJson.java | 40 ++--- .../avaje/ebean/text/json/EJsonReader.java | 144 ++++++++++-------- .../avaje/ebean/text/json/EJsonWriter.java | 6 +- .../avaje/ebean/text/json/JsonContext.java | 16 +- .../ebean/text/json/JsonReadOptions.java | 7 +- .../ebean/text/json/JsonWriteBeanVisitor.java | 12 +- .../avaje/ebean/text/json/package-info.java | 29 ++-- .../com/avaje/ebean/util/CamelCaseHelper.java | 6 +- .../java/com/avaje/ebean/util/ClassUtil.java | 2 +- .../com/avaje/ebean/util/StringHelper.java | 113 ++++---------- 35 files changed, 248 insertions(+), 342 deletions(-) diff --git a/src/main/java/com/avaje/ebean/event/BeanFindController.java b/src/main/java/com/avaje/ebean/event/BeanFindController.java index f53eeb602..6d51b8e4f 100644 --- a/src/main/java/com/avaje/ebean/event/BeanFindController.java +++ b/src/main/java/com/avaje/ebean/event/BeanFindController.java @@ -25,7 +25,7 @@ public interface BeanFindController { /** * Return true if this controller should intercept and process this find request. - * + *

* Return false to allow the default behavior to process the request. */ boolean isInterceptFind(BeanQueryRequest request); @@ -37,7 +37,7 @@ public interface BeanFindController { /** * Return true if this controller should intercept and process this findMany request. - * + *

* Return false to allow the default behavior to process the request. */ boolean isInterceptFindMany(BeanQueryRequest request); diff --git a/src/main/java/com/avaje/ebean/event/BeanPersistController.java b/src/main/java/com/avaje/ebean/event/BeanPersistController.java index 6896350d0..69f6f6b68 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPersistController.java +++ b/src/main/java/com/avaje/ebean/event/BeanPersistController.java @@ -11,16 +11,14 @@ package com.avaje.ebean.event; * for the insert, update, delete or fetch. To explicitly use this same * transaction you should use this transaction via methods on EbeanServer. *

- * - *
- * 
- *        Object extaBeanToSave = ...;
- *        Transaction t = request.getTransaction();
- *        EbeanServer server = request.getEbeanServer();
- *        server.save(extraBeanToSave, t);
- * 
- * 
- * + *
{@code
+ *
+ *   Object extaBeanToSave = ...;
+ *   Transaction t = request.getTransaction();
+ *   EbeanServer server = request.getEbeanServer();
+ *   server.save(extraBeanToSave, t);
+ *
+ * }
*

* It is worth noting that BeanPersistListener is different in three main ways * from BeanPersistController postXXX methods. @@ -47,9 +45,8 @@ public interface BeanPersistController { *

* Lowest values are executed first. *

- * - * @return an int used to control the order BeanPersistController's are - * executed + * + * @return an int used to control the order BeanPersistController's are executed */ int getExecutionOrder(); diff --git a/src/main/java/com/avaje/ebean/event/BeanPersistListener.java b/src/main/java/com/avaje/ebean/event/BeanPersistListener.java index ad4c0eb66..94a630b63 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPersistListener.java +++ b/src/main/java/com/avaje/ebean/event/BeanPersistListener.java @@ -17,13 +17,13 @@ import java.util.Set; * from BeanPersistController postXXX methods. *
    *
  • - * BeanPersistListener only sees successfully committed events. - * BeanPersistController pre and post methods occur before the commit or a - * rollback and will see events that are later rolled back + * BeanPersistListener only sees successfully committed events. + * BeanPersistController pre and post methods occur before the commit or a + * rollback and will see events that are later rolled back *
  • *
  • - * BeanPersistListener runs in a background thread and will not effect the - * response time of the actual persist where as BeanPersistController code will + * BeanPersistListener runs in a background thread and will not effect the + * response time of the actual persist where as BeanPersistController code will *
  • *
*

@@ -31,6 +31,7 @@ import java.util.Set; * A BeanPersistListener is either found automatically via class path search or * can be added programmatically via {@link ServerConfig#add(BeanPersistListener)}}. *

+ * * @see ServerConfig#add(BeanPersistListener) */ public interface BeanPersistListener { @@ -43,35 +44,30 @@ public interface BeanPersistListener { /** * Notified that a bean has been inserted. - * - * @param bean - * The bean that was inserted. + * + * @param bean The bean that was inserted. */ void inserted(Object bean); /** * Notified that a bean has been updated. - * - * @param bean - * The bean that was updated. - * @param updatedProperties - * The properties that were modified by this update. + * + * @param bean The bean that was updated. + * @param updatedProperties The properties that were modified by this update. */ void updated(Object bean, Set updatedProperties); /** * Notified that a bean has been deleted. - * - * @param bean - * The bean that was deleted. + * + * @param bean The bean that was deleted. */ void deleted(Object bean); /** * Notified that a bean has been soft deleted. * - * @param bean - * The bean that was soft deleted. + * @param bean The bean that was soft deleted. */ void softDeleted(Object bean); diff --git a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java index c1b4cca99..55b07de91 100644 --- a/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java +++ b/src/main/java/com/avaje/ebean/event/BeanPostConstructListener.java @@ -5,9 +5,9 @@ import com.avaje.ebean.EbeanServer; /** * Fired after a bean is constructed, but not yet loaded from database. *

- * Note: You MUST NOT set any default values, as in a following step, + * Note: You MUST NOT set any default values, as in a following step, * properties will get unload. Use {@link BeanPostLoad} instead. - * + *

* it's intended to do some dependency-injection here. * If you plan to use this feature you should use {@link EbeanServer#createEntityBean(Class)} * to create new beans. @@ -25,12 +25,12 @@ public interface BeanPostConstructListener { * Called immediately after construction. Perform DI here. */ void autowire(Object bean); - + /** * Called after every @PostConstruct annotated method of the bean is executed */ void postConstruct(Object bean); - + /** * Called after {@link EbeanServer#createEntityBean(Class)}. Only for new beans. * intended to set default values here. diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java index 419e04c9c..5f2bd0c73 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEvent.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEvent.java @@ -2,8 +2,6 @@ package com.avaje.ebean.event; /** * The bulk table event. - * - * @author Robin Bygrave */ public interface BulkTableEvent { diff --git a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java index e3583cf7b..9161488a0 100644 --- a/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java +++ b/src/main/java/com/avaje/ebean/event/BulkTableEventListener.java @@ -1,19 +1,15 @@ package com.avaje.ebean.event; -import java.util.Set; - import com.avaje.ebean.Ebean; +import java.util.Set; + /** * Listen for bulk table events that occur. *

* These events can be triggered via * {@link Ebean#externalModification(String, boolean, boolean, boolean)} or * automatically determined from Ebean bulk update statements. - *

- * - * @author Robin Bygrave - * */ public interface BulkTableEventListener { diff --git a/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java b/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java index 7ac3f0b84..de5b858b1 100644 --- a/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java +++ b/src/main/java/com/avaje/ebean/event/ServerConfigStartup.java @@ -7,9 +7,6 @@ import com.avaje.ebean.config.ServerConfig; *

* Provides a simple way to construct and register multiple listeners and * adapters that need shared services without using DI. - *

- * - * @author Robin Bygrave */ public interface ServerConfigStartup { diff --git a/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java b/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java index 4deb57d00..9bb359121 100644 --- a/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java +++ b/src/main/java/com/avaje/ebean/event/changelog/BeanChange.java @@ -52,7 +52,7 @@ public class BeanChange { } public String toString() { - return "table:" + table + " id:" + id+" values:"+values; + return "table:" + table + " id:" + id + " values:" + values; } /** diff --git a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java index 0285e83cf..4f86166fb 100644 --- a/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java +++ b/src/main/java/com/avaje/ebean/event/changelog/ChangeSet.java @@ -44,7 +44,7 @@ public class ChangeSet { /** * Arbitrary user context information expected to be optionally populated by ChangeLogPrepare. */ - Map userContext; + Map userContext; /** * The bean changes. @@ -180,7 +180,7 @@ public class ChangeSet { /** * Return a user context value - anything you set yourself in ChangeLogListener prepare(). */ - public Map getUserContext() { + public Map getUserContext() { if (userContext == null) { userContext = new LinkedHashMap<>(); } @@ -194,7 +194,7 @@ public class ChangeSet { * in the foreground thread. *

*/ - public void setUserContext(Map userContext) { + public void setUserContext(Map userContext) { this.userContext = userContext; } diff --git a/src/main/java/com/avaje/ebean/event/package.html b/src/main/java/com/avaje/ebean/event/package.html index 83dea44fa..3a984105d 100644 --- a/src/main/java/com/avaje/ebean/event/package.html +++ b/src/main/java/com/avaje/ebean/event/package.html @@ -1,10 +1,10 @@ - - Persist and Query Event Controllers and Listeners + + Persist and Query Event Controllers and Listeners Persist and Query Event Controllers and Listeners - \ No newline at end of file + diff --git a/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java b/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java index 3059dc368..d5fa97fe5 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java +++ b/src/main/java/com/avaje/ebean/meta/MetaBeanInfo.java @@ -8,10 +8,10 @@ public interface MetaBeanInfo { * Collect the current query plan statistics return the non-empty statistics. */ List collectQueryPlanStatistics(boolean reset); - + /** * Collect the current query plan statistics return all the statistics (include query plans that haven't had query executions). - */ + */ List collectAllQueryPlanStatistics(boolean reset); } diff --git a/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java b/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java index 795b1a999..cddda6663 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java +++ b/src/main/java/com/avaje/ebean/meta/MetaInfoManager.java @@ -33,9 +33,8 @@ public interface MetaInfoManager { * This is used to look at the amount of lazy loading occurring for a given * query origin point and highlight potential for tuning a query. *

- * - * @param reset - * Set to true to reset the underlying statistics after collection. + * + * @param reset Set to true to reset the underlying statistics after collection. */ List collectNodeStatistics(boolean reset); diff --git a/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java b/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java index 4ed1934d3..9a70d302f 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java +++ b/src/main/java/com/avaje/ebean/meta/MetaObjectGraphNodeStats.java @@ -8,7 +8,7 @@ import com.avaje.ebean.bean.ObjectGraphNode; * These statistics can be used to identify origin queries that result in lots * of lazy loading. *

- * + * * @see MetaInfoManager#collectNodeStatistics(boolean) */ public interface MetaObjectGraphNodeStats { @@ -38,4 +38,4 @@ public interface MetaObjectGraphNodeStats { */ long getTotalBeans(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java index 84caeb727..0c8040e84 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java +++ b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanOriginCount.java @@ -9,7 +9,7 @@ import com.avaje.ebean.bean.ObjectGraphNode; * This basically points to the bit of original code and query that results in * this query directly or via lazy loading. *

- * + * * @see MetaQueryPlanStatistic * @see MetaInfoManager#collectQueryPlanStatistics(boolean) */ @@ -30,4 +30,4 @@ public interface MetaQueryPlanOriginCount { */ long getCount(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java index 371ba6a28..54a771fd0 100644 --- a/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java +++ b/src/main/java/com/avaje/ebean/meta/MetaQueryPlanStatistic.java @@ -4,7 +4,7 @@ import java.util.List; /** * Query execution statistics Meta data. - * + * * @see MetaInfoManager#collectQueryPlanStatistics(boolean) */ public interface MetaQueryPlanStatistic { diff --git a/src/main/java/com/avaje/ebean/search/TextCommonTerms.java b/src/main/java/com/avaje/ebean/search/TextCommonTerms.java index c1cad820a..36d50fd29 100644 --- a/src/main/java/com/avaje/ebean/search/TextCommonTerms.java +++ b/src/main/java/com/avaje/ebean/search/TextCommonTerms.java @@ -5,7 +5,6 @@ package com.avaje.ebean.search; *

* This maps to an ElasticSearch "common terms query". *

- *
{@code
  *
  *  TextCommonTerms options = new TextCommonTerms()
@@ -20,7 +19,6 @@ package com.avaje.ebean.search;
  *    .findList();
  *
  * }
- * *
{@code
  *
  *   // ElasticSearch expression
diff --git a/src/main/java/com/avaje/ebean/search/TextQueryString.java b/src/main/java/com/avaje/ebean/search/TextQueryString.java
index 40f0d5e55..b5e3c5324 100644
--- a/src/main/java/com/avaje/ebean/search/TextQueryString.java
+++ b/src/main/java/com/avaje/ebean/search/TextQueryString.java
@@ -5,7 +5,6 @@ package com.avaje.ebean.search;
  * 

* This maps to an ElasticSearch "query string query". *

- * *
{@code
  *
  *  TextQueryString options = new TextQueryString()
@@ -20,8 +19,6 @@ package com.avaje.ebean.search;
  *       .findList();
  *
  * }
- * - * *
{@code
  *
  *  // just use default options
@@ -33,7 +30,6 @@ package com.avaje.ebean.search;
  *       .findList();
  *
  * }
- * */ public class TextQueryString { @@ -234,6 +230,7 @@ public class TextQueryString { this.analyzeWildcard = analyzeWildcard; return this; } + /** * Set the auto generate phrase queries mode. */ diff --git a/src/main/java/com/avaje/ebean/search/TextSimple.java b/src/main/java/com/avaje/ebean/search/TextSimple.java index 789f764ba..995f800f1 100644 --- a/src/main/java/com/avaje/ebean/search/TextSimple.java +++ b/src/main/java/com/avaje/ebean/search/TextSimple.java @@ -5,7 +5,6 @@ package com.avaje.ebean.search; *

* This maps to an ElasticSearch "simple text query". *

- * *
{@code
  *
  *  TextSimple options = new TextSimple()
diff --git a/src/main/java/com/avaje/ebean/text/StringFormatter.java b/src/main/java/com/avaje/ebean/text/StringFormatter.java
index 1fd677cb4..82585a3e7 100644
--- a/src/main/java/com/avaje/ebean/text/StringFormatter.java
+++ b/src/main/java/com/avaje/ebean/text/StringFormatter.java
@@ -5,8 +5,6 @@ package com.avaje.ebean.text;
  * 

* Basic interface to support CSV, JSON and XML processing. *

- * - * @author rbygrave */ public interface StringFormatter { diff --git a/src/main/java/com/avaje/ebean/text/StringParser.java b/src/main/java/com/avaje/ebean/text/StringParser.java index c03371310..41784dc21 100644 --- a/src/main/java/com/avaje/ebean/text/StringParser.java +++ b/src/main/java/com/avaje/ebean/text/StringParser.java @@ -4,9 +4,6 @@ package com.avaje.ebean.text; * Convert a String value into an Object value. *

* Basic interface to support CSV, JSON and XML processing. - *

- * - * @author rbygrave */ public interface StringParser { diff --git a/src/main/java/com/avaje/ebean/text/TextException.java b/src/main/java/com/avaje/ebean/text/TextException.java index ac41a3c07..9b0953407 100644 --- a/src/main/java/com/avaje/ebean/text/TextException.java +++ b/src/main/java/com/avaje/ebean/text/TextException.java @@ -2,8 +2,6 @@ package com.avaje.ebean.text; /** * An exception occurred typically in processing CSV, JSON or XML. - * - * @author rbygrave */ public class TextException extends RuntimeException { diff --git a/src/main/java/com/avaje/ebean/text/TimeStringParser.java b/src/main/java/com/avaje/ebean/text/TimeStringParser.java index 8185acfed..087136bce 100644 --- a/src/main/java/com/avaje/ebean/text/TimeStringParser.java +++ b/src/main/java/com/avaje/ebean/text/TimeStringParser.java @@ -4,8 +4,6 @@ import java.sql.Time; /** * Parser for TIME types that supports both HH:mm:ss and HH:mm. - * - * @author rbygrave */ public final class TimeStringParser implements StringParser { @@ -49,8 +47,7 @@ public final class TimeStringParser implements StringParser { return new Time(hour, minute, second); } catch (NumberFormatException e) { - throw new java.lang.IllegalArgumentException("Number format Error parsing time [" + s + "] " - + e.getMessage(), e); + throw new java.lang.IllegalArgumentException("Number format Error parsing time [" + s + "] " + e.getMessage(), e); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java b/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java index b550be252..d91d942bc 100644 --- a/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java +++ b/src/main/java/com/avaje/ebean/text/csv/CsvCallback.java @@ -9,9 +9,7 @@ import com.avaje.ebean.EbeanServer; * processing. It is expected that the DefaultCsvCallback provides a good base * class that you can extend. *

- * - * @author rbygrave - * + * * @param */ public interface CsvCallback { @@ -28,12 +26,11 @@ public interface CsvCallback { /** * Read the header row. *

- * This is only called if {@link CsvReader#setHasHeader(boolean,boolean)} has + * This is only called if {@link CsvReader#setHasHeader(boolean, boolean)} has * been set to true. *

- * - * @param line - * the header line content. + * + * @param line the header line content. */ void readHeader(String[] line); @@ -54,13 +51,10 @@ public interface CsvCallback { * and will not save the bean for you. You have complete control and must do * these things yourself (if that is want you want). *

- * - * @param row - * the index of the content being processed - * @param line - * the content that has been used to load the bean - * @param bean - * the entity bean after it has been loaded from the csv content + * + * @param row the index of the content being processed + * @param line the content that has been used to load the bean + * @param bean the entity bean after it has been loaded from the csv content */ void processBean(int row, String[] line, T bean); @@ -78,11 +72,9 @@ public interface CsvCallback { * This gives the callback the opportunity to rollback the transaction if one * was created. *

- * - * @param row - * the row that the error has occured on - * @param e - * the error that occured + * + * @param row the row that the error has occured on + * @param e the error that occured */ void endWithError(int row, Exception e); diff --git a/src/main/java/com/avaje/ebean/text/csv/CsvReader.java b/src/main/java/com/avaje/ebean/text/csv/CsvReader.java index 76ce0f2ef..7b707277c 100644 --- a/src/main/java/com/avaje/ebean/text/csv/CsvReader.java +++ b/src/main/java/com/avaje/ebean/text/csv/CsvReader.java @@ -1,47 +1,45 @@ package com.avaje.ebean.text.csv; +import com.avaje.ebean.text.StringParser; + import java.io.Reader; import java.util.Locale; -import com.avaje.ebean.text.StringParser; - /** * Reads CSV data turning it into object graphs that you can be saved (inserted) * or processed yourself. - * *

* This first example doesn't use a {@link CsvCallback} and this means it will * automatically create a transaction, save the customers and commit the * transaction when successful. *

- * - *
+ *
+ * 
{@code
  * try {
- *   File f = new File("src/test/resources/test1.csv");
- * 
+ *   File f = new File("src/test/resources/test1.csv");
+ *
  *   FileReader reader = new FileReader(f);
- * 
+ *
  *   CsvReader<Customer> csvReader = Ebean.createCsvReader(Customer.class);
- * 
+ *
  *   csvReader.setPersistBatchSize(20);
- * 
- *   csvReader.addProperty("status");
+ *
+ *   csvReader.addProperty("status");
  *   // ignore the next property
  *   csvReader.addIgnore();
- *   csvReader.addProperty("name");
- *   csvReader.addDateTime("anniversary", "dd-MMM-yyyy");
- *   csvReader.addProperty("billingAddress.line1");
- *   csvReader.addProperty("billingAddress.city");
- * 
+ *   csvReader.addProperty("name");
+ *   csvReader.addDateTime("anniversary", "dd-MMM-yyyy");
+ *   csvReader.addProperty("billingAddress.line1");
+ *   csvReader.addProperty("billingAddress.city");
+ *
  *   csvReader.process(reader);
- * 
+ *
  * } catch (Exception e) {
  *   throw new RuntimeException(e);
  * }
- * 
- * - * @param - * the entity bean type + * }
+ * + * @param the entity bean type */ public interface CsvReader { @@ -170,4 +168,4 @@ public interface CsvReader { */ void process(Reader reader, CsvCallback callback) throws Exception; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java b/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java index 822924888..20b7d7ba2 100644 --- a/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java +++ b/src/main/java/com/avaje/ebean/text/csv/DefaultCsvCallback.java @@ -15,9 +15,7 @@ import org.slf4j.LoggerFactory; * For customising the processing you can extend this object and override the * appropriate methods. *

- * - * @author rob - * + * * @param */ public class DefaultCsvCallback implements CsvCallback { @@ -89,12 +87,10 @@ public class DefaultCsvCallback implements CsvCallback { /** * Override to read the heading line. *

- * This is only called if {@link CsvReader#setHasHeader(boolean,boolean)} is + * This is only called if {@link CsvReader#setHasHeader(boolean, boolean)} is * set to true. - *

*

* By default this does nothing (effectively ignoring the heading). - *

*/ public void readHeader(String[] line) { diff --git a/src/main/java/com/avaje/ebean/text/json/EJson.java b/src/main/java/com/avaje/ebean/text/json/EJson.java index e22eb0903..f915f8244 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJson.java +++ b/src/main/java/com/avaje/ebean/text/json/EJson.java @@ -1,5 +1,10 @@ package com.avaje.ebean.text.json; +import com.avaje.ebeaninternal.server.type.ModifyAwareList; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + import java.io.IOException; import java.io.Reader; import java.io.Writer; @@ -8,11 +13,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.avaje.ebeaninternal.server.type.ModifyAwareList; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; - /** * Utility that converts between JSON content and simple java Maps/Lists. */ @@ -24,14 +24,14 @@ public class EJson { public static String write(Object object) throws IOException { return EJsonWriter.write(object); } - + /** * Write the nested Map/List as json to the writer. */ public static void write(Object object, Writer writer) throws IOException { EJsonWriter.write(object, writer); } - + /** * Write the nested Map/List as json to the jsonGenerator. */ @@ -50,35 +50,35 @@ public class EJson { * Parse the json and return as a Map additionally specifying if the returned map should * be modify aware meaning that it can detect when it has been modified. */ - public static Map parseObject(String json, boolean modifyAware) throws IOException { + public static Map parseObject(String json, boolean modifyAware) throws IOException { return EJsonReader.parseObject(json, modifyAware); } /** * Parse the json and return as a Map. */ - public static Map parseObject(String json) throws IOException { + public static Map parseObject(String json) throws IOException { return EJsonReader.parseObject(json); } /** * Parse the json and return as a Map taking a reader. */ - public static Map parseObject(Reader reader, boolean modifyAware) throws IOException { + public static Map parseObject(Reader reader, boolean modifyAware) throws IOException { return EJsonReader.parseObject(reader, modifyAware); } /** * Parse the json and return as a Map taking a reader. */ - public static Map parseObject(Reader reader) throws IOException { + public static Map parseObject(Reader reader) throws IOException { return EJsonReader.parseObject(reader); } - + /** * Parse the json and return as a Map taking a JsonParser. */ - public static Map parseObject(JsonParser parser) throws IOException { + public static Map parseObject(JsonParser parser) throws IOException { return EJsonReader.parseObject(parser); } @@ -88,7 +88,7 @@ public class EJson { * Used when the first token is checked to see if the value is null prior to calling this. *

*/ - public static Map parseObject(JsonParser parser, JsonToken token) throws IOException { + public static Map parseObject(JsonParser parser, JsonToken token) throws IOException { return EJsonReader.parseObject(parser, token); } @@ -105,14 +105,14 @@ public class EJson { public static List parseList(String json) throws IOException { return EJsonReader.parseList(json); } - + /** * Parse the json and return as a List taking a Reader. */ public static List parseList(Reader reader) throws IOException { return EJsonReader.parseList(reader); } - + /** * Parse the json and return as a List taking a JsonParser. */ @@ -124,7 +124,7 @@ public class EJson { * Parse the json returning as a List taking into account the current token. */ public static List parseList(JsonParser parser, JsonToken currentToken) throws IOException { - return (List)EJsonReader.parse(parser, currentToken, false); + return (List) EJsonReader.parse(parser, currentToken, false); } /** @@ -133,14 +133,14 @@ public class EJson { public static Object parse(String json) throws IOException { return EJsonReader.parse(json); } - + /** * Parse the json and return as a List or Map. */ public static Object parse(Reader reader) throws IOException { return EJsonReader.parse(reader); } - + /** * Parse the json and return as a List or Map. */ @@ -156,6 +156,6 @@ public class EJson { if (list == null) { return null; } - return ((ModifyAwareList)list).asSet(); + return ((ModifyAwareList) list).asSet(); } } diff --git a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java index a6ee75616..c52230926 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJsonReader.java +++ b/src/main/java/com/avaje/ebean/text/json/EJsonReader.java @@ -1,5 +1,13 @@ package com.avaje.ebean.text.json; +import com.avaje.ebeaninternal.server.type.ModifyAwareFlag; +import com.avaje.ebeaninternal.server.type.ModifyAwareList; +import com.avaje.ebeaninternal.server.type.ModifyAwareMap; +import com.avaje.ebeaninternal.server.type.ModifyAwareOwner; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -9,28 +17,20 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import com.avaje.ebeaninternal.server.type.ModifyAwareFlag; -import com.avaje.ebeaninternal.server.type.ModifyAwareList; -import com.avaje.ebeaninternal.server.type.ModifyAwareMap; -import com.avaje.ebeaninternal.server.type.ModifyAwareOwner; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; - class EJsonReader { static final JsonFactory json = new JsonFactory(); @SuppressWarnings("unchecked") - static Map parseObject(String json, boolean modifyAware) throws IOException { + static Map parseObject(String json, boolean modifyAware) throws IOException { return (Map) parse(json, modifyAware); } @SuppressWarnings("unchecked") - static Map parseObject(String json) throws IOException { + static Map parseObject(String json) throws IOException { return (Map) parse(json); } - + @SuppressWarnings("unchecked") static Map parseObject(Reader reader) throws IOException { return (Map) parse(reader); @@ -48,7 +48,7 @@ class EJsonReader { @SuppressWarnings("unchecked") static Map parseObject(JsonParser parser, JsonToken token) throws IOException { - return (Map)parse(parser, token, false); + return (Map) parse(parser, token, false); } @SuppressWarnings("unchecked") @@ -60,12 +60,12 @@ class EJsonReader { static List parseList(String json) throws IOException { return (List) parse(json); } - + @SuppressWarnings("unchecked") static List parseList(Reader reader) throws IOException { return (List) parse(reader); } - + @SuppressWarnings("unchecked") static List parseList(JsonParser parser, boolean modifyAware) throws IOException { return (List) parse(parser, modifyAware); @@ -112,12 +112,12 @@ class EJsonReader { private final ModifyAwareFlag modifyAwareOwner; private int depth; - + private Stack stack; private Context currentContext; - EJsonReader(JsonParser parser, boolean modifyAware) { + EJsonReader(JsonParser parser, boolean modifyAware) { this.parser = parser; this.modifyAware = modifyAware; this.modifyAwareOwner = (modifyAware) ? new ModifyAwareFlag() : null; @@ -167,12 +167,18 @@ class EJsonReader { token = parser.nextToken(); // if it is a simple value just return it switch (token) { - case VALUE_NULL: return null; - case VALUE_FALSE: return Boolean.FALSE; - case VALUE_TRUE: return Boolean.TRUE; - case VALUE_STRING: return parser.getText(); - case VALUE_NUMBER_INT: return parser.getLongValue(); - case VALUE_NUMBER_FLOAT: return parser.getDecimalValue(); + case VALUE_NULL: + return null; + case VALUE_FALSE: + return Boolean.FALSE; + case VALUE_TRUE: + return Boolean.TRUE; + case VALUE_STRING: + return parser.getText(); + case VALUE_NUMBER_INT: + return parser.getLongValue(); + case VALUE_NUMBER_FLOAT: + return parser.getDecimalValue(); } } @@ -195,59 +201,59 @@ class EJsonReader { private void processJsonToken(JsonToken token) throws IOException { switch (token) { - case START_ARRAY: - startArray(); - break; + case START_ARRAY: + startArray(); + break; - case START_OBJECT: - startObject(); - break; + case START_OBJECT: + startObject(); + break; - case FIELD_NAME: - currentContext.setKey(parser.getCurrentName()); - break; + case FIELD_NAME: + currentContext.setKey(parser.getCurrentName()); + break; - case VALUE_STRING: - setValue(parser.getValueAsString()); - break; + case VALUE_STRING: + setValue(parser.getValueAsString()); + break; - case VALUE_NUMBER_INT: - setValue(parser.getLongValue()); - break; - - case VALUE_NUMBER_FLOAT: - setValue(parser.getDecimalValue()); - break; + case VALUE_NUMBER_INT: + setValue(parser.getLongValue()); + break; - case VALUE_TRUE: - setValue(Boolean.TRUE); - break; + case VALUE_NUMBER_FLOAT: + setValue(parser.getDecimalValue()); + break; - case VALUE_FALSE: - setValue(Boolean.FALSE); - break; + case VALUE_TRUE: + setValue(Boolean.TRUE); + break; - case VALUE_NULL: - setValueNull(); - break; + case VALUE_FALSE: + setValue(Boolean.FALSE); + break; - case END_OBJECT: - endObject(); - break; + case VALUE_NULL: + setValueNull(); + break; - case END_ARRAY: - endArray(); - break; + case END_OBJECT: + endObject(); + break; - default: - break; + case END_ARRAY: + endArray(); + break; + + default: + break; } } - + private static final class Stack { - + private Context head; - + private void push(Context context) { if (context != null) { context.next = head; @@ -272,15 +278,20 @@ class EJsonReader { private static abstract class Context { Context next; + abstract void popContext(Context temp); + abstract Object getValue(); + abstract void setKey(String key); + abstract void setValue(Object value); + abstract void setValueNull(); } - + private static class ObjectContext extends Context { - + private final Map map; private String key; @@ -315,7 +326,7 @@ class EJsonReader { } private static class ArrayContext extends Context { - + private final List values; ArrayContext() { @@ -333,7 +344,7 @@ class EJsonReader { Object getValue() { return values; } - + void setValue(Object value) { values.add(value); } @@ -341,7 +352,8 @@ class EJsonReader { void setValueNull() { // ignore } - void setKey(String key) { + + void setKey(String key) { // not expected } } diff --git a/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java b/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java index 0deda8742..add09e160 100644 --- a/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java +++ b/src/main/java/com/avaje/ebean/text/json/EJsonWriter.java @@ -1,5 +1,8 @@ package com.avaje.ebean.text.json; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerator; + import java.io.IOException; import java.io.StringWriter; import java.io.Writer; @@ -11,9 +14,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; - class EJsonWriter { /** diff --git a/src/main/java/com/avaje/ebean/text/json/JsonContext.java b/src/main/java/com/avaje/ebean/text/json/JsonContext.java index dc67d9824..71d86e2b0 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonContext.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonContext.java @@ -61,20 +61,18 @@ public interface JsonContext { /** * Create and return a new bean reading for the bean type given the JSON options and source. *

- * Note that JsonOption provides an option for setting a persistence context and also enabling - * further lazy loading. Further lazy loading requires a persistence context so if that is set - * on then a persistence context is created if there is not one set. - *

+ * Note that JsonOption provides an option for setting a persistence context and also enabling + * further lazy loading. Further lazy loading requires a persistence context so if that is set + * on then a persistence context is created if there is not one set. */ JsonBeanReader createBeanReader(Class cls, JsonParser parser, JsonReadOptions options) throws JsonIOException; /** * Create and return a new bean reading for the bean type given the JSON options and source. *

- * Note that JsonOption provides an option for setting a persistence context and also enabling - * further lazy loading. Further lazy loading requires a persistence context so if that is set - * on then a persistence context is created if there is not one set. - *

+ * Note that JsonOption provides an option for setting a persistence context and also enabling + * further lazy loading. Further lazy loading requires a persistence context so if that is set + * on then a persistence context is created if there is not one set. */ JsonBeanReader createBeanReader(BeanType beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException; @@ -234,4 +232,4 @@ public interface JsonContext { */ void writeScalar(JsonGenerator generator, Object scalarValue) throws IOException; -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java index d348a3875..6864302c6 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonReadOptions.java @@ -64,9 +64,8 @@ public class JsonReadOptions { /** * Set to true to enable lazy loading on partially populated beans. *

- * If this is set to true a persistence context will be created if one has - * not already been supplied. - *

+ * If this is set to true a persistence context will be created if one has + * not already been supplied. */ public JsonReadOptions setEnableLazyLoading(boolean enableLazyLoading) { this.enableLazyLoading = enableLazyLoading; @@ -117,4 +116,4 @@ public class JsonReadOptions { this.loadContext = loadContext; } -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java b/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java index 1ab885c81..c84b62829 100644 --- a/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java +++ b/src/main/java/com/avaje/ebean/text/json/JsonWriteBeanVisitor.java @@ -8,9 +8,7 @@ package com.avaje.ebean.text.json; * You register a JsonWriteBeanVisitor with {@link JsonWriteOptions}. *

* - * @param - * the type of entity bean - * + * @param the type of entity bean * @see JsonWriteOptions */ public interface JsonWriteBeanVisitor { @@ -19,11 +17,9 @@ public interface JsonWriteBeanVisitor { * Visit the bean that has just been writing it's content to JSON. You can * write your own additional JSON content to the JsonWriter if you wish. * - * @param bean - * the bean that has been writing it's content - * @param jsonWriter - * the JsonWriter which you can append custom json content to if you - * wish. + * @param bean the bean that has been writing it's content + * @param jsonWriter the JsonWriter which you can append custom json content to if you + * wish. */ void visit(T bean, JsonWriter jsonWriter); diff --git a/src/main/java/com/avaje/ebean/text/json/package-info.java b/src/main/java/com/avaje/ebean/text/json/package-info.java index cdb33b989..0c1ea677d 100644 --- a/src/main/java/com/avaje/ebean/text/json/package-info.java +++ b/src/main/java/com/avaje/ebean/text/json/package-info.java @@ -1,29 +1,28 @@ /** * JSON formatting and parsing objects (See JsonContext). *

- * The goal is to provide JSON support taking into account + * The goal is to provide JSON support taking into account * various ORM issues such as partial objects (for fetching and * updating), reference beans and - * bi-directional relationships. + * bi-directional relationships. *

- * *

Example:

- *
+ * 
{@code
  *  // find some customers ...
- *  
- * List<Customer> list = Ebean.find(Customer.class)
- *     .select("id, name, status, shippingAddress")
- *     .fetch("billingAddress","line1, city")
- *     .fetch("billingAddress.country", "*")
- *     .fetch("contacts", "firstName,email")
- *     .order().desc("id")
+ *
+ * List list = Ebean.find(Customer.class)
+ *     .select("id, name, status, shippingAddress")
+ *     .fetch("billingAddress","line1, city")
+ *     .fetch("billingAddress.country", "*")
+ *     .fetch("contacts", "firstName,email")
+ *     .order().desc("id")
  *     .findList();
- * 
+ *
  * JsonContext json = Ebean.json();
  *
  *  // output as a JSON string
  * String jsonOutput = json.toJson(list);
- * 
- * 
+ * + * }
*/ -package com.avaje.ebean.text.json; \ No newline at end of file +package com.avaje.ebean.text.json; diff --git a/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java b/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java index 77241d949..4a73ffbb0 100644 --- a/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java +++ b/src/main/java/com/avaje/ebean/util/CamelCaseHelper.java @@ -4,10 +4,8 @@ public class CamelCaseHelper { /** * To camel from underscore. - * - * @param underscore - * the underscore - * + * + * @param underscore the underscore * @return the string */ public static String toCamelFromUnderscore(String underscore) { diff --git a/src/main/java/com/avaje/ebean/util/ClassUtil.java b/src/main/java/com/avaje/ebean/util/ClassUtil.java index 50645921c..300145bb6 100644 --- a/src/main/java/com/avaje/ebean/util/ClassUtil.java +++ b/src/main/java/com/avaje/ebean/util/ClassUtil.java @@ -16,7 +16,7 @@ public class ClassUtil { Type[] typeArguments = getSuperclassTypeParameter(subclass); if (typeArguments.length != 2) { throw new IllegalArgumentException("Expected type with 2 generic argument types but got " - + typeArguments.length + " - " + Arrays.toString(typeArguments)); + + typeArguments.length + " - " + Arrays.toString(typeArguments)); } return getRawType(typeArguments[1]); diff --git a/src/main/java/com/avaje/ebean/util/StringHelper.java b/src/main/java/com/avaje/ebean/util/StringHelper.java index 947a4bb1d..384defbc4 100644 --- a/src/main/java/com/avaje/ebean/util/StringHelper.java +++ b/src/main/java/com/avaje/ebean/util/StringHelper.java @@ -47,7 +47,7 @@ public class StringHelper { * either single or double quotes). */ private static HashMap parseNameQuotedValue(HashMap map, - String tag, int pos) throws RuntimeException { + String tag, int pos) throws RuntimeException { int equalsPos = tag.indexOf("=", pos); if (equalsPos > -1) { @@ -55,14 +55,13 @@ public class StringHelper { char firstQuote = tag.charAt(equalsPos + 1); if (firstQuote != SINGLE_QUOTE && firstQuote != DOUBLE_QUOTE) { throw new RuntimeException("missing begin quote at " + (equalsPos) + "[" - + tag.charAt(equalsPos + 1) + "] in [" + tag + "]"); + + tag.charAt(equalsPos + 1) + "] in [" + tag + "]"); } // check for end quote... int endQuotePos = tag.indexOf(firstQuote, equalsPos + 2); if (endQuotePos == -1) { - throw new RuntimeException("missing end quote [" + firstQuote + "] after " + pos - + " in [" + tag + "]"); + throw new RuntimeException("missing end quote [" + firstQuote + "] after " + pos + " in [" + tag + "]"); } // we have a valid name and value... @@ -112,15 +111,12 @@ public class StringHelper { * always return a StringMap. If allNameValuePairs is null, or no name values * can be parsed out an empty StringMap is returned. * - * @param allNameValuePairs - * the entire string to be parsed. - * @param listDelimiter - * (typically ';') the delimited between the list - * @param nameValueSeparator - * (typically '=') the separator between the name and value + * @param allNameValuePairs the entire string to be parsed. + * @param listDelimiter (typically ';') the delimited between the list + * @param nameValueSeparator (typically '=') the separator between the name and value */ public static Map delimitedToMap(String allNameValuePairs, - String listDelimiter, String nameValueSeparator) { + String listDelimiter, String nameValueSeparator) { HashMap params = new HashMap<>(); if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) { @@ -134,10 +130,8 @@ public class StringHelper { /** * Trims off recurring strings from the front of a string. * - * @param source - * the source string - * @param trim - * the string to trim off the front + * @param source the source string + * @param trim the string to trim off the front */ public static String trimFront(String source, String trim) { if (source == null) { @@ -162,7 +156,7 @@ public class StringHelper { * Recursively pulls out the key value pairs from a raw string. */ private static HashMap getKeyValue(HashMap map, int pos, - String allNameValuePairs, String listDelimiter, String nameValueSeparator) { + String allNameValuePairs, String listDelimiter, String nameValueSeparator) { if (pos >= allNameValuePairs.length()) { // dp("end as "+pos+" >= "+allNameValuePairs.length() ); @@ -183,7 +177,7 @@ public class StringHelper { // dp("Ignoring as nothing between delim and equals... // delim:"+delimPos+" eq:"+equalsPos); return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + nameValueSeparator); } if (equalsPos > delimPos) { // there is a key without a value? @@ -193,7 +187,7 @@ public class StringHelper { map.put(key, null); } return getKeyValue(map, delimPos + 1, allNameValuePairs, listDelimiter, - nameValueSeparator); + nameValueSeparator); } String key = allNameValuePairs.substring(pos, equalsPos); @@ -219,21 +213,16 @@ public class StringHelper { * Convert a string that has delimited values (say comma delimited) in a * String[]. You must explicitly choose whether or not to include empty values * (say two commas that a right beside each other. - * - *

+ *

* e.g. "alpha,beta,,theta"
* With keepEmpties true, this results in a String[] of size 4 with the third * one having a String of 0 length. With keepEmpties false, this results in a * String[] of size 3. - *

- *

- *

- *

+ *

* e.g. ",alpha,beta,,theta,"
* With keepEmpties true, this results in a String[] of size 6 with the * 1st,4th and 6th one having a String of 0 length. With keepEmpties false, * this results in a String[] of size 3. - *

*/ public static String[] delimitedToArray(String str, String delimiter, boolean keepEmpties) { @@ -245,7 +234,7 @@ public class StringHelper { } private static void delimiter(String str, String delimiter, boolean keepEmpties, int startPos, - ArrayList list) { + ArrayList list) { int endPos = str.indexOf(delimiter, startPos); if (endPos == -1) { @@ -272,24 +261,18 @@ public class StringHelper { * This returns the FIRST string in str that is bounded on the left by * leftBound, and bounded on the right by rightBound. This will return null if * the leftBound is not found within str. - * - *

+ *

* If leftBound can't be found this returns null. - *

- *

+ *

* This rightBound can't be found then this throws a * StringIndexOutOfBoundsException. - *

* - * @param str - * the base string that we will search for the bounded string. - * @param leftBound - * the left bound of the string. - * @param rightBound - * the right bound of the string. + * @param str the base string that we will search for the bounded string. + * @param leftBound the left bound of the string. + * @param rightBound the right bound of the string. */ public static String getBoundedString(String str, String leftBound, String rightBound) - throws RuntimeException { + throws RuntimeException { if (str == null) { throw new RuntimeException("string to parse is null?"); @@ -317,7 +300,7 @@ public class StringHelper { * replaceString. Actually removes the left and right bound strings aswell. */ public static String setBoundedString(String str, String leftBound, String rightBound, - String replaceString) { + String replaceString) { int startPos = str.indexOf(leftBound); if (startPos > -1) { @@ -334,43 +317,13 @@ public class StringHelper { } } - // public static String replaceString(String str, String oldSub, String - // newSub) { - // - // if (str == null) { - // return null; - // } - // StringBuilder newSB = new StringBuilder(str.length()+20); - // int iPos = 0; - // int iPrevPos = 0; - // - // while (true) { - // iPos = str.indexOf(oldSub, iPrevPos); - // if (iPos > -1) { - // // found - // newSB.append(str.substring(iPrevPos, iPos)); - // newSB.append(newSub); - // iPrevPos = iPos + oldSub.length(); - // } else { - // // not found - // newSB.append(str.substring(iPrevPos)); - // break; - // } - // } - // - // return newSB.toString(); - // } - /** * This method takes a String and will replace all occurrences of the match * String with that of the replace String. * - * @param source - * the source string - * @param match - * the string used to find a match - * @param replace - * the string used to replace match with + * @param source the source string + * @param match the string used to find a match + * @param replace the string used to replace match with * @return the source string after the search and replace */ public static String replaceString(String source, String match, String replace) { @@ -395,7 +348,7 @@ public class StringHelper { * occurs. */ public static String replaceString(String source, String match, String replace, - int additionalSize, int startPos, int endPos) { + int additionalSize, int startPos, int endPos) { if (source == null) { return null; @@ -461,14 +414,12 @@ public class StringHelper { * A search and replace with multiple matching strings. *

* Useful when converting CRNL CR and NL all to a BR tag for example. - *

+ *
{@code
    *
-   * 
-   * 
-   * String[] multi = { "\r\n", "\r", "\n" };
-   * content = StringHelper.replaceStringMulti(content, multi, "<br/>");
-   * 
-   * 
+ * String[] multi = { "\r\n", "\r", "\n" }; + * content = StringHelper.replaceStringMulti(content, multi, "
"); + * + * }
*/ public static String replaceStringMulti(String source, String[] match, String replace) { return replaceStringMulti(source, match, replace, 30, 0, source.length()); @@ -483,7 +434,7 @@ public class StringHelper { *

*/ public static String replaceStringMulti(String source, String[] match, String replace, - int additionalSize, int startPos, int endPos) { + int additionalSize, int startPos, int endPos) { int shortestMatch = match[0].length(); From 58760fe001cb35c4768e1b33506a5b6cc1023df6 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:17:21 +1300 Subject: [PATCH 80/87] no effective change - format test code --- .../java/com/avaje/ebean/BaseTestCase.java | 10 +- src/test/java/com/avaje/ebean/ColumnTest.java | 17 +- .../com/avaje/ebean/EbeanServer_eqlTest.java | 10 +- .../com/avaje/ebean/EbeanServer_refresh.java | 3 +- .../avaje/ebean/EbeanServer_saveAllTest.java | 9 +- .../java/com/avaje/ebean/PropertyTest.java | 5 +- .../java/com/avaje/ebean/RawSqlKeyTest.java | 14 +- .../com/avaje/ebean/TestDirtyProperties.java | 88 +++--- .../com/avaje/ebean/TestFilterWithEnum.java | 9 +- .../ebean/TestPropertyChangeListener.java | 31 ++- .../com/avaje/ebean/TestRawSqlBuilder.java | 68 +++-- .../ebean/TestRawSqlBuilderDistinct.java | 6 +- .../avaje/ebean/TestRawSqlColumnParsing.java | 253 +++++++++--------- .../ebean/TestUnsetLoadedProperties.java | 2 +- .../avaje/ebean/TextExpressionListTest.java | 80 +++--- .../java/com/avaje/ebean/TxScopeTest.java | 5 +- .../java/com/avaje/ebean/UpdateQueryTest.java | 100 +++---- .../ebean/bean/EntityBeanInterceptTest.java | 4 +- .../com/avaje/ebean/common/BeanListTest.java | 4 +- .../com/avaje/ebean/common/BeanMapTest.java | 24 +- .../ebean/config/DbMigrationConfigTest.java | 4 +- .../ebean/config/PropertiesWrapperTest.java | 40 +-- .../avaje/ebean/config/ServerConfigTest.java | 2 +- .../dbplatform/BasicSqlLimitOffsetTest.java | 6 +- .../BasicSqlStandardLimiterTest.java | 6 +- .../dbplatform/DbPlatformTypeLookupTest.java | 4 +- .../dbplatform/DbPlatformTypeParserTest.java | 4 +- .../config/dbplatform/DbTypeMapTest.java | 18 +- .../dbplatform/MySqlHistorySupportTest.java | 4 +- .../PostgresHistorySupportTest.java | 4 +- .../dbplatform/PostgresPlatformTest.java | 1 - .../dbmigration/ddlgeneration/Helper.java | 2 +- .../platform/H2HistoryDdlTest.java | 4 +- .../ddlgeneration/platform/IndexSetTest.java | 7 +- .../platform/util/VowelRemoverTest.java | 6 +- .../MigrationXmlWriterTest.java | 6 +- .../ebean/dbmigration/model/EntryTest.java | 8 +- .../ebean/dbmigration/model/MColumnTest.java | 4 +- .../ebean/dbmigration/model/MTableTest.java | 46 ++-- .../model/MigrationVersionTest.java | 4 +- .../dbmigration/model/ModelContainerTest.java | 6 +- .../dbmigration/model/PendingDropsTest.java | 12 +- .../build/ModelBuildBeanVisitorTest.java | 6 +- .../ebean/event/BeanFindControllerTest.java | 11 +- .../avaje/ebean/event/BeanPostLoadTest.java | 10 +- .../java/com/avaje/ebean/json/EJsonTests.java | 48 ++-- .../com/avaje/ebean/plugin/BeanTypeTest.java | 20 +- .../ebean/plugin/ExpressionPathTest.java | 26 +- .../com/avaje/ebean/plugin/SpiServerTest.java | 9 +- .../avaje/ebean/server/type/MyDayOfWeek.java | 14 +- .../ebean/server/type/TestTypeManager.java | 2 +- .../avaje/ebean/text/PathPropertiesTests.java | 4 +- .../ebean/text/json/JsonContextTest.java | 20 +- .../text/json/JsonWriteOptionsTests.java | 5 +- .../avaje/ebean/util/CamelCaseHelperTest.java | 4 +- .../api/HashQueryPlanBuilderTest.java | 12 +- .../ebeaninternal/api/HashQueryPlanTest.java | 38 +-- .../ebeaninternal/api/TDSpiEbeanServer.java | 32 ++- .../server/cache/CacheBeanDataTest.java | 2 +- .../cache/CachedBeanDataFromBeanTest.java | 6 +- .../cache/CachedBeanDataSerializeTest.java | 22 +- ...faultCacheHolder_getCacheOptions_Test.java | 4 +- .../server/cache/DefaultServerCacheTest.java | 4 +- .../DefaultServerCache_RunEvictionTest.java | 8 +- .../DefaultChangeLogRegisterTest.java | 19 +- .../server/changelog/Helper.java | 8 +- .../server/core/BasicTypeConverterTest.java | 5 +- .../core/DefaultBackgroundExecutorTest.java | 20 +- ...faultServer_createOrmQueryRequestTest.java | 120 ++++----- .../server/core/TestDiffHelpInsertSimple.java | 4 +- .../core/TestDiffHelpInsertWithEmbedded.java | 4 +- .../server/core/TestDiffHelpSimple.java | 99 ++++--- .../server/core/TestDiffHelpWithEmbedded.java | 73 +++-- .../core/bootup/DistillPackagesTest.java | 6 +- .../server/deploy/BeanCascadeInfoTest.java | 5 +- .../server/deploy/BeanDescriptorTest.java | 4 +- .../BeanDescriptor_documentMappingTest.java | 10 +- .../deploy/BeanDescriptor_registerTest.java | 17 +- ...eanDescriptor_whenCreatedPropertyTest.java | 8 +- .../deploy/BeanPropertyAssocManyTest.java | 9 +- .../deploy/DeployPropertyParserMapTests.java | 16 +- .../TestBeanDescriptorHasIdProperty.java | 47 ++-- .../deploy/TestCollectionLoadedStatus.java | 25 +- .../deploy/TestNotEnhancedMappedSuper.java | 12 +- ...estReferenceWithConstructorProperties.java | 17 +- .../UpdateTimestampFactoryTest.java | 4 +- .../expression/AllEqualsExpressionTest.java | 8 +- .../DefaultExampleExpressionTest.java | 14 +- .../expression/DefaultExpressionListTest.java | 26 +- .../expression/ExistsQueryExpressionTest.java | 24 +- .../server/expression/IdInExpressionTest.java | 8 +- .../expression/InQueryExpressionTest.java | 26 +- .../IsEmptyExpressionQueryTest.java | 44 +-- .../expression/JunctionExpressionTest.java | 10 +- .../server/expression/LikeExpressionTest.java | 16 +- .../expression/LogicExpressionTest.java | 24 +- .../server/expression/NoopExpressionTest.java | 16 +- .../server/expression/NotExpressionTest.java | 14 +- .../server/expression/NullExpressionTest.java | 10 +- .../expression/PrepareDocNestedTest.java | 90 +++---- .../server/grammer/EqlParserTest.java | 6 +- .../server/lib/ShutdownManagerTest.java | 4 +- .../lib/sql/TestDataSourceMaxWithEntity.java | 13 +- .../server/loadcontext/DLoadContextTest.java | 22 +- .../server/query/OrderVersionDescTest.java | 4 +- .../server/query/SplitNameTest.java | 9 +- .../TestFutureRowCountErrorHandling.java | 117 ++++---- .../server/querydefn/DefaultOrmQueryTest.java | 30 +-- .../querydefn/OrmQueryDetailParserTest.java | 4 +- .../server/querydefn/OrmQueryDetailTest.java | 14 +- .../server/querydefn/OrmQueryPlanKeyTest.java | 8 +- .../querydefn/OrmQueryPropertiesTest.java | 14 +- .../server/rawsql/TestRawSqlParsing.java | 39 ++- .../text/json/TestJsonWriteVisitor.java | 12 +- .../json/TestTextJsonBeanReadVisitor.java | 12 +- .../server/text/json/WriteJsonDirtyTest.java | 8 +- .../server/text/json/WriteJsonTest.java | 6 +- .../transaction/JdbcTransactionTest.java | 6 +- .../server/type/ConvertInetAddressTest.java | 14 +- .../server/type/DefaultTypeFactoryTest.java | 4 +- .../server/type/DefaultTypeManagerTest.java | 5 +- .../ebeaninternal/server/type/JsonTester.java | 2 +- .../server/type/ModifyAwareListTest.java | 11 +- .../server/type/ModifyAwareMapTest.java | 8 +- .../server/type/ScalarTypeBooleanTest.java | 6 +- .../server/type/ScalarTypeDateTest.java | 4 +- .../server/type/ScalarTypeDurationTest.java | 10 +- .../type/ScalarTypeDurationWithNanosTest.java | 8 +- .../server/type/ScalarTypeInstantTest.java | 10 +- .../type/ScalarTypeJodaLocalDateTimeTest.java | 4 +- .../server/type/ScalarTypeLocalDateTest.java | 5 +- .../server/type/ScalarTypeLocalTimeTest.java | 6 +- .../ScalarTypeLocalTimeWithNanosTest.java | 7 +- .../server/type/ScalarTypeMonthDayTest.java | 5 +- .../type/ScalarTypeOffsetDateTimeTest.java | 6 +- .../server/type/ScalarTypePathTest.java | 6 +- .../type/ScalarTypePostgresHstoreTest.java | 20 +- .../server/type/ScalarTypeYearTest.java | 6 +- .../server/type/ScalarTypeZoneIdTest.java | 4 +- .../type/ScalarTypeZonedDateTimeTest.java | 6 +- .../server/type/TestEnumToBeanType.java | 45 ++-- .../TestScalarTypeUUIDBinaryConversion.java | 12 +- .../ebeaninternal/server/util/Md5Test.java | 4 +- .../support/DocStoreBeanBaseAdapterTest.java | 4 +- .../api/support/DocStoreDeleteEventTest.java | 8 +- .../api/support/DocStoreIndexEventTest.java | 10 +- .../autofetch/AutofetchEmbeddedTest.java | 19 +- .../MainAutoFetchExcludeLazyLobs.java | 44 ++- .../tests/autofetch/MainAutoQueryTune1.java | 36 +-- .../tests/autofetch/TunedQueryInfoTest.java | 123 +++++---- .../TunedQueryWithNullFetchedBeanTest.java | 45 ++-- .../com/avaje/tests/basic/MainDbBoolean.java | 234 ++++++++-------- .../basic/MyTestDataSourcePoolListener.java | 37 ++- .../tests/basic/TestAssocOneEqExpression.java | 57 ++-- .../com/avaje/tests/basic/TestBatchLazy.java | 17 +- .../avaje/tests/basic/TestBatchLazyMany.java | 27 +- .../tests/basic/TestBeanReferenceRefresh.java | 69 +++-- .../tests/basic/TestDeleteByIdCollection.java | 11 +- .../basic/TestDeleteCascadingOneToMany.java | 17 +- .../basic/TestDeleteImportedPartial.java | 7 +- .../avaje/tests/basic/TestDeleteOneToOne.java | 7 +- .../basic/TestDeleteOneToOneMultiple.java | 5 +- .../basic/TestDeletePartialNoVersion.java | 89 +++--- .../avaje/tests/basic/TestDynamicUpdate.java | 67 +++-- ...stEnhancementCollectionInitialisation.java | 15 +- .../avaje/tests/basic/TestExplicitInsert.java | 16 +- .../com/avaje/tests/basic/TestFetchId.java | 38 +-- .../com/avaje/tests/basic/TestIUDVanilla.java | 9 +- .../com/avaje/tests/basic/TestInEmpty.java | 13 +- .../com/avaje/tests/basic/TestInheritRef.java | 17 +- .../com/avaje/tests/basic/TestJodaType.java | 25 +- .../tests/basic/TestJoinInheritance.java | 128 +++++---- .../basic/TestLazyLoadEmptyOneToMany.java | 19 +- .../tests/basic/TestLazyLoadInCache.java | 95 ++++--- .../com/avaje/tests/basic/TestLimitQuery.java | 44 +-- .../avaje/tests/basic/TestLoadBeanCache.java | 45 ++-- .../tests/basic/TestLogTransLogOnError.java | 19 +- .../avaje/tests/basic/TestM2MCascadeOne.java | 6 +- .../com/avaje/tests/basic/TestM2MVanilla.java | 21 +- .../avaje/tests/basic/TestManyLazyLoad.java | 4 +- .../tests/basic/TestManyOneInterface.java | 33 ++- .../avaje/tests/basic/TestMappedSuper.java | 46 ++-- .../avaje/tests/basic/TestMetaAnnotation.java | 10 +- .../tests/basic/TestMultipleOneToOneIUD.java | 5 +- .../tests/basic/TestNonUpdateProperty.java | 3 +- .../tests/basic/TestOrderByAnnotation.java | 37 ++- .../basic/TestOrderTotalAmountFormula.java | 19 +- .../basic/TestOrderTotalAmountReportBean.java | 73 +++-- .../tests/basic/TestOrderTotalAmountSql.java | 9 +- .../tests/basic/TestPersistenceContext.java | 125 +++++---- .../java/com/avaje/tests/basic/TestQuery.java | 11 +- .../tests/basic/TestQueryWhereBetween.java | 11 +- .../avaje/tests/basic/TestQueryWithCache.java | 6 +- .../tests/basic/TestReadOnlyPropagation.java | 149 +++++------ .../tests/basic/TestSaveDeleteOneToOne.java | 45 ++-- .../basic/TestSaveDeleteOneToOneMultiple.java | 33 ++- .../basic/TestSharedInstancePropagation.java | 86 +++--- .../com/avaje/tests/basic/TestTransient.java | 5 +- .../tests/basic/TestUpdateManyToOne.java | 7 +- .../com/avaje/tests/basic/TestUuidInsert.java | 33 ++- .../basic/TestUuidInsertMasterDetail.java | 7 +- .../tests/basic/TestWhereAnnotation.java | 11 +- .../basic/delete/TestDeleteByIdList.java | 9 +- .../basic/delete/TestDeleteCascadeById.java | 9 +- .../tests/basic/encrypt/BasicEncryptKey.java | 19 +- .../basic/encrypt/BasicEncyptKeyManager.java | 20 +- .../tests/basic/encrypt/TestEncrypt.java | 23 +- .../basic/encrypt/TestEncryptBinary.java | 9 +- .../basic/event/TestPreInsertValidation.java | 51 ++-- .../tests/basic/event/TestQueryAdapter.java | 47 ++-- .../tests/basic/join/TestSecondaryJoin.java | 13 +- .../basic/lob/TestBasicClobFetchEager.java | 32 ++- .../tests/basic/lob/TestBasicClobNoVer.java | 31 ++- .../avaje/tests/basic/lob/TestByteOnly.java | 7 +- .../avaje/tests/basic/one2one/Booking.java | 105 ++++---- .../avaje/tests/basic/one2one/Invoice.java | 57 ++-- .../one2one/TestOne2OneBookingInvoice.java | 5 +- .../com/avaje/tests/basic/one2one/Tire.java | 60 ++--- .../tests/basic/type/BSimpleWithGen.java | 57 ++-- .../basic/type/TestEnumValueAnnotation.java | 13 +- .../basic/type/TestExtraScalarTypes.java | 23 +- .../tests/basic/type/TestInetAddressType.java | 37 ++- .../basic/type/TestQueryBooleanProperty.java | 3 +- .../tests/basic/type/TestSqlRowUUID.java | 9 +- .../batchinsert/TestBatchInsertSimple.java | 6 +- ...tBatchInsertWithInitialisedCollection.java | 2 +- .../TestBatchOnCascadeExceptionHandling.java | 7 +- .../avaje/tests/batchload/TestBasicLazy.java | 21 +- .../tests/batchload/TestBasicNavOnEmpty.java | 35 ++- .../batchload/TestBatchLazyWithCacheHits.java | 18 +- .../batchload/TestBatchLazyWithDeleted.java | 20 +- .../batchload/TestEmptyManyLazyLoad.java | 3 +- .../avaje/tests/batchload/TestLazyJoin.java | 17 +- .../avaje/tests/batchload/TestLazyJoin2.java | 28 +- .../TestLazyLoadEmptyCollection.java | 13 +- .../TestLazyLoadNonExistantBean.java | 12 +- .../TestLazyLoadNonExistentBean.java | 12 +- .../tests/batchload/TestLoadOnDirty.java | 25 +- .../batchload/TestQueryDisableLazyLoad.java | 20 +- .../avaje/tests/batchload/TestQueryJoin.java | 13 +- .../batchload/TestQueryJoinToAssocOne.java | 36 +-- .../batchload/TestSecondQueryNoRows.java | 8 +- .../tests/batchload/TestSecondaryQueries.java | 93 ++++--- .../com/avaje/tests/cache/TestCacheBasic.java | 5 +- .../tests/cache/TestCacheCollectionIds.java | 39 ++- .../avaje/tests/cache/TestCacheCustomer.java | 13 +- .../TestCacheInterceptSaveWhenLazyLoaded.java | 8 +- .../avaje/tests/cache/TestCacheNaturalId.java | 6 +- .../cache/TestCacheReferenceLazyLoad.java | 5 +- .../tests/cache/TestExternalNotification.java | 2 +- .../cache/TestL2CacheWithSharedBean.java | 9 +- .../com/avaje/tests/cache/TestQueryCache.java | 53 ++-- .../tests/cache/TestQueryCacheCountry.java | 39 ++- .../TestPrivateOwnedAddRemoveOrphan.java | 47 ++-- ...TestPrivateOwnedIgnoreTransientOrphan.java | 73 +++-- .../TestPrivateOwnedNoCascadeRemove.java | 11 +- .../tests/compositekeys/TestCKeyDelete.java | 5 +- .../tests/compositekeys/TestCKeyLazyLoad.java | 21 +- ...aoCompositeKeyWithAnnotationOverrides.java | 7 +- .../avaje/tests/compositekeys/TestCore.java | 11 +- ...ascadeDeleteChildrenWithCompositeKeys.java | 85 ++++-- .../tests/compositekeys/db/AuditInfo.java | 79 +++--- .../avaje/tests/compositekeys/db/CaoBean.java | 8 +- .../avaje/tests/compositekeys/db/CaoKey.java | 63 +++-- .../avaje/tests/compositekeys/db/Item.java | 167 ++++++------ .../avaje/tests/compositekeys/db/ItemKey.java | 91 +++---- .../avaje/tests/compositekeys/db/Parcel.java | 41 ++- .../compositekeys/db/ParcelLocation.java | 59 ++-- .../avaje/tests/compositekeys/db/Region.java | 74 +++-- .../tests/compositekeys/db/RegionKey.java | 63 +++-- .../avaje/tests/compositekeys/db/SubType.java | 51 ++-- .../tests/compositekeys/db/SubTypeKey.java | 51 ++-- .../avaje/tests/compositekeys/db/Type.java | 88 +++--- .../avaje/tests/compositekeys/db/TypeKey.java | 63 +++-- .../com/avaje/tests/config/TestTableName.java | 45 ++-- .../contructor/TestProtectedConstructor.java | 21 +- .../avaje/tests/ddd/iud/TestDExhEntityEl.java | 32 +-- .../avaje/tests/ddd/iud/TestDPersonEl.java | 4 +- .../avaje/tests/ddd/iud/TestDPersonIUD.java | 32 +-- .../avaje/tests/ddl/MainDdlWithSchema.java | 30 +-- .../TestDeleteByIdWithPersistenceContext.java | 27 +- .../avaje/tests/delete/TestDeleteByQuery.java | 6 +- .../avaje/tests/draftable/DocLinkTest.java | 36 +-- .../tests/draftable/LinkQueryPublishTest.java | 8 +- .../tests/draftable/OrganisationTest.java | 15 +- .../java/com/avaje/tests/el/TestELBasic.java | 94 ++++--- .../avaje/tests/el/TestPathExpression.java | 12 +- .../avaje/tests/el/TestUnderscoreParam.java | 4 +- .../TestConstructorPutfieldReplacement.java | 17 +- .../enhancement/TestEnhancementEquals.java | 25 +- .../avaje/tests/family/TestInheritance.java | 79 +++--- .../avaje/tests/genkey/TestGeneratedKeys.java | 53 ++-- .../com/avaje/tests/genkey/TestSeqBatch.java | 39 ++- .../avaje/tests/idkeys/TestGeneratedKeys.java | 207 +++++++------- .../com/avaje/tests/idkeys/TestLazyLoad.java | 52 ++-- .../idkeys/TestPropertyChangeSupport.java | 8 +- .../tests/idkeys/TestSimpleIdInsert.java | 12 +- .../com/avaje/tests/idkeys/db/AuditLog.java | 57 ++-- .../avaje/tests/idkeys/db/GenKeyIdentity.java | 41 ++- .../avaje/tests/idkeys/db/GenKeySequence.java | 43 ++- .../avaje/tests/idkeys/db/GenKeyTable.java | 41 ++- .../avaje/tests/inheritance/InnerReport.java | 6 +- .../tests/inheritance/Stockforecast.java | 7 +- .../inheritance/TestDuplcateKeyException.java | 75 +++--- .../tests/inheritance/TestInheritInsert.java | 23 +- .../TestInheritanceBatchLazyLoad.java | 10 +- .../inheritance/TestInheritanceJoins.java | 174 ++++++------ .../inheritance/TestInheritanceOnMany.java | 2 +- .../inheritance/TestInheritanceRawSql.java | 39 ++- .../tests/inheritance/TestIntInherit.java | 69 +++-- .../tests/inheritance/TestSkippable.java | 109 ++++---- .../cache/TestInheritanceCache.java | 8 +- .../company/domain/AbstractBar.java | 52 ++-- .../tests/inheritance/company/domain/Foo.java | 48 ++-- .../company/domain/TestInheritAbstract.java | 78 +++--- .../inheritance/model/AbstractBaseClass.java | 14 +- .../inheritance/model/CalculationResult.java | 72 ++--- .../inheritance/model/Configuration.java | 56 ++-- .../inheritance/model/Configurations.java | 3 +- .../inheritance/model/GroupConfiguration.java | 55 ++-- .../model/ProductConfiguration.java | 43 ++- .../com/avaje/tests/insert/MainDbCopy.java | 38 +-- .../tests/insert/TestInsertCollection.java | 34 ++- .../tests/insert/TestInsertOnStringKey.java | 31 ++- .../com/avaje/tests/iud/TestCarWheelIud.java | 62 ++--- .../tests/iud/TestInsertQueryUpdate.java | 25 +- .../tests/iud/TestInsertUpdateTrans.java | 63 +++-- .../com/avaje/tests/json/TestDbJson_List.java | 5 +- .../avaje/tests/json/TestJsonNodeBasic.java | 8 +- .../avaje/tests/json/TestJsonNodeBlob.java | 6 +- .../avaje/tests/json/TestJsonNodeJsonb.java | 6 +- .../avaje/tests/json/TestJsonNodeVarchar.java | 6 +- .../include/TestJsonExcludeEmptyList.java | 1 - .../json/include/TestJsonExcludeEmptySet.java | 1 - .../TestJacksonIgnore.java | 4 +- .../TestTransientObjectProperty.java | 8 +- .../java/com/avaje/tests/level/Level1.java | 83 +++--- .../java/com/avaje/tests/level/Level2.java | 63 +++-- .../java/com/avaje/tests/level/Level3.java | 36 +-- .../java/com/avaje/tests/level/Level4.java | 36 +-- .../tests/level/test/ManyToManyTest.java | 28 +- .../com/avaje/tests/lib/EbeanTestCase.java | 43 ++- .../java/com/avaje/tests/lib/TestMessage.java | 23 +- .../lifecycle/TestLifecycleAnnotatedBean.java | 24 +- .../java/com/avaje/tests/model/BaseModel.java | 15 +- .../tests/model/array/TestDbArray_basic.java | 22 +- .../com/avaje/tests/model/basic/Address.java | 5 +- .../avaje/tests/model/basic/CKeyDetail.java | 2 +- .../java/com/avaje/tests/model/basic/Car.java | 1 + .../com/avaje/tests/model/basic/Customer.java | 10 +- .../model/basic/EBasicWithLifecycle.java | 2 +- .../avaje/tests/model/basic/MyLobSize.java | 4 +- .../com/avaje/tests/model/basic/Order.java | 8 +- .../tests/model/basic/ResetBasicData.java | 1 - .../com/avaje/tests/model/basic/Truck.java | 1 + .../basic/metaannotation/SizeMedium.java | 8 +- .../xtra/TestDeleteUnloadedChildren.java | 2 +- .../avaje/tests/model/bridge/BSiteUser.java | 4 +- .../avaje/tests/model/bridge/BSiteUserB.java | 4 +- .../avaje/tests/model/bridge/BSiteUserC.java | 4 +- .../com/avaje/tests/model/cache/EColAB.java | 4 +- .../com/avaje/tests/model/carwheel/Car.java | 53 ++-- .../com/avaje/tests/model/carwheel/Tire.java | 34 +-- .../com/avaje/tests/model/carwheel/Wheel.java | 70 ++--- .../avaje/tests/model/carwheeltruck/TCar.java | 3 +- .../tests/model/carwheeltruck/TTruck.java | 8 +- .../tests/model/carwheeltruck/TWheel.java | 6 +- .../TestTruckCarWheelInhertiance.java | 5 +- .../tests/model/composite/RCustomer.java | 43 ++- .../tests/model/composite/RCustomerKey.java | 97 ++++--- .../avaje/tests/model/composite/ROrder.java | 135 +++++----- .../avaje/tests/model/composite/ROrderPK.java | 99 ++++--- .../model/converstation/Conversation.java | 29 +- .../tests/model/converstation/Group.java | 15 +- .../tests/model/converstation/Message.java | 16 +- .../model/converstation/Participation.java | 22 +- .../com/avaje/tests/model/ddd/DExhEntity.java | 61 +++-- .../com/avaje/tests/model/ddd/DPerson.java | 119 ++++---- .../avaje/tests/model/draftable/Document.java | 2 +- .../com/avaje/tests/model/draftable/Link.java | 3 +- .../tests/model/embedded/EEmbDatePeriod.java | 31 ++- .../avaje/tests/model/embedded/EEmbInner.java | 66 ++--- .../avaje/tests/model/embedded/EEmbOuter.java | 85 +++--- .../avaje/tests/model/embedded/EInvoice.java | 3 +- .../avaje/tests/model/embedded/EPerson.java | 4 +- .../tests/model/embedded/Eembeddable.java | 2 +- .../tests/model/embedded/PrimaryRevision.java | 2 +- .../avaje/tests/model/family/ChildPerson.java | 29 +- .../tests/model/family/GrandParentPerson.java | 22 +- .../tests/model/family/InheritablePerson.java | 25 +- .../tests/model/family/ParentPerson.java | 24 +- .../model/history/TestHistoryExclude.java | 7 +- .../model/history/TestHistoryInclude.java | 6 +- .../avaje/tests/model/info/InfoCompany.java | 8 +- .../avaje/tests/model/info/InfoCustomer.java | 2 +- .../model/inheritexposedtype/IXPhoto.java | 2 +- .../model/inheritexposedtype/IXResource.java | 9 +- .../test/TestInheritExposeDtype.java | 7 +- .../tests/model/inheritmany/IMRelated.java | 6 +- .../avaje/tests/model/inheritmany/IMRoot.java | 9 +- .../tests/model/inheritmany/IMRootOne.java | 2 +- .../tests/model/inheritmany/IMRootTwo.java | 7 +- .../avaje/tests/model/inheritmany/MBase.java | 2 +- .../avaje/tests/model/inheritmany/MMedia.java | 8 +- .../tests/model/inheritmany/MPicture.java | 2 +- .../tests/model/inheritmany/MProfile.java | 2 +- .../TestMediaInheritanceJoinToMany.java | 33 ++- .../avaje/tests/model/interfaces/Address.java | 56 ++-- .../tests/model/interfaces/IAddress.java | 5 +- .../avaje/tests/model/interfaces/IPerson.java | 5 +- .../avaje/tests/model/interfaces/Person.java | 58 ++-- .../tests/model/ivo/SimpleKnownImmutable.java | 4 +- .../ivo/converter/CMoneyCompoundType.java | 70 ++--- .../ivo/converter/ExhangeCompoundType.java | 64 ++--- .../converter/JodaIntervalCompoundType.java | 73 +++-- .../ivo/converter/MoneyTypeConverter.java | 18 +- .../model/ivo/converter/OidTypeConverter.java | 21 +- .../ivo/converter/RateTypeConverter.java | 18 +- .../model/ivo/converter/SysTimeConverter.java | 26 +- .../model/joda/TestJodaInsertUpdate.java | 4 +- .../avaje/tests/model/json/EBasicHstore.java | 2 +- .../tests/model/json/EBasicJsonList.java | 2 +- .../avaje/tests/model/json/EBasicJsonMap.java | 2 +- .../tests/model/json/EBasicJsonMapBlob.java | 2 +- .../tests/model/json/EBasicJsonMapClob.java | 2 +- .../tests/model/json/EBasicJsonMapJsonB.java | 2 +- .../model/json/EBasicJsonMapVarchar.java | 2 +- .../com/avaje/tests/model/m2m/DCredit.java | 12 +- .../java/com/avaje/tests/model/m2m/DRot.java | 12 +- .../com/avaje/tests/model/m2m/MnyTopic.java | 4 +- .../java/com/avaje/tests/model/m2m/Role.java | 5 +- .../com/avaje/tests/model/m2m/Tenant.java | 5 +- .../java/com/avaje/tests/model/m2o/Empl.java | 2 +- .../com/avaje/tests/model/map/MpRole.java | 7 +- .../tests/model/mappedsuper/ASimpleBean.java | 4 +- .../mappedsuper/NotEnhancedMappedSuper.java | 6 +- .../com/avaje/tests/model/noid/NoIdBean.java | 2 +- .../tests/model/noid/TestInsertNoIdBean.java | 2 +- .../avaje/tests/model/onetoone/Account.java | 15 +- .../avaje/tests/model/onetoone/OtoChild.java | 10 +- .../avaje/tests/model/onetoone/OtoMaster.java | 4 +- .../onetoone/TestOneToOneCascadeSave.java | 17 +- .../TestOneToOneOptionalRelationship.java | 58 ++-- .../com/avaje/tests/model/onetoone/User.java | 13 +- .../tests/model/onetoone/album/Cover.java | 1 - .../album/DeleteById_SoftDelete_Tests.java | 6 +- .../tests/model/orderentity/OrderEntity.java | 11 +- .../model/orderentity/OrderItemEntity.java | 7 +- .../com/avaje/tests/model/prnt/MPrinter.java | 33 ++- .../tests/model/prnt/MPrinterListener.java | 2 +- .../avaje/tests/model/prnt/MPrinterState.java | 12 +- .../com/avaje/tests/model/pview/Paggview.java | 2 +- .../com/avaje/tests/model/pview/Pview.java | 7 +- .../avaje/tests/model/pview/TestPview.java | 8 +- .../com/avaje/tests/model/pview/Wview.java | 5 +- .../tests/model/selfref/BaseResourceFile.java | 5 +- .../tests/model/selfref/ResourceFile.java | 11 +- .../avaje/tests/model/selfref/SelfParent.java | 25 +- .../tests/model/selfref/SelfRefExample.java | 15 +- .../selfref/TestResourceFileSelfRef.java | 5 +- .../model/selfref/TestSelfRefExample.java | 12 +- .../model/selfref/TestTextJsonSelfRef.java | 18 +- .../tests/model/softdelete/ESoftDelBook.java | 2 +- .../tests/model/survey/TestOrderByFetch.java | 10 +- .../tevent/TestAssocOneNullTraverse.java | 4 +- .../avaje/tests/model/types/SomeFileBean.java | 5 +- .../tests/model/types/SomeNewTypesBean.java | 12 +- .../tests/model/types/SomePeriodBean.java | 3 +- .../com/avaje/tests/model/view/EOrderAgg.java | 3 +- .../tests/model/view/TestViewBaseEntity.java | 18 +- .../tests/model/zero/WithZeroParent.java | 10 +- ...stPersistenceContextOnUpdateDuringTxn.java | 20 +- .../TestPersistenceContextQueryScope.java | 25 +- ...estPersistenceContextScopeUsingOrders.java | 12 +- .../TestPersistenceContextServerConfig.java | 10 +- .../TestAddOrderByWithFirstRowsMaxRows.java | 54 ++-- .../query/TestAutofetchTuneWithJoin.java | 8 +- .../query/TestConnectionCloseOnSqlerr.java | 9 +- .../tests/query/TestDefaultFetchLazy.java | 11 +- .../query/TestExprNestedDisjunction.java | 66 ++--- .../TestImplicitJoinOnParentRelationship.java | 49 ++-- .../tests/query/TestInvalidFetchPath.java | 12 +- .../tests/query/TestJoinOptOneCascade.java | 5 +- .../tests/query/TestLimitAlterFetchMany.java | 13 +- .../com/avaje/tests/query/TestLimitQuery.java | 12 +- .../avaje/tests/query/TestManyWhereJoin.java | 125 +++++---- .../tests/query/TestManyWhereJoinM2M.java | 27 +- .../tests/query/TestMyAdHocSqlSelect.java | 30 +-- .../query/TestOneToManyCorrectGrouping.java | 7 +- .../com/avaje/tests/query/TestQueryAlias.java | 13 +- .../avaje/tests/query/TestQueryExists.java | 16 +- .../query/TestQueryFetchJoinWithOrder.java | 33 ++- .../query/TestQueryFetchManyTwoDeep.java | 121 +++++---- .../tests/query/TestQueryFetchSkipPath.java | 17 +- .../tests/query/TestQueryFilterMany.java | 16 +- .../tests/query/TestQueryFilterManyOnM2M.java | 3 +- .../query/TestQueryFilterManyOnSecondary.java | 29 +- .../query/TestQueryFilterManySimple.java | 21 +- .../avaje/tests/query/TestQueryFindEach.java | 22 +- .../tests/query/TestQueryFindEachWhile.java | 22 +- .../tests/query/TestQueryFindIterate.java | 104 +++---- .../tests/query/TestQueryFindMapTypedKey.java | 10 +- .../tests/query/TestQueryFindPagedList.java | 56 ++-- .../tests/query/TestQueryFindReadOnly.java | 9 +- .../avaje/tests/query/TestQueryFindVisit.java | 13 +- .../tests/query/TestQueryInAssocOne.java | 9 +- .../tests/query/TestQueryJoinBatchSize.java | 19 +- .../tests/query/TestQueryJoinMulipleMany.java | 11 +- .../tests/query/TestQueryMultiManyOrder.java | 11 +- .../tests/query/TestQueryNullAssocOne.java | 9 +- .../query/TestQueryPathJoinAndOrder.java | 11 +- .../query/TestQueryPlanCacheRowCount.java | 13 +- .../tests/query/TestRefToLazyLoadMany.java | 9 +- .../com/avaje/tests/query/TestRowCount.java | 11 +- .../com/avaje/tests/query/TestSubQuery.java | 34 ++- .../tests/query/TestThreeLevelQueryJoin.java | 11 +- .../avaje/tests/query/TestWhereRawClause.java | 35 ++- .../aggregation/TestAggregationCount.java | 24 +- .../query/autotune/TestAutoTuneProfiling.java | 6 +- .../embedded/TestMultipleEmbeddedLoading.java | 40 +-- .../joins/TestDisjunctWhereOuterJoin.java | 17 +- .../joins/TestDisjunctWhereOuterOnMany.java | 41 ++- .../query/joins/TestQueryJoinManyNonRoot.java | 60 +++-- .../joins/TestQueryJoinQueryNonRoot.java | 19 +- .../TestQueryManyToOneWhereClauseJoin.java | 61 +++-- .../query/lazy/TestQueryDefaultBatchSize.java | 41 ++- .../tests/query/orderby/TestOrderByClear.java | 6 +- .../query/orderby/TestOrderByOnComplex.java | 5 +- .../orderby/TestOrderByWithDistinct.java | 166 ++++++------ .../orderby/TestOrderByWithDistinctTake2.java | 37 ++- .../orderby/TestOrderByWithFunction.java | 5 +- .../query/orderby/TestOrderByWithMany.java | 19 +- .../other/TestFindIdsWithInheritance.java | 21 +- .../query/other/TestFindIterateHeapDump.java | 14 +- ...stFindPartialWithConstructorSetFields.java | 6 +- .../other/TestFindWhereUsingEnumerated.java | 11 +- .../query/other/TestFormulaWithFindCount.java | 17 +- .../query/other/TestManyLazyLoadingQuery.java | 60 ++--- .../other/TestManyToManyLazyLoading.java | 23 +- .../TestObjectGraphNodeStatsCollection.java | 43 ++- .../tests/query/other/TestOneToManyAsMap.java | 13 +- .../other/TestQueryConversationRowCount.java | 51 ++-- .../tests/query/other/TestQueryDistinct.java | 38 +-- .../other/TestQueryRawExpressionMany.java | 4 +- .../other/TestQueryRowCountWithMany.java | 46 ++-- .../query/other/TestQuerySingleAttribute.java | 56 ++-- .../tests/query/other/TestSelfParent.java | 9 +- .../query/other/TestSubQueryBinding.java | 3 +- .../query/other/TestWhereAnnotation.java | 41 ++- .../query/other/TestWhereLikeWithSlash.java | 10 +- .../softdelete/TestSoftDeletePagingList.java | 6 +- .../tests/query/sqlquery/SqlQueryTests.java | 2 - .../sqlquery/TestNativeILikeExpression.java | 4 +- .../tests/rawsql/TestInsertSqlLogging.java | 5 +- .../tests/rawsql/TestOrderReportTotal.java | 14 +- .../tests/rawsql/TestRawSqlAsKeyword.java | 121 +++++---- .../rawsql/TestRawSqlCustomerAggregate.java | 15 +- .../tests/rawsql/TestRawSqlMasterDetail.java | 176 ++++++------ .../tests/rawsql/TestRawSqlNamedParams.java | 13 +- .../tests/rawsql/TestRawSqlOrmQuery.java | 79 +++--- .../rawsql/TestRawSqlOrmQueryDistinct.java | 13 +- .../tests/rawsql/TestRawSqlOrmWrapper.java | 34 ++- .../tests/rawsql/TestRawSqlOrmWrapper2.java | 23 +- .../tests/rawsql/TestRawSqlOrmWrapper3.java | 36 ++- .../rawsql/TestRawSqlPositionedParams.java | 10 +- .../tests/rawsql/TestRawSqlUnparsedQuery.java | 42 +-- .../tests/rawsql/TestRawSqlWithResultSet.java | 39 ++- .../rawsql/inherit/ParentRawSqlTest.java | 106 ++++---- .../avaje/tests/readaudit/TestReadAudit.java | 65 ++--- .../tests/refresh/TestRefreshWithMany.java | 28 +- .../saveassociation/TestSaveAssociation.java | 7 +- .../tests/saveassociation/TestSaveSamePK.java | 9 +- .../TestInheritQuery.java | 250 ++++++++--------- .../model/PalletLocation.java | 47 ++-- .../model/PalletLocationExternal.java | 19 +- .../model/Warehouse.java | 85 +++--- .../singleTableInheritance/model/Zone.java | 57 ++-- .../model/ZoneExternal.java | 29 +- .../model/ZoneInternal.java | 26 +- .../tests/softdelete/TestSoftDeleteBasic.java | 44 +-- .../tests/softdelete/TestSoftDeleteBook.java | 20 +- .../TestSoftDeleteOptionalRelationship.java | 6 +- .../tests/sp/TestManyToManySaveTwice.java | 11 +- .../com/avaje/tests/sp/model/IdEntity.java | 89 +++--- .../com/avaje/tests/sp/model/car/Car.java | 33 ++- .../com/avaje/tests/sp/model/car/Wheel.java | 10 +- .../avaje/tests/text/csv/TestCsvReader.java | 13 +- .../text/csv/TestCsvReaderWithCallback.java | 13 +- .../tests/text/csv/TestTimeStringParser.java | 9 +- .../json/TestJsonBeanDescriptorParse.java | 37 ++- .../TestJsonInheritanceDiscriminator.java | 13 +- .../avaje/tests/text/json/TestJsonMap.java | 6 +- .../avaje/tests/text/json/TestJsonSimple.java | 23 +- .../json/TestJsonSomeEnumWithToString.java | 9 +- .../json/TestTextJsonBeanReadVisitor.java | 23 +- .../text/json/TestTextJsonCompoundType.java | 6 +- .../text/json/TestTextJsonInheritance.java | 15 +- .../text/json/TestTextJsonInsertUpdate.java | 7 +- .../text/json/TestTextJsonInvokeLazy.java | 9 +- .../json/TestTextJsonReadManyLazyLoad.java | 19 +- .../text/json/TestTextJsonReferenceBean.java | 33 ++- .../tests/text/json/TestTextJsonSimple.java | 25 +- .../text/json/TestTextJsonSuperSimple.java | 13 +- .../text/json/TestTextJsonUpdateCascade.java | 15 +- .../avaje/tests/timezone/TimezoneTests.java | 12 +- .../java/com/avaje/tests/timezone/TzBean.java | 2 +- .../com/avaje/tests/timezone/TzBeanTests.java | 11 +- .../transaction/TestBatchPersistCascade.java | 16 +- .../TestCreateTransactionWithIsolation.java | 2 +- .../TestDeleteFromPersistenceContext.java | 26 +- .../transaction/TestInsertManyAndRef.java | 9 +- .../avaje/tests/transaction/TestNested.java | 5 +- .../transaction/TestNestedBeginRequired.java | 6 +- .../TestNestedBeginRequiredWithFailure.java | 11 +- .../TestNestedBeginRequiresNew.java | 6 +- ...TestNestedBeginRequiresNewWithFailure.java | 6 +- .../transaction/TestPersistContextClear.java | 9 +- ...TransactionNotTerminatedAfterRollback.java | 110 ++++---- .../com/avaje/tests/types/TestFileType.java | 32 +-- .../tests/types/TestFileTypeFetching.java | 10 +- .../com/avaje/tests/types/TestHstore.java | 2 +- .../com/avaje/tests/types/TestNewTypes.java | 18 +- .../com/avaje/tests/types/TestPeriodType.java | 22 +- .../unidirectional/TestUniDirectional.java | 9 +- .../avaje/tests/unitinternal/HelloMain.java | 13 +- .../avaje/tests/unitinternal/TestBasics.java | 39 ++- .../unitinternal/TestEqualsOnEnhanced.java | 5 +- .../tests/unitinternal/TestLocaleParse.java | 5 +- .../unitinternal/TestNamingConvention.java | 20 +- .../unitinternal/TestNullCollectionSet.java | 9 +- .../tests/unitinternal/TestOrderByParse.java | 4 +- .../unitinternal/TestOriginIntEncoding.java | 5 +- .../TestTxTypeOnTransactional.java | 13 +- .../TestVanillaCollectionSet.java | 9 +- .../update/TestEmbeddedRefreshUpdate.java | 7 +- .../tests/update/TestJsonStatelessUpdate.java | 33 ++- .../avaje/tests/update/TestMarkAsDirty.java | 21 +- .../tests/update/TestPostgresTruncate.java | 3 +- .../TestSqlUpdateBindMultipleLists.java | 2 +- .../tests/update/TestSqlUpdateInTxn.java | 34 ++- .../tests/update/TestStatelessUpdate.java | 65 +++-- .../update/TestUpdateAllLoadedProperties.java | 8 +- .../avaje/tests/update/TestUpdatePartial.java | 20 +- .../tests/update/TestUpdatePartialNoVer.java | 3 +- 644 files changed, 8222 insertions(+), 8513 deletions(-) diff --git a/src/test/java/com/avaje/ebean/BaseTestCase.java b/src/test/java/com/avaje/ebean/BaseTestCase.java index 6e0a5cc64..c85bd477a 100644 --- a/src/test/java/com/avaje/ebean/BaseTestCase.java +++ b/src/test/java/com/avaje/ebean/BaseTestCase.java @@ -10,12 +10,12 @@ import org.slf4j.LoggerFactory; import java.sql.Types; public class BaseTestCase { - + protected static Logger logger = LoggerFactory.getLogger(BaseTestCase.class); - + static { logger.debug("... preStart"); - if (!AgentLoader.loadAgentFromClasspath("ebean-agent","debug=1;packages=com.avaje.tests,org.avaje.test")) { + if (!AgentLoader.loadAgentFromClasspath("ebean-agent", "debug=1;packages=com.avaje.tests,org.avaje.test")) { logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded"); } } @@ -101,7 +101,7 @@ public class BaseTestCase { protected void loadCountryCache() { Ebean.find(Country.class) - .setLoadBeanCache(true) - .findList(); + .setLoadBeanCache(true) + .findList(); } } diff --git a/src/test/java/com/avaje/ebean/ColumnTest.java b/src/test/java/com/avaje/ebean/ColumnTest.java index d8c9f7d19..191b33b51 100644 --- a/src/test/java/com/avaje/ebean/ColumnTest.java +++ b/src/test/java/com/avaje/ebean/ColumnTest.java @@ -13,36 +13,37 @@ public class ColumnTest { @Test public void equals_when_same() { - assertSame(col(1, "name", null),col(1, "name", null)); + assertSame(col(1, "name", null), col(1, "name", null)); } @Test public void equals_when_same_withAlias() { - assertSame(col(1, "t0.name", "t0"),col(1, "t0.name", "t0")); + assertSame(col(1, "t0.name", "t0"), col(1, "t0.name", "t0")); } @Test public void equals_when_diffIndex() { - assertDifferent(col(1, "name", null),col(2, "name", null)); + assertDifferent(col(1, "name", null), col(2, "name", null)); } @Test public void equals_when_diffProperty() { - assertDifferent(col(1, "name", null),col(1, "diffName", null)); + assertDifferent(col(1, "name", null), col(1, "diffName", null)); } @Test public void equals_when_diffAlias() { - assertDifferent(col(1, "t1.name", "t1"),col(1, "t1.name", "t0")); + assertDifferent(col(1, "t1.name", "t1"), col(1, "t1.name", "t0")); } @Test public void equals_when_diffAliasNullLast() { - assertDifferent(col(1, "t1.name", "t1"),col(1, "t1.name", null)); + assertDifferent(col(1, "t1.name", "t1"), col(1, "t1.name", null)); } + @Test public void equals_when_diffAliasNullFirst() { - assertDifferent(col(1, "t1.name", null),col(1, "t1.name", "t1")); + assertDifferent(col(1, "t1.name", null), col(1, "t1.name", "t1")); } @@ -55,4 +56,4 @@ public class ColumnTest { assertThat(key).isNotEqualTo(key1); assertThat(key.hashCode()).isNotEqualTo(key1.hashCode()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/EbeanServer_eqlTest.java b/src/test/java/com/avaje/ebean/EbeanServer_eqlTest.java index 5113cd7c7..aa16871c9 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_eqlTest.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_eqlTest.java @@ -97,8 +97,8 @@ public class EbeanServer_eqlTest extends BaseTestCase { ResetBasicData.reset(); Query query = server() - .createNamedQuery(Customer.class, "withContacts") - .setParameter("id", 1); + .createNamedQuery(Customer.class, "withContacts") + .setParameter("id", 1); query.setUseCache(false); query.findUnique(); @@ -112,12 +112,12 @@ public class EbeanServer_eqlTest extends BaseTestCase { ResetBasicData.reset(); Query query = server() - .createNamedQuery(Customer.class, "withContactsById") - .setParameter("id", 1); + .createNamedQuery(Customer.class, "withContactsById") + .setParameter("id", 1); query.setUseCache(false); query.findUnique(); assertThat(query.getGeneratedSql()).contains("from o_customer t0 left join contact t1 on t1.customer_id = t0.id "); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/EbeanServer_refresh.java b/src/test/java/com/avaje/ebean/EbeanServer_refresh.java index 19306f73d..d04eb0a05 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_refresh.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_refresh.java @@ -2,7 +2,6 @@ package com.avaje.ebean; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Test; @@ -22,7 +21,7 @@ public class EbeanServer_refresh { server.save(basic); int rows = - server.update(EBasic.class) + server.update(EBasic.class) .set("status", EBasic.Status.ACTIVE) .where().idEq(basic.getId()) .update(); diff --git a/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java b/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java index 4bf49df0a..e08f91f08 100644 --- a/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java +++ b/src/test/java/com/avaje/ebean/EbeanServer_saveAllTest.java @@ -29,7 +29,7 @@ public class EbeanServer_saveAllTest extends BaseTestCase { } for (EBasicVer someBean : someBeans) { - someBean.setName(someBean.getName()+"-mod"); + someBean.setName(someBean.getName() + "-mod"); } // act @@ -113,11 +113,10 @@ public class EbeanServer_saveAllTest extends BaseTestCase { } - private List beans(int count) { List beans = new ArrayList<>(); - for (int i = 0; i changedProps = beanState.getChangedProps(); Assert.assertEquals(1, changedProps.size()); Assert.assertTrue(changedProps.contains("name")); - + Map dirtyValues = beanState.getDirtyValues(); Assert.assertEquals(1, dirtyValues.size()); Assert.assertTrue(dirtyValues.keySet().contains("name")); - + ValuePair valuePair = dirtyValues.get("name"); Assert.assertNotNull(valuePair); - Assert.assertEquals("changedFoo",valuePair.getNewValue()); - Assert.assertEquals("foo",valuePair.getOldValue()); - + Assert.assertEquals("changedFoo", valuePair.getNewValue()); + Assert.assertEquals("foo", valuePair.getOldValue()); + Eembeddable embeddableRead = emain.getEmbeddable(); embeddableRead.setDescription("embChanged"); - + Set changedProps2 = beanState.getChangedProps(); Assert.assertEquals(2, changedProps2.size()); Assert.assertTrue(changedProps2.contains("name")); Assert.assertTrue(changedProps2.contains("embeddable.description")); - + Map dirtyValues2 = beanState.getDirtyValues(); Assert.assertEquals(2, dirtyValues2.size()); Assert.assertTrue(dirtyValues2.keySet().contains("name")); Assert.assertTrue(dirtyValues2.keySet().contains("embeddable.description")); - - ValuePair valuePair2 = dirtyValues2.get("embeddable.description"); - Assert.assertEquals("embChanged",valuePair2.getNewValue()); - Assert.assertEquals("bar",valuePair2.getOldValue()); - } + ValuePair valuePair2 = dirtyValues2.get("embeddable.description"); + Assert.assertEquals("embChanged", valuePair2.getNewValue()); + Assert.assertEquals("bar", valuePair2.getOldValue()); + } @Test public void testEmbeddedUpdateSetNewBean() { - + EMain emain = new EMain(); - EntityBean eb = (EntityBean)emain; + EntityBean eb = (EntityBean) emain; EntityBeanIntercept ebi = eb._ebean_getIntercept(); emain.setId(1); emain.setName("foo"); Eembeddable embeddable = setEmbeddedBean(emain, "bar"); setEmbeddedLoaded(embeddable); - + // sets loaded state so follow setters are deemed as changes to the bean ebi.setLoaded(); - + emain.setName("changedFoo"); Assert.assertSame(embeddable, emain.getEmbeddable()); @@ -90,48 +88,48 @@ public class TestDirtyProperties extends BaseTestCase { Eembeddable embeddable2 = setEmbeddedBean(emain, "changeEmbeddedInstance"); Assert.assertSame(embeddable2, emain.getEmbeddable()); Assert.assertNotSame(embeddable, emain.getEmbeddable()); - - + + DefaultBeanState beanState = new DefaultBeanState(eb); - + Set changedProps2 = beanState.getChangedProps(); Assert.assertEquals(2, changedProps2.size()); Assert.assertTrue(changedProps2.contains("name")); - + Assert.assertTrue("The whole bean instance has changed", changedProps2.contains("embeddable")); - + Map dirtyValues2 = beanState.getDirtyValues(); Assert.assertEquals(2, dirtyValues2.size()); Assert.assertTrue(dirtyValues2.keySet().contains("name")); Assert.assertTrue(dirtyValues2.keySet().contains("embeddable")); - - + + ValuePair valuePair2 = dirtyValues2.get("embeddable"); Assert.assertSame(embeddable2, valuePair2.getNewValue()); Assert.assertSame(embeddable, valuePair2.getOldValue()); - + } private void setEmbeddedLoaded(Eembeddable embeddable) { - ((EntityBean)embeddable)._ebean_getIntercept().setLoaded(); + ((EntityBean) embeddable)._ebean_getIntercept().setLoaded(); } - + private Eembeddable setEmbeddedBean(EMain emain, String description) { - + Eembeddable embeddable = new Eembeddable(); embeddable.setDescription(description); - + emain.setEmbeddable(embeddable); - - EntityBean owner = (EntityBean)emain; - EntityBeanIntercept ebi= owner._ebean_getIntercept(); - + + EntityBean owner = (EntityBean) emain; + EntityBeanIntercept ebi = owner._ebean_getIntercept(); + // hooks the embeddable bean back to the owner int embeddablePropertyIndex = ebi.findProperty("embeddable"); Assert.assertTrue(embeddablePropertyIndex > -1); - ((EntityBean)embeddable)._ebean_getIntercept().setEmbeddedOwner(owner, embeddablePropertyIndex); + ((EntityBean) embeddable)._ebean_getIntercept().setEmbeddedOwner(owner, embeddablePropertyIndex); return embeddable; } } diff --git a/src/test/java/com/avaje/ebean/TestFilterWithEnum.java b/src/test/java/com/avaje/ebean/TestFilterWithEnum.java index 252cfec2b..39881f4b9 100644 --- a/src/test/java/com/avaje/ebean/TestFilterWithEnum.java +++ b/src/test/java/com/avaje/ebean/TestFilterWithEnum.java @@ -1,12 +1,11 @@ package com.avaje.ebean; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestFilterWithEnum extends BaseTestCase { diff --git a/src/test/java/com/avaje/ebean/TestPropertyChangeListener.java b/src/test/java/com/avaje/ebean/TestPropertyChangeListener.java index d43b928c4..49c7a23e5 100644 --- a/src/test/java/com/avaje/ebean/TestPropertyChangeListener.java +++ b/src/test/java/com/avaje/ebean/TestPropertyChangeListener.java @@ -1,50 +1,49 @@ package com.avaje.ebean; +import com.avaje.tests.model.basic.Customer; +import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; - -import com.avaje.tests.model.basic.Customer; -import com.avaje.tests.model.basic.ResetBasicData; - public class TestPropertyChangeListener extends BaseTestCase { @Test public void test() { - + ResetBasicData.reset(); - + List list = Ebean.find(Customer.class).findList(); - + Listener listener = new Listener(); - + Customer customer = list.get(0); Ebean.getBeanState(customer).addPropertyChangeListener(listener); - + customer.setName("modName"); customer.setSmallnote("modSmallNote"); - + Assert.assertEquals(2, listener.events.size()); Assert.assertEquals("modName", listener.events.get(0).getNewValue()); Assert.assertEquals("name", listener.events.get(0).getPropertyName()); Assert.assertEquals("modSmallNote", listener.events.get(1).getNewValue()); Assert.assertEquals("smallnote", listener.events.get(1).getPropertyName()); - + } - + class Listener implements PropertyChangeListener { List events = new ArrayList<>(); - + @Override public void propertyChange(PropertyChangeEvent evt) { events.add(evt); } } - + } diff --git a/src/test/java/com/avaje/ebean/TestRawSqlBuilder.java b/src/test/java/com/avaje/ebean/TestRawSqlBuilder.java index 7b44f9592..01171720d 100644 --- a/src/test/java/com/avaje/ebean/TestRawSqlBuilder.java +++ b/src/test/java/com/avaje/ebean/TestRawSqlBuilder.java @@ -1,12 +1,11 @@ package com.avaje.ebean; +import com.avaje.ebean.RawSql.Sql; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import com.avaje.tests.model.rawsql.ERawSqlAggBean; import org.junit.Test; -import com.avaje.ebean.RawSql.Sql; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -50,8 +49,8 @@ public class TestRawSqlBuilder extends BaseTestCase { RawSql rawSql = r.create(); Ebean.find(Customer.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); } @Test @@ -84,7 +83,7 @@ public class TestRawSqlBuilder extends BaseTestCase { assertEquals("id desc", sql.getOrderBy()); r = RawSqlBuilder - .parse("select id, sum(x) from t_cust where id > ? group by id order by id desc"); + .parse("select id, sum(x) from t_cust where id > ? group by id order by id desc"); sql = r.getSql(); assertEquals("id, sum(x)", sql.getPreFrom()); assertEquals("from t_cust where id > ?", sql.getPreWhere()); @@ -96,7 +95,7 @@ public class TestRawSqlBuilder extends BaseTestCase { public void testWithHaving() { RawSqlBuilder r = RawSqlBuilder - .parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ? order by id desc"); + .parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ? order by id desc"); Sql sql = r.getSql(); assertEquals("id, sum(x)", sql.getPreFrom()); assertEquals("from t_cust where id > ?", sql.getPreWhere()); @@ -106,7 +105,7 @@ public class TestRawSqlBuilder extends BaseTestCase { // no where r = RawSqlBuilder - .parse("select id, sum(x) from t_cust group by id having sum(x) > ? order by id desc"); + .parse("select id, sum(x) from t_cust group by id having sum(x) > ? order by id desc"); sql = r.getSql(); assertEquals("id, sum(x)", sql.getPreFrom()); assertEquals("from t_cust", sql.getPreWhere()); @@ -125,7 +124,7 @@ public class TestRawSqlBuilder extends BaseTestCase { // no order by r = RawSqlBuilder - .parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ?"); + .parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ?"); sql = r.getSql(); assertEquals("id, sum(x)", sql.getPreFrom()); assertEquals("from t_cust where id > ?", sql.getPreWhere()); @@ -140,7 +139,7 @@ public class TestRawSqlBuilder extends BaseTestCase { @Test public void testWithOrderSiblingsByName() { - String s = "SELECT ID, DESCRIPTION, NAME, PARENT_ID FROM SOME_TABLE WHERE lower(NAME) like :name START WITH ID = :parentId CONNECT BY PRIOR ID = PARENT_ID order siblings by NAME"; + String s = "SELECT ID, DESCRIPTION, NAME, PARENT_ID FROM SOME_TABLE WHERE lower(NAME) like :name START WITH ID = :parentId CONNECT BY PRIOR ID = PARENT_ID order siblings by NAME"; RawSql rawSql = RawSqlBuilder.parse(s).create(); @@ -153,24 +152,23 @@ public class TestRawSqlBuilder extends BaseTestCase { } - @Test public void testWithAlias() { - String rs = "select o.id, o.status, c.id, c.name, "+ - " d.id, d.order_qty, p.id, p.name " + - "from o_order o join o_customer c on c.id = o.kcustomer_id " + - "join o_order_detail d on d.order_id = o.id " + - "join o_product p on p.id = d.product_id " + - "where o.id <= :maxOrderId and p.id = :productId "+ - "order by o.id, d.id asc"; + String rs = "select o.id, o.status, c.id, c.name, " + + " d.id, d.order_qty, p.id, p.name " + + "from o_order o join o_customer c on c.id = o.kcustomer_id " + + "join o_order_detail d on d.order_id = o.id " + + "join o_product p on p.id = d.product_id " + + "where o.id <= :maxOrderId and p.id = :productId " + + "order by o.id, d.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("c", "customer") - .tableAliasMapping("d", "details") - .tableAliasMapping("p", "details.product") - .create(); + .tableAliasMapping("c", "customer") + .tableAliasMapping("d", "details") + .tableAliasMapping("p", "details.product") + .create(); RawSql.ColumnMapping columnMapping = rawSql.getColumnMapping(); assertEquals(0, columnMapping.getIndexPosition("id")); @@ -187,12 +185,12 @@ public class TestRawSqlBuilder extends BaseTestCase { @Test public void testWithCoalesceFunction() { - String rs = "select id, coalesce(status,'E') as status, "+ - " budgets.amount as budget," + - " COALESCE(month_sums.sum,0.0) as transaction_sum, " + - " COALESCE(month_balances.balance,0.0) as balance, " + - " COALESCE(month_sums.end_date,date_trunc('month',budgets.month),month_balances.end_date) as data_month"+ - " from o_order order by id asc"; + String rs = "select id, coalesce(status,'E') as status, " + + " budgets.amount as budget," + + " COALESCE(month_sums.sum,0.0) as transaction_sum, " + + " COALESCE(month_balances.balance,0.0) as balance, " + + " COALESCE(month_sums.end_date,date_trunc('month',budgets.month),month_balances.end_date) as data_month" + + " from o_order order by id asc"; RawSqlBuilder builder = RawSqlBuilder.parse(rs); @@ -217,11 +215,11 @@ public class TestRawSqlBuilder extends BaseTestCase { ResetBasicData.reset(); String sql = "select DATE_TRUNC('DAY', d.order_date) as day," + - " count(*) as total," + - " sum(case when d.status = 0 then 2 else 3 end) as scheduled," + - " sum(case when d.status = 1 then 1 else 0 end) as completed" + - " from o_order d" + - " group by DATE_TRUNC('DAY', d.order_date)"; + " count(*) as total," + + " sum(case when d.status = 0 then 2 else 3 end) as scheduled," + + " sum(case when d.status = 1 then 1 else 0 end) as completed" + + " from o_order d" + + " group by DATE_TRUNC('DAY', d.order_date)"; RawSql rawSql = RawSqlBuilder.parse(sql).create(); @@ -233,9 +231,9 @@ public class TestRawSqlBuilder extends BaseTestCase { assertEquals(3, columnMapping.getIndexPosition("completed")); Query query = Ebean.find(ERawSqlAggBean.class) - .setRawSql(rawSql) - .having().gt("total", 2) - .query(); + .setRawSql(rawSql) + .having().gt("total", 2) + .query(); query.findList(); diff --git a/src/test/java/com/avaje/ebean/TestRawSqlBuilderDistinct.java b/src/test/java/com/avaje/ebean/TestRawSqlBuilderDistinct.java index 93ec4ed87..292e41050 100644 --- a/src/test/java/com/avaje/ebean/TestRawSqlBuilderDistinct.java +++ b/src/test/java/com/avaje/ebean/TestRawSqlBuilderDistinct.java @@ -1,10 +1,8 @@ package com.avaje.ebean; -import junit.framework.TestCase; - -import org.junit.Assert; - import com.avaje.ebean.RawSql.Sql; +import junit.framework.TestCase; +import org.junit.Assert; public class TestRawSqlBuilderDistinct extends TestCase { diff --git a/src/test/java/com/avaje/ebean/TestRawSqlColumnParsing.java b/src/test/java/com/avaje/ebean/TestRawSqlColumnParsing.java index 51f89e364..a7824456e 100644 --- a/src/test/java/com/avaje/ebean/TestRawSqlColumnParsing.java +++ b/src/test/java/com/avaje/ebean/TestRawSqlColumnParsing.java @@ -1,164 +1,163 @@ package com.avaje.ebean; -import java.util.Map; - -import junit.framework.TestCase; - import com.avaje.ebean.RawSql.ColumnMapping; import com.avaje.ebean.RawSql.ColumnMapping.Column; +import junit.framework.TestCase; + +import java.util.Map; public class TestRawSqlColumnParsing extends TestCase { - public void test_simple() { - - ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a,b,c"); - Map mapping = columnMapping.mapping(); - Column c = mapping.get("a"); - - assertEquals("a",c.getDbColumn()); - assertEquals(0, c.getIndexPos()); - assertEquals("a",c.getPropertyName()); + public void test_simple() { - c = mapping.get("b"); - assertEquals("b",c.getDbColumn()); - assertEquals(1, c.getIndexPos()); - assertEquals("b",c.getPropertyName()); + ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a,b,c"); + Map mapping = columnMapping.mapping(); + Column c = mapping.get("a"); - c = mapping.get("c"); - assertEquals("c",c.getDbColumn()); - assertEquals(2, c.getIndexPos()); - assertEquals("c",c.getPropertyName()); + assertEquals("a", c.getDbColumn()); + assertEquals(0, c.getIndexPos()); + assertEquals("a", c.getPropertyName()); - } + c = mapping.get("b"); + assertEquals("b", c.getDbColumn()); + assertEquals(1, c.getIndexPos()); + assertEquals("b", c.getPropertyName()); - public void test_simpleWithSpacing() { - - ColumnMapping columnMapping = DRawSqlColumnsParser.parse(" a , b , c "); - Map mapping = columnMapping.mapping(); - Column c = mapping.get("a"); - - assertEquals("a",c.getDbColumn()); - assertEquals(0, c.getIndexPos()); - assertEquals("a", c.getPropertyName()); + c = mapping.get("c"); + assertEquals("c", c.getDbColumn()); + assertEquals(2, c.getIndexPos()); + assertEquals("c", c.getPropertyName()); - c = mapping.get("b"); - assertEquals("b",c.getDbColumn()); - assertEquals(1, c.getIndexPos()); - assertEquals("b",c.getPropertyName()); + } - c = mapping.get("c"); - assertEquals("c",c.getDbColumn()); - assertEquals(2, c.getIndexPos()); - assertEquals("c",c.getPropertyName()); + public void test_simpleWithSpacing() { - } - - public void test_withAlias() { - - ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, c c2 , d d3 , e e4 "); - Map mapping = columnMapping.mapping(); - - assertEquals(5, mapping.size()); - - Column c = mapping.get("a0"); - - assertEquals("a",c.getDbColumn()); - assertEquals(0, c.getIndexPos()); - assertEquals("a0",c.getPropertyName()); + ColumnMapping columnMapping = DRawSqlColumnsParser.parse(" a , b , c "); + Map mapping = columnMapping.mapping(); + Column c = mapping.get("a"); - c = mapping.get("b1"); - assertEquals("b",c.getDbColumn()); - assertEquals(1, c.getIndexPos()); - assertEquals("b1",c.getPropertyName()); + assertEquals("a", c.getDbColumn()); + assertEquals(0, c.getIndexPos()); + assertEquals("a", c.getPropertyName()); - c = mapping.get("c2"); - assertEquals("c",c.getDbColumn()); - assertEquals(2, c.getIndexPos()); - assertEquals("c2",c.getPropertyName()); + c = mapping.get("b"); + assertEquals("b", c.getDbColumn()); + assertEquals(1, c.getIndexPos()); + assertEquals("b", c.getPropertyName()); - c = mapping.get("d3"); - assertEquals("d",c.getDbColumn()); - assertEquals(3, c.getIndexPos()); - assertEquals("d3",c.getPropertyName()); + c = mapping.get("c"); + assertEquals("c", c.getDbColumn()); + assertEquals(2, c.getIndexPos()); + assertEquals("c", c.getPropertyName()); - - c = mapping.get("e4"); - assertEquals("e",c.getDbColumn()); - assertEquals(4, c.getIndexPos()); - assertEquals("e4",c.getPropertyName()); + } - } + public void test_withAlias() { - public void test_withDatabaseFunction() { + ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, c c2 , d d3 , e e4 "); + Map mapping = columnMapping.mapping(); - ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, MONTH(MAKEDATE(2015, 241)) m2 , d d3 , e e4 "); - Map mapping = columnMapping.mapping(); + assertEquals(5, mapping.size()); - assertEquals(5, mapping.size()); + Column c = mapping.get("a0"); - Column c = mapping.get("a0"); + assertEquals("a", c.getDbColumn()); + assertEquals(0, c.getIndexPos()); + assertEquals("a0", c.getPropertyName()); - assertEquals("a",c.getDbColumn()); - assertEquals(0, c.getIndexPos()); - assertEquals("a0",c.getPropertyName()); + c = mapping.get("b1"); + assertEquals("b", c.getDbColumn()); + assertEquals(1, c.getIndexPos()); + assertEquals("b1", c.getPropertyName()); - c = mapping.get("b1"); - assertEquals("b",c.getDbColumn()); - assertEquals(1, c.getIndexPos()); - assertEquals("b1",c.getPropertyName()); + c = mapping.get("c2"); + assertEquals("c", c.getDbColumn()); + assertEquals(2, c.getIndexPos()); + assertEquals("c2", c.getPropertyName()); - c = mapping.get("m2"); - assertEquals("MONTH(MAKEDATE(2015, 241))",c.getDbColumn()); - assertEquals(2, c.getIndexPos()); - assertEquals("m2",c.getPropertyName()); - - c = mapping.get("d3"); - assertEquals("d",c.getDbColumn()); - assertEquals(3, c.getIndexPos()); - assertEquals("d3",c.getPropertyName()); + c = mapping.get("d3"); + assertEquals("d", c.getDbColumn()); + assertEquals(3, c.getIndexPos()); + assertEquals("d3", c.getPropertyName()); - c = mapping.get("e4"); - assertEquals("e",c.getDbColumn()); - assertEquals(4, c.getIndexPos()); - assertEquals("e4",c.getPropertyName()); + c = mapping.get("e4"); + assertEquals("e", c.getDbColumn()); + assertEquals(4, c.getIndexPos()); + assertEquals("e4", c.getPropertyName()); - } + } - public void test_withAsAlias() { - - ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a as a0,'b' b1, \"c(blah)\" as c2 , d as d3 , e as e4 "); - Map mapping = columnMapping.mapping(); - - assertEquals(5, mapping.size()); - - Column c = mapping.get("a0"); - - assertEquals("a",c.getDbColumn()); - assertEquals(0, c.getIndexPos()); - assertEquals("a0",c.getPropertyName()); + public void test_withDatabaseFunction() { - c = mapping.get("b1"); - assertEquals("'b'",c.getDbColumn()); - assertEquals(1, c.getIndexPos()); - assertEquals("b1",c.getPropertyName()); + ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, MONTH(MAKEDATE(2015, 241)) m2 , d d3 , e e4 "); + Map mapping = columnMapping.mapping(); - c = mapping.get("c2"); - assertEquals("\"c(blah)\"",c.getDbColumn()); - assertEquals(2, c.getIndexPos()); - assertEquals("c2",c.getPropertyName()); + assertEquals(5, mapping.size()); - c = mapping.get("d3"); - assertEquals("d",c.getDbColumn()); - assertEquals(3, c.getIndexPos()); - assertEquals("d3",c.getPropertyName()); + Column c = mapping.get("a0"); - - c = mapping.get("e4"); - assertEquals("e",c.getDbColumn()); - assertEquals(4, c.getIndexPos()); - assertEquals("e4",c.getPropertyName()); + assertEquals("a", c.getDbColumn()); + assertEquals(0, c.getIndexPos()); + assertEquals("a0", c.getPropertyName()); - } + c = mapping.get("b1"); + assertEquals("b", c.getDbColumn()); + assertEquals(1, c.getIndexPos()); + assertEquals("b1", c.getPropertyName()); + + c = mapping.get("m2"); + assertEquals("MONTH(MAKEDATE(2015, 241))", c.getDbColumn()); + assertEquals(2, c.getIndexPos()); + assertEquals("m2", c.getPropertyName()); + + c = mapping.get("d3"); + assertEquals("d", c.getDbColumn()); + assertEquals(3, c.getIndexPos()); + assertEquals("d3", c.getPropertyName()); + + + c = mapping.get("e4"); + assertEquals("e", c.getDbColumn()); + assertEquals(4, c.getIndexPos()); + assertEquals("e4", c.getPropertyName()); + + } + + public void test_withAsAlias() { + + ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a as a0,'b' b1, \"c(blah)\" as c2 , d as d3 , e as e4 "); + Map mapping = columnMapping.mapping(); + + assertEquals(5, mapping.size()); + + Column c = mapping.get("a0"); + + assertEquals("a", c.getDbColumn()); + assertEquals(0, c.getIndexPos()); + assertEquals("a0", c.getPropertyName()); + + c = mapping.get("b1"); + assertEquals("'b'", c.getDbColumn()); + assertEquals(1, c.getIndexPos()); + assertEquals("b1", c.getPropertyName()); + + c = mapping.get("c2"); + assertEquals("\"c(blah)\"", c.getDbColumn()); + assertEquals(2, c.getIndexPos()); + assertEquals("c2", c.getPropertyName()); + + c = mapping.get("d3"); + assertEquals("d", c.getDbColumn()); + assertEquals(3, c.getIndexPos()); + assertEquals("d3", c.getPropertyName()); + + + c = mapping.get("e4"); + assertEquals("e", c.getDbColumn()); + assertEquals(4, c.getIndexPos()); + assertEquals("e4", c.getPropertyName()); + + } } diff --git a/src/test/java/com/avaje/ebean/TestUnsetLoadedProperties.java b/src/test/java/com/avaje/ebean/TestUnsetLoadedProperties.java index fa6937e69..50d055848 100644 --- a/src/test/java/com/avaje/ebean/TestUnsetLoadedProperties.java +++ b/src/test/java/com/avaje/ebean/TestUnsetLoadedProperties.java @@ -57,7 +57,7 @@ public class TestUnsetLoadedProperties extends BaseTestCase { assertThat(beanState.getLoadedProps()).containsExactly("id", "name", "email"); // unset the loaded state for email - ((EntityBean)user)._ebean_getIntercept().setPropertyLoaded("email", false); + ((EntityBean) user)._ebean_getIntercept().setPropertyLoaded("email", false); assertThat(beanState.getLoadedProps()).containsExactly("id", "name"); } diff --git a/src/test/java/com/avaje/ebean/TextExpressionListTest.java b/src/test/java/com/avaje/ebean/TextExpressionListTest.java index d13c0df39..50d096b46 100644 --- a/src/test/java/com/avaje/ebean/TextExpressionListTest.java +++ b/src/test/java/com/avaje/ebean/TextExpressionListTest.java @@ -12,51 +12,51 @@ public class TextExpressionListTest { public void syntax() { Ebean.find(Order.class) - .text().match("name", "rob"); + .text().match("name", "rob"); Ebean.find(Order.class) - .text().should() - .match("name", "rob") - .match("note", "war and peace"); + .text().should() + .match("name", "rob") + .match("note", "war and peace"); Ebean.find(Order.class) - .text() - .should() - .match("title", "war and peace") - .match("author", "leo tolstoy") - .should() - .match("translator", "Constance Garnett") - .match("translator", "Louise Maude"); + .text() + .should() + .match("title", "war and peace") + .match("author", "leo tolstoy") + .should() + .match("translator", "Constance Garnett") + .match("translator", "Louise Maude"); Ebean.find(Order.class) - .text() - .should() - .match("title", "war and peace") - .match("author", "leo tolstoy") - .should() - .match("translator", "Constance Garnett", new Match().opAnd().boost(2).minShouldMatch("75%")) - .match("translator", "Louise Maude") - .where() - .gt("reviewDate", 12345); + .text() + .should() + .match("title", "war and peace") + .match("author", "leo tolstoy") + .should() + .match("translator", "Constance Garnett", new Match().opAnd().boost(2).minShouldMatch("75%")) + .match("translator", "Louise Maude") + .where() + .gt("reviewDate", 12345); Ebean.find(Order.class) - .text() - .must() - .match("title", "quick") - .endJunction() - .should() - .match("title", "brown") - .match("title", "dog") - .endJunction() - .mustNot() - .match("title", "lazy") - .endJunction() - .where() - .gt("reviewDate", 12345); + .text() + .must() + .match("title", "quick") + .endJunction() + .should() + .match("title", "brown") + .match("title", "dog") + .endJunction() + .mustNot() + .match("title", "lazy") + .endJunction() + .where() + .gt("reviewDate", 12345); } @@ -65,16 +65,16 @@ public class TextExpressionListTest { public void syntax_multiMatch() { Ebean.find(Order.class) - .text() - .multiMatch("Will Smith", "title", "*name"); + .text() + .multiMatch("Will Smith", "title", "*name"); MultiMatch match = MultiMatch.fields("title", "*name") - .opAnd() - .type(MultiMatch.Type.PHRASE_PREFIX); + .opAnd() + .type(MultiMatch.Type.PHRASE_PREFIX); Ebean.find(Order.class) - .text() - .multiMatch("Will Smith", match); + .text() + .multiMatch("Will Smith", match); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/TxScopeTest.java b/src/test/java/com/avaje/ebean/TxScopeTest.java index 5c3a4245b..046c5b1e9 100644 --- a/src/test/java/com/avaje/ebean/TxScopeTest.java +++ b/src/test/java/com/avaje/ebean/TxScopeTest.java @@ -3,7 +3,8 @@ package com.avaje.ebean; import com.avaje.ebean.config.PersistBatch; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class TxScopeTest { @@ -64,4 +65,4 @@ public class TxScopeTest { assertNull(scope.getBatch()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/UpdateQueryTest.java b/src/test/java/com/avaje/ebean/UpdateQueryTest.java index 4f52d1866..74cb6f878 100644 --- a/src/test/java/com/avaje/ebean/UpdateQueryTest.java +++ b/src/test/java/com/avaje/ebean/UpdateQueryTest.java @@ -17,12 +17,12 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); UpdateQuery update = server.update(Customer.class); Query query = update - .set("status", Customer.Status.ACTIVE) - .set("updtime", new Timestamp(System.currentTimeMillis())) - .where() - .eq("status", Customer.Status.NEW) - .gt("id", 1000) - .query(); + .set("status", Customer.Status.ACTIVE) + .set("updtime", new Timestamp(System.currentTimeMillis())) + .where() + .eq("status", Customer.Status.NEW) + .gt("id", 1000) + .query(); query.update(); @@ -42,14 +42,14 @@ public class UpdateQueryTest extends BaseTestCase { UpdateQuery update = server.update(Customer.class); Query query = update - .set("status", Customer.Status.ACTIVE) - .set("updtime", new Timestamp(System.currentTimeMillis())) - .where() - .eq("status", Customer.Status.NEW) - .eq("billingAddress.country", nz) - //.isEmpty("contacts") - .gt("id", 1000) - .query(); + .set("status", Customer.Status.ACTIVE) + .set("updtime", new Timestamp(System.currentTimeMillis())) + .where() + .eq("status", Customer.Status.NEW) + .eq("billingAddress.country", nz) + //.isEmpty("contacts") + .gt("id", 1000) + .query(); query.update(); @@ -62,12 +62,12 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); Query updateQuery = server - .update(Customer.class) - .set("status", Customer.Status.ACTIVE) - .where() - .isEmpty("contacts") - .gt("id", 1000) - .query(); + .update(Customer.class) + .set("status", Customer.Status.ACTIVE) + .where() + .isEmpty("contacts") + .gt("id", 1000) + .query(); updateQuery.update(); @@ -80,11 +80,11 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); Query updateQuery = server - .update(Customer.class) - .setNull("status") - .where() - .gt("id", 1000) - .query(); + .update(Customer.class) + .setNull("status") + .where() + .gt("id", 1000) + .query(); updateQuery.update(); @@ -97,11 +97,11 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); Query updateQuery = server - .update(Customer.class) - .set("status", null) - .where() - .gt("id", 1000) - .query(); + .update(Customer.class) + .set("status", null) + .where() + .gt("id", 1000) + .query(); updateQuery.update(); @@ -114,11 +114,11 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); Query updateQuery = server - .update(Customer.class) - .setRaw("status = coalesce(status, 'A')") - .where() - .gt("id", 1000) - .query(); + .update(Customer.class) + .setRaw("status = coalesce(status, 'A')") + .where() + .gt("id", 1000) + .query(); updateQuery.update(); @@ -131,11 +131,11 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); Query updateQuery = server - .update(Customer.class) - .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) - .where() - .gt("id", 1000) - .query(); + .update(Customer.class) + .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) + .where() + .gt("id", 1000) + .query(); updateQuery.update(); @@ -148,11 +148,11 @@ public class UpdateQueryTest extends BaseTestCase { EbeanServer server = server(); int rows = server - .update(Customer.class) - .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) - .where() - .gt("id", 10000) - .update(); + .update(Customer.class) + .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) + .where() + .gt("id", 10000) + .update(); assertThat(rows).isEqualTo(0); } @@ -161,11 +161,11 @@ public class UpdateQueryTest extends BaseTestCase { public void useViaEbean() { int rows = Ebean.update(Customer.class) - .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) - .where() - .gt("id", 10000) - .update(); + .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE) + .where() + .gt("id", 10000) + .update(); assertThat(rows).isEqualTo(0); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java b/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java index c4db21e0b..16fb3b063 100644 --- a/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java +++ b/src/test/java/com/avaje/ebean/bean/EntityBeanInterceptTest.java @@ -32,7 +32,7 @@ public class EntityBeanInterceptTest extends BaseTestCase { Customer customer = list.get(0); - EntityBeanIntercept ebi = ((EntityBean)customer)._ebean_getIntercept(); + EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept(); assertFalse(ebi.hasDirtyProperty(propertyNames)); @@ -76,4 +76,4 @@ public class EntityBeanInterceptTest extends BaseTestCase { assertThat(ebi.isPartial()).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/common/BeanListTest.java b/src/test/java/com/avaje/ebean/common/BeanListTest.java index 6dca3d9ec..cd7225b3b 100644 --- a/src/test/java/com/avaje/ebean/common/BeanListTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanListTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class BeanListTest { @@ -270,7 +270,7 @@ public class BeanListTest { return true; } if (other instanceof SomeBean) { - return this.val.equals(((SomeBean)other).val); + return this.val.equals(((SomeBean) other).val); } else { return false; } diff --git a/src/test/java/com/avaje/ebean/common/BeanMapTest.java b/src/test/java/com/avaje/ebean/common/BeanMapTest.java index a5683bab8..c10195ccc 100644 --- a/src/test/java/com/avaje/ebean/common/BeanMapTest.java +++ b/src/test/java/com/avaje/ebean/common/BeanMapTest.java @@ -36,7 +36,7 @@ public class BeanMapTest { @Test public void testAdd() throws Exception { - BeanMap map = new BeanMap<>(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.put("1", object1); map.put("4", null); @@ -59,7 +59,7 @@ public class BeanMapTest { @Test public void testAddAll_given_emptyStart() throws Exception { - BeanMap set = new BeanMap<>(); + BeanMap set = new BeanMap<>(); set.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -72,7 +72,7 @@ public class BeanMapTest { @Test public void testAdd_given_someAlreadyIn() throws Exception { - BeanMap map = new BeanMap<>(some()); + BeanMap map = new BeanMap<>(some()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -88,7 +88,7 @@ public class BeanMapTest { @Test public void testAddSome_given_someAlreadyIn() throws Exception { - BeanMap map = new BeanMap<>(some()); + BeanMap map = new BeanMap<>(some()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -101,7 +101,7 @@ public class BeanMapTest { @Test public void testRemove_given_beansInAdditions() throws Exception { - BeanMap map = new BeanMap<>(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.putAll(all()); assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -117,7 +117,7 @@ public class BeanMapTest { @Test public void testRemoveAll_given_beansInAdditions() throws Exception { - BeanMap map = new BeanMap<>(); + BeanMap map = new BeanMap<>(); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.putAll(all()); assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3); @@ -133,7 +133,7 @@ public class BeanMapTest { @Test public void testRemove_given_beansNotInAdditions() throws Exception { - BeanMap map = new BeanMap<>(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -148,7 +148,7 @@ public class BeanMapTest { @Test public void testRemoveAll_given_beansNotInAdditions() throws Exception { - BeanMap map = new BeanMap<>(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -163,7 +163,7 @@ public class BeanMapTest { @Test public void testClear() throws Exception { - BeanMap map = new BeanMap<>(all()); + BeanMap map = new BeanMap<>(all()); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); // act @@ -177,8 +177,8 @@ public class BeanMapTest { @Test public void testClear_given_someBeansInAdditions() throws Exception { - BeanMap map = new BeanMap<>(); - map.put("1",object1); + BeanMap map = new BeanMap<>(); + map.put("1", object1); map.setModifyListening(BeanCollection.ModifyListenMode.ALL); map.put("2", object2); map.put("3", object3); @@ -191,4 +191,4 @@ public class BeanMapTest { assertThat(map.getModifyAdditions()).isEmpty(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/DbMigrationConfigTest.java b/src/test/java/com/avaje/ebean/config/DbMigrationConfigTest.java index e86f92be3..b99c28fa9 100644 --- a/src/test/java/com/avaje/ebean/config/DbMigrationConfigTest.java +++ b/src/test/java/com/avaje/ebean/config/DbMigrationConfigTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class DbMigrationConfigTest { @@ -20,4 +20,4 @@ public class DbMigrationConfigTest { assertThat(migrationConfig.getMigrationPath()).isEqualTo("dbmigration/myapp"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/PropertiesWrapperTest.java b/src/test/java/com/avaje/ebean/config/PropertiesWrapperTest.java index 6337548ac..c1ad49dc6 100644 --- a/src/test/java/com/avaje/ebean/config/PropertiesWrapperTest.java +++ b/src/test/java/com/avaje/ebean/config/PropertiesWrapperTest.java @@ -21,7 +21,7 @@ public class PropertiesWrapperTest { public void testGetEnum() { Properties properties = new Properties(); - properties.put("platform","postgres"); + properties.put("platform", "postgres"); PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties); assertEquals(Platform.POSTGRES, pw.getEnum(Platform.class, "platform", Platform.H2)); @@ -33,17 +33,17 @@ public class PropertiesWrapperTest { public void testTrimPropertyValues() { Properties properties = new Properties(); - properties.put("someBasic"," hello "); - properties.put("someInt"," 42 "); - properties.put("noTrimReqr","jim"); - properties.put("includeSpaces"," jim bob "); + properties.put("someBasic", " hello "); + properties.put("someInt", " 42 "); + properties.put("noTrimReqr", "jim"); + properties.put("includeSpaces", " jim bob "); PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties); - assertEquals("hello",pw.get("someBasic")); + assertEquals("hello", pw.get("someBasic")); assertEquals(42, pw.getInt("someInt", 1)); assertNull(pw.get("doesNotExist", null)); - assertEquals("jim",pw.get("noTrimReqr")); - assertEquals("jim bob",pw.get("includeSpaces")); + assertEquals("jim", pw.get("noTrimReqr")); + assertEquals("jim bob", pw.get("includeSpaces")); } @Test @@ -53,9 +53,9 @@ public class PropertiesWrapperTest { String tmpDir = System.getProperty("java.io.tmpdir"); Properties properties = new Properties(); - properties.put("someBasic","hello"); - properties.put("someInt","42"); - properties.put("someDouble","5.5"); + properties.put("someBasic", "hello"); + properties.put("someInt", "42"); + properties.put("someDouble", "5.5"); properties.put("somePath", "${HOME}/hello"); properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb"); @@ -63,28 +63,28 @@ public class PropertiesWrapperTest { assertEquals(42, pw.getInt("someInt", 99)); assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D)))); - assertEquals(home+"/hello", pw.get("somePath", null)); - assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", pw.get("someSystemProp")); + assertEquals(home + "/hello", pw.get("somePath", null)); + assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp")); Properties properties1 = pw.asPropertiesLowerCase(); assertEquals("hello", properties1.getProperty("somebasic")); assertEquals("42", properties1.getProperty("someint")); - assertEquals(home+"/hello", properties1.get("somepath")); - assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", properties1.get("somesystemprop")); + assertEquals(home + "/hello", properties1.get("somepath")); + assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", properties1.get("somesystemprop")); pw = new PropertiesWrapper(properties); assertEquals(42, pw.getInt("someInt", 99)); assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D)))); - assertEquals(home+"/hello", pw.get("somePath", null)); - assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", pw.get("someSystemProp")); + assertEquals(home + "/hello", pw.get("somePath", null)); + assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp")); properties1 = pw.asPropertiesLowerCase(); assertEquals("hello", properties1.getProperty("somebasic")); assertEquals("42", properties1.getProperty("someint")); - assertEquals(home+"/hello", properties1.get("somepath")); - assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", properties1.get("somesystemprop")); + assertEquals(home + "/hello", properties1.get("somepath")); + assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", properties1.get("somesystemprop")); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java index 9b95de0e7..63435d9f5 100644 --- a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java +++ b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java @@ -28,7 +28,7 @@ public class ServerConfigTest { Properties props = new Properties(); props.setProperty("persistBatch", "INSERT"); props.setProperty("persistBatchOnCascade", "INSERT"); - props.setProperty("dbuuid","binary"); + props.setProperty("dbuuid", "binary"); props.setProperty("jdbcFetchSizeFindEach", "42"); props.setProperty("jdbcFetchSizeFindList", "43"); props.setProperty("backgroundExecutorShutdownSecs", "98"); diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlLimitOffsetTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlLimitOffsetTest.java index b61391bb1..413f48b6c 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlLimitOffsetTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlLimitOffsetTest.java @@ -13,7 +13,7 @@ public class BasicSqlLimitOffsetTest { String query = "select * from mytab order by id"; String sql = limiter.limit(query, 0, 10); - assertThat(sql).isEqualTo(query+" limit 10"); + assertThat(sql).isEqualTo(query + " limit 10"); } @Test @@ -21,7 +21,7 @@ public class BasicSqlLimitOffsetTest { String query = "select * from mytab order by id"; String sql = limiter.limit(query, 5, 10); - assertThat(sql).isEqualTo(query+" limit 10 offset 5"); + assertThat(sql).isEqualTo(query + " limit 10 offset 5"); } @Test @@ -31,4 +31,4 @@ public class BasicSqlLimitOffsetTest { String sql = limiter.limit(query, 0, 0); assertThat(sql).isEqualTo(query); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlStandardLimiterTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlStandardLimiterTest.java index e1723b1ab..66298d7c3 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlStandardLimiterTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/BasicSqlStandardLimiterTest.java @@ -13,7 +13,7 @@ public class BasicSqlStandardLimiterTest { String query = "select * from mytab order by id"; String sql = limiter.limit(query, 0, 10); - assertThat(sql).isEqualTo(query+" fetch next 10 rows only"); + assertThat(sql).isEqualTo(query + " fetch next 10 rows only"); } @Test @@ -21,7 +21,7 @@ public class BasicSqlStandardLimiterTest { String query = "select * from mytab order by id"; String sql = limiter.limit(query, 5, 10); - assertThat(sql).isEqualTo(query+" offset 5 rows fetch next 10 rows only"); + assertThat(sql).isEqualTo(query + " offset 5 rows fetch next 10 rows only"); } @Test @@ -32,4 +32,4 @@ public class BasicSqlStandardLimiterTest { assertThat(sql).isEqualTo(query); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookupTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookupTest.java index fd306c2be..a20752ebc 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookupTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeLookupTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import java.sql.Types; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DbPlatformTypeLookupTest { @@ -50,4 +50,4 @@ public class DbPlatformTypeLookupTest { assertEquals(lookup.byId(ExtraDbTypes.JSONVarchar), DbType.JSONVARCHAR); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java index 45e5ceb18..66e3d60c2 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/DbPlatformTypeParserTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DbPlatformTypeParserTest { @@ -64,4 +64,4 @@ public class DbPlatformTypeParserTest { assertEquals(type.getDefaultScale(), 0); assertEquals(type.renderType(0, 0), "something(asd"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/DbTypeMapTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/DbTypeMapTest.java index cb5e6598f..be909c483 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/DbTypeMapTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/DbTypeMapTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class DbTypeMapTest { @@ -13,16 +13,16 @@ public class DbTypeMapTest { PostgresPlatform pg = new PostgresPlatform(); DbPlatformTypeMapping dbTypeMap = pg.getDbTypeMap(); - assertThat(dbTypeMap.lookup("clob", false).renderType(0,0)).isEqualTo("text"); + assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("text"); assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("text"); - assertThat(dbTypeMap.lookup("varchar", true).renderType(20,0)).isEqualTo("varchar(20)"); + assertThat(dbTypeMap.lookup("varchar", true).renderType(20, 0)).isEqualTo("varchar(20)"); - assertThat(dbTypeMap.lookup("json", false).renderType(0,0)).isEqualTo("json"); - assertThat(dbTypeMap.lookup("jsonb", false).renderType(0,0)).isEqualTo("jsonb"); - assertThat(dbTypeMap.lookup("jsonclob", false).renderType(0,0)).isEqualTo("text"); - assertThat(dbTypeMap.lookup("jsonblob", false).renderType(0,0)).isEqualTo("bytea"); - assertThat(dbTypeMap.lookup("jsonvarchar", false).renderType(200,0)).isEqualTo("varchar(200)"); + assertThat(dbTypeMap.lookup("json", false).renderType(0, 0)).isEqualTo("json"); + assertThat(dbTypeMap.lookup("jsonb", false).renderType(0, 0)).isEqualTo("jsonb"); + assertThat(dbTypeMap.lookup("jsonclob", false).renderType(0, 0)).isEqualTo("text"); + assertThat(dbTypeMap.lookup("jsonblob", false).renderType(0, 0)).isEqualTo("bytea"); + assertThat(dbTypeMap.lookup("jsonvarchar", false).renderType(200, 0)).isEqualTo("varchar(200)"); } @@ -35,4 +35,4 @@ public class DbTypeMapTest { assertThat(dbType).isSameAs(json); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/MySqlHistorySupportTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/MySqlHistorySupportTest.java index 53f03710d..deae7ebab 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/MySqlHistorySupportTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/MySqlHistorySupportTest.java @@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals; public class MySqlHistorySupportTest { private MySqlHistorySupport support = new MySqlHistorySupport(); - + @Test public void getAsOfPredicate() { @@ -29,4 +29,4 @@ public class MySqlHistorySupportTest { String upper = support.getSysPeriodUpper("t0", "sys_period"); assertEquals(upper, "t0.sys_period_end"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresHistorySupportTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresHistorySupportTest.java index 79a87069f..5f022f3db 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresHistorySupportTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresHistorySupportTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class PostgresHistorySupportTest { @@ -35,4 +35,4 @@ public class PostgresHistorySupportTest { assertEquals(upper, "upper(t0.sys_period)"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java index 9078e53f2..1f73168cf 100644 --- a/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java +++ b/src/test/java/com/avaje/ebean/config/dbplatform/PostgresPlatformTest.java @@ -9,7 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat; public class PostgresPlatformTest { - @Test public void testTypeConversion() { diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/Helper.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/Helper.java index 5c0b307fc..acd195dcf 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/Helper.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/Helper.java @@ -62,7 +62,7 @@ public class Helper { public static String asText(Object instance, String relativePath) throws IOException { InputStream is = instance.getClass().getResourceAsStream(relativePath); if (is == null) { - throw new IllegalArgumentException("resource "+relativePath+" not found"); + throw new IllegalArgumentException("resource " + relativePath + " not found"); } return asText(is); } diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdlTest.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdlTest.java index 641e67ce1..9c267aa12 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdlTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/H2HistoryDdlTest.java @@ -17,7 +17,7 @@ public class H2HistoryDdlTest { @Test public void testRegenerateHistoryTriggers() throws Exception { - SpiEbeanServer ebeanServer = (SpiEbeanServer)Ebean.getDefaultServer(); + SpiEbeanServer ebeanServer = (SpiEbeanServer) Ebean.getDefaultServer(); HistoryTableUpdate update = new HistoryTableUpdate("c_user"); update.add(HistoryTableUpdate.Change.ADD, "one"); @@ -38,4 +38,4 @@ public class H2HistoryDdlTest { assertThat(write.dropAll().isEmpty()).isTrue(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/IndexSetTest.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/IndexSetTest.java index 8b1dc4573..67e88740e 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/IndexSetTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/IndexSetTest.java @@ -3,7 +3,8 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform; import com.avaje.ebean.dbmigration.ddlgeneration.platform.util.IndexSet; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class IndexSetTest { @@ -18,9 +19,9 @@ public class IndexSetTest { assertFalse(set.add(new String[]{"one_column"})); assertTrue(set.add(new String[]{"a", "b"})); - assertTrue(set.add(new String[]{"b","c"})); + assertTrue(set.add(new String[]{"b", "c"})); assertTrue(set.add(new String[]{"a"})); assertFalse(set.add(new String[]{"a", "b"})); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/VowelRemoverTest.java b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/VowelRemoverTest.java index 2767cf2c7..712e660ee 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/VowelRemoverTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/ddlgeneration/platform/util/VowelRemoverTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform.util; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class VowelRemoverTest { @@ -10,8 +10,8 @@ public class VowelRemoverTest { public void testTrim() throws Exception { - assertEquals("fk_abcd",VowelRemover.trim("fk_abcde",4)); + assertEquals("fk_abcd", VowelRemover.trim("fk_abcde", 4)); assertEquals("fk_a", VowelRemover.trim("fk_aaaaaa", 4)); assertEquals("ab_avrylngtblnm", VowelRemover.trim("ab_averylongtablename", 4)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java b/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java index 4a555e4dc..5da4f95b3 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/migrationreader/MigrationXmlWriterTest.java @@ -16,14 +16,14 @@ public class MigrationXmlWriterTest { assertThat(migration.getChangeSet()).hasSize(1); assertThat(migration.getChangeSet().get(0).getChangeSetChildren()).hasSize(3); - File temp = File.createTempFile("migrationWrite",".xml"); + File temp = File.createTempFile("migrationWrite", ".xml"); new MigrationXmlWriter("THIS IS A GENERATED FILE - DO NOT MODIFY").write(migration, temp); Migration migrationRead = MigrationXmlReader.read(temp); assertThat(migrationRead.getChangeSet()).hasSize(1); assertThat(migrationRead.getChangeSet().get(0).getChangeSetChildren()).hasSize(3); - temp = File.createTempFile("migrationWrite",".xml"); + temp = File.createTempFile("migrationWrite", ".xml"); new MigrationXmlWriter(null).write(migration, temp); Migration migrationRead2 = MigrationXmlReader.read(temp); @@ -31,4 +31,4 @@ public class MigrationXmlWriterTest { assertThat(migrationRead2.getChangeSet()).hasSize(1); assertThat(migrationRead.getChangeSet().get(0).getChangeSetChildren()).hasSize(3); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/EntryTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/EntryTest.java index 46f7eeb57..1ca6d29c8 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/EntryTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/EntryTest.java @@ -91,7 +91,7 @@ public class EntryTest { PendingDrops.Entry entry = createEntry(pending); - assertThat(entry.removeDrops(changeSet("one","two"))).isTrue(); + assertThat(entry.removeDrops(changeSet("one", "two"))).isTrue(); assertThat(entry.list).asList().doesNotContain(pending); } @@ -117,7 +117,7 @@ public class EntryTest { PendingDrops.Entry entry = createEntry(pending); - assertThat(entry.removeDrops(changeSet("one","two"))).isFalse(); + assertThat(entry.removeDrops(changeSet("one", "two"))).isFalse(); assertThat(entry.list).asList().contains(pending); assertThat(pending.getChangeSetChildren()).asList().hasSize(2); @@ -143,9 +143,9 @@ public class EntryTest { static PendingDrops.Entry createEntry(ChangeSet... pending) { PendingDrops.Entry entry = new PendingDrops.Entry(MigrationVersion.parse("1.1")); - for (ChangeSet changeSet: pending) { + for (ChangeSet changeSet : pending) { entry.add(changeSet); } return entry; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/MColumnTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/MColumnTest.java index 0bcdf6e5e..d722ffb17 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/MColumnTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/MColumnTest.java @@ -4,7 +4,7 @@ import com.avaje.ebean.dbmigration.migration.AlterColumn; import org.jetbrains.annotations.NotNull; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class MColumnTest { @@ -319,4 +319,4 @@ public class MColumnTest { assertThat(diff.getApplyChanges()).hasSize(1); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/MTableTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/MTableTest.java index 794461e46..3686b8847 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/MTableTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/MTableTest.java @@ -10,35 +10,35 @@ import org.junit.Test; import java.util.List; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class MTableTest { static MTable base() { MTable table = new MTable("tab"); - table.addColumn(new MColumn("id","bigint")); - table.addColumn(new MColumn("name","varchar(20)")); - table.addColumn(new MColumn("status","varchar(3)")); + table.addColumn(new MColumn("id", "bigint")); + table.addColumn(new MColumn("name", "varchar(20)")); + table.addColumn(new MColumn("status", "varchar(3)")); return table; } static MTable newTable() { MTable table = new MTable("tab"); - table.addColumn(new MColumn("id","bigint")); - table.addColumn(new MColumn("name","varchar(20)")); - table.addColumn(new MColumn("comment","varchar(1000)")); + table.addColumn(new MColumn("id", "bigint")); + table.addColumn(new MColumn("name", "varchar(20)")); + table.addColumn(new MColumn("comment", "varchar(1000)")); return table; } static MTable newTableAdd2Columns() { MTable table = new MTable("tab"); - table.addColumn(new MColumn("id","bigint")); - table.addColumn(new MColumn("name","varchar(20)")); - table.addColumn(new MColumn("status","varchar(3)")); - table.addColumn(new MColumn("comment","varchar(1000)")); - table.addColumn(new MColumn("note","varchar(2000)")); + table.addColumn(new MColumn("id", "bigint")); + table.addColumn(new MColumn("name", "varchar(20)")); + table.addColumn(new MColumn("status", "varchar(3)")); + table.addColumn(new MColumn("comment", "varchar(1000)")); + table.addColumn(new MColumn("note", "varchar(2000)")); return table; } @@ -48,8 +48,8 @@ public class MTableTest { MTable table = new MTable("tab"); table.addColumn(modCol); - table.addColumn(new MColumn("id","bigint")); - table.addColumn(new MColumn("status","varchar(3)")); + table.addColumn(new MColumn("id", "bigint")); + table.addColumn(new MColumn("status", "varchar(3)")); return table; } @@ -60,8 +60,8 @@ public class MTableTest { base.registerPendingDropColumn("fullName"); base.registerPendingDropColumn("last"); - assertThat(base.allHistoryColumns(false)).containsExactly("id","name","status"); - assertThat(base.allHistoryColumns(true)).containsExactly("id","name","status","fullName","last"); + assertThat(base.allHistoryColumns(false)).containsExactly("id", "name", "status"); + assertThat(base.allHistoryColumns(true)).containsExactly("id", "name", "status", "fullName", "last"); } @Test @@ -80,14 +80,14 @@ public class MTableTest { List createChanges = diff.getApplyChanges(); assertThat(createChanges).hasSize(1); - AddColumn addColumn = (AddColumn)createChanges.get(0); + AddColumn addColumn = (AddColumn) createChanges.get(0); assertThat(addColumn.getColumn()).extracting("name").contains("comment"); assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)"); List dropChanges = diff.getDropChanges(); assertThat(dropChanges).hasSize(1); - DropColumn dropColumn = (DropColumn)dropChanges.get(0); + DropColumn dropColumn = (DropColumn) dropChanges.get(0); assertThat(dropColumn.getColumnName()).isEqualTo("status"); assertThat(dropColumn.getTableName()).isEqualTo("tab"); } @@ -101,9 +101,9 @@ public class MTableTest { List createChanges = diff.getApplyChanges(); assertThat(createChanges).hasSize(1); - AddColumn addColumn = (AddColumn)createChanges.get(0); - assertThat(addColumn.getColumn()).extracting("name").contains("comment","note"); - assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)","varchar(2000)"); + AddColumn addColumn = (AddColumn) createChanges.get(0); + assertThat(addColumn.getColumn()).extracting("name").contains("comment", "note"); + assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)", "varchar(2000)"); assertThat(diff.getDropChanges()).hasSize(0); @@ -118,7 +118,7 @@ public class MTableTest { List createChanges = diff.getApplyChanges(); assertThat(createChanges).hasSize(1); - AlterColumn alterColumn = (AlterColumn)createChanges.get(0); + AlterColumn alterColumn = (AlterColumn) createChanges.get(0); assertThat(alterColumn.getColumnName()).isEqualTo("name"); assertThat(alterColumn.getType()).isEqualTo("varchar(30)"); assertThat(alterColumn.isNotnull()).isEqualTo(true); @@ -224,4 +224,4 @@ public class MTableTest { assertThat(diff.getDropChanges().get(0)).isInstanceOf(DropHistoryTable.class); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java index 1ce65cd6e..76f33f4cf 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/MigrationVersionTest.java @@ -14,7 +14,7 @@ public class MigrationVersionTest { @Test public void sort() { - List list= new ArrayList<>(); + List list = new ArrayList<>(); list.add(MigrationVersion.parse("1.1__point")); list.add(MigrationVersion.parse("3.0__three")); list.add(MigrationVersion.parse("1.0__init")); @@ -166,4 +166,4 @@ public class MigrationVersionTest { assertThat(v1.compareTo(v3)).isEqualTo(-1); assertThat(v1.compareTo(v4)).isEqualTo(-1); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerTest.java index a56df0111..d669edc95 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/ModelContainerTest.java @@ -63,8 +63,8 @@ public class ModelContainerTest { List normalColumns = base.getTable("document").allHistoryColumns(false); List historyColumns = base.getTable("document").allHistoryColumns(true); - assertThat(historyColumns).contains("zong","boom","baz","bar"); - assertThat(normalColumns).doesNotContain("zing","zong","boom","baz","bar"); + assertThat(historyColumns).contains("zong", "boom", "baz", "bar"); + assertThat(normalColumns).doesNotContain("zing", "zong", "boom", "baz", "bar"); } @NotNull @@ -90,4 +90,4 @@ public class ModelContainerTest { private Migration mig(String path) { return MigrationXmlReader.read(ModelContainerTest.class.getResourceAsStream(path)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java index f0762a9fe..235e258b4 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/PendingDropsTest.java @@ -31,8 +31,8 @@ public class PendingDropsTest { DropColumn one = col("one"); DropColumn two = col("two"); - pendingDrops.add(V1_1, changeSet(one,two)); - pendingDrops.add(V1_1, changeSet("three","four")); + pendingDrops.add(V1_1, changeSet(one, two)); + pendingDrops.add(V1_1, changeSet("three", "four")); assertThat(pendingDrops.testGetEntryFor(V1_1).list).asList().hasSize(2); ChangeSet applied = changeSet("two"); @@ -50,11 +50,11 @@ public class PendingDropsTest { DropColumn one = col("one"); DropColumn two = col("two"); - pendingDrops.add(V1_1, changeSet(one,two)); - pendingDrops.add(V1_1, changeSet("three","four")); + pendingDrops.add(V1_1, changeSet(one, two)); + pendingDrops.add(V1_1, changeSet("three", "four")); assertThat(pendingDrops.testGetEntryFor(V1_1).list).asList().hasSize(2); - ChangeSet applied = changeSet("two","one"); + ChangeSet applied = changeSet("two", "one"); applied.setDropsFor("1.1"); assertThat(pendingDrops.appliedDropsFor(applied)).isFalse(); @@ -243,4 +243,4 @@ public class PendingDropsTest { return EntryTest.col(colName); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java index 6dcdbc8a8..23c3c7f76 100644 --- a/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java +++ b/src/test/java/com/avaje/ebean/dbmigration/model/build/ModelBuildBeanVisitorTest.java @@ -5,10 +5,10 @@ import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.config.DbConstraintNaming; import com.avaje.ebean.dbmigration.ddlgeneration.platform.DefaultConstraintMaxLength; -import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebean.dbmigration.model.MTable; import com.avaje.ebean.dbmigration.model.ModelContainer; import com.avaje.ebean.dbmigration.model.visitor.VisitAllUsing; +import com.avaje.ebeaninternal.api.SpiEbeanServer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -18,7 +18,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase { @Test public void test() { - SpiEbeanServer defaultServer = (SpiEbeanServer)Ebean.getDefaultServer(); + SpiEbeanServer defaultServer = (SpiEbeanServer) Ebean.getDefaultServer(); ModelContainer model = new ModelContainer(); @@ -39,4 +39,4 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase { MTable customer = model.getTable("o_customer"); assertThat(customer).isNotNull(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java b/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java index 2128c8b2a..3100b9e47 100644 --- a/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanFindControllerTest.java @@ -13,10 +13,7 @@ import org.junit.Test; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class BeanFindControllerTest extends BaseTestCase { @@ -93,7 +90,7 @@ public class BeanFindControllerTest extends BaseTestCase { @SuppressWarnings("unchecked") @Override public T find(BeanQueryRequest request) { - return (T)createBean(); + return (T) createBean(); } @Override @@ -107,7 +104,7 @@ public class BeanFindControllerTest extends BaseTestCase { public BeanCollection findMany(BeanQueryRequest request) { BeanList list = new BeanList<>(); - list.add((T)createBean()); + list.add((T) createBean()); return list; } } @@ -118,4 +115,4 @@ public class BeanFindControllerTest extends BaseTestCase { b.setName("47"); return b; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java index 7cbe11ee0..3acb39469 100644 --- a/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java +++ b/src/test/java/com/avaje/ebean/event/BeanPostLoadTest.java @@ -31,9 +31,9 @@ public class BeanPostLoadTest extends BaseTestCase { ebeanServer.save(bean); EBasicVer found = ebeanServer.find(EBasicVer.class) - .select("name, other") - .setId(bean.getId()) - .findUnique(); + .select("name, other") + .setId(bean.getId()) + .findUnique(); assertThat(postLoad.methodsCalled).hasSize(1); assertThat(postLoad.methodsCalled).containsExactly("postLoad"); @@ -61,7 +61,7 @@ public class BeanPostLoadTest extends BaseTestCase { config.getClasses().add(EBasicVer.class); config.add(postLoad); - + return EbeanServerFactory.create(config); } @@ -97,4 +97,4 @@ public class BeanPostLoadTest extends BaseTestCase { } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/json/EJsonTests.java b/src/test/java/com/avaje/ebean/json/EJsonTests.java index 598d4fdeb..faa299305 100644 --- a/src/test/java/com/avaje/ebean/json/EJsonTests.java +++ b/src/test/java/com/avaje/ebean/json/EJsonTests.java @@ -14,30 +14,26 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class EJsonTests { @Test public void test_map_simple() throws IOException { - + JsonFactory factory = new JsonFactory(); - + String jsonInput = "{\"name\":\"rob\",\"age\":12}"; JsonParser jsonParser = factory.createParser(jsonInput); Object result = EJson.parse(jsonParser); - + assertTrue(result instanceof Map); - Map map = (Map)result; + Map map = (Map) result; assertEquals("rob", map.get("name")); assertEquals(12L, map.get("age")); - + String jsonOutput = EJson.write(result); assertEquals(jsonInput, jsonOutput); } @@ -51,7 +47,7 @@ public class EJsonTests { JsonParser jsonParser = factory.createParser(jsonInput); - Map map = EJson.parseObject(jsonParser); + Map map = EJson.parseObject(jsonParser); assertNotNull(map); assertEquals("rob", map.get("name")); @@ -85,16 +81,16 @@ public class EJsonTests { Object result = EJson.parse(jsonInput); assertTrue(result instanceof Map); - Map map = (Map)result; + Map map = (Map) result; assertEquals(4, map.size()); assertEquals("rob", map.get("name")); assertEquals(12L, map.get("age")); - Map org = (Map)map.get("org"); + Map org = (Map) map.get("org"); assertEquals("superorg", org.get("name")); assertEquals(4L, org.get("rating")); - List nums = (List)map.get("nums"); + List nums = (List) map.get("nums"); assertEquals(3, nums.size()); assertEquals(1L, nums.get(0)); assertEquals(2L, nums.get(1)); @@ -111,7 +107,7 @@ public class EJsonTests { Object result = EJson.parse(jsonInput); assertTrue(result instanceof Map); - Map map = (Map)result; + Map map = (Map) result; assertEquals("rob", map.get("name")); assertNull(map.get("age")); @@ -181,7 +177,7 @@ public class EJsonTests { assertTrue(result instanceof List); - List> list = (List>)result; + List> list = (List>) result; assertEquals(2, list.size()); assertEquals("rob", list.get(0).get("name")); assertEquals(12L, list.get(0).get("age")); @@ -201,11 +197,11 @@ public class EJsonTests { Object result = EJson.parse(reader); assertTrue(result instanceof Map); - Map map = (Map)result; + Map map = (Map) result; assertEquals("rob", map.get("name")); assertNull(map.get("age")); - Map friend = (Map)map.get("friend"); + Map friend = (Map) map.get("friend"); assertEquals("mike", friend.get("name")); assertEquals(13L, friend.get("age")); } @@ -215,7 +211,7 @@ public class EJsonTests { public void test_map_nested_modifyAware() throws IOException { String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}"; - ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); + ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); assertFalse(map.isMarkedDirty()); assertEquals(4, map.size()); @@ -229,7 +225,7 @@ public class EJsonTests { public void test_map_nested_modifyAwareNestedList() throws IOException { String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}"; - ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); + ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); assertFalse(map.isMarkedDirty()); List nums = (List) map.get("nums"); @@ -242,11 +238,11 @@ public class EJsonTests { public void test_map_nested_modifyAwareNestedObject() throws IOException { String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}"; - ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); + ModifyAwareMap map = (ModifyAwareMap) EJson.parseObject(jsonInput, true); assertFalse(map.isMarkedDirty()); - Map org = (Map) map.get("org"); - org.put("extra","foo"); + Map org = (Map) map.get("org"); + org.put("extra", "foo"); assertTrue(map.isMarkedDirty()); } @@ -272,13 +268,13 @@ public class EJsonTests { Set set = EJson.parseSet(jsonInput, true); - ModifyAwareOwner modAware = (ModifyAwareOwner)set; + ModifyAwareOwner modAware = (ModifyAwareOwner) set; assertFalse(modAware.isMarkedDirty()); Iterator iterator = set.iterator(); if (iterator.hasNext()) { - Map map = (Map)iterator.next(); - map.put("name","stu"); + Map map = (Map) iterator.next(); + map.put("name", "stu"); assertTrue(modAware.isMarkedDirty()); } } diff --git a/src/test/java/com/avaje/ebean/plugin/BeanTypeTest.java b/src/test/java/com/avaje/ebean/plugin/BeanTypeTest.java index 1ca3b45db..730a04285 100644 --- a/src/test/java/com/avaje/ebean/plugin/BeanTypeTest.java +++ b/src/test/java/com/avaje/ebean/plugin/BeanTypeTest.java @@ -18,9 +18,7 @@ import com.avaje.tests.model.basic.Vehicle; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class BeanTypeTest { @@ -123,7 +121,7 @@ public class BeanTypeTest { BeanDocType orderDocType = beanType(Order.class).docStore(); FetchPath customer = orderDocType.getEmbedded("customer"); assertThat(customer).isNotNull(); - assertThat(customer.getProperties(null)).contains("id","name"); + assertThat(customer.getProperties(null)).contains("id", "name"); } @Test @@ -173,12 +171,12 @@ public class BeanTypeTest { @Test public void docStoreApplyPath() throws Exception { - SpiQuery orderQuery = (SpiQuery)server.find(Order.class); + SpiQuery orderQuery = (SpiQuery) server.find(Order.class); beanType(Order.class).docStore().applyPath(orderQuery); OrmQueryDetail detail = orderQuery.getDetail(); assertThat(detail.getChunk("customer", false).getSelectProperties()) - .containsExactly("id", "name"); + .containsExactly("id", "name"); } @@ -214,12 +212,12 @@ public class BeanTypeTest { @Test public void getDiscColumn_when_default() { - assertEquals(beanType(Car.class).getDiscColumn(),"dtype"); + assertEquals(beanType(Car.class).getDiscColumn(), "dtype"); } @Test public void getDiscColumn_when_set() { - assertEquals(beanType(Stockforecast.class).getDiscColumn(),"type"); + assertEquals(beanType(Stockforecast.class).getDiscColumn(), "type"); } @Test @@ -231,13 +229,13 @@ public class BeanTypeTest { @Test public void addInheritanceWhere_when_leaf() { Query query = server.find(Vehicle.class); - beanType(Car.class).addInheritanceWhere((SpiQuery)query); + beanType(Car.class).addInheritanceWhere((SpiQuery) query); } @Test public void addInheritanceWhere_when_root() { Query query = server.find(Vehicle.class); - beanType(Vehicle.class).addInheritanceWhere((SpiQuery)query); + beanType(Vehicle.class).addInheritanceWhere((SpiQuery) query); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/plugin/ExpressionPathTest.java b/src/test/java/com/avaje/ebean/plugin/ExpressionPathTest.java index e920074e1..7654fc6b9 100644 --- a/src/test/java/com/avaje/ebean/plugin/ExpressionPathTest.java +++ b/src/test/java/com/avaje/ebean/plugin/ExpressionPathTest.java @@ -82,37 +82,37 @@ public class ExpressionPathTest { BeanType customerBeanType = beanType(Customer.class); BeanType orderBeanType = beanType(Order.class); - - + + Customer customer = new Customer(); customer.setName("foo"); server.save(customer); - + customer = server.find(Customer.class, customer.getId()); assertThat(customer.getName()).isEqualTo("foo"); - + customerBeanType.getExpressionPath("name").pathSet(customer, "bar"); server.save(customer); - + customer = server.find(Customer.class, customer.getId()); assertThat(customer.getName()).isEqualTo("bar"); - - + + Order order = new Order(); order.setCustomer(customer); - + server.save(order); - + order = server.find(Order.class, order.getId()); - + ExpressionPath customerNamePath = orderBeanType.getExpressionPath("customer.name"); assertThat(customerNamePath.pathGet(order)).isEqualTo("bar"); - + customerNamePath.pathSet(order, "baz"); server.save(order); - + order = server.find(Order.class, order.getId()); assertThat(order.getCustomer().getName()).isEqualTo("baz"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java b/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java index 7f41b08e3..f79f27cd9 100644 --- a/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java +++ b/src/test/java/com/avaje/ebean/plugin/SpiServerTest.java @@ -7,12 +7,7 @@ import org.junit.Test; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class SpiServerTest { @@ -51,4 +46,4 @@ public class SpiServerTest { assertTrue(!allTypes.isEmpty()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/server/type/MyDayOfWeek.java b/src/test/java/com/avaje/ebean/server/type/MyDayOfWeek.java index 453c2b25d..b7710be00 100644 --- a/src/test/java/com/avaje/ebean/server/type/MyDayOfWeek.java +++ b/src/test/java/com/avaje/ebean/server/type/MyDayOfWeek.java @@ -7,11 +7,11 @@ import com.avaje.ebean.annotation.EnumValue; */ public enum MyDayOfWeek { - @EnumValue("MONDAY ") MONDAY, - @EnumValue("TUESDAY ") TUESDAY, - @EnumValue("WEDNESDAY") WEDNESDAY, - @EnumValue("THURSDAY ") THURSDAY, - @EnumValue("FRIDAY ") FRIDAY, - @EnumValue("SATURDAY ") SATURDAY, - @EnumValue("SUNDAY ") SUNDAY + @EnumValue("MONDAY ")MONDAY, + @EnumValue("TUESDAY ")TUESDAY, + @EnumValue("WEDNESDAY")WEDNESDAY, + @EnumValue("THURSDAY ")THURSDAY, + @EnumValue("FRIDAY ")FRIDAY, + @EnumValue("SATURDAY ")SATURDAY, + @EnumValue("SUNDAY ")SUNDAY } diff --git a/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java b/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java index 6f3ce1442..7334947df 100644 --- a/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java +++ b/src/test/java/com/avaje/ebean/server/type/TestTypeManager.java @@ -83,7 +83,7 @@ public class TestTypeManager extends BaseTestCase { Assert.assertTrue(checkImmutable.isImmutable()); ScalarDataReader dataReader = typeManager - .recursiveCreateScalarDataReader(ExhangeCMoneyRate.class); + .recursiveCreateScalarDataReader(ExhangeCMoneyRate.class); Assert.assertTrue(dataReader instanceof CtCompoundType); dataReader = typeManager.recursiveCreateScalarDataReader(CMoney.class); diff --git a/src/test/java/com/avaje/ebean/text/PathPropertiesTests.java b/src/test/java/com/avaje/ebean/text/PathPropertiesTests.java index 90aba639c..81f94a5c7 100644 --- a/src/test/java/com/avaje/ebean/text/PathPropertiesTests.java +++ b/src/test/java/com/avaje/ebean/text/PathPropertiesTests.java @@ -4,9 +4,7 @@ import com.avaje.ebean.FetchPath; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class PathPropertiesTests { diff --git a/src/test/java/com/avaje/ebean/text/json/JsonContextTest.java b/src/test/java/com/avaje/ebean/text/json/JsonContextTest.java index affad9527..738f42650 100644 --- a/src/test/java/com/avaje/ebean/text/json/JsonContextTest.java +++ b/src/test/java/com/avaje/ebean/text/json/JsonContextTest.java @@ -16,11 +16,7 @@ import java.util.List; import java.util.Map; import static org.assertj.core.api.StrictAssertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class JsonContextTest { @@ -40,9 +36,9 @@ public class JsonContextTest { ResetBasicData.reset(); List orders = Ebean.find(Order.class) - .fetch("customer", "id, name") - .where().eq("customer.id", 1) - .findList(); + .fetch("customer", "id, name") + .where().eq("customer.id", 1) + .findList(); String json = Ebean.json().toJson(orders); @@ -65,9 +61,9 @@ public class JsonContextTest { ResetBasicData.reset(); List orders = Ebean.find(Order.class) - .select("status") - .fetch("customer", "id, name") - .findList(); + .select("status") + .fetch("customer", "id, name") + .findList(); String json = Ebean.json().toJson(orders); @@ -220,4 +216,4 @@ public class JsonContextTest { assertEquals("START[{\"count\":12}]END", writer.toString()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebean/text/json/JsonWriteOptionsTests.java b/src/test/java/com/avaje/ebean/text/json/JsonWriteOptionsTests.java index 7ef2f9775..d8dfd8842 100644 --- a/src/test/java/com/avaje/ebean/text/json/JsonWriteOptionsTests.java +++ b/src/test/java/com/avaje/ebean/text/json/JsonWriteOptionsTests.java @@ -12,10 +12,10 @@ public class JsonWriteOptionsTests { @Test public void test_parse() { - + JsonWriteOptions options = JsonWriteOptions.parsePath("id,status,name"); FetchPath pathProps = options.getPathProperties(); - + //Assert.assertEquals(1, pathProps.getPaths().size()); assertTrue(pathProps.getProperties(null).contains("id")); assertTrue(pathProps.getProperties(null).contains("name")); @@ -57,5 +57,4 @@ public class JsonWriteOptionsTests { } - } diff --git a/src/test/java/com/avaje/ebean/util/CamelCaseHelperTest.java b/src/test/java/com/avaje/ebean/util/CamelCaseHelperTest.java index b8f30baf1..77997fe58 100644 --- a/src/test/java/com/avaje/ebean/util/CamelCaseHelperTest.java +++ b/src/test/java/com/avaje/ebean/util/CamelCaseHelperTest.java @@ -2,7 +2,7 @@ package com.avaje.ebean.util; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class CamelCaseHelperTest { @@ -28,4 +28,4 @@ public class CamelCaseHelperTest { assertEquals(CamelCaseHelper.toCamelFromUnderscore("HELLO"), "HELLO"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilderTest.java b/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilderTest.java index bcefc1289..20473c058 100644 --- a/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilderTest.java +++ b/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilderTest.java @@ -13,27 +13,27 @@ public class HashQueryPlanBuilderTest { @Test public void test_pair_0_1() { - assertThat(combine(0, 31)).isNotEqualTo(combine(1,0)); + assertThat(combine(0, 31)).isNotEqualTo(combine(1, 0)); } @Test public void test_pair_0_10_adjust_0() { - assertThat(combine(0, 310)).isNotEqualTo(combine(10,0)); + assertThat(combine(0, 310)).isNotEqualTo(combine(10, 0)); } @Test public void test_pair_0_10_adjust_10() { - assertThat(combine(0, 320)).isNotEqualTo(combine(10,10)); + assertThat(combine(0, 320)).isNotEqualTo(combine(10, 10)); } @Test public void test_pair_0_10_adjust_40() { - assertThat(combine(0, 350)).isNotEqualTo(combine(10,40)); + assertThat(combine(0, 350)).isNotEqualTo(combine(10, 40)); } @Test public void test_pair_0_10_adjust_90() { - assertThat(combine(0, 400)).isNotEqualTo(combine(10,90)); + assertThat(combine(0, 400)).isNotEqualTo(combine(10, 90)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanTest.java b/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanTest.java index 666dd0da9..d49e9f6a7 100644 --- a/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanTest.java +++ b/src/test/java/com/avaje/ebeaninternal/api/HashQueryPlanTest.java @@ -18,28 +18,28 @@ public class HashQueryPlanTest { @Test public void testEquals() throws Exception { - assertThat(hqp("foo",10, 7)).isEqualTo(hqp("foo",10, 7)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 11, 7)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 9, 7)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 10, 8)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 10, 6)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("bar", 10, 6)); - assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp(null, 10, 7)); - assertThat(hqp(null,10, 7)).isNotEqualTo(hqp("foo", 10, 7)); - assertThat(hqp(null,10, 7)).isEqualTo(hqp(null, 10, 7)); + assertThat(hqp("foo", 10, 7)).isEqualTo(hqp("foo", 10, 7)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 11, 7)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 9, 7)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 8)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 6)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("bar", 10, 6)); + assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp(null, 10, 7)); + assertThat(hqp(null, 10, 7)).isNotEqualTo(hqp("foo", 10, 7)); + assertThat(hqp(null, 10, 7)).isEqualTo(hqp(null, 10, 7)); } @Test public void testHashCode() throws Exception { - assertThat(hc("foo",10, 7)).isEqualTo(hc("foo",10, 7)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 11, 7)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 9, 7)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 10, 8)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 10, 6)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc("bar", 10, 6)); - assertThat(hc("foo",10, 7)).isNotEqualTo(hc(null, 10, 7)); - assertThat(hc(null,10, 7)).isNotEqualTo(hc("foo", 10, 7)); - assertThat(hc(null,10, 7)).isEqualTo(hc(null, 10, 7)); + assertThat(hc("foo", 10, 7)).isEqualTo(hc("foo", 10, 7)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 11, 7)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 9, 7)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 8)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 6)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("bar", 10, 6)); + assertThat(hc("foo", 10, 7)).isNotEqualTo(hc(null, 10, 7)); + assertThat(hc(null, 10, 7)).isNotEqualTo(hc("foo", 10, 7)); + assertThat(hc(null, 10, 7)).isEqualTo(hc(null, 10, 7)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java index aeb4dc840..bcdd913d4 100644 --- a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java +++ b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java @@ -1,6 +1,34 @@ package com.avaje.ebeaninternal.api; -import com.avaje.ebean.*; +import com.avaje.ebean.AutoTune; +import com.avaje.ebean.BackgroundExecutor; +import com.avaje.ebean.BeanState; +import com.avaje.ebean.CallableSql; +import com.avaje.ebean.DocumentStore; +import com.avaje.ebean.ExpressionFactory; +import com.avaje.ebean.Filter; +import com.avaje.ebean.FutureIds; +import com.avaje.ebean.FutureList; +import com.avaje.ebean.FutureRowCount; +import com.avaje.ebean.PagedList; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryEachConsumer; +import com.avaje.ebean.QueryEachWhileConsumer; +import com.avaje.ebean.QueryIterator; +import com.avaje.ebean.SqlQuery; +import com.avaje.ebean.SqlRow; +import com.avaje.ebean.SqlUpdate; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TransactionCallback; +import com.avaje.ebean.TxCallable; +import com.avaje.ebean.TxIsolation; +import com.avaje.ebean.TxRunnable; +import com.avaje.ebean.TxScope; +import com.avaje.ebean.Update; +import com.avaje.ebean.UpdateQuery; +import com.avaje.ebean.ValuePair; +import com.avaje.ebean.Version; import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.CallStack; import com.avaje.ebean.bean.EntityBeanIntercept; @@ -34,8 +62,10 @@ import java.util.Set; public class TDSpiEbeanServer implements SpiEbeanServer { String name; + public TDSpiEbeanServer() { } + public TDSpiEbeanServer(String name) { this.name = name; } diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/CacheBeanDataTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/CacheBeanDataTest.java index bfb172161..93303dafe 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/CacheBeanDataTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/CacheBeanDataTest.java @@ -109,7 +109,7 @@ public class CacheBeanDataTest extends BaseTestCase { assertNotNull(cacheData); - EPerson newPerson = (EPerson)desc.cacheEmbeddedBeanLoad(cacheData, context); + EPerson newPerson = (EPerson) desc.cacheEmbeddedBeanLoad(cacheData, context); assertNotNull(newPerson.getId()); assertNotNull(newPerson.getName()); diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBeanTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBeanTest.java index c208b2fcd..4c2da302e 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBeanTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataFromBeanTest.java @@ -53,15 +53,15 @@ public class CachedBeanDataFromBeanTest extends BaseTestCase { car.setDriver("Jimmy"); car.setNotes("some notes"); - BeanDescriptor carDesc = server.getBeanDescriptor(Car.class); + BeanDescriptor carDesc = server.getBeanDescriptor(Car.class); CachedBeanData cacheData = CachedBeanDataFromBean.extract(carDesc, (EntityBean) car); Car newCar = new Car(); - EntityBean entityBean = (EntityBean)newCar; + EntityBean entityBean = (EntityBean) newCar; CachedBeanDataToBean.load(carDesc, entityBean, cacheData, new DefaultPersistenceContext()); assertEquals(newCar.getId(), car.getId()); assertEquals(newCar.getDriver(), car.getDriver()); assertEquals(newCar.getNotes(), car.getNotes()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java index 8d48f7f84..44f40cf5c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/CachedBeanDataSerializeTest.java @@ -32,7 +32,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { Map map = new LinkedHashMap<>(); map.put("name", "rob"); map.put("some", "thing"); - map.put("whenCreated", ""+System.currentTimeMillis()); + map.put("whenCreated", "" + System.currentTimeMillis()); long version = System.currentTimeMillis(); CachedBeanData write = new CachedBeanData(null, "C", map, version); @@ -65,13 +65,13 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { ResetBasicData.reset(); List customers = Ebean.find(Customer.class) - .orderBy().asc("id") - .setMaxRows(1).findList(); + .orderBy().asc("id") + .setMaxRows(1).findList(); Customer customer = customers.get(0); BeanDescriptor desc = getBeanDescriptor(Customer.class); - CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean)customer); + CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) customer); ByteArrayOutputStream os = new ByteArrayOutputStream(); writeToStream(extract, os); @@ -83,7 +83,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { assertEquals(read.getData(), extract.getData()); Customer loadCustomer = new Customer(); - CachedBeanDataToBean.load(desc, (EntityBean)loadCustomer, read, new DefaultPersistenceContext()); + CachedBeanDataToBean.load(desc, (EntityBean) loadCustomer, read, new DefaultPersistenceContext()); assertEquals(loadCustomer.getVersion(), customer.getVersion()); assertEquals(loadCustomer.getId(), customer.getId()); @@ -101,20 +101,20 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { bean.setContent(stringContent.getBytes("UTF-8")); BeanDescriptor desc = getBeanDescriptor(TBytesOnly.class); - CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean)bean); + CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) bean); ByteArrayOutputStream os = new ByteArrayOutputStream(); writeToStream(extract, os); byte[] bytes = os.toByteArray(); CachedBeanData read = readFromStream(bytes); - byte[] extraContent = (byte[])extract.getData("content"); + byte[] extraContent = (byte[]) extract.getData("content"); assertEquals(stringContent, new String(extraContent)); assertTrue(Arrays.equals(bean.getContent(), extraContent)); - TBytesOnly loadBean= new TBytesOnly(); - CachedBeanDataToBean.load(desc, (EntityBean)loadBean, read, new DefaultPersistenceContext()); + TBytesOnly loadBean = new TBytesOnly(); + CachedBeanDataToBean.load(desc, (EntityBean) loadBean, read, new DefaultPersistenceContext()); assertEquals(loadBean.getId(), bean.getId()); assertTrue(Arrays.equals(loadBean.getContent(), bean.getContent())); @@ -124,7 +124,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { ByteArrayInputStream is = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(is); - return (CachedBeanData)ois.readObject(); + return (CachedBeanData) ois.readObject(); } private void writeToStream(CachedBeanData extract, ByteArrayOutputStream os) throws IOException { @@ -135,4 +135,4 @@ public class CachedBeanDataSerializeTest extends BaseTestCase { oos.close(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder_getCacheOptions_Test.java b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder_getCacheOptions_Test.java index d0cbd1052..45f99062a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder_getCacheOptions_Test.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultCacheHolder_getCacheOptions_Test.java @@ -7,7 +7,7 @@ import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Product; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DefaultCacheHolder_getCacheOptions_Test { @@ -49,4 +49,4 @@ public class DefaultCacheHolder_getCacheOptions_Test { ServerCacheOptions options = cacheHolder.getCacheOptions(Order.class.getName(), ServerCacheType.QUERY); assertEquals(options.getMaxSecsToLive(), 120); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCacheTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCacheTest.java index 5d84632dc..40f7ad26d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCacheTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCacheTest.java @@ -3,7 +3,7 @@ package com.avaje.ebeaninternal.server.cache; import com.avaje.ebean.cache.ServerCacheOptions; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DefaultServerCacheTest { @@ -85,4 +85,4 @@ public class DefaultServerCacheTest { assertEquals(cache.trimFrequency, 42); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache_RunEvictionTest.java b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache_RunEvictionTest.java index 9706c95a0..788125f93 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache_RunEvictionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/cache/DefaultServerCache_RunEvictionTest.java @@ -26,7 +26,7 @@ public class DefaultServerCache_RunEvictionTest { private final Random random = new Random(); - public DefaultServerCache_RunEvictionTest(){ + public DefaultServerCache_RunEvictionTest() { this.cache = createCache(); } @@ -46,14 +46,14 @@ public class DefaultServerCache_RunEvictionTest { private void doStuff() { for (int i = 0; i < 500; i++) { - String key = ""+random.nextInt(20000); + String key = "" + random.nextInt(20000); int mode = random.nextInt(10); if (mode < 8) { cache.get(key); } else { - cache.put(key, key+"-"+System.currentTimeMillis()); + cache.put(key, key + "-" + System.currentTimeMillis()); } } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegisterTest.java b/src/test/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegisterTest.java index 8386683b4..d71f60adc 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegisterTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/changelog/DefaultChangeLogRegisterTest.java @@ -10,10 +10,7 @@ import com.avaje.tests.model.basic.Customer; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class DefaultChangeLogRegisterTest extends BaseTestCase { @@ -26,17 +23,17 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase { assertNull(register.getChangeFilter(Address.class)); ChangeLogFilter changeFilter = register.getChangeFilter(Customer.class); - DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter)changeFilter; + DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter) changeFilter; assertFalse(updateFilter.includeInserts); assertThat(updateFilter.updateProperties).containsExactly("name", "status"); changeFilter = register.getChangeFilter(Country.class); - DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter; + DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter; assertTrue(countryFilter.includeInserts); // use default setting changeFilter = register.getChangeFilter(Contact.class); - DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter; + DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter; assertTrue(contactFilter.includeInserts); } @@ -49,17 +46,17 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase { assertNull(register.getChangeFilter(Address.class)); ChangeLogFilter changeFilter = register.getChangeFilter(Customer.class); - DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter)changeFilter; + DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter) changeFilter; assertFalse(updateFilter.includeInserts); assertThat(updateFilter.updateProperties).containsExactly("name", "status"); changeFilter = register.getChangeFilter(Country.class); - DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter; + DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter; assertTrue(countryFilter.includeInserts); // use default setting changeFilter = register.getChangeFilter(Contact.class); - DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter; + DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter; assertFalse(contactFilter.includeInserts); } @@ -70,7 +67,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase { DefaultChangeLogRegister register = new DefaultChangeLogRegister(true); ChangeLogFilter changeFilter = register.getChangeFilter(ProductConfiguration.class); assertNotNull(changeFilter); - DefaultChangeLogRegister.BasicFilter basicFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter; + DefaultChangeLogRegister.BasicFilter basicFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter; assertTrue(basicFilter.includeInserts); } diff --git a/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java b/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java index bad5f5920..de37b64b9 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java +++ b/src/test/java/com/avaje/ebeaninternal/server/changelog/Helper.java @@ -24,7 +24,7 @@ public class Helper { cs.setSource("myApp"); cs.setUserId("user234"); cs.setUserIpAddress("123.4.5.6"); - cs.getUserContext().put("someKey","user defined input"); + cs.getUserContext().put("someKey", "user defined input"); List changes = cs.getChanges(); @@ -41,7 +41,7 @@ public class Helper { values.put("name", new ValuePair("rob", null)); values.put("modified", new ValuePair(new Timestamp(System.currentTimeMillis()), null)); - BeanChange bean = new BeanChange("mytable", startId+1, ChangeType.INSERT, null); + BeanChange bean = new BeanChange("mytable", startId + 1, ChangeType.INSERT, null); bean.setValues(values); return bean; } @@ -55,14 +55,14 @@ public class Helper { values.put("modified", new ValuePair(new Timestamp(System.currentTimeMillis()), null)); - BeanChange bean = new BeanChange("mytable", startId+2, ChangeType.UPDATE, null); + BeanChange bean = new BeanChange("mytable", startId + 2, ChangeType.UPDATE, null); bean.setValues(values); return bean; } @NotNull private BeanChange createDelete(long startId) { - return new BeanChange("mytable", startId+3, ChangeType.DELETE, new HashMap<>()); + return new BeanChange("mytable", startId + 3, ChangeType.DELETE, new HashMap<>()); } } diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/BasicTypeConverterTest.java b/src/test/java/com/avaje/ebeaninternal/server/core/BasicTypeConverterTest.java index 4f061a77f..442e0c65f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/BasicTypeConverterTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/BasicTypeConverterTest.java @@ -2,7 +2,8 @@ package com.avaje.ebeaninternal.server.core; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class BasicTypeConverterTest { @@ -31,4 +32,4 @@ public class BasicTypeConverterTest { assertFalse(BasicTypeConverter.toBoolean("F", "T")); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java b/src/test/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java index 1a6569208..801a02b72 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/DefaultBackgroundExecutorTest.java @@ -5,26 +5,28 @@ import org.junit.Test; public class DefaultBackgroundExecutorTest { - @Test @Ignore + @Test + @Ignore public void shutdown_when_running_expect_waitAndNiceShutdown() throws Exception { DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 20, "test"); - es.execute(new RunFor(3000,"a")); - es.execute(new RunFor(3000,"b")); - es.execute(new RunFor(3000,"c")); + es.execute(new RunFor(3000, "a")); + es.execute(new RunFor(3000, "b")); + es.execute(new RunFor(3000, "c")); es.shutdown(); } - @Test @Ignore + @Test + @Ignore public void shutdown_when_rougeRunnable_expect_InterruptedException() throws Exception { DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test"); - es.execute(new RunFor(300000,"a")); - es.execute(new RunFor(3000,"b")); - es.execute(new RunFor(3000,"c")); + es.execute(new RunFor(300000, "a")); + es.execute(new RunFor(3000, "b")); + es.execute(new RunFor(3000, "c")); es.shutdown(); } @@ -51,4 +53,4 @@ public class DefaultBackgroundExecutorTest { } } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java b/src/test/java/com/avaje/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java index d45ee0f5e..05cd0f840 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java @@ -69,14 +69,14 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void when_fetch_order_different_then_different() { assertDifferent(detail(query().select("id,name").fetch("details").fetch("customer")), - detail(query().select("id,name").fetch("customer").fetch("details"))); + detail(query().select("id,name").fetch("customer").fetch("details"))); } @Test public void when_extra_queryFetchToMany_then_same() { assertDifferent(detail(query().select("id,name").fetch("customer")), - detail(query().select("id,name").fetch("customer").fetch("details", new FetchConfig().query()))); + detail(query().select("id,name").fetch("customer").fetch("details", new FetchConfig().query()))); } @Test @@ -84,7 +84,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { // with the fetch of customer the foreign key must be added to the root query assertDifferent(detail(query().select("id,name")), - detail(query().select("id,name").fetch("customer", new FetchConfig().query()))); + detail(query().select("id,name").fetch("customer", new FetchConfig().query()))); } @Test @@ -98,15 +98,15 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void when_fetchConfig_then_differentPlan() throws Exception { DefaultOrmQuery query1 = (DefaultOrmQuery) Ebean.find(Order.class) - .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) - .fetch("details.product", "sku, name"); + .select("status, shipDate") + .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetch("details.product", "sku, name"); DefaultOrmQuery query2 = (DefaultOrmQuery) Ebean.find(Order.class) - .select("status, shipDate") - .fetch("details", "orderQty, unitPrice") - .fetch("details.product", "sku, name"); + .select("status, shipDate") + .fetch("details", "orderQty, unitPrice") + .fetch("details.product", "sku, name"); assertDifferent(detail(query1), detail(query2)); } @@ -115,9 +115,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_fetchJoins_expect_detailJoinsPreserveOrder() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetch("details"); + .select("status, orderDate") + .fetch("customer", "name") + .fetch("details"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -129,9 +129,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_fetchJoinsAndWhere_expect_fetchJoinsOnlyInFetchPaths() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("details") - .where().eq("customer.name", "rob").query(); + .select("status, orderDate") + .fetch("details") + .where().eq("customer.name", "rob").query(); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -143,9 +143,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_queryFetch_expect_getFetchPaths_doesNotIncludeQueryJoin() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetch("details", new FetchConfig().query()); + .select("status, orderDate") + .fetch("customer", "name") + .fetch("details", new FetchConfig().query()); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -157,9 +157,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_queryFetch_expect_getFetchPaths_doesNotIncludeQueryJoin_via_fetchQuery() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetchQuery("details"); + .select("status, orderDate") + .fetch("customer", "name") + .fetchQuery("details"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -171,9 +171,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_lazyFetch_expect_getFetchPaths_doesNotIncludeQueryJoin() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetch("details", new FetchConfig().lazy()); + .select("status, orderDate") + .fetch("customer", "name") + .fetch("details", new FetchConfig().lazy()); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -185,9 +185,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_lazyFetch_expect_getFetchPaths_doesNotIncludeQueryJoin_via_fetchLazy() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetchLazy("details"); + .select("status, orderDate") + .fetch("customer", "name") + .fetchLazy("details"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -199,10 +199,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_lazyFetchAndHasChildren_expect_getFetchPaths_doesNotIncludeJoinOrChild() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("customer", "name") - .fetch("details", new FetchConfig().lazy()) - .fetch("details.product"); + .select("status, orderDate") + .fetch("customer", "name") + .fetch("details", new FetchConfig().lazy()) + .fetch("details.product"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -214,10 +214,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_fetchMany_expect_getFetchPaths_containsAllInOrder() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("details") - .fetch("details.product") - .fetch("customer", "name"); + .select("status, orderDate") + .fetch("details") + .fetch("details.product") + .fetch("customer", "name"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -229,10 +229,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void testJoinOrder_when_queryJoin_expect_getFetchPaths_excludesQueryJoinAndChildren() { Query query = Ebean.find(Order.class) - .select("status, orderDate") - .fetch("details", new FetchConfig().query()) - .fetch("details.product") - .fetch("customer", "name"); + .select("status, orderDate") + .fetch("details", new FetchConfig().query()) + .fetch("details.product") + .fetch("customer", "name"); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -244,10 +244,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void test_removeJoinToMany_when_multipleManyPaths() { Query query = Ebean.find(Order.class) - .fetch("details") - .fetch("details.product") - .fetch("customer") - .fetch("customer.contacts"); // second many path + .fetch("details") + .fetch("details.product") + .fetch("customer") + .fetch("customer.contacts"); // second many path OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -259,11 +259,11 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void test_removeAllJoinToMany_when_firstRow() { Query query = Ebean.find(Order.class) - .setFirstRow(1) - .fetch("details") // many path - .fetch("details.product") - .fetch("customer") - .fetch("customer.contacts"); // many path + .setFirstRow(1) + .fetch("details") // many path + .fetch("details.product") + .fetch("customer") + .fetch("customer.contacts"); // many path OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -275,11 +275,11 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void test_removeAllJoinToMany_when_maxRows() { Query query = Ebean.find(Order.class) - .setMaxRows(1) - .fetch("details") // many path - .fetch("details.product") - .fetch("customer") - .fetch("customer.contacts"); // many path + .setMaxRows(1) + .fetch("details") // many path + .fetch("details.product") + .fetch("customer") + .fetch("customer.contacts"); // many path OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -291,12 +291,12 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { public void test_removeJoinToMany_when_filterMany() { Query query = Ebean.find(Order.class) - .fetch("details") - .fetch("details.product") - .fetch("customer") - .fetch("customer.contacts") - .filterMany("details").eq("orderQuantity", 10) - .query(); + .fetch("details") + .fetch("details.product") + .fetch("customer") + .fetch("customer.contacts") + .filterMany("details").eq("orderQuantity", 10) + .query(); OrmQueryRequest queryRequest = queryRequest(query); OrmQueryDetail detail = queryRequest.getQuery().getDetail(); @@ -313,4 +313,4 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase { assertThat(detail1.isSameByPlan(detail2)).isFalse(); assertThat(detail1.queryPlanHash()).isNotEqualTo(detail2.queryPlanHash()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertSimple.java b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertSimple.java index 2c5bc082a..94b99b5b2 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertSimple.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertSimple.java @@ -17,9 +17,7 @@ import java.sql.Timestamp; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestDiffHelpInsertSimple extends BaseTestCase { diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertWithEmbedded.java b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertWithEmbedded.java index 3de19e019..100bb015b 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertWithEmbedded.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpInsertWithEmbedded.java @@ -13,9 +13,7 @@ import org.junit.Test; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class TestDiffHelpInsertWithEmbedded extends BaseTestCase { diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpSimple.java b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpSimple.java index f39f3b86f..c53139b1b 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpSimple.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpSimple.java @@ -1,13 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.Date; -import java.sql.Timestamp; -import java.util.Map; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -17,21 +9,28 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Order.Status; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Date; +import java.sql.Timestamp; +import java.util.Map; +import java.util.Set; public class TestDiffHelpSimple extends BaseTestCase { - long firstTime = System.currentTimeMillis()-10000; + long firstTime = System.currentTimeMillis() - 10000; long secondTime = System.currentTimeMillis(); EbeanServer server; BeanDescriptor orderDesc; - + public TestDiffHelpSimple() { server = Ebean.getServer(null); - SpiEbeanServer spiServer = (SpiEbeanServer)server; + SpiEbeanServer spiServer = (SpiEbeanServer) server; orderDesc = spiServer.getBeanDescriptor(Order.class); } - + private Order createBaseOrder(EbeanServer server) { Order order1 = new Order(); order1.setId(12); @@ -42,13 +41,13 @@ public class TestDiffHelpSimple extends BaseTestCase { order1.setOrderDate(new Date(firstTime)); return order1; } - + @Test public void testBasicChanges() { - - + + Order order1 = createBaseOrder(server); - + Order order2 = new Order(); order2.setId(14); order2.setCretime(new Timestamp(secondTime)); @@ -56,11 +55,11 @@ public class TestDiffHelpSimple extends BaseTestCase { order2.setStatus(Status.COMPLETE); order2.setShipDate(new Date(secondTime)); order2.setOrderDate(new Date(secondTime)); - + Map diff = DiffHelp.diff(order1, order2, orderDesc); - + Assert.assertEquals(5, diff.size()); - + Set keySet = diff.keySet(); Assert.assertTrue(keySet.contains("cretime")); Assert.assertTrue(keySet.contains("status")); @@ -99,74 +98,74 @@ public class TestDiffHelpSimple extends BaseTestCase { @Test public void testIdIgnored() { - + Order order1 = createBaseOrder(server); Order order2 = createBaseOrder(server); order2.setId(14); - + Map diff = DiffHelp.diff(order1, order2, orderDesc); - - Assert.assertEquals(0, diff.size()); + + Assert.assertEquals(0, diff.size()); } - + @Test public void testSecondValueNull() { - + Order order1 = createBaseOrder(server); - + Order order2 = createBaseOrder(server); order2.setCustomer(server.getReference(Customer.class, 2133)); order2.setStatus(Status.COMPLETE); order2.setShipDate(null); - + Map diff = DiffHelp.diff(order1, order2, orderDesc); - + Assert.assertEquals(3, diff.size()); - + Set keySet = diff.keySet(); Assert.assertTrue(keySet.contains("status")); Assert.assertTrue(keySet.contains("customer.id")); Assert.assertTrue(keySet.contains("shipDate")); - + ValuePair shipDatePair = diff.get("shipDate"); - Assert.assertEquals(order1.getShipDate(),shipDatePair.getNewValue()); - Assert.assertEquals(order2.getShipDate(),shipDatePair.getOldValue()); + Assert.assertEquals(order1.getShipDate(), shipDatePair.getNewValue()); + Assert.assertEquals(order2.getShipDate(), shipDatePair.getOldValue()); Assert.assertNull(shipDatePair.getOldValue()); } - - + + @Test public void testFirstValueNull() { - + Order order1 = createBaseOrder(server); order1.setShipDate(null); - - Order order2 = createBaseOrder(server); + + Order order2 = createBaseOrder(server); order2.setShipDate(new Date(secondTime)); - + Map diff = DiffHelp.diff(order1, order2, orderDesc); - - Assert.assertEquals(1, diff.size()); + + Assert.assertEquals(1, diff.size()); Set keySet = diff.keySet(); Assert.assertTrue(keySet.contains("shipDate")); - + ValuePair shipDatePair = diff.get("shipDate"); - Assert.assertEquals(order1.getShipDate(),shipDatePair.getNewValue()); - Assert.assertEquals(order2.getShipDate(),shipDatePair.getOldValue()); + Assert.assertEquals(order1.getShipDate(), shipDatePair.getNewValue()); + Assert.assertEquals(order2.getShipDate(), shipDatePair.getOldValue()); Assert.assertNull(shipDatePair.getNewValue()); } - + @Test public void testBothNull() { - + Order order1 = createBaseOrder(server); order1.setShipDate(null); - - Order order2 = createBaseOrder(server); + + Order order2 = createBaseOrder(server); order2.setShipDate(null); - + Map diff = DiffHelp.diff(order1, order2, orderDesc); - - Assert.assertEquals(0, diff.size()); + + Assert.assertEquals(0, diff.size()); } } diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpWithEmbedded.java b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpWithEmbedded.java index 328d0b482..b7001ac1f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpWithEmbedded.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/TestDiffHelpWithEmbedded.java @@ -1,10 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -13,57 +8,61 @@ import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.tests.model.embedded.EMain; import com.avaje.tests.model.embedded.Eembeddable; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Map; public class TestDiffHelpWithEmbedded extends BaseTestCase { EbeanServer server; BeanDescriptor emainDesc; - + public TestDiffHelpWithEmbedded() { server = Ebean.getServer(null); - SpiEbeanServer spiServer = (SpiEbeanServer)server; + SpiEbeanServer spiServer = (SpiEbeanServer) server; emainDesc = spiServer.getBeanDescriptor(EMain.class); } - + @Test public void testChangeExistingEmbedded() { - + EMain emain1 = createEMain(); EMain emain2 = createEMain(); - + emain2.getEmbeddable().setDescription("baz"); - + Map diff = DiffHelp.diff(emain1, emain2, emainDesc); Assert.assertEquals(1, diff.size()); ValuePair valuePair = diff.get("embeddable.description"); - + Assert.assertNotNull(valuePair); - Assert.assertEquals("bar",valuePair.getNewValue()); - Assert.assertEquals("baz",valuePair.getOldValue()); + Assert.assertEquals("bar", valuePair.getNewValue()); + Assert.assertEquals("baz", valuePair.getOldValue()); } - + /** * Same result as testChangeExistingEmbedded. */ @Test public void testSetViaNewEmbedded() { - + EMain emain1 = createEMain(); EMain emain2 = createEMain(); - + Eembeddable embeddable = new Eembeddable(); embeddable.setDescription("baz"); emain2.setEmbeddable(embeddable); - - + + Map diff = DiffHelp.diff(emain1, emain2, emainDesc); Assert.assertEquals(1, diff.size()); ValuePair valuePair = diff.get("embeddable.description"); - + Assert.assertNotNull(valuePair); - Assert.assertEquals("bar",valuePair.getNewValue()); - Assert.assertEquals("baz",valuePair.getOldValue()); + Assert.assertEquals("bar", valuePair.getNewValue()); + Assert.assertEquals("baz", valuePair.getOldValue()); } @Test @@ -78,37 +77,37 @@ public class TestDiffHelpWithEmbedded extends BaseTestCase { ValuePair valuePair = diff.get("embeddable.description"); Assert.assertNotNull(valuePair); - Assert.assertEquals("bar",valuePair.getNewValue()); - Assert.assertEquals("baz",valuePair.getOldValue()); + Assert.assertEquals("bar", valuePair.getNewValue()); + Assert.assertEquals("baz", valuePair.getOldValue()); } @Test public void testFirstEmbeddedIsNull() { - + EMain emain1 = createEMain(); emain1.setEmbeddable(null); EMain emain2 = createEMain(); - + Map diff = DiffHelp.diff(emain1, emain2, emainDesc); Assert.assertEquals(1, diff.size()); ValuePair valuePair = diff.get("embeddable.description"); - + Assert.assertNotNull(valuePair); Assert.assertNull(valuePair.getNewValue()); Assert.assertEquals("bar", valuePair.getOldValue()); } - + @Test public void testSecondEmbeddedIsNull() { - + EMain emain1 = createEMain(); EMain emain2 = createEMain(); emain2.setEmbeddable(null); - + Map diff = DiffHelp.diff(emain1, emain2, emainDesc); Assert.assertEquals(1, diff.size()); ValuePair valuePair = diff.get("embeddable.description"); - + Assert.assertNotNull(valuePair); Assert.assertNull(valuePair.getOldValue()); Assert.assertEquals("bar", valuePair.getNewValue()); @@ -132,27 +131,27 @@ public class TestDiffHelpWithEmbedded extends BaseTestCase { @Test public void testBothEmbeddedIsNull() { - + EMain emain1 = createEMain(); emain1.setEmbeddable(null); EMain emain2 = createEMain(); emain2.setEmbeddable(null); - + Map diff = DiffHelp.diff(emain1, emain2, emainDesc); Assert.assertEquals(0, diff.size()); } private EMain createEMain() { - + EMain emain = new EMain(); emain.setName("foo"); emain.setVersion(13l); - + Eembeddable embeddable = new Eembeddable(); embeddable.setDescription("bar"); emain.setEmbeddable(embeddable); - + return emain; } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackagesTest.java b/src/test/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackagesTest.java index b96ea9bd7..42d74df56 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackagesTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/core/bootup/DistillPackagesTest.java @@ -1,8 +1,10 @@ package com.avaje.ebeaninternal.server.core.bootup; import org.junit.Test; + import java.util.Arrays; import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; public class DistillPackagesTest { @@ -39,7 +41,7 @@ public class DistillPackagesTest { @Test public void when_unordered_expect_naturalOrder() throws Exception { - List distill = DistillPackages.distill(group("z.x.y","two"), group("one", "one.sub.me")); + List distill = DistillPackages.distill(group("z.x.y", "two"), group("one", "one.sub.me")); assertThat(distill).containsExactly("one", "two", "z.x.y"); } @@ -47,4 +49,4 @@ public class DistillPackagesTest { return Arrays.asList(packages); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfoTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfoTest.java index cd9ff6809..67b6ed937 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfoTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanCascadeInfoTest.java @@ -4,7 +4,8 @@ import org.junit.Test; import javax.persistence.CascadeType; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class BeanCascadeInfoTest { @@ -78,4 +79,4 @@ public class BeanCascadeInfoTest { assertFalse(info.isRefresh()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorTest.java index b01379ed2..c1f42db66 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorTest.java @@ -61,10 +61,10 @@ public class BeanDescriptorTest extends BaseTestCase { from.setName("rob"); Customer to = new Customer(); - customerDesc.merge((EntityBean)from, (EntityBean)to); + customerDesc.merge((EntityBean) from, (EntityBean) to); assertThat(to.getId()).isEqualTo(42); assertThat(to.getName()).isEqualTo("rob"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java index b33d422cb..e78e0a813 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_documentMappingTest.java @@ -44,10 +44,10 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase { class TDVisitor extends DocPropertyAdapter { StringBuilder sb = new StringBuilder(); - + @Override public void visitProperty(DocPropertyMapping property) { - sb.append(property.getName()+","); + sb.append(property.getName() + ","); } @Override @@ -63,7 +63,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase { @Override public void visitBeginObject(DocPropertyMapping property) { - sb.append(" object{"+property.getName()+":"); + sb.append(" object{" + property.getName() + ":"); } @Override @@ -73,7 +73,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase { @Override public void visitBeginList(DocPropertyMapping property) { - sb.append(" nested{"+property.getName()+": ["); + sb.append(" nested{" + property.getName() + ": ["); } @Override @@ -82,4 +82,4 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase { } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java index 8bfc3bb6a..7803284f1 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java @@ -9,10 +9,7 @@ import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.tests.model.basic.EBasic; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class BeanDescriptor_registerTest { @@ -29,7 +26,7 @@ public class BeanDescriptor_registerTest { config.setDefaultServer(false); config.getClasses().add(EBasic.class); - SpiEbeanServer ebeanServer = (SpiEbeanServer)EbeanServerFactory.create(config); + SpiEbeanServer ebeanServer = (SpiEbeanServer) EbeanServerFactory.create(config); BeanDescriptor desc = ebeanServer.getBeanDescriptor(EBasic.class); persistListenerRegistrationTests(desc); @@ -50,10 +47,10 @@ public class BeanDescriptor_registerTest { assertEquals(2, ((ChainedBeanPersistController) desc.getPersistController()).size()); desc.deregister(controller1); - assertEquals(1, ((ChainedBeanPersistController)desc.getPersistController()).size()); + assertEquals(1, ((ChainedBeanPersistController) desc.getPersistController()).size()); desc.deregister(controller2); - assertEquals(0, ((ChainedBeanPersistController)desc.getPersistController()).size()); + assertEquals(0, ((ChainedBeanPersistController) desc.getPersistController()).size()); } private void persistListenerRegistrationTests(BeanDescriptor desc) { @@ -72,10 +69,10 @@ public class BeanDescriptor_registerTest { assertEquals(2, ((ChainedBeanPersistListener) persistListener).size()); desc.deregister(listener1); - assertEquals(1, ((ChainedBeanPersistListener)desc.getPersistListener()).size()); + assertEquals(1, ((ChainedBeanPersistListener) desc.getPersistListener()).size()); desc.deregister(listener2); - assertEquals(0, ((ChainedBeanPersistListener)desc.getPersistListener()).size()); + assertEquals(0, ((ChainedBeanPersistListener) desc.getPersistListener()).size()); } public static class Listener1 extends AbstractBeanPersistListener { @@ -111,4 +108,4 @@ public class BeanDescriptor_registerTest { return EBasic.class.isAssignableFrom(cls); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_whenCreatedPropertyTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_whenCreatedPropertyTest.java index f9c3e9195..9a6e07b5f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_whenCreatedPropertyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor_whenCreatedPropertyTest.java @@ -17,19 +17,19 @@ public class BeanDescriptor_whenCreatedPropertyTest extends BaseTestCase { @Test public void test() { - SpiEbeanServer server = (SpiEbeanServer)Ebean.getDefaultServer(); + SpiEbeanServer server = (SpiEbeanServer) Ebean.getDefaultServer(); BeanDescriptor desc = server.getBeanDescriptor(Customer.class); BeanProperty whenCreatedProperty = desc.getWhenCreatedProperty(); - assertEquals("cretime",whenCreatedProperty.getDbColumn()); + assertEquals("cretime", whenCreatedProperty.getDbColumn()); BeanProperty whenModifiedProperty = desc.getWhenModifiedProperty(); - assertEquals("updtime",whenModifiedProperty.getDbColumn()); + assertEquals("updtime", whenModifiedProperty.getDbColumn()); BeanDescriptor eBasicDesc = server.getBeanDescriptor(EBasic.class); assertNull(eBasicDesc.getWhenCreatedProperty()); assertNull(eBasicDesc.getWhenModifiedProperty()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java index faf9f50ac..273f11793 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocManyTest.java @@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.deploy; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.EntityBean; -import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Test; @@ -12,9 +11,7 @@ import java.util.ArrayList; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class BeanPropertyAssocManyTest extends BaseTestCase { @@ -22,7 +19,7 @@ public class BeanPropertyAssocManyTest extends BaseTestCase { BeanDescriptor customerDesc = spiEbeanServer().getBeanDescriptor(Customer.class); BeanPropertyAssocMany contacts() { - return (BeanPropertyAssocMany)customerDesc.getBeanProperty("contacts"); + return (BeanPropertyAssocMany) customerDesc.getBeanProperty("contacts"); } @Test @@ -63,4 +60,4 @@ public class BeanPropertyAssocManyTest extends BaseTestCase { assertThat(contactIdsForOne).isNotEmpty(); assertThat(contactIdsForMultiple).isNotEmpty(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java index c2a2dfa7a..b1251d555 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/DeployPropertyParserMapTests.java @@ -1,25 +1,25 @@ package com.avaje.ebeaninternal.server.deploy; -import java.util.HashMap; -import java.util.Map; - import org.junit.Assert; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; + public class DeployPropertyParserMapTests { @Test public void test_like_escape() { - - + + Map map = new HashMap<>(); map.put("customer.name", "t1.name"); map.put("id", "t0.id"); - + DeployPropertyParserMap parser = new DeployPropertyParserMap(map); - + String output = parser.parse("(lower(customer.name) like ? escape'' or id > ?)"); Assert.assertEquals("(lower(t1.name) like ? escape'' or t0.id > ?)", output); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestBeanDescriptorHasIdProperty.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestBeanDescriptorHasIdProperty.java index 0d6b90405..eda5c7373 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestBeanDescriptorHasIdProperty.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestBeanDescriptorHasIdProperty.java @@ -15,52 +15,49 @@ import org.junit.Test; import java.sql.Timestamp; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestBeanDescriptorHasIdProperty extends BaseTestCase { SpiEbeanServer spiServer; - + public TestBeanDescriptorHasIdProperty() { EbeanServer server = Ebean.getServer(null); - spiServer = (SpiEbeanServer)server; + spiServer = (SpiEbeanServer) server; } - + @Test public void testHasId() { - + BeanDescriptor beanDescriptor = spiServer.getBeanDescriptor(Order.class); assertNotNull(beanDescriptor.getIdProperty()); assertEquals("id", beanDescriptor.getIdProperty().getName()); - + assertNotNull(beanDescriptor.getVersionProperty()); assertEquals("updtime", beanDescriptor.getVersionProperty().getName()); - + Order order = new Order(); - + assertFalse(beanDescriptor.hasIdValue(entityBean(order))); assertFalse(beanDescriptor.hasVersionProperty(getIntercept(order))); - + order.setId(23); order.setUpdtime(new Timestamp(System.currentTimeMillis())); assertTrue(beanDescriptor.hasIdValue(entityBean(order))); assertTrue(beanDescriptor.hasVersionProperty(getIntercept(order))); - + } @Test public void testIsReference() { - + BeanDescriptor beanDescriptor = spiServer.getBeanDescriptor(Customer.class); - + Customer order = new Customer(); EntityBeanIntercept ebi = getIntercept(order); assertFalse(beanDescriptor.hasIdPropertyOnly(ebi)); - + order.setId(23); assertTrue(beanDescriptor.hasIdPropertyOnly(ebi)); @@ -91,23 +88,23 @@ public class TestBeanDescriptorHasIdProperty extends BaseTestCase { BeanDescriptor rcustDesc = spiServer.getBeanDescriptor(RCustomer.class); - Map idForJson = (Map)rcustDesc.getIdForJson(rCustomer); - assertEquals("comp",idForJson.get("company")); - assertEquals("fred",idForJson.get("name")); + Map idForJson = (Map) rcustDesc.getIdForJson(rCustomer); + assertEquals("comp", idForJson.get("company")); + assertEquals("fred", idForJson.get("name")); assertEquals(2, idForJson.size()); - RCustomerKey keyVal = (RCustomerKey)rcustDesc.convertIdFromJson(idForJson); - assertEquals("comp",keyVal.getCompany()); - assertEquals("fred",keyVal.getName()); + RCustomerKey keyVal = (RCustomerKey) rcustDesc.convertIdFromJson(idForJson); + assertEquals("comp", keyVal.getCompany()); + assertEquals("fred", keyVal.getName()); } private EntityBean entityBean(Object bean) { - return (EntityBean)bean; + return (EntityBean) bean; } private EntityBeanIntercept getIntercept(Object bean) { - return ((EntityBean)bean)._ebean_getIntercept(); + return ((EntityBean) bean)._ebean_getIntercept(); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestCollectionLoadedStatus.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestCollectionLoadedStatus.java index dd2922574..00c602947 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestCollectionLoadedStatus.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestCollectionLoadedStatus.java @@ -1,10 +1,5 @@ package com.avaje.ebeaninternal.server.deploy; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; @@ -13,30 +8,34 @@ import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestCollectionLoadedStatus extends BaseTestCase { @Test public void test() { - - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); + + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); BeanDescriptor custDesc = server.getBeanDescriptor(Customer.class); - + Customer customer = new Customer(); - EntityBean eb = (EntityBean)customer; + EntityBean eb = (EntityBean) customer; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + BeanProperty contactsProperty = custDesc.getBeanProperty("contacts"); Assert.assertFalse(ebi.isLoadedProperty(contactsProperty.getPropertyIndex())); - + Object contactsViaInternal = contactsProperty.getValue(eb); Assert.assertNull(contactsViaInternal); Assert.assertFalse(ebi.isLoadedProperty(contactsProperty.getPropertyIndex())); - + List contacts = customer.getContacts(); Assert.assertNotNull(contacts); Assert.assertTrue(contacts instanceof BeanCollection); Assert.assertTrue(ebi.isLoadedProperty(contactsProperty.getPropertyIndex())); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestNotEnhancedMappedSuper.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestNotEnhancedMappedSuper.java index e0f7d5d06..4b15049d9 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestNotEnhancedMappedSuper.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestNotEnhancedMappedSuper.java @@ -19,22 +19,22 @@ public class TestNotEnhancedMappedSuper extends BaseTestCase { Ebean.save(bean); Assert.assertNotNull(bean.getId()); - + bean.setName("junk mod"); Ebean.save(bean); - + ASimpleBean fetched = Ebean.find(ASimpleBean.class, bean.getId()); Assert.assertEquals("junk mod", fetched.getName()); Assert.assertEquals(bean.getName(), fetched.getName()); - + Ebean.delete(bean); ASimpleBean fetched2 = Ebean.find(ASimpleBean.class, bean.getId()); Assert.assertNull(fetched2); - + NotEnhancedMappedSuper mappedSuper = new NotEnhancedMappedSuper(); boolean enhanced = (mappedSuper instanceof EntityBean); Assert.assertFalse(enhanced); - + } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestReferenceWithConstructorProperties.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestReferenceWithConstructorProperties.java index f3fd14694..5e62a1e3d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/TestReferenceWithConstructorProperties.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/TestReferenceWithConstructorProperties.java @@ -1,15 +1,14 @@ package com.avaje.ebeaninternal.server.deploy; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Set; public class TestReferenceWithConstructorProperties extends BaseTestCase { @@ -18,21 +17,21 @@ public class TestReferenceWithConstructorProperties extends BaseTestCase { */ @Test public void test() { - + ResetBasicData.reset(); Order order = Ebean.getReference(Order.class, 1); BeanState beanState = Ebean.getBeanState(order); Set loadedProps = beanState.getLoadedProps(); - + Assert.assertEquals(1, loadedProps.size()); Assert.assertTrue(beanState.isReference()); // read the status invokes lazy loading order.getStatus(); - + Assert.assertFalse(beanState.isReference()); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactoryTest.java b/src/test/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactoryTest.java index a2293efa7..5ff3b7741 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactoryTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/deploy/generatedproperty/UpdateTimestampFactoryTest.java @@ -9,7 +9,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; public class UpdateTimestampFactoryTest { @@ -65,4 +65,4 @@ public class UpdateTimestampFactoryTest { Object value = generatedProperty.getInsertValue(null, null, System.currentTimeMillis()); assertTrue(value instanceof java.util.Date); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java index 9321e9811..efd439120 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/AllEqualsExpressionTest.java @@ -95,24 +95,24 @@ public class AllEqualsExpressionTest { } AllEqualsExpression exp(String key0, Object val1) { - LinkedHashMap map = new LinkedHashMap<>(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); return exp(map); } AllEqualsExpression exp(String key0, Object val1, String key2, Object val2) { - LinkedHashMap map = new LinkedHashMap<>(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); map.put(key2, val2); return exp(map); } AllEqualsExpression exp(String key0, Object val1, String key2, Object val2, String key3, Object val3) { - LinkedHashMap map = new LinkedHashMap<>(); + LinkedHashMap map = new LinkedHashMap<>(); map.put(key0, val1); map.put(key2, val2); map.put(key3, val3); return exp(map); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java index 934dfb00a..bf62014f3 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExampleExpressionTest.java @@ -33,19 +33,19 @@ public class DefaultExampleExpressionTest extends BaseTestCase { DefaultExampleExpression exp() { Customer customer = customer(); - return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO); + return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO); } DefaultExampleExpression expExtra() { Customer customer = customer(); customer.setSmallnote("smallNote"); - return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO); + return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO); } DefaultExampleExpression expDiffName() { Customer customer = customer(); customer.setName("otherName"); - return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO); + return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO); } BeanDescriptor customerBeanDescriptor() { @@ -54,7 +54,7 @@ public class DefaultExampleExpressionTest extends BaseTestCase { DefaultExampleExpression prepare(DefaultExampleExpression expr) { - SpiQuery query = (SpiQuery)spiEbeanServer().find(Customer.class); + SpiQuery query = (SpiQuery) spiEbeanServer().find(Customer.class); BeanQueryRequest request = create(query); expr.containsMany(customerBeanDescriptor(), new ManyWhereJoins()); expr.prepareExpression(request); @@ -83,8 +83,8 @@ public class DefaultExampleExpressionTest extends BaseTestCase { ResetBasicData.reset(); Query query1 = server().find(Customer.class) - .where().exampleLike(customer) - .query(); + .where().exampleLike(customer) + .query(); query1.findList(); @@ -121,4 +121,4 @@ public class DefaultExampleExpressionTest extends BaseTestCase { assertThat(prepare(expExtra()).isSameByPlan(prepare(exp()))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java index eb848e91f..e0cce5945 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/DefaultExpressionListTest.java @@ -14,56 +14,56 @@ public class DefaultExpressionListTest { } DefaultExpressionList spi(ExpressionList list) { - return (DefaultExpressionList)list; + return (DefaultExpressionList) list; } @Test public void isSameByPlan_when_same() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(spi(exp().eq("a", 10).eq("b", 20)))).isTrue(); + .isSameByPlan(spi(exp().eq("a", 10).eq("b", 20)))).isTrue(); } @Test public void isSameByPlan_when_diffExpressionType() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(new NoopExpression())).isFalse(); + .isSameByPlan(new NoopExpression())).isFalse(); } @Test public void isSameByPlan_when_less() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(spi(exp().eq("a", 10)))).isFalse(); + .isSameByPlan(spi(exp().eq("a", 10)))).isFalse(); } @Test public void isSameByPlan_when_lessEmptyLast() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(spi(exp()))).isFalse(); + .isSameByPlan(spi(exp()))).isFalse(); } @Test public void isSameByPlan_when_lessEmptyFirst() { assertThat(spi(exp()) - .isSameByPlan(spi(exp().eq("a", 10)))).isFalse(); + .isSameByPlan(spi(exp().eq("a", 10)))).isFalse(); } @Test public void isSameByPlan_when_more() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(spi(exp().eq("a", 10).eq("b", 20).eq("c", 30)))).isFalse(); + .isSameByPlan(spi(exp().eq("a", 10).eq("b", 20).eq("c", 30)))).isFalse(); } @Test public void isSameByPlan_when_diffProperties() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByPlan(spi(exp().eq("c", 10).eq("b", 20)))).isFalse(); + .isSameByPlan(spi(exp().eq("c", 10).eq("b", 20)))).isFalse(); } @@ -71,28 +71,28 @@ public class DefaultExpressionListTest { public void isSameByBind_when_same() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isTrue(); + .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isTrue(); } @Test public void isSameByBind_when_diffValues() { assertThat(spi(exp().eq("a", 10).eq("b", 20)) - .isSameByBind(spi(exp().eq("a", 10).eq("b", 30)))).isFalse(); + .isSameByBind(spi(exp().eq("a", 10).eq("b", 30)))).isFalse(); } @Test public void isSameByBind_when_less() { assertThat(spi(exp().eq("a", 10)) - .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse(); + .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse(); } @Test public void isSameByBind_when_more() { assertThat(spi(exp().eq("a", 10)) - .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse(); + .isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpressionTest.java index 78752ba3d..9144703ab 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/ExistsQueryExpressionTest.java @@ -19,67 +19,67 @@ public class ExistsQueryExpressionTest { @Test public void isSameByPlan_when_same() { - assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"a", 10))).isTrue(); + assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "a", 10))).isTrue(); } @Test public void isSameByPlan_when_diffBind_same() { - assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"a", 20))).isTrue(); + assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "a", 20))).isTrue(); } @Test public void isSameByPlan_when_diffNot() { - assertThat(exp(true,"a", 10).isSameByPlan(exp(false,"a", 10))).isFalse(); + assertThat(exp(true, "a", 10).isSameByPlan(exp(false, "a", 10))).isFalse(); } @Test public void isSameByPlan_when_diffSql() { - assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"b", 10))).isFalse(); + assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "b", 10))).isFalse(); } @Test public void isSameByBind_when_sameBindValues() { - assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 10))).isTrue(); + assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 10))).isTrue(); } @Test public void isSameByBind_when_sameMultipleBindValues() { - assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, "ABC", 20))).isTrue(); + assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, "ABC", 20))).isTrue(); } @Test public void isSameByBind_when_diffMultipleBindValues() { - assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, "ABC", 21))).isFalse(); + assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, "ABC", 21))).isFalse(); } @Test public void isSameByBind_when_diffMultipleBindValuesByOrder() { - assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, 20, "ABC"))).isFalse(); + assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, 20, "ABC"))).isFalse(); } @Test public void isSameByBind_when_diffBindValues() { - assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 20))).isFalse(); + assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 20))).isFalse(); } @Test public void isSameByBind_when_lessBindValues() { - assertThat(exp(true,"a", 10, 20).isSameByBind(exp(true,"a", 20))).isFalse(); + assertThat(exp(true, "a", 10, 20).isSameByBind(exp(true, "a", 20))).isFalse(); } @Test public void isSameByBind_when_moreBindValues() { - assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 10, 20))).isFalse(); + assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 10, 20))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/IdInExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/IdInExpressionTest.java index b1b2ab7b2..9d4793684 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/IdInExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/IdInExpressionTest.java @@ -42,7 +42,7 @@ public class IdInExpressionTest { @Test public void isSameByBind_when_mulitpleSameBindValues() { - assertThat(exp(10,"ABC", 20).isSameByBind(exp(10, "ABC", 20))).isTrue(); + assertThat(exp(10, "ABC", 20).isSameByBind(exp(10, "ABC", 20))).isTrue(); } @Test @@ -54,14 +54,14 @@ public class IdInExpressionTest { @Test public void isSameByBind_when_lessBindValues() { - assertThat(exp(10,"ABC", 20).isSameByBind(exp(10, "ABC"))).isFalse(); + assertThat(exp(10, "ABC", 20).isSameByBind(exp(10, "ABC"))).isFalse(); } @Test public void isSameByBind_when_moreBindValues() { - assertThat(exp(10,"ABC").isSameByBind(exp(10, "ABC", 30))).isFalse(); + assertThat(exp(10, "ABC").isSameByBind(exp(10, "ABC", 30))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/InQueryExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/InQueryExpressionTest.java index c1e15dedf..168f0a5b2 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/InQueryExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/InQueryExpressionTest.java @@ -18,72 +18,72 @@ public class InQueryExpressionTest { @Test public void isSameByPlan_when_same() { - assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sql", 10))).isTrue(); + assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sql", 10))).isTrue(); } @Test public void isSameByPlan_when_diffBind_same() { - assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sql", 20))).isTrue(); + assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sql", 20))).isTrue(); } @Test public void isSameByPlan_when_diffNPropertyName() { - assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("nameDiff",true,"sql", 10))).isFalse(); + assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("nameDiff", true, "sql", 10))).isFalse(); } @Test public void isSameByPlan_when_diffNot() { - assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",false,"sql", 10))).isFalse(); + assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", false, "sql", 10))).isFalse(); } @Test public void isSameByPlan_when_diffSql() { - assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sqlDiff", 10))).isFalse(); + assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sqlDiff", 10))).isFalse(); } @Test public void isSameByBind_when_sameBindValues() { - assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 10))).isTrue(); + assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 10))).isTrue(); } @Test public void isSameByBind_when_sameMultipleBindValues() { - assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, "ABC", 20))).isTrue(); + assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, "ABC", 20))).isTrue(); } @Test public void isSameByBind_when_diffMultipleBindValues() { - assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, "ABC", 21))).isFalse(); + assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, "ABC", 21))).isFalse(); } @Test public void isSameByBind_when_diffMultipleBindValuesByOrder() { - assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, 20, "ABC"))).isFalse(); + assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, 20, "ABC"))).isFalse(); } @Test public void isSameByBind_when_diffBindValues() { - assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 20))).isFalse(); + assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 20))).isFalse(); } @Test public void isSameByBind_when_lessBindValues() { - assertThat(exp("name",true,"sql", 10, 20).isSameByBind(exp("name",true,"sql", 20))).isFalse(); + assertThat(exp("name", true, "sql", 10, 20).isSameByBind(exp("name", true, "sql", 20))).isFalse(); } @Test public void isSameByBind_when_moreBindValues() { - assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 10, 20))).isFalse(); + assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 10, 20))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpressionQueryTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpressionQueryTest.java index 62b133123..68998ee0c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpressionQueryTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/IsEmptyExpressionQueryTest.java @@ -18,9 +18,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id") - .where().isEmpty("contacts") - .query(); + .select("id") + .where().isEmpty("contacts") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select t0.id from o_customer t0 where not exists (select 1 from contact where customer_id = t0.id"); @@ -32,9 +32,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id") - .where().isNotEmpty("contacts") - .query(); + .select("id") + .where().isNotEmpty("contacts") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select t0.id from o_customer t0 where exists (select 1 from contact where customer_id = t0.id"); @@ -46,9 +46,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Contact.class) - .select("id") - .where().isEmpty("notes") - .query(); + .select("id") + .where().isEmpty("notes") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select t0.id from contact t0 where not exists (select 1 from contact_note where contact_id = t0.id"); @@ -60,9 +60,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Contact.class) - .select("id") - .where().isNotEmpty("notes") - .query(); + .select("id") + .where().isNotEmpty("notes") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select t0.id from contact t0 where exists (select 1 from contact_note where contact_id = t0.id"); @@ -75,9 +75,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Contact.class) - .select("id") - .where().isEmpty("notes") - .query(); + .select("id") + .where().isEmpty("notes") + .query(); query.findList(); } @@ -89,9 +89,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id") - .where().isEmpty("contacts.notes") - .query(); + .select("id") + .where().isEmpty("contacts.notes") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select distinct t0.id from o_customer t0 join contact u1 on u1.customer_id = t0.id where not exists (select 1 from contact_note where contact_id = u1.id)"); @@ -103,12 +103,12 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id") - .where().isNotEmpty("contacts.notes") - .query(); + .select("id") + .where().isNotEmpty("contacts.notes") + .query(); query.findList(); assertThat(sqlOf(query)).contains("select distinct t0.id from o_customer t0 join contact u1 on u1.customer_id = t0.id where exists (select 1 from contact_note where contact_id = u1.id)"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java index d9d2052ea..70342fc2a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/JunctionExpressionTest.java @@ -35,27 +35,27 @@ public class JunctionExpressionTest { public void isSameByPlan_when_same() { assertThat(and(exp(eq("a", 10), eq("b", 10))) - .isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue(); + .isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue(); } @Test public void copyForPlanKey_isSameByPlan_when_same() { assertThat(and(exp(eq("a", 10), eq("b", 10)).copyForPlanKey()) - .isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue(); + .isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue(); } @Test public void copyForPlanKey_isSameByPlan_when_diff() { assertThat(and(exp(eq("a", 10), eq("b", 10)).copyForPlanKey()) - .isSameByPlan(and(exp(eq("a", 10), eq("c", 10))))).isFalse(); + .isSameByPlan(and(exp(eq("a", 10), eq("c", 10))))).isFalse(); } @Test public void isSameByPlan_when_diffType() { assertThat(and(exp(eq("a", 10), eq("b", 10))) - .isSameByPlan(or(exp(eq("a", 10), eq("b", 10))))).isFalse(); + .isSameByPlan(or(exp(eq("a", 10), eq("b", 10))))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/LikeExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/LikeExpressionTest.java index 85a2aef8f..9c21352b4 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/LikeExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/LikeExpressionTest.java @@ -18,35 +18,35 @@ public class LikeExpressionTest extends BaseExpressionTest { public void isSameByPlan_when_same() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByPlan(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue(); + .isSameByPlan(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue(); } @Test public void isSameByPlan_when_diffBind_then_stillSame() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByPlan(exp("a", "bor", true, LikeType.STARTS_WITH))).isTrue(); + .isSameByPlan(exp("a", "bor", true, LikeType.STARTS_WITH))).isTrue(); } @Test public void isSameByPlan_when_diffCaseInsensitive() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByPlan(exp("a", "rob", false, LikeType.STARTS_WITH))).isFalse(); + .isSameByPlan(exp("a", "rob", false, LikeType.STARTS_WITH))).isFalse(); } @Test public void isSameByPlan_when_diffLikeType() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByPlan(exp("a", "rob", true, LikeType.ENDS_WITH))).isFalse(); + .isSameByPlan(exp("a", "rob", true, LikeType.ENDS_WITH))).isFalse(); } @Test public void isSameByPlan_when_diffProperty() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByPlan(exp("b", "rob", true, LikeType.STARTS_WITH))).isFalse(); + .isSameByPlan(exp("b", "rob", true, LikeType.STARTS_WITH))).isFalse(); } @@ -54,13 +54,13 @@ public class LikeExpressionTest extends BaseExpressionTest { public void isSameByBind_when_sameBindValues() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByBind(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue(); + .isSameByBind(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue(); } @Test public void isSameByBind_when_diffBindValues() { assertThat(exp("a", "rob", true, LikeType.STARTS_WITH) - .isSameByBind(exp("a", "bor", true, LikeType.STARTS_WITH))).isFalse(); + .isSameByBind(exp("a", "bor", true, LikeType.STARTS_WITH))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/LogicExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/LogicExpressionTest.java index 099584e0f..a126f341c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/LogicExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/LogicExpressionTest.java @@ -25,56 +25,56 @@ public class LogicExpressionTest extends BaseExpressionTest { public void isSameByPlan_when_same() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByPlan(and(eq("a", 10), eq("b", 10)))).isTrue(); + .isSameByPlan(and(eq("a", 10), eq("b", 10)))).isTrue(); } @Test public void isSameByPlan_when_diffBind_then_stillSame() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByPlan(and(eq("a", 20), eq("b", 20)))).isTrue(); + .isSameByPlan(and(eq("a", 20), eq("b", 20)))).isTrue(); } @Test public void isSameByPlan_when_diffExp1_then_diff() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByPlan(and(eq("c", 10), eq("b", 10)))).isFalse(); + .isSameByPlan(and(eq("c", 10), eq("b", 10)))).isFalse(); } @Test public void isSameByPlan_when_diffExp2_then_diff() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse(); + .isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse(); } @Test public void isSameByPlan_when_diffType_then_diff() { assertThat(or(eq("a", 10), eq("b", 10)) - .isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse(); + .isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse(); } @Test public void isSameByPlan_when_diffExpressionType() { assertThat(or(eq("a", 10), eq("b", 10)) - .isSameByPlan(new NoopExpression())).isFalse(); + .isSameByPlan(new NoopExpression())).isFalse(); } @Test public void isSameByBind_when_sameBindValues() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByBind(and(eq("a", 10), eq("c", 10)))).isTrue(); + .isSameByBind(and(eq("a", 10), eq("c", 10)))).isTrue(); } @Test public void isSameByBind_when_diffBindValues() { assertThat(and(eq("a", 10), eq("b", 10)) - .isSameByBind(and(eq("a", 10), eq("c", 20)))).isFalse(); + .isSameByBind(and(eq("a", 10), eq("c", 20)))).isFalse(); } @Test @@ -109,9 +109,9 @@ public class LogicExpressionTest extends BaseExpressionTest { assertThat(path).isNull(); assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression)and.expOne).nestedPath).isEqualTo("details"); + assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details"); assertThat(and.expTwo).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression)and.expTwo).nestedPath).isEqualTo("shipments"); + assertThat(((NestedPathWrapperExpression) and.expTwo).nestedPath).isEqualTo("shipments"); } @Test @@ -123,7 +123,7 @@ public class LogicExpressionTest extends BaseExpressionTest { assertThat(path).isNull(); assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class); - assertThat(((NestedPathWrapperExpression)and.expOne).nestedPath).isEqualTo("details"); + assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details"); assertThat(and.expTwo).isInstanceOf(SimpleExpression.class); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/NoopExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/NoopExpressionTest.java index 5b40071d6..7e9c896a3 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/NoopExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/NoopExpressionTest.java @@ -15,9 +15,9 @@ public class NoopExpressionTest extends BaseTestCase { public void test() { Query query = Ebean.find(Customer.class) - .select("id") - .where().add(NoopExpression.INSTANCE) - .query(); + .select("id") + .where().add(NoopExpression.INSTANCE) + .query(); query.findList(); String generatedSql = sqlOf(query); @@ -29,11 +29,11 @@ public class NoopExpressionTest extends BaseTestCase { public void test_withPreAndPost() { Query query = Ebean.find(Customer.class) - .select("id") - .where().eq("name", null) - .add(NoopExpression.INSTANCE) - .ne("status", null) - .query(); + .select("id") + .where().eq("name", null) + .add(NoopExpression.INSTANCE) + .ne("status", null) + .query(); query.findList(); String generatedSql = sqlOf(query); diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/NotExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/NotExpressionTest.java index 4bb5abe33..638f74aaa 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/NotExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/NotExpressionTest.java @@ -18,41 +18,41 @@ public class NotExpressionTest { public void isSameByPlan_when_same() { assertThat(not(eq("a", 10)) - .isSameByPlan(not(eq("a", 10)))).isTrue(); + .isSameByPlan(not(eq("a", 10)))).isTrue(); } @Test public void isSameByPlan_when_sameByPlan() { assertThat(not(eq("a", 10)) - .isSameByPlan(not(eq("a", 20)))).isTrue(); + .isSameByPlan(not(eq("a", 20)))).isTrue(); } @Test public void isSameByPlan_when_different() { assertThat(not(eq("a", 10)) - .isSameByPlan(not(eq("b", 10)))).isFalse(); + .isSameByPlan(not(eq("b", 10)))).isFalse(); } @Test public void isSameByPlan_when_differentExpressionType() { assertThat(not(eq("a", 10)) - .isSameByPlan(new NoopExpression())).isFalse(); + .isSameByPlan(new NoopExpression())).isFalse(); } @Test public void isSameByBind_when_same() { assertThat(not(eq("a", 10)) - .isSameByBind(not(eq("b", 10)))).isTrue(); + .isSameByBind(not(eq("b", 10)))).isTrue(); } @Test public void isSameByBind_when_different() { assertThat(not(eq("a", 10)) - .isSameByBind(not(eq("a", 20)))).isFalse(); + .isSameByBind(not(eq("a", 20)))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/NullExpressionTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/NullExpressionTest.java index b5aa39a96..45bd468dc 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/NullExpressionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/NullExpressionTest.java @@ -68,28 +68,28 @@ public class NullExpressionTest extends BaseExpressionTest { public void isSameByBind_true() throws Exception { assertThat(nullExp("customer.name", false) - .isSameByBind(nullExp("customer.name", false))).isTrue(); + .isSameByBind(nullExp("customer.name", false))).isTrue(); } @Test public void isSameByPlan_true() throws Exception { assertThat(nullExp("customer.name", false) - .isSameByPlan(nullExp("customer.name", false))).isTrue(); + .isSameByPlan(nullExp("customer.name", false))).isTrue(); } @Test public void isSameByPlan_false_when_notNullDiff() throws Exception { assertThat(new NullExpression("customer.name", false) - .isSameByPlan(new NullExpression("customer.name", true))).isFalse(); + .isSameByPlan(new NullExpression("customer.name", true))).isFalse(); } @Test public void isSameByPlan_false_when_propertyNameDiff() throws Exception { assertThat(new NullExpression("customer.startDate", true) - .isSameByPlan(new NullExpression("customer.name", true))).isFalse(); + .isSameByPlan(new NullExpression("customer.name", true))).isFalse(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/expression/PrepareDocNestedTest.java b/src/test/java/com/avaje/ebeaninternal/server/expression/PrepareDocNestedTest.java index 977bd01aa..9449a0d86 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/expression/PrepareDocNestedTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/expression/PrepareDocNestedTest.java @@ -17,12 +17,12 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .gt("details.orderQty", 1) - .query().where(); + .where() + .gt("details.orderQty", 1) + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); @@ -34,13 +34,13 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare_when_multipleOfSamePath() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); + .where() + .gt("details.orderQty", 1) + .gt("details.unitPrice", 1) + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); @@ -52,21 +52,21 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare_when_mixed() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .gt("customer.id", 1) - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); + .where() + .gt("customer.id", 1) + .gt("details.orderQty", 1) + .gt("details.unitPrice", 1) + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); assertEquals(underlyingList.size(), 2); assertNull(exp.allDocNestedPath); - DefaultExpressionList second = (DefaultExpressionList)underlyingList.get(1); + DefaultExpressionList second = (DefaultExpressionList) underlyingList.get(1); assertEquals(second.allDocNestedPath, "details"); } @@ -74,23 +74,23 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare_when_nestedJunction() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .not() - .gt("customer.id", 1) - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); + .where() + .not() + .gt("customer.id", 1) + .gt("details.orderQty", 1) + .gt("details.unitPrice", 1) + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); assertEquals(underlyingList.size(), 1); assertNull(exp.allDocNestedPath); - JunctionExpression junction = (JunctionExpression)underlyingList.get(0); + JunctionExpression junction = (JunctionExpression) underlyingList.get(0); List junctionUnderlying = junction.exprList.getUnderlyingList(); - JunctionExpression nestedNestedPath = (JunctionExpression)junctionUnderlying.get(1); + JunctionExpression nestedNestedPath = (JunctionExpression) junctionUnderlying.get(1); assertEquals(nestedNestedPath.exprList.allDocNestedPath, "details"); } @@ -98,23 +98,23 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare_when_nestedMultiple() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .isNotNull("shipments.shipTime") - .gt("details.orderQty", 1) - .gt("details.unitPrice", 1) - .query().where(); + .where() + .isNotNull("shipments.shipTime") + .gt("details.orderQty", 1) + .gt("details.unitPrice", 1) + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); assertEquals(underlyingList.size(), 2); assertNull(exp.allDocNestedPath); - DefaultExpressionList shipExpr = (DefaultExpressionList)underlyingList.get(0); + DefaultExpressionList shipExpr = (DefaultExpressionList) underlyingList.get(0); assertEquals(shipExpr.allDocNestedPath, "shipments"); - DefaultExpressionList detailsExpr = (DefaultExpressionList)underlyingList.get(1); + DefaultExpressionList detailsExpr = (DefaultExpressionList) underlyingList.get(1); assertEquals(detailsExpr.allDocNestedPath, "details"); } @@ -123,26 +123,26 @@ public class PrepareDocNestedTest extends BaseTestCase { public void prepare_when_manyMixed() throws Exception { ExpressionList where = Ebean.find(Order.class) - .where() - .gt("customer.id", 1) // 0 - .isNotNull("shipments.shipTime") // shipments 0 - .isNotNull("status") // 1 - .gt("details.orderQty", 1) // details 0 - .isNotNull("orderDate") // 2 - .gt("details.unitPrice", 1) // details 1 - .query().where(); + .where() + .gt("customer.id", 1) // 0 + .isNotNull("shipments.shipTime") // shipments 0 + .isNotNull("status") // 1 + .gt("details.orderQty", 1) // details 0 + .isNotNull("orderDate") // 2 + .gt("details.unitPrice", 1) // details 1 + .query().where(); - DefaultExpressionList exp = (DefaultExpressionList)where; + DefaultExpressionList exp = (DefaultExpressionList) where; PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class)); List underlyingList = exp.getUnderlyingList(); assertEquals(underlyingList.size(), 5); assertNull(exp.allDocNestedPath); - DefaultExpressionList shipExpr = (DefaultExpressionList)underlyingList.get(3); + DefaultExpressionList shipExpr = (DefaultExpressionList) underlyingList.get(3); assertEquals(shipExpr.allDocNestedPath, "shipments"); - DefaultExpressionList detailsExpr = (DefaultExpressionList)underlyingList.get(4); + DefaultExpressionList detailsExpr = (DefaultExpressionList) underlyingList.get(4); assertEquals(detailsExpr.allDocNestedPath, "details"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/grammer/EqlParserTest.java b/src/test/java/com/avaje/ebeaninternal/server/grammer/EqlParserTest.java index f9c12cfeb..fd75611e6 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/grammer/EqlParserTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/grammer/EqlParserTest.java @@ -207,7 +207,7 @@ public class EqlParserTest extends BaseTestCase { public void where_in_when_namedParamAsList() throws Exception { Query query = parse("where name in (:names)"); - query.setParameter("names", Arrays.asList("Baz","Maz","Jim")); + query.setParameter("names", Arrays.asList("Baz", "Maz", "Jim")); query.findList(); assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ?, ? )"); @@ -467,8 +467,8 @@ public class EqlParserTest extends BaseTestCase { private Query parse(String raw) { Query query = Ebean.find(Customer.class); - EqlParser.parse(raw, (SpiQuery)query); + EqlParser.parse(raw, (SpiQuery) query); return query; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/lib/ShutdownManagerTest.java b/src/test/java/com/avaje/ebeaninternal/server/lib/ShutdownManagerTest.java index 3d554a56b..30b7a283d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/lib/ShutdownManagerTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/lib/ShutdownManagerTest.java @@ -25,8 +25,8 @@ public class ShutdownManagerTest extends BaseTestCase { @Test public void test_noShutdownHook() { - System.setProperty("ebean.registerShutdownHook","false"); + System.setProperty("ebean.registerShutdownHook", "false"); Ebean.getDefaultServer(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java b/src/test/java/com/avaje/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java index ad97b3b5e..ca247f553 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java +++ b/src/test/java/com/avaje/ebeaninternal/server/lib/sql/TestDataSourceMaxWithEntity.java @@ -1,12 +1,11 @@ package com.avaje.ebeaninternal.server.lib.sql; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebeaninternal.server.core.DefaultBackgroundExecutor; import com.avaje.tests.model.basic.Customer; +import org.junit.Test; public class TestDataSourceMaxWithEntity extends BaseTestCase { @@ -20,7 +19,7 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase { } EbeanServer server = Ebean.getServer(null); - + DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 30, "testDs"); @@ -31,7 +30,7 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase { } Thread.sleep(30000); - + server.shutdown(true, false); } catch (Exception e) { @@ -53,12 +52,12 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase { } public void run() { - + server.find(Customer.class).findCount(); try { - System.out.println(position+" sleep " + sleepMillis); + System.out.println(position + " sleep " + sleepMillis); Thread.sleep(sleepMillis); - System.out.println(position+" sleep done"); + System.out.println(position + " sleep done"); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/src/test/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContextTest.java b/src/test/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContextTest.java index 151d6a5da..e3531aa19 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContextTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/loadcontext/DLoadContextTest.java @@ -27,7 +27,7 @@ public class DLoadContextTest extends BaseTestCase { queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); @@ -38,11 +38,11 @@ public class DLoadContextTest extends BaseTestCase { @Test public void construct_when_fetchQuery_expect_100_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer",new FetchConfig().query())); + OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().query())); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); assertThat(customer.firstBatchSize).isEqualTo(100); @@ -56,7 +56,7 @@ public class DLoadContextTest extends BaseTestCase { queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); assertThat(customer.firstBatchSize).isEqualTo(100); @@ -66,11 +66,11 @@ public class DLoadContextTest extends BaseTestCase { @Test public void construct_when_fetchQuery50_expect_50_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer",new FetchConfig().query(50))); + OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().query(50))); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); assertThat(customer.firstBatchSize).isEqualTo(50); @@ -80,11 +80,11 @@ public class DLoadContextTest extends BaseTestCase { @Test public void construct_when_fetchQueryFirst20Lazy5_expect_20_5_batchSize() { - OrmQueryRequest queryRequest = queryRequest(query().fetch("customer",new FetchConfig().queryFirst(20).lazy(5))); + OrmQueryRequest queryRequest = queryRequest(query().fetch("customer", new FetchConfig().queryFirst(20).lazy(5))); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadBeanContext customer = graphContext.getBeanContext("customer"); assertThat(customer.firstBatchSize).isEqualTo(20); @@ -95,15 +95,15 @@ public class DLoadContextTest extends BaseTestCase { public void construct_when_fetch_expect_100_100_batchSize() { // the fetch is converted to a query join due to the maxRows - OrmQueryRequest queryRequest = queryRequest(query().fetch("details").setMaxRows(100)) ; + OrmQueryRequest queryRequest = queryRequest(query().fetch("details").setMaxRows(100)); queryRequest.initTransIfRequired(); queryRequest.endTransIfRequired(); - DLoadContext graphContext = (DLoadContext)queryRequest.getGraphContext(); + DLoadContext graphContext = (DLoadContext) queryRequest.getGraphContext(); DLoadManyContext details = graphContext.getManyContext("details"); assertThat(details.firstBatchSize).isEqualTo(100); assertThat(details.secondaryBatchSize).isEqualTo(100); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java b/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java index 6eeae26ba..391a657c2 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/query/OrderVersionDescTest.java @@ -73,9 +73,9 @@ public class OrderVersionDescTest { } private Version at(long diff) { - Timestamp timestamp = new Timestamp(now + diff); + Timestamp timestamp = new Timestamp(now + diff); Version ver = new Version(); ver.setStart(timestamp); return ver; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/query/SplitNameTest.java b/src/test/java/com/avaje/ebeaninternal/server/query/SplitNameTest.java index b5070b11d..b46751cda 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/query/SplitNameTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/query/SplitNameTest.java @@ -2,15 +2,16 @@ package com.avaje.ebeaninternal.server.query; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class SplitNameTest { @Test public void add() throws Exception { - assertEquals(SplitName.add("a","b"), "a.b"); - assertEquals(SplitName.add("a","b.c"), "a.b.c"); + assertEquals(SplitName.add("a", "b"), "a.b"); + assertEquals(SplitName.add("a", "b.c"), "a.b.c"); } @Test @@ -79,4 +80,4 @@ public class SplitNameTest { assertEquals(split[0], "a"); assertNull(split[1]); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/query/TestFutureRowCountErrorHandling.java b/src/test/java/com/avaje/ebeaninternal/server/query/TestFutureRowCountErrorHandling.java index 233bd873b..a294e06fb 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/query/TestFutureRowCountErrorHandling.java +++ b/src/test/java/com/avaje/ebeaninternal/server/query/TestFutureRowCountErrorHandling.java @@ -1,10 +1,5 @@ package com.avaje.ebeaninternal.server.query; -import java.util.concurrent.ExecutionException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -15,88 +10,92 @@ import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.ExecutionException; + +public class TestFutureRowCountErrorHandling extends BaseTestCase { -public class TestFutureRowCountErrorHandling extends BaseTestCase { - @Test public void testFutureRowCount() throws InterruptedException { - + ResetBasicData.reset(); - + EbeanServer server = Ebean.getServer(null); - + Query query = server.createQuery(Customer.class) .where().eq("doesNotExist", "this will fail") .query(); - + FutureRowCount futureRowCount = server.findFutureCount(query, null); - - QueryFutureRowCount internalRowCount = (QueryFutureRowCount)futureRowCount; + + QueryFutureRowCount internalRowCount = (QueryFutureRowCount) futureRowCount; Transaction t = internalRowCount.getTransaction(); - + try { futureRowCount.get(); - Assert.assertTrue("never get here as the SQL is invalid",false); - + Assert.assertTrue("never get here as the SQL is invalid", false); + } catch (ExecutionException e) { - // Confirm the Transaction has been rolled back + // Confirm the Transaction has been rolled back Assert.assertFalse("Underlying transaction was rolled back cleanly", t.isActive()); } - - } - - @Test - public void testFutureIds() throws InterruptedException { - - ResetBasicData.reset(); - - EbeanServer server = Ebean.getServer(null); - - Query query = server.createQuery(Customer.class) - .where().eq("doesNotExist", "this will fail") - .query(); - - FutureIds futureIds = server.findFutureIds(query, null); - - QueryFutureIds internalFuture = (QueryFutureIds)futureIds; - Transaction t = internalFuture.getTransaction(); - - try { - internalFuture.get(); - Assert.assertTrue("never get here as the SQL is invalid",false); - - } catch (ExecutionException e) { - // Confirm the Transaction has been rolled back - Assert.assertFalse("Underlying transaction was rolled back cleanly", t.isActive()); - } - + } - @Test - public void testFutureList() throws InterruptedException { - + public void testFutureIds() throws InterruptedException { + ResetBasicData.reset(); - + EbeanServer server = Ebean.getServer(null); - + Query query = server.createQuery(Customer.class) .where().eq("doesNotExist", "this will fail") .query(); - - FutureList futureList = server.findFutureList(query, null); - - QueryFutureList internalFuture = (QueryFutureList)futureList; + + FutureIds futureIds = server.findFutureIds(query, null); + + QueryFutureIds internalFuture = (QueryFutureIds) futureIds; Transaction t = internalFuture.getTransaction(); - + try { internalFuture.get(); - Assert.assertTrue("never get here as the SQL is invalid",false); - + Assert.assertTrue("never get here as the SQL is invalid", false); + } catch (ExecutionException e) { - // Confirm the Transaction has been rolled back + // Confirm the Transaction has been rolled back Assert.assertFalse("Underlying transaction was rolled back cleanly", t.isActive()); } - + + } + + + @Test + public void testFutureList() throws InterruptedException { + + ResetBasicData.reset(); + + EbeanServer server = Ebean.getServer(null); + + Query query = server.createQuery(Customer.class) + .where().eq("doesNotExist", "this will fail") + .query(); + + FutureList futureList = server.findFutureList(query, null); + + QueryFutureList internalFuture = (QueryFutureList) futureList; + Transaction t = internalFuture.getTransaction(); + + try { + internalFuture.get(); + Assert.assertTrue("never get here as the SQL is invalid", false); + + } catch (ExecutionException e) { + // Confirm the Transaction has been rolled back + Assert.assertFalse("Underlying transaction was rolled back cleanly", t.isActive()); + } + } } diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQueryTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQueryTest.java index ced5d21d7..b6a24fa40 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQueryTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/DefaultOrmQueryTest.java @@ -12,7 +12,7 @@ public class DefaultOrmQueryTest { @Test public void checkForId_when_eqId_then_translatedTo_setId() { - DefaultOrmQuery q1 = (DefaultOrmQuery)Ebean.find(Order.class).where().eq("id", 42).query(); + DefaultOrmQuery q1 = (DefaultOrmQuery) Ebean.find(Order.class).where().eq("id", 42).query(); assertThat(q1.getWhereExpressions()).isNotNull(); assertThat(q1.getId()).isNull(); @@ -25,7 +25,7 @@ public class DefaultOrmQueryTest { @Test public void checkForId_when_idEq_ok() { - DefaultOrmQuery q1 = (DefaultOrmQuery)Ebean.find(Order.class).where().idEq(42).query(); + DefaultOrmQuery q1 = (DefaultOrmQuery) Ebean.find(Order.class).where().idEq(42).query(); assertThat(q1.getId()).isEqualTo(42); q1.checkIdEqualTo(); assertThat(q1.getId()).isEqualTo(42); @@ -34,8 +34,8 @@ public class DefaultOrmQueryTest { @Test public void when_addWhere_then_planChanges() { - DefaultOrmQuery q1 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("name", "a","b","c").query(); - DefaultOrmQuery q2 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("id", 2,2,3).query(); + DefaultOrmQuery q1 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("name", "a", "b", "c").query(); + DefaultOrmQuery q2 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("id", 2, 2, 3).query(); prepare(q1, q2); assertThat(q1.createQueryPlanKey()).isNotEqualTo(q2.createQueryPlanKey()); @@ -45,8 +45,8 @@ public class DefaultOrmQueryTest { @Test public void when_sameWhereWithDiffBindValues_then_planSame_bindDiff() { - DefaultOrmQuery q1 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("id", 1,2,3).query(); - DefaultOrmQuery q2 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("id", 2,2,3).query(); + DefaultOrmQuery q1 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("id", 1, 2, 3).query(); + DefaultOrmQuery q2 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("id", 2, 2, 3).query(); prepare(q1, q2); assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey()); @@ -56,8 +56,8 @@ public class DefaultOrmQueryTest { @Test public void when_sameWhereAndBindValues_then_planSameAndBind() { - DefaultOrmQuery q1 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("id", 1,2,3).query(); - DefaultOrmQuery q2 = (DefaultOrmQuery)Ebean.find(Order.class).where().in("id", 1,2,3).query(); + DefaultOrmQuery q1 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("id", 1, 2, 3).query(); + DefaultOrmQuery q2 = (DefaultOrmQuery) Ebean.find(Order.class).where().in("id", 1, 2, 3).query(); prepare(q1, q2); assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey()); @@ -67,13 +67,13 @@ public class DefaultOrmQueryTest { @Test public void when_diffFirstMaxRows_then_differentPlan() throws Exception { - DefaultOrmQuery query1 = (DefaultOrmQuery)Ebean.find(Order.class) - .setFirstRow(0) - .setMaxRows(31); + DefaultOrmQuery query1 = (DefaultOrmQuery) Ebean.find(Order.class) + .setFirstRow(0) + .setMaxRows(31); - DefaultOrmQuery query2 = (DefaultOrmQuery)Ebean.find(Order.class) - .setFirstRow(1) - .setMaxRows(0); + DefaultOrmQuery query2 = (DefaultOrmQuery) Ebean.find(Order.class) + .setFirstRow(1) + .setMaxRows(0); prepare(query1, query2); assertThat(query1.createQueryPlanKey()).isNotEqualTo(query2.createQueryPlanKey()); @@ -83,4 +83,4 @@ public class DefaultOrmQueryTest { q1.prepare(null); q2.prepare(null); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java index 3be9f7943..1d215347c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailParserTest.java @@ -77,7 +77,7 @@ public class OrmQueryDetailParserTest extends BaseTestCase { chunk = detail.getChunk("details.product", false); assertThat(chunk.getPath()).isEqualTo("details.product"); - assertThat(chunk.getIncluded()).contains("sku","description"); + assertThat(chunk.getIncluded()).contains("sku", "description"); } @Test @@ -113,4 +113,4 @@ public class OrmQueryDetailParserTest extends BaseTestCase { assertThat(chunk.isQueryFetch()).isTrue(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailTest.java index fa69d51ee..285a9a5f7 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryDetailTest.java @@ -6,9 +6,7 @@ import com.avaje.tests.model.basic.Order; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class OrmQueryDetailTest extends BaseTestCase { @@ -227,8 +225,8 @@ public class OrmQueryDetailTest extends BaseTestCase { detail.sortFetchPaths(orderDesc()); - assertThat(detail.getFetchPaths()).containsExactly("customer","customer.contacts"); - assertThat(detail.getChunk("customer",false).getIncluded()).containsExactly("id"); + assertThat(detail.getFetchPaths()).containsExactly("customer", "customer.contacts"); + assertThat(detail.getChunk("customer", false).getIncluded()).containsExactly("id"); } @Test @@ -240,8 +238,8 @@ public class OrmQueryDetailTest extends BaseTestCase { detail.sortFetchPaths(orderDesc()); - assertThat(detail.getFetchPaths()).containsExactly("customer","customer.contacts"); - assertThat(detail.getChunk("customer",false).getIncluded()).containsExactly("name"); + assertThat(detail.getFetchPaths()).containsExactly("customer", "customer.contacts"); + assertThat(detail.getChunk("customer", false).getIncluded()).containsExactly("name"); } @Test @@ -257,4 +255,4 @@ public class OrmQueryDetailTest extends BaseTestCase { return getBeanDescriptor(Order.class); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java index 9f8676f3a..611f9e55b 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPlanKeyTest.java @@ -236,17 +236,17 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { SpiExpressionList list_id_eq_42() { return (SpiExpressionList) server().find(Customer.class) - .where().eq("id", 42); + .where().eq("id", 42); } SpiExpressionList list_id_eq_43() { return (SpiExpressionList) server().find(Customer.class) - .where().eq("id", 43); + .where().eq("id", 43); } SpiExpressionList list_id_eq_42_and_name_eq_rob() { return (SpiExpressionList) server().find(Customer.class) - .where().eq("id", 43).eq("name", "rob"); + .where().eq("id", 43).eq("name", "rob"); } @@ -345,4 +345,4 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest { assertThat(key1).isEqualTo(key2); assertThat(key1.hashCode()).isEqualTo(key2.hashCode()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java index d1233fe6f..2731fc18d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/querydefn/OrmQueryPropertiesTest.java @@ -16,7 +16,7 @@ public class OrmQueryPropertiesTest { @Test(expected = IllegalArgumentException.class) public void construct_with_propertySet_when_null() { - new OrmQueryProperties(null, (LinkedHashSet)null); + new OrmQueryProperties(null, (LinkedHashSet) null); } @Test @@ -55,35 +55,35 @@ public class OrmQueryPropertiesTest { public void append_when_empty() { OrmQueryProperties p1 = new OrmQueryProperties(); - assertThat(append("select ",p1)).isEqualTo("select "); + assertThat(append("select ", p1)).isEqualTo("select "); } @Test public void append_when_someProperties() { OrmQueryProperties p1 = new OrmQueryProperties(null, "id,name"); - assertThat(append("select ",p1)).isEqualTo("select (id,name) "); + assertThat(append("select ", p1)).isEqualTo("select (id,name) "); } @Test public void append_when_somePropertiesWithOptions() { OrmQueryProperties p1 = new OrmQueryProperties(null, "id,name +cache"); - assertThat(append("select ",p1)).isEqualTo("select (id,name +cache) "); + assertThat(append("select ", p1)).isEqualTo("select (id,name +cache) "); } @Test public void append_when_path_and_emptyProperties() { OrmQueryProperties p1 = new OrmQueryProperties("customer", ""); - assertThat(append("fetch ",p1)).isEqualTo("fetch customer "); + assertThat(append("fetch ", p1)).isEqualTo("fetch customer "); } @Test public void append_when_path_and_somePropertiesWithOptions() { OrmQueryProperties p1 = new OrmQueryProperties("customer", "id,name +cache"); - assertThat(append("fetch ",p1)).isEqualTo("fetch customer (id,name +cache) "); + assertThat(append("fetch ", p1)).isEqualTo("fetch customer (id,name +cache) "); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/rawsql/TestRawSqlParsing.java b/src/test/java/com/avaje/ebeaninternal/server/rawsql/TestRawSqlParsing.java index 601aca988..361b99164 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/rawsql/TestRawSqlParsing.java +++ b/src/test/java/com/avaje/ebeaninternal/server/rawsql/TestRawSqlParsing.java @@ -1,30 +1,29 @@ package com.avaje.ebeaninternal.server.rawsql; -import junit.framework.TestCase; - import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSql.Sql; import com.avaje.ebean.RawSqlBuilder; +import junit.framework.TestCase; public class TestRawSqlParsing extends TestCase { - public void test() { - - String sql - = " select order_id, sum(order_qty*unit_price) as totalAmount" - + " from o_order_detail " - + " group by order_id"; + public void test() { - RawSql rawSql = RawSqlBuilder - .parse(sql) - .columnMapping("order_id","order.id") - //.columnMapping("sum(order_qty*unit_price)","totalAmount") - .create(); - - Sql rs = rawSql.getSql(); - - String s = rs.toString(); - assertTrue(s, s.contains("[order_id, sum")); - - } + String sql + = " select order_id, sum(order_qty*unit_price) as totalAmount" + + " from o_order_detail " + + " group by order_id"; + + RawSql rawSql = RawSqlBuilder + .parse(sql) + .columnMapping("order_id", "order.id") + //.columnMapping("sum(order_qty*unit_price)","totalAmount") + .create(); + + Sql rs = rawSql.getSql(); + + String s = rs.toString(); + assertTrue(s, s.contains("[order_id, sum")); + + } } diff --git a/src/test/java/com/avaje/ebeaninternal/server/text/json/TestJsonWriteVisitor.java b/src/test/java/com/avaje/ebeaninternal/server/text/json/TestJsonWriteVisitor.java index 3b43323c8..2d9288e4d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/text/json/TestJsonWriteVisitor.java +++ b/src/test/java/com/avaje/ebeaninternal/server/text/json/TestJsonWriteVisitor.java @@ -26,12 +26,12 @@ public class TestJsonWriteVisitor extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name, status") - .fetch("billingAddress", "line1, city") - .fetch("billingAddress.country", "*") - .fetch("contacts", "firstName,email") - .order().desc("id") - .findList(); + .select("id, name, status") + .fetch("billingAddress", "line1, city") + .fetch("billingAddress.country", "*") + .fetch("contacts", "firstName,email") + .order().desc("id") + .findList(); JsonContext json = Ebean.json(); diff --git a/src/test/java/com/avaje/ebeaninternal/server/text/json/TestTextJsonBeanReadVisitor.java b/src/test/java/com/avaje/ebeaninternal/server/text/json/TestTextJsonBeanReadVisitor.java index 9341e3d3d..5faec58e6 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/text/json/TestTextJsonBeanReadVisitor.java +++ b/src/test/java/com/avaje/ebeaninternal/server/text/json/TestTextJsonBeanReadVisitor.java @@ -26,12 +26,12 @@ public class TestTextJsonBeanReadVisitor extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name, status, shippingAddress") - .fetch("billingAddress", "line1, city") - .fetch("billingAddress.country", "*") - .fetch("contacts", "firstName,email") - .order().desc("id") - .findList(); + .select("id, name, status, shippingAddress") + .fetch("billingAddress", "line1, city") + .fetch("billingAddress.country", "*") + .fetch("contacts", "firstName,email") + .order().desc("id") + .findList(); JsonContext json = Ebean.json(); diff --git a/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonDirtyTest.java b/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonDirtyTest.java index 4b3f64772..819fb62db 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonDirtyTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonDirtyTest.java @@ -26,16 +26,16 @@ public class WriteJsonDirtyTest { List customers = Ebean.find(Customer.class).findList(); Customer customer = Ebean.find(Customer.class).setId(customers.get(0).getId()) - .setUseCache(false) - .findUnique(); + .setUseCache(false) + .findUnique(); - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); BeanDescriptor descriptor = server.getBeanDescriptor(Customer.class); customer.setName("dirtyCustName"); customer.setAnniversary(new Date(System.currentTimeMillis())); - EntityBean entityBean = (EntityBean)customer; + EntityBean entityBean = (EntityBean) customer; boolean[] dirtyProperties = entityBean._ebean_getIntercept().getDirtyProperties(); StringWriter writer = new StringWriter(); diff --git a/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonTest.java b/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonTest.java index a200d80df..e347b2533 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/text/json/WriteJsonTest.java @@ -1,8 +1,8 @@ package com.avaje.ebeaninternal.server.text.json; +import com.avaje.ebean.FetchPath; import com.avaje.ebean.config.JsonConfig; import com.avaje.ebean.text.PathProperties; -import com.avaje.ebean.FetchPath; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import org.junit.Test; @@ -10,7 +10,7 @@ import org.junit.Test; import java.io.IOException; import java.io.StringWriter; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; public class WriteJsonTest { @@ -56,4 +56,4 @@ public class WriteJsonTest { writeJson.endAssocMany(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/transaction/JdbcTransactionTest.java b/src/test/java/com/avaje/ebeaninternal/server/transaction/JdbcTransactionTest.java index 7d9b5ecc6..7b6b35a6b 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/transaction/JdbcTransactionTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/transaction/JdbcTransactionTest.java @@ -54,7 +54,7 @@ public class JdbcTransactionTest { contactNatKeyCache.getStatistics(true); Customer.find.byId(19898989); - Ebean.find(Contact.class).where().eq("email","junk@foo.com").findUnique(); + Ebean.find(Contact.class).where().eq("email", "junk@foo.com").findUnique(); assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(1); assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(1); @@ -64,7 +64,7 @@ public class JdbcTransactionTest { // these don't hit L2 cache due to the save of b1 Customer.find.byId(29898989); - Ebean.find(Contact.class).where().eq("email","junk2@foo.com").findUnique(); + Ebean.find(Contact.class).where().eq("email", "junk2@foo.com").findUnique(); assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(0); assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(0); @@ -74,4 +74,4 @@ public class JdbcTransactionTest { } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ConvertInetAddressTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ConvertInetAddressTest.java index 04b4890be..1cf8a89cc 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ConvertInetAddressTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ConvertInetAddressTest.java @@ -1,32 +1,32 @@ package com.avaje.ebeaninternal.server.type; -import java.net.InetAddress; - import org.junit.Assert; import org.junit.Test; +import java.net.InetAddress; + public class ConvertInetAddressTest { @Test public void forString() { - + InetAddress addr = ConvertInetAddresses.forString("128.1.10.23"); Assert.assertNotNull(addr); Assert.assertEquals("128.1.10.23", addr.getHostAddress()); - + String ip6addr = "2001:db8:85a3:0:0:8a2e:370:7334"; InetAddress addr6 = ConvertInetAddresses.forString(ip6addr); String uriAddr6 = ConvertInetAddresses.toUriString(addr6); - Assert.assertEquals("["+ip6addr+"]", uriAddr6); + Assert.assertEquals("[" + ip6addr + "]", uriAddr6); Assert.assertEquals(ip6addr, addr6.getHostAddress()); } @Test public void toUriString() { - + InetAddress addr = ConvertInetAddresses.forString("128.1.10.23"); Assert.assertEquals("128.1.10.23", addr.getHostAddress()); - + String uriAddr = ConvertInetAddresses.toUriString(addr); Assert.assertEquals("128.1.10.23", uriAddr); } diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactoryTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactoryTest.java index f4db70110..323e644ef 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactoryTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactoryTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import java.sql.Types; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class DefaultTypeFactoryTest { @@ -24,4 +24,4 @@ public class DefaultTypeFactoryTest { assertEquals(Types.VARCHAR, stStringBoolean.getJdbcType()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeManagerTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeManagerTest.java index cca2a3e9f..013f4b017 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeManagerTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/DefaultTypeManagerTest.java @@ -5,7 +5,8 @@ import com.avaje.ebean.config.dbplatform.PostgresPlatform; import com.avaje.ebeaninternal.server.core.bootup.BootupClasses; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class DefaultTypeManagerTest { @@ -32,4 +33,4 @@ public class DefaultTypeManagerTest { assertFalse(typeManager.isIntegerType(" A")); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/JsonTester.java b/src/test/java/com/avaje/ebeaninternal/server/type/JsonTester.java index fab435c37..5fd9d493b 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/JsonTester.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/JsonTester.java @@ -21,7 +21,7 @@ public class JsonTester { protected ScalarType type; - public JsonTester(ScalarType type ) { + public JsonTester(ScalarType type) { this.type = type; } diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java index dea108068..2e6a2dc6d 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareListTest.java @@ -2,7 +2,11 @@ package com.avaje.ebeaninternal.server.type; import org.junit.Test; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; import static org.junit.Assert.*; @@ -11,9 +15,10 @@ public class ModifyAwareListTest { private ModifyAwareList createList() { ArrayList list = new ArrayList(); - list.addAll(Arrays.asList("A","B","C","D","E")); + list.addAll(Arrays.asList("A", "B", "C", "D", "E")); return new ModifyAwareList<>(list); } + private ModifyAwareList createEmptyList() { return new ModifyAwareList<>(new ArrayList<>()); } @@ -237,4 +242,4 @@ public class ModifyAwareListTest { assertTrue(set.isMarkedDirty()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java index a50997680..b6fb8d94a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ModifyAwareMapTest.java @@ -2,7 +2,11 @@ package com.avaje.ebeaninternal.server.type; import org.junit.Test; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; import static org.junit.Assert.*; @@ -177,4 +181,4 @@ public class ModifyAwareMapTest { assertEquals(map.size(), entries.size()); assertFalse(map.isMarkedDirty()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeBooleanTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeBooleanTest.java index 19e36c2c7..04c4ed125 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeBooleanTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeBooleanTest.java @@ -6,9 +6,7 @@ import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.TOne; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ScalarTypeBooleanTest { @@ -42,4 +40,4 @@ public class ScalarTypeBooleanTest { assertEquals(json, "{\"id\":42,\"active\":false}"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDateTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDateTest.java index 4742b8e17..55f86c213 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDateTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDateTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import java.sql.Date; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class ScalarTypeDateTest { @@ -19,4 +19,4 @@ public class ScalarTypeDateTest { Date parsed = type.parse(format); assertEquals(parsed, postgresInfinityDate); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationTest.java index 5a41641d2..8b75ba954 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationTest.java @@ -9,9 +9,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.time.Duration; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class ScalarTypeDurationTest { @@ -61,7 +59,7 @@ public class ScalarTypeDurationTest { Duration val1 = type.toBeanType(duration); Duration val2 = type.toBeanType(seconds); - Duration val3 = type.toBeanType((int)seconds); + Duration val3 = type.toBeanType((int) seconds); assertEquals(duration, val1); assertEquals(duration, val2); @@ -79,7 +77,7 @@ public class ScalarTypeDurationTest { @Test public void testParse() throws Exception { - Duration duration = type.parse("PT20M34S"); + Duration duration = type.parse("PT20M34S"); assertEquals(Duration.ofSeconds(1234), duration); } @@ -105,4 +103,4 @@ public class ScalarTypeDurationTest { } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationWithNanosTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationWithNanosTest.java index 199835aa2..6ae6d1a13 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationWithNanosTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeDurationWithNanosTest.java @@ -10,9 +10,7 @@ import java.io.ObjectOutputStream; import java.math.BigDecimal; import java.time.Duration; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class ScalarTypeDurationWithNanosTest { @@ -79,7 +77,7 @@ public class ScalarTypeDurationWithNanosTest { public void testParse() throws Exception { Duration duration = Duration.ofSeconds(323, 1500000); - Duration val1 = type.parse("PT5M23.0015S"); + Duration val1 = type.parse("PT5M23.0015S"); assertEquals(duration, val1); } @@ -104,4 +102,4 @@ public class ScalarTypeDurationWithNanosTest { jsonTester.test(duration); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstantTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstantTest.java index ccb40bce2..926cc4e1c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstantTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstantTest.java @@ -10,9 +10,7 @@ import java.io.ObjectOutputStream; import java.sql.Timestamp; import java.time.Instant; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ScalarTypeInstantTest { @@ -69,7 +67,7 @@ public class ScalarTypeInstantTest { Instant now = Instant.now(); Timestamp timestamp = Timestamp.from(now); String formatted = type.formatValue(now); - assertEquals(""+timestamp.getTime(), formatted); + assertEquals("" + timestamp.getTime(), formatted); } @Test @@ -77,7 +75,7 @@ public class ScalarTypeInstantTest { Instant now = Instant.now(); Timestamp timestamp = Timestamp.from(now); - Instant val1 = type.parse(""+timestamp.getTime()); + Instant val1 = type.parse("" + timestamp.getTime()); assertEquals(now, val1); } @@ -133,4 +131,4 @@ public class ScalarTypeInstantTest { } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTimeTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTimeTest.java index 948fee29a..9febb2a31 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTimeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTimeTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.sql.Timestamp; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class ScalarTypeJodaLocalDateTimeTest { @@ -40,4 +40,4 @@ public class ScalarTypeJodaLocalDateTimeTest { return new Timestamp(t.toDateTime(DateTimeZone.getDefault()).getMillis()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTest.java index f556822f0..8ca29d809 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTest.java @@ -5,7 +5,8 @@ import org.junit.Test; import java.sql.Date; import java.time.LocalDate; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class ScalarTypeLocalDateTest { @@ -53,4 +54,4 @@ public class ScalarTypeLocalDateTest { assertEquals(localDate, localDate1); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeTest.java index 1f5211cdc..c4b1dbeb9 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeTest.java @@ -10,9 +10,7 @@ import java.io.ObjectOutputStream; import java.sql.Time; import java.time.LocalTime; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class ScalarTypeLocalTimeTest { @@ -101,4 +99,4 @@ public class ScalarTypeLocalTimeTest { jsonTester.test(localTime); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeWithNanosTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeWithNanosTest.java index 31d23fedb..c7b08cc86 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeWithNanosTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTimeWithNanosTest.java @@ -9,9 +9,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.time.LocalTime; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class ScalarTypeLocalTimeWithNanosTest { @@ -102,5 +100,4 @@ public class ScalarTypeLocalTimeWithNanosTest { } - -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java index 1b3c05fc8..18b3f6d87 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDayTest.java @@ -6,7 +6,8 @@ import java.sql.Date; import java.time.LocalDate; import java.time.MonthDay; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; public class ScalarTypeMonthDayTest { @@ -72,4 +73,4 @@ public class ScalarTypeMonthDayTest { public void testReadWriteData() throws Exception { } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeOffsetDateTimeTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeOffsetDateTimeTest.java index db565a2ea..615cde86e 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeOffsetDateTimeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeOffsetDateTimeTest.java @@ -6,9 +6,7 @@ import org.junit.Test; import java.sql.Timestamp; import java.time.OffsetDateTime; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ScalarTypeOffsetDateTimeTest { @@ -76,4 +74,4 @@ public class ScalarTypeOffsetDateTimeTest { jsonTester = new JsonTester(typeIso); jsonTester.test(now); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePathTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePathTest.java index b14c2569b..25a0c04bb 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePathTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePathTest.java @@ -10,9 +10,9 @@ import static org.junit.Assert.assertEquals; public class ScalarTypePathTest { private static final String TEMP_PATH = new File("/tmp").getAbsolutePath(); - + private ScalarTypePath type = new ScalarTypePath(); - + @Test public void convertFromDbString() throws Exception { @@ -35,4 +35,4 @@ public class ScalarTypePathTest { assertEquals(path, converted); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java index 9a52898aa..21209cda6 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypePostgresHstoreTest.java @@ -12,9 +12,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ScalarTypePostgresHstoreTest { @@ -34,10 +32,10 @@ public class ScalarTypePostgresHstoreTest { @Test public void testIsDirty() throws Exception { - Map emptyMap = new HashMap<>(); + Map emptyMap = new HashMap<>(); assertTrue(hstore.isDirty(emptyMap)); - ModifyAwareMap modAware = new ModifyAwareMap<>(emptyMap); + ModifyAwareMap modAware = new ModifyAwareMap<>(emptyMap); assertFalse(hstore.isDirty(modAware)); modAware.put("foo", "Rob"); assertTrue(hstore.isDirty(emptyMap)); @@ -46,7 +44,7 @@ public class ScalarTypePostgresHstoreTest { @Test @SuppressWarnings("unchecked") public void testParse() throws Exception { - Map map = (Map)hstore.parse("{\"name\":\"rob\"}"); + Map map = (Map) hstore.parse("{\"name\":\"rob\"}"); assertEquals(1, map.size()); assertEquals("rob", map.get("name")); } @@ -54,7 +52,7 @@ public class ScalarTypePostgresHstoreTest { @Test(expected = RuntimeException.class) @SuppressWarnings("unchecked") public void testParseDateTime() throws Exception { - Map map = (Map)hstore.convertFromMillis(1234L); + Map map = (Map) hstore.convertFromMillis(1234L); assertEquals(1, map.size()); assertEquals("rob", map.get("name")); } @@ -62,7 +60,7 @@ public class ScalarTypePostgresHstoreTest { @Test public void testJsonWrite() throws Exception { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); assertEquals("{\"key\":{}}", generateJson(map)); @@ -88,13 +86,13 @@ public class ScalarTypePostgresHstoreTest { } @SuppressWarnings("unchecked") - private Map parseHstore(String json) throws IOException { + private Map parseHstore(String json) throws IOException { JsonParser parser = jsonFactory.createParser(json); // BeanProperty reads the first token checking for null so // simulate that here JsonToken token = parser.nextToken(); assertEquals(JsonToken.START_OBJECT, token); - return (Map)hstore.jsonRead(parser); + return (Map) hstore.jsonRead(parser); } private String generateJson(Map map) throws IOException { @@ -113,4 +111,4 @@ public class ScalarTypePostgresHstoreTest { return writer.toString(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeYearTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeYearTest.java index 9246221f7..7552dd21c 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeYearTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeYearTest.java @@ -9,9 +9,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.time.Year; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class ScalarTypeYearTest { @@ -97,4 +95,4 @@ public class ScalarTypeYearTest { jsonTester.test(Year.of(2013)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZoneIdTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZoneIdTest.java index ac59b0da5..daddf28d7 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZoneIdTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZoneIdTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import java.time.ZoneId; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class ScalarTypeZoneIdTest { @@ -37,4 +37,4 @@ public class ScalarTypeZoneIdTest { assertEquals(zoneId, val1); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZonedDateTimeTest.java b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZonedDateTimeTest.java index 0e9c7aa08..13cdb9c8a 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZonedDateTimeTest.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/ScalarTypeZonedDateTimeTest.java @@ -6,9 +6,7 @@ import org.junit.Test; import java.sql.Timestamp; import java.time.ZonedDateTime; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ScalarTypeZonedDateTimeTest { @@ -77,4 +75,4 @@ public class ScalarTypeZonedDateTimeTest { jsonTester = new JsonTester(typeIso); jsonTester.test(now); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/TestEnumToBeanType.java b/src/test/java/com/avaje/ebeaninternal/server/type/TestEnumToBeanType.java index 75e86eca3..39515a80f 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/TestEnumToBeanType.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/TestEnumToBeanType.java @@ -1,39 +1,38 @@ package com.avaje.ebeaninternal.server.type; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebeaninternal.server.type.ScalarTypeEnumStandard.OrdinalEnum; import com.avaje.ebeaninternal.server.type.ScalarTypeEnumStandard.StringEnum; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; +import org.junit.Assert; +import org.junit.Test; public class TestEnumToBeanType { @Test public void test() { - - StringEnum stringEnum = new ScalarTypeEnumStandard.StringEnum(Order.Status.class); - - OrdinalEnum ordinalEnum = new ScalarTypeEnumStandard.OrdinalEnum(Order.Status.class); - - EnumToDbValueMap beanDbMap = EnumToDbValueMap.create(false); - beanDbMap.add(Customer.Status.ACTIVE, "A", Customer.Status.ACTIVE.name()); - beanDbMap.add(Customer.Status.NEW, "N", Customer.Status.NEW.name()); - beanDbMap.add(Customer.Status.INACTIVE, "I", Customer.Status.INACTIVE.name()); - - ScalarTypeEnumWithMapping withMapping = new ScalarTypeEnumWithMapping(beanDbMap, Customer.Status.class, 1); - - - Object approved = stringEnum.toBeanType(Order.Status.APPROVED); - Assert.assertTrue(approved == Order.Status.APPROVED); - approved = ordinalEnum.toBeanType(Order.Status.APPROVED); - Assert.assertTrue(approved == Order.Status.APPROVED); + StringEnum stringEnum = new ScalarTypeEnumStandard.StringEnum(Order.Status.class); - Object active = withMapping.toBeanType(Customer.Status.ACTIVE); - Assert.assertTrue(active == Customer.Status.ACTIVE); + OrdinalEnum ordinalEnum = new ScalarTypeEnumStandard.OrdinalEnum(Order.Status.class); + + EnumToDbValueMap beanDbMap = EnumToDbValueMap.create(false); + beanDbMap.add(Customer.Status.ACTIVE, "A", Customer.Status.ACTIVE.name()); + beanDbMap.add(Customer.Status.NEW, "N", Customer.Status.NEW.name()); + beanDbMap.add(Customer.Status.INACTIVE, "I", Customer.Status.INACTIVE.name()); + + ScalarTypeEnumWithMapping withMapping = new ScalarTypeEnumWithMapping(beanDbMap, Customer.Status.class, 1); + + + Object approved = stringEnum.toBeanType(Order.Status.APPROVED); + Assert.assertTrue(approved == Order.Status.APPROVED); + + approved = ordinalEnum.toBeanType(Order.Status.APPROVED); + Assert.assertTrue(approved == Order.Status.APPROVED); + + Object active = withMapping.toBeanType(Customer.Status.ACTIVE); + Assert.assertTrue(active == Customer.Status.ACTIVE); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/type/TestScalarTypeUUIDBinaryConversion.java b/src/test/java/com/avaje/ebeaninternal/server/type/TestScalarTypeUUIDBinaryConversion.java index 9a760a3d8..9bc8b3631 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/type/TestScalarTypeUUIDBinaryConversion.java +++ b/src/test/java/com/avaje/ebeaninternal/server/type/TestScalarTypeUUIDBinaryConversion.java @@ -1,22 +1,22 @@ package com.avaje.ebeaninternal.server.type; -import java.util.UUID; - import org.junit.Assert; import org.junit.Test; +import java.util.UUID; + public class TestScalarTypeUUIDBinaryConversion { @Test public void testConversion() { - + UUID id = UUID.randomUUID(); - + byte[] bytes = ScalarTypeUUIDBinary.convertToBytes(id); Assert.assertEquals(16, bytes.length); - + UUID id2 = ScalarTypeUUIDBinary.convertFromBytes(bytes); Assert.assertEquals(id, id2); } - + } diff --git a/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java b/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java index 2d676d13a..ccf719454 100644 --- a/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java +++ b/src/test/java/com/avaje/ebeaninternal/server/util/Md5Test.java @@ -2,7 +2,7 @@ package com.avaje.ebeaninternal.server.util; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class Md5Test { @@ -15,4 +15,4 @@ public class Md5Test { assertEquals(hash1, hash2); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java index 090e9b932..83c2d6d36 100644 --- a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java +++ b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreBeanBaseAdapterTest.java @@ -26,7 +26,7 @@ public class DocStoreBeanBaseAdapterTest extends BaseTestCase { SpiEbeanServer server = spiEbeanServer(); BeanDescriptor orderDesc = server.getBeanDescriptor(Order.class); - DeployBeanDescriptor deployDesc = (DeployBeanDescriptor)mock(DeployBeanDescriptor.class); + DeployBeanDescriptor deployDesc = (DeployBeanDescriptor) mock(DeployBeanDescriptor.class); TDAdapter adapter = new TDAdapter<>(orderDesc, deployDesc); @@ -65,4 +65,4 @@ public class DocStoreBeanBaseAdapterTest extends BaseTestCase { public void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocStoreUpdateContext txn) throws IOException { } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEventTest.java b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEventTest.java index f864180a5..5d3e61013 100644 --- a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEventTest.java +++ b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreDeleteEventTest.java @@ -14,9 +14,7 @@ import org.mockito.Mockito; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; public class DocStoreDeleteEventTest { @@ -35,7 +33,7 @@ public class DocStoreDeleteEventTest { public void docStoreUpdate() throws Exception { BeanType mock = (BeanType) Mockito.mock(BeanType.class); - BeanDocType mockDocType = (BeanDocType)Mockito.mock(BeanDocType.class); + BeanDocType mockDocType = (BeanDocType) Mockito.mock(BeanDocType.class); when(mock.docStore()).thenReturn(mockDocType); DocStoreDeleteEvent event = new DocStoreDeleteEvent(mock, 42); @@ -62,4 +60,4 @@ public class DocStoreDeleteEventTest { StrictAssertions.assertThat(entry.getPath()).isNull(); assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.DELETE); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java index 67128499a..b487f6499 100644 --- a/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java +++ b/src/test/java/com/avaje/ebeanservice/docstore/api/support/DocStoreIndexEventTest.java @@ -13,9 +13,7 @@ import org.mockito.Mockito; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; public class DocStoreIndexEventTest { @@ -33,8 +31,8 @@ public class DocStoreIndexEventTest { @SuppressWarnings("unchecked") public void docStoreUpdate() throws Exception { - BeanType mock = (BeanType)Mockito.mock(BeanType.class); - BeanDocType mockDocType = (BeanDocType)Mockito.mock(BeanDocType.class); + BeanType mock = (BeanType) Mockito.mock(BeanType.class); + BeanDocType mockDocType = (BeanDocType) Mockito.mock(BeanDocType.class); when(mock.docStore()).thenReturn(mockDocType); Order bean = new Order(); @@ -65,4 +63,4 @@ public class DocStoreIndexEventTest { assertThat(entry.getPath()).isNull(); assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.INDEX); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/autofetch/AutofetchEmbeddedTest.java b/src/test/java/com/avaje/tests/autofetch/AutofetchEmbeddedTest.java index ab24df13c..4d3df1ec8 100644 --- a/src/test/java/com/avaje/tests/autofetch/AutofetchEmbeddedTest.java +++ b/src/test/java/com/avaje/tests/autofetch/AutofetchEmbeddedTest.java @@ -1,15 +1,12 @@ package com.avaje.tests.autofetch; -import java.util.List; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.embedded.EMain; import com.avaje.tests.model.embedded.Eembeddable; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AutofetchEmbeddedTest extends BaseTestCase { @@ -18,23 +15,23 @@ public class AutofetchEmbeddedTest extends BaseTestCase { @Test public void testEmbeddedBeanLazyLoadAndUpdate() { - + EMain testBean = new EMain(); testBean.setName("test"); testBean.getEmbeddable().setDescription("test description"); Ebean.save(testBean); EMain partialBean = Ebean.find(EMain.class).select("version").setId(testBean.getId()).findUnique(); - + logger.info(" -- invoke lazy loading of embedded bean"); Eembeddable embeddable = partialBean.getEmbeddable(); embeddable.setDescription("modified description"); - + logger.info(" -- update bean"); Ebean.save(partialBean); - + } - + @Test public void testEmbeddedBeanQueryTuning() { // Ebean.getServer(null).getAutoTune().setProfiling(true); diff --git a/src/test/java/com/avaje/tests/autofetch/MainAutoFetchExcludeLazyLobs.java b/src/test/java/com/avaje/tests/autofetch/MainAutoFetchExcludeLazyLobs.java index e53931b16..296e334fd 100644 --- a/src/test/java/com/avaje/tests/autofetch/MainAutoFetchExcludeLazyLobs.java +++ b/src/test/java/com/avaje/tests/autofetch/MainAutoFetchExcludeLazyLobs.java @@ -7,28 +7,26 @@ import java.util.List; public class MainAutoFetchExcludeLazyLobs { - public static void main(String[] args) { - - EBasicClob a = new EBasicClob(); - a.setName("name 1"); - a.setTitle("a title"); - a.setDescription("not that meaningful"); - - Ebean.save(a); - - List list = Ebean.find(EBasicClob.class) - .setAutoTune(true) - .findList(); - - for (EBasicClob bean : list) { - bean.getName(); - // although we read the description - // autofetch will not include it later - bean.getDescription(); - } - - - - + public static void main(String[] args) { + + EBasicClob a = new EBasicClob(); + a.setName("name 1"); + a.setTitle("a title"); + a.setDescription("not that meaningful"); + + Ebean.save(a); + + List list = Ebean.find(EBasicClob.class) + .setAutoTune(true) + .findList(); + + for (EBasicClob bean : list) { + bean.getName(); + // although we read the description + // autofetch will not include it later + bean.getDescription(); } + + + } } diff --git a/src/test/java/com/avaje/tests/autofetch/MainAutoQueryTune1.java b/src/test/java/com/avaje/tests/autofetch/MainAutoQueryTune1.java index 1f6cb05e5..f720fa691 100644 --- a/src/test/java/com/avaje/tests/autofetch/MainAutoQueryTune1.java +++ b/src/test/java/com/avaje/tests/autofetch/MainAutoQueryTune1.java @@ -8,27 +8,27 @@ import java.util.List; public class MainAutoQueryTune1 { - public static void main(String[] args) { + public static void main(String[] args) { - ResetBasicData.reset(); + ResetBasicData.reset(); - MainAutoQueryTune1 me = new MainAutoQueryTune1(); - me.tuneJoin(); - } + MainAutoQueryTune1 me = new MainAutoQueryTune1(); + me.tuneJoin(); + } - private void tuneJoin() { - List list = Ebean.find(Order.class) - .setAutoTune(true) - .fetch("customer") - .where() - .eq("status", Order.Status.NEW) - .eq("customer.name", "Rob") - .order().asc("id") - .findList(); + private void tuneJoin() { + List list = Ebean.find(Order.class) + .setAutoTune(true) + .fetch("customer") + .where() + .eq("status", Order.Status.NEW) + .eq("customer.name", "Rob") + .order().asc("id") + .findList(); - for (Order order : list) { - order.getId(); + for (Order order : list) { + order.getId(); order.getOrderDate(); - } - } + } + } } diff --git a/src/test/java/com/avaje/tests/autofetch/TunedQueryInfoTest.java b/src/test/java/com/avaje/tests/autofetch/TunedQueryInfoTest.java index 9a80c7684..a785e9dfe 100644 --- a/src/test/java/com/avaje/tests/autofetch/TunedQueryInfoTest.java +++ b/src/test/java/com/avaje/tests/autofetch/TunedQueryInfoTest.java @@ -1,14 +1,5 @@ package com.avaje.tests.autofetch; -import java.util.List; -import java.util.Set; - -import com.avaje.ebeaninternal.server.autotune.model.Origin; -import org.avaje.ebeantest.LoggedSqlCollector; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -17,82 +8,90 @@ import com.avaje.ebean.bean.EntityBean; import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.ebean.cache.ServerCacheManager; import com.avaje.ebeaninternal.api.SpiQuery; +import com.avaje.ebeaninternal.server.autotune.model.Origin; import com.avaje.ebeaninternal.server.autotune.service.TunedQueryInfo; import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; +import java.util.Set; public class TunedQueryInfoTest extends BaseTestCase { EbeanServer server = Ebean.getServer(null); - + private void init() { - + ResetBasicData.reset(); - + ServerCacheManager serverCacheManager = Ebean.getServer(null).getServerCacheManager(); serverCacheManager.clearAll(); } - + @Test public void withSelectEmpty() { - + init(); - + OrmQueryDetail tunedDetail = new OrmQueryDetail(); tunedDetail.select(""); TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail); Query query = server.find(Order.class).setId(1); - + tunedInfo.tuneQuery((SpiQuery) query); - + Order order = query.findUnique(); - EntityBean eb = (EntityBean)order; + EntityBean eb = (EntityBean) order; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + Assert.assertTrue(ebi.isFullyLoadedBean()); - + Set loadedPropertyNames = ebi.getLoadedPropertyNames(); Assert.assertNull(loadedPropertyNames); - + // invoke lazy loading order.getCustomer(); } - + @Test public void withSelectSomethingThatDoesNotExist() { - + init(); - + OrmQueryDetail tunedDetail = new OrmQueryDetail(); tunedDetail.select("somethingThatDoesNotExist"); TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail); Query query = server.find(Order.class).setId(1); - + tunedInfo.tuneQuery((SpiQuery) query); - + LoggedSqlCollector.start(); - + Order order = query.findUnique(); - EntityBean eb = (EntityBean)order; + EntityBean eb = (EntityBean) order; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + Assert.assertFalse(ebi.isFullyLoadedBean()); - + // id and any ToMany relationships Set loadedPropertyNames = ebi.getLoadedPropertyNames(); Assert.assertNotNull(loadedPropertyNames); - + // invoke lazy loading order.getCustomer(); - + List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(2, loggedSql.size()); - + Assert.assertTrue(trimSql(loggedSql.get(0), 1).contains("select t0.id, t0.id from o_order t0 where t0.id = ?")); Assert.assertTrue(trimSql(loggedSql.get(1), 1).contains("select t0.id, t0.status,")); } @@ -106,72 +105,72 @@ public class TunedQueryInfoTest extends BaseTestCase { @Test public void withSelectSomeIncludeLazyLoaded() { - + init(); OrmQueryDetail tunedDetail = new OrmQueryDetail(); tunedDetail.select("status, customer"); - + TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail); - + Query query = server.find(Order.class).setId(1); - + tunedInfo.tuneQuery((SpiQuery) query); - + LoggedSqlCollector.start(); - + Order order = query.findUnique(); - EntityBean eb = (EntityBean)order; + EntityBean eb = (EntityBean) order; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + Assert.assertFalse(ebi.isFullyLoadedBean()); - + Set loadedPropertyNames = ebi.getLoadedPropertyNames(); Assert.assertNotNull(loadedPropertyNames); - + Assert.assertTrue(loadedPropertyNames.contains("status")); Assert.assertTrue(loadedPropertyNames.contains("customer")); - + // no lazy loading expected here order.getCustomer(); - + List loggedSql = LoggedSqlCollector.stop(); - Assert.assertEquals(1, loggedSql.size()); + Assert.assertEquals(1, loggedSql.size()); } - + @Test public void withSelectSome() { - + init(); - + OrmQueryDetail tunedDetail = new OrmQueryDetail(); tunedDetail.select("status"); - + TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail); - + Query query = server.find(Order.class).setId(1); - + tunedInfo.tuneQuery((SpiQuery) query); - + LoggedSqlCollector.start(); - + Order order = query.findUnique(); - EntityBean eb = (EntityBean)order; + EntityBean eb = (EntityBean) order; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + Assert.assertFalse(ebi.isFullyLoadedBean()); - + Set loadedPropertyNames = ebi.getLoadedPropertyNames(); Assert.assertNotNull(loadedPropertyNames); - + Assert.assertTrue(loadedPropertyNames.contains("status")); Assert.assertFalse(loadedPropertyNames.contains("customer")); - + // no lazy loading expected here order.getCustomer(); - + List loggedSql = LoggedSqlCollector.stop(); - Assert.assertEquals(2, loggedSql.size()); + Assert.assertEquals(2, loggedSql.size()); } - + } diff --git a/src/test/java/com/avaje/tests/autofetch/TunedQueryWithNullFetchedBeanTest.java b/src/test/java/com/avaje/tests/autofetch/TunedQueryWithNullFetchedBeanTest.java index 501614941..60f829223 100644 --- a/src/test/java/com/avaje/tests/autofetch/TunedQueryWithNullFetchedBeanTest.java +++ b/src/test/java/com/avaje/tests/autofetch/TunedQueryWithNullFetchedBeanTest.java @@ -1,12 +1,5 @@ package com.avaje.tests.autofetch; -import java.util.List; -import java.util.Set; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -16,32 +9,38 @@ import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; +import java.util.Set; public class TunedQueryWithNullFetchedBeanTest extends BaseTestCase { EbeanServer server = Ebean.getServer(null); - + @Test public void withFetchOfNullBeanJoin() { - + ResetBasicData.reset(); - + Customer newCustomer = new Customer(); newCustomer.setName("TestFetchBillingAddress"); server.save(newCustomer); - + Query query = server.find(Customer.class) - .setId(newCustomer.getId()) - .fetch("billingAddress","id"); - + .setId(newCustomer.getId()) + .fetch("billingAddress", "id"); + LoggedSqlCollector.start(); - + Customer customer = query.findUnique(); - EntityBean eb = (EntityBean)customer; + EntityBean eb = (EntityBean) customer; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + Assert.assertTrue(ebi.isFullyLoadedBean()); - + // find the internal property index for "billingAddress" String[] propNames = eb._ebean_getPropertyNames(); int pos = 0; @@ -50,19 +49,19 @@ public class TunedQueryWithNullFetchedBeanTest extends BaseTestCase { pos = i; } } - + // The billing address is loaded (but value null) Assert.assertTrue(ebi.isLoadedProperty(pos)); - + Set loadedPropertyNames = ebi.getLoadedPropertyNames(); Assert.assertNull(loadedPropertyNames); - + // no lazy loading expected here, value is null Address billingAddress = customer.getBillingAddress(); Assert.assertNull(billingAddress); - + // assert only one query executed List loggedSql = LoggedSqlCollector.stop(); - Assert.assertEquals(1, loggedSql.size()); + Assert.assertEquals(1, loggedSql.size()); } } diff --git a/src/test/java/com/avaje/tests/basic/MainDbBoolean.java b/src/test/java/com/avaje/tests/basic/MainDbBoolean.java index e3c2ab758..a4fe53a0f 100644 --- a/src/test/java/com/avaje/tests/basic/MainDbBoolean.java +++ b/src/test/java/com/avaje/tests/basic/MainDbBoolean.java @@ -1,156 +1,154 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.Query; import com.avaje.ebean.SqlRow; -import org.avaje.datasource.DataSourceConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.PostgresPlatform; import com.avaje.tests.model.basic.TOne; import com.avaje.tests.model.basic.TSDetail; import com.avaje.tests.model.basic.TSMaster; +import org.avaje.datasource.DataSourceConfig; +import org.junit.Assert; + +import java.util.List; /** * Used to run some tests manually on a specific Database type. */ public class MainDbBoolean { - - public static void main(String[] args) { - - MainDbBoolean me = new MainDbBoolean(); - - EbeanServer server = me.createEbeanServer(); - me.simpleCheck(server); - - EbeanServer oraServer = me.createOracleEbeanServer(); - me.simpleCheck(oraServer); - } - /** - * Create a server for running small oracle specific tests manually. - * DDL generation etc. - */ - private EbeanServer createOracleEbeanServer() { + public static void main(String[] args) { - System.setProperty("ebean.ignoreExtraDdl", "true"); + MainDbBoolean me = new MainDbBoolean(); - ServerConfig c = new ServerConfig(); - c.setName("ora"); + EbeanServer server = me.createEbeanServer(); + me.simpleCheck(server); - // requires oracle driver in class path - DataSourceConfig oraDb = new DataSourceConfig(); - oraDb.setDriver("oracle.jdbc.driver.OracleDriver"); - oraDb.setUsername("junk"); - oraDb.setPassword("junk"); - oraDb.setUrl("jdbc:oracle:thin:junk/junk@localhost:1521:XE"); - oraDb.setHeartbeatSql("select count(*) from dual"); - - - c.loadFromProperties(); - c.setDdlGenerate(true); - c.setDdlRun(true); - c.setDefaultServer(false); - c.setRegister(false); - c.setDataSourceConfig(oraDb); - - //c.setDatabaseBooleanTrue("1"); - //c.setDatabaseBooleanFalse("0"); - c.setDatabaseBooleanTrue("T"); - c.setDatabaseBooleanFalse("F"); + EbeanServer oraServer = me.createOracleEbeanServer(); + me.simpleCheck(oraServer); + } - c.addClass(TOne.class); - c.addClass(TSMaster.class); - c.addClass(TSDetail.class); + /** + * Create a server for running small oracle specific tests manually. + * DDL generation etc. + */ + private EbeanServer createOracleEbeanServer() { - return EbeanServerFactory.create(c); + System.setProperty("ebean.ignoreExtraDdl", "true"); - } - - private EbeanServer createEbeanServer() { + ServerConfig c = new ServerConfig(); + c.setName("ora"); - System.setProperty("ebean.ignoreExtraDdl", "true"); + // requires oracle driver in class path + DataSourceConfig oraDb = new DataSourceConfig(); + oraDb.setDriver("oracle.jdbc.driver.OracleDriver"); + oraDb.setUsername("junk"); + oraDb.setPassword("junk"); + oraDb.setUrl("jdbc:oracle:thin:junk/junk@localhost:1521:XE"); + oraDb.setHeartbeatSql("select count(*) from dual"); - ServerConfig c = new ServerConfig(); - c.setName("pgtest"); - // requires postgres driver in class path - DataSourceConfig postgresDb = new DataSourceConfig(); - postgresDb.setDriver("org.postgresql.Driver"); - postgresDb.setUsername("test"); - postgresDb.setPassword("test"); - postgresDb.setUrl("jdbc:postgresql://127.0.0.1:5432/test"); - postgresDb.setHeartbeatSql("select count(*) from t_one"); - - c.loadFromProperties(); - c.setDdlGenerate(true); - c.setDdlRun(true); - c.setDefaultServer(false); - c.setRegister(false); - c.setDataSourceConfig(postgresDb); - - //c.setDatabaseBooleanTrue("1"); - //c.setDatabaseBooleanFalse("0"); - c.setDatabaseBooleanTrue("T"); - c.setDatabaseBooleanFalse("F"); + c.loadFromProperties(); + c.setDdlGenerate(true); + c.setDdlRun(true); + c.setDefaultServer(false); + c.setRegister(false); + c.setDataSourceConfig(oraDb); - c.setDatabasePlatform(new PostgresPlatform()); + //c.setDatabaseBooleanTrue("1"); + //c.setDatabaseBooleanFalse("0"); + c.setDatabaseBooleanTrue("T"); + c.setDatabaseBooleanFalse("F"); - c.addClass(TOne.class); + c.addClass(TOne.class); + c.addClass(TSMaster.class); + c.addClass(TSDetail.class); - return EbeanServerFactory.create(c); + return EbeanServerFactory.create(c); - } + } - private void simpleCheck(EbeanServer server) { + private EbeanServer createEbeanServer() { - TOne o = new TOne(); - o.setName("banan"); - o.setDescription("this one is true"); - o.setActive(true); + System.setProperty("ebean.ignoreExtraDdl", "true"); - server.save(o); + ServerConfig c = new ServerConfig(); + c.setName("pgtest"); - TOne o2 = new TOne(); - o2.setName("banan"); - o2.setDescription("this one is false"); - o2.setActive(false); + // requires postgres driver in class path + DataSourceConfig postgresDb = new DataSourceConfig(); + postgresDb.setDriver("org.postgresql.Driver"); + postgresDb.setUsername("test"); + postgresDb.setPassword("test"); + postgresDb.setUrl("jdbc:postgresql://127.0.0.1:5432/test"); + postgresDb.setHeartbeatSql("select count(*) from t_one"); - server.save(o2); + c.loadFromProperties(); + c.setDdlGenerate(true); + c.setDdlRun(true); + c.setDefaultServer(false); + c.setRegister(false); + c.setDataSourceConfig(postgresDb); - - List list = server.find(TOne.class) - .setAutoTune(false) - .order("id") - .findList(); - - Assert.assertTrue(list.size() == 2); - Assert.assertTrue(list.get(0).isActive()); - Assert.assertFalse(!list.get(0).isActive()); - - String sql = "select id, name, active from t_oneb order by id"; - List sqlRows = server.createSqlQuery(sql).findList(); - Assert.assertTrue(sqlRows.size() == 2); - Object active0 = sqlRows.get(0).get("active"); - Object active1 = sqlRows.get(1).get("active"); - - Assert.assertTrue("T".equals(active0)); - Assert.assertTrue("F".equals(active1)); - - + //c.setDatabaseBooleanTrue("1"); + //c.setDatabaseBooleanFalse("0"); + c.setDatabaseBooleanTrue("T"); + c.setDatabaseBooleanFalse("F"); - Query query = server.find(TOne.class) - .setAutoTune(false) - .order("id"); - - int rc = query.findCount(); - Assert.assertTrue(rc > 0); - - - System.out.println("done"); - } + c.setDatabasePlatform(new PostgresPlatform()); + + c.addClass(TOne.class); + + return EbeanServerFactory.create(c); + + } + + private void simpleCheck(EbeanServer server) { + + TOne o = new TOne(); + o.setName("banan"); + o.setDescription("this one is true"); + o.setActive(true); + + server.save(o); + + TOne o2 = new TOne(); + o2.setName("banan"); + o2.setDescription("this one is false"); + o2.setActive(false); + + server.save(o2); + + + List list = server.find(TOne.class) + .setAutoTune(false) + .order("id") + .findList(); + + Assert.assertTrue(list.size() == 2); + Assert.assertTrue(list.get(0).isActive()); + Assert.assertFalse(!list.get(0).isActive()); + + String sql = "select id, name, active from t_oneb order by id"; + List sqlRows = server.createSqlQuery(sql).findList(); + Assert.assertTrue(sqlRows.size() == 2); + Object active0 = sqlRows.get(0).get("active"); + Object active1 = sqlRows.get(1).get("active"); + + Assert.assertTrue("T".equals(active0)); + Assert.assertTrue("F".equals(active1)); + + + Query query = server.find(TOne.class) + .setAutoTune(false) + .order("id"); + + int rc = query.findCount(); + Assert.assertTrue(rc > 0); + + + System.out.println("done"); + } } diff --git a/src/test/java/com/avaje/tests/basic/MyTestDataSourcePoolListener.java b/src/test/java/com/avaje/tests/basic/MyTestDataSourcePoolListener.java index 4cf1adc4d..1459c4e90 100644 --- a/src/test/java/com/avaje/tests/basic/MyTestDataSourcePoolListener.java +++ b/src/test/java/com/avaje/tests/basic/MyTestDataSourcePoolListener.java @@ -1,29 +1,22 @@ package com.avaje.tests.basic; -import java.sql.Connection; - import org.avaje.datasource.DataSourcePoolListener; -public class MyTestDataSourcePoolListener implements DataSourcePoolListener -{ - public static int SLEEP_AFTER_BORROW = 0; - - public void onAfterBorrowConnection(Connection c) - { - if (SLEEP_AFTER_BORROW > 0) - { - try - { - Thread.sleep(SLEEP_AFTER_BORROW); - } - catch (InterruptedException e) - { - throw new RuntimeException(e); - } - } - } +import java.sql.Connection; - public void onBeforeReturnConnection(Connection c) - { +public class MyTestDataSourcePoolListener implements DataSourcePoolListener { + public static int SLEEP_AFTER_BORROW = 0; + + public void onAfterBorrowConnection(Connection c) { + if (SLEEP_AFTER_BORROW > 0) { + try { + Thread.sleep(SLEEP_AFTER_BORROW); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } + } + + public void onBeforeReturnConnection(Connection c) { + } } diff --git a/src/test/java/com/avaje/tests/basic/TestAssocOneEqExpression.java b/src/test/java/com/avaje/tests/basic/TestAssocOneEqExpression.java index 50fb2fe99..1e26e7a11 100644 --- a/src/test/java/com/avaje/tests/basic/TestAssocOneEqExpression.java +++ b/src/test/java/com/avaje/tests/basic/TestAssocOneEqExpression.java @@ -1,8 +1,5 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -10,35 +7,37 @@ import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestAssocOneEqExpression extends BaseTestCase { @Test - public void test() { - - ResetBasicData.reset(); - - Customer c = new Customer(); - c.setId(1); - - Query query = Ebean.find(Order.class) - .where().eq("customer", c) - .query(); - - query.findList(); - String sql = query.getGeneratedSql(); - Assert.assertTrue(sql.contains("where t0.kcustomer_id = ?")); - - Address b = new Address(); - b.setId((short)1); - - Query q2 = Ebean.find(Order.class) - .where().eq("customer.billingAddress", b) - .query(); - - q2.findList(); - sql = q2.getGeneratedSql(); - Assert.assertTrue(sql.contains("where t1.billing_address_id = ?")); + public void test() { - } + ResetBasicData.reset(); + + Customer c = new Customer(); + c.setId(1); + + Query query = Ebean.find(Order.class) + .where().eq("customer", c) + .query(); + + query.findList(); + String sql = query.getGeneratedSql(); + Assert.assertTrue(sql.contains("where t0.kcustomer_id = ?")); + + Address b = new Address(); + b.setId((short) 1); + + Query q2 = Ebean.find(Order.class) + .where().eq("customer.billingAddress", b) + .query(); + + q2.findList(); + sql = q2.getGeneratedSql(); + Assert.assertTrue(sql.contains("where t1.billing_address_id = ?")); + + } } diff --git a/src/test/java/com/avaje/tests/basic/TestBatchLazy.java b/src/test/java/com/avaje/tests/basic/TestBatchLazy.java index 7c1e27457..b79513816 100644 --- a/src/test/java/com/avaje/tests/basic/TestBatchLazy.java +++ b/src/test/java/com/avaje/tests/basic/TestBatchLazy.java @@ -14,12 +14,12 @@ import java.util.List; public class TestBatchLazy extends BaseTestCase { @Test - public void testMe() { - - ResetBasicData.reset(); + public void testMe() { - Query query = Ebean.find(Order.class); - List list = query.findList(); + ResetBasicData.reset(); + + Query query = Ebean.find(Order.class); + List list = query.findList(); for (Order order : list) { @@ -35,8 +35,7 @@ public class TestBatchLazy extends BaseTestCase { Ebean.getDefaultServer().getAutoTune().collectProfiling(); Ebean.getDefaultServer().getAutoTune().reportProfiling(); - } - - - + } + + } diff --git a/src/test/java/com/avaje/tests/basic/TestBatchLazyMany.java b/src/test/java/com/avaje/tests/basic/TestBatchLazyMany.java index d3cbe44dc..6dd0699f9 100644 --- a/src/test/java/com/avaje/tests/basic/TestBatchLazyMany.java +++ b/src/test/java/com/avaje/tests/basic/TestBatchLazyMany.java @@ -1,36 +1,35 @@ package com.avaje.tests.basic; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; public class TestBatchLazyMany extends BaseTestCase { @Test - public void testMe() { - - ResetBasicData.reset(); - - Order order2 = Ebean.getReference(Order.class, 1); - order2.getOrderDate(); + public void testMe() { + + ResetBasicData.reset(); + + Order order2 = Ebean.getReference(Order.class, 1); + order2.getOrderDate(); // List list = Ebean.find(Order.class) // //.join("details") // //.join("details", "+fetchquery") // .findList(); -// +// // Order order = list.get(0); // //List details = order.getDetails(); // //details.size(); -// +// // Customer customer = order.getCustomer(); // customer.getName(); // System.out.println("done"); - - } - - + + } + + } diff --git a/src/test/java/com/avaje/tests/basic/TestBeanReferenceRefresh.java b/src/test/java/com/avaje/tests/basic/TestBeanReferenceRefresh.java index d1f510bed..bd7948d7b 100644 --- a/src/test/java/com/avaje/tests/basic/TestBeanReferenceRefresh.java +++ b/src/test/java/com/avaje/tests/basic/TestBeanReferenceRefresh.java @@ -1,53 +1,52 @@ package com.avaje.tests.basic; -import java.sql.Date; - -import com.avaje.ebean.cache.ServerCache; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import com.avaje.ebean.cache.ServerCache; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Date; public class TestBeanReferenceRefresh extends BaseTestCase { @Test - public void testMe() { - - ResetBasicData.reset(); + public void testMe() { + + ResetBasicData.reset(); ServerCache beanCache = Ebean.getServerCacheManager().getBeanCache(Order.class); beanCache.clear(); Order order = Ebean.getReference(Order.class, 1); - - Assert.assertTrue(Ebean.getBeanState(order).isReference()); - - // invoke lazy loading - Date orderDate = order.getOrderDate(); - Assert.assertNotNull(orderDate); - - Customer customer = order.getCustomer(); - Assert.assertNotNull(customer); - - Assert.assertFalse(Ebean.getBeanState(order).isReference()); - Assert.assertNotNull(order.getStatus()); - Assert.assertNotNull(order.getDetails()); - Assert.assertNull(Ebean.getBeanState(order).getLoadedProps()); - - Status status = order.getStatus(); - Assert.assertTrue(status != Order.Status.SHIPPED); - order.setStatus(Order.Status.SHIPPED); - Ebean.refresh(order); - - Status statusRefresh = order.getStatus(); - Assert.assertEquals(status,statusRefresh); - - } - - + + Assert.assertTrue(Ebean.getBeanState(order).isReference()); + + // invoke lazy loading + Date orderDate = order.getOrderDate(); + Assert.assertNotNull(orderDate); + + Customer customer = order.getCustomer(); + Assert.assertNotNull(customer); + + Assert.assertFalse(Ebean.getBeanState(order).isReference()); + Assert.assertNotNull(order.getStatus()); + Assert.assertNotNull(order.getDetails()); + Assert.assertNull(Ebean.getBeanState(order).getLoadedProps()); + + Status status = order.getStatus(); + Assert.assertTrue(status != Order.Status.SHIPPED); + order.setStatus(Order.Status.SHIPPED); + Ebean.refresh(order); + + Status statusRefresh = order.getStatus(); + Assert.assertEquals(status, statusRefresh); + + } + + } diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java b/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java index f2e22e346..088197310 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteByIdCollection.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestDeleteByIdCollection extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteCascadingOneToMany.java b/src/test/java/com/avaje/tests/basic/TestDeleteCascadingOneToMany.java index 5d84b6725..3dbb5a0a3 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteCascadingOneToMany.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteCascadingOneToMany.java @@ -1,21 +1,20 @@ package com.avaje.tests.basic; -import junit.framework.TestCase; - import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Article; import com.avaje.tests.model.basic.Section; +import junit.framework.TestCase; public class TestDeleteCascadingOneToMany extends TestCase { - public void testDeleteCascadingOneToMany() { - Section s0 = new Section("some content"); - Article a0 = new Article("art1","auth1"); - a0.addSection(s0); + public void testDeleteCascadingOneToMany() { + Section s0 = new Section("some content"); + Article a0 = new Article("art1", "auth1"); + a0.addSection(s0); - Ebean.save(a0); + Ebean.save(a0); - Ebean.delete(a0); - } + Ebean.delete(a0); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteImportedPartial.java b/src/test/java/com/avaje/tests/basic/TestDeleteImportedPartial.java index cadcfda3e..c9a02dba3 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteImportedPartial.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteImportedPartial.java @@ -1,12 +1,11 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.PFile; import com.avaje.tests.model.basic.PFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestDeleteImportedPartial extends BaseTestCase { @@ -20,7 +19,7 @@ public class TestDeleteImportedPartial extends BaseTestCase { Integer contentId = persistentFile.getFileContent().getId(); PFile partialPfile = Ebean.find(PFile.class).select("id").where().idEq(persistentFile.getId()) - .findUnique(); + .findUnique(); // should delete file and fileContent Ebean.delete(partialPfile); diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteOneToOne.java b/src/test/java/com/avaje/tests/basic/TestDeleteOneToOne.java index 9feab8730..5fe5106e3 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteOneToOne.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteOneToOne.java @@ -1,12 +1,11 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.PersistentFile; import com.avaje.tests.model.basic.PersistentFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestDeleteOneToOne extends BaseTestCase { @@ -14,7 +13,7 @@ public class TestDeleteOneToOne extends BaseTestCase { public void testCreateDeletePersistentFile() { PersistentFile persistentFile = new PersistentFile("test.txt", new PersistentFileContent( - "test".getBytes())); + "test".getBytes())); Ebean.save(persistentFile); Integer id = persistentFile.getId(); diff --git a/src/test/java/com/avaje/tests/basic/TestDeleteOneToOneMultiple.java b/src/test/java/com/avaje/tests/basic/TestDeleteOneToOneMultiple.java index 872ccf155..fe546bdc5 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeleteOneToOneMultiple.java +++ b/src/test/java/com/avaje/tests/basic/TestDeleteOneToOneMultiple.java @@ -1,12 +1,11 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.PFile; import com.avaje.tests.model.basic.PFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestDeleteOneToOneMultiple extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestDeletePartialNoVersion.java b/src/test/java/com/avaje/tests/basic/TestDeletePartialNoVersion.java index 199c18f7c..376b9c8e4 100644 --- a/src/test/java/com/avaje/tests/basic/TestDeletePartialNoVersion.java +++ b/src/test/java/com/avaje/tests/basic/TestDeletePartialNoVersion.java @@ -1,55 +1,54 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TMapSuperEntity; +import org.junit.Assert; +import org.junit.Test; public class TestDeletePartialNoVersion extends BaseTestCase { @Test - public void testNoVersion() { - - TMapSuperEntity e = new TMapSuperEntity(); - e.setName("babanaone"); - - Ebean.save(e); - - // select includes a transient property - TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) - .where().idEq(e.getId()) - .select("id, name") - .findUnique(); - - Assert.assertNotNull(e2); - - e2.setName("banaban2"); - Ebean.save(e2); - - Ebean.delete(e2); - } - - - public void testWithVersion() { - - TMapSuperEntity e = new TMapSuperEntity(); - e.setName("babanatwo"); - - Ebean.save(e); - - // select includes a transient property - TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) - .where().idEq(e.getId()) - .select("id, name, version") - .findUnique(); - - Assert.assertNotNull(e2); - - e2.setName("banaban2two"); - Ebean.save(e2); - - Ebean.delete(e2); - } + public void testNoVersion() { + + TMapSuperEntity e = new TMapSuperEntity(); + e.setName("babanaone"); + + Ebean.save(e); + + // select includes a transient property + TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) + .where().idEq(e.getId()) + .select("id, name") + .findUnique(); + + Assert.assertNotNull(e2); + + e2.setName("banaban2"); + Ebean.save(e2); + + Ebean.delete(e2); + } + + + public void testWithVersion() { + + TMapSuperEntity e = new TMapSuperEntity(); + e.setName("babanatwo"); + + Ebean.save(e); + + // select includes a transient property + TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) + .where().idEq(e.getId()) + .select("id, name, version") + .findUnique(); + + Assert.assertNotNull(e2); + + e2.setName("banaban2two"); + Ebean.save(e2); + + Ebean.delete(e2); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestDynamicUpdate.java b/src/test/java/com/avaje/tests/basic/TestDynamicUpdate.java index e36454a0e..4aede36f0 100644 --- a/src/test/java/com/avaje/tests/basic/TestDynamicUpdate.java +++ b/src/test/java/com/avaje/tests/basic/TestDynamicUpdate.java @@ -1,54 +1,53 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.tests.model.embedded.EMain; +import org.junit.Assert; +import org.junit.Test; public class TestDynamicUpdate extends BaseTestCase { @Test - public void testUpdate() { + public void testUpdate() { - // insert - EMain b = new EMain(); - b.setName("aaa"); - b.getEmbeddable().setDescription("123"); + // insert + EMain b = new EMain(); + b.setName("aaa"); + b.getEmbeddable().setDescription("123"); - EbeanServer server = Ebean.getServer(null); - - server.save(b); + EbeanServer server = Ebean.getServer(null); - Assert.assertNotNull(b.getId()); + server.save(b); - // reload object und update the name - EMain b2 = server.find(EMain.class, b.getId()); + Assert.assertNotNull(b.getId()); - b2.getEmbeddable().setDescription("ABC"); - - BeanState beanState = server.getBeanState(b2); - boolean dirty = beanState.isDirty(); + // reload object und update the name + EMain b2 = server.find(EMain.class, b.getId()); + + b2.getEmbeddable().setDescription("ABC"); + + BeanState beanState = server.getBeanState(b2); + boolean dirty = beanState.isDirty(); Assert.assertTrue(dirty); - - server.save(b2); - server.beginTransaction(); - try { - EMain b3 = server.find(EMain.class, b.getId()); - Assert.assertEquals("ABC", b3.getEmbeddable().getDescription()); - } finally { - server.endTransaction(); - } - EMain b4 = server.find(EMain.class, b.getId()); - b4.setName("bbb"); - b4.getEmbeddable().setDescription("123"); - server.save(b4); + server.save(b2); - EMain b5 = server.find(EMain.class, b.getId()); - Assert.assertEquals("123", b5.getEmbeddable().getDescription()); - } + server.beginTransaction(); + try { + EMain b3 = server.find(EMain.class, b.getId()); + Assert.assertEquals("ABC", b3.getEmbeddable().getDescription()); + } finally { + server.endTransaction(); + } + EMain b4 = server.find(EMain.class, b.getId()); + b4.setName("bbb"); + b4.getEmbeddable().setDescription("123"); + server.save(b4); + + EMain b5 = server.find(EMain.class, b.getId()); + Assert.assertEquals("123", b5.getEmbeddable().getDescription()); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestEnhancementCollectionInitialisation.java b/src/test/java/com/avaje/tests/basic/TestEnhancementCollectionInitialisation.java index c8af36eac..6b0e6d5b1 100644 --- a/src/test/java/com/avaje/tests/basic/TestEnhancementCollectionInitialisation.java +++ b/src/test/java/com/avaje/tests/basic/TestEnhancementCollectionInitialisation.java @@ -1,29 +1,28 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestEnhancementCollectionInitialisation extends BaseTestCase { - + @Test public void testListInitialisation() { - + Customer customer = new Customer(); BeanState beanState = Ebean.getBeanState(customer); if (beanState != null) { List orders = customer.getOrders(); Assert.assertNotNull(orders); } - + } } diff --git a/src/test/java/com/avaje/tests/basic/TestExplicitInsert.java b/src/test/java/com/avaje/tests/basic/TestExplicitInsert.java index d86cf3043..3c585a08c 100644 --- a/src/test/java/com/avaje/tests/basic/TestExplicitInsert.java +++ b/src/test/java/com/avaje/tests/basic/TestExplicitInsert.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic; -import java.util.List; - -import com.avaje.tests.model.basic.Customer; -import com.avaje.tests.model.basic.MyEBasicConfigStartup; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; +import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.EBasic; +import com.avaje.tests.model.basic.MyEBasicConfigStartup; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; @@ -61,9 +60,6 @@ public class TestExplicitInsert extends BaseTestCase { Assert.assertEquals(b.getId(), server.getBeanId(b)); - - - EBasic b2 = server.find(EBasic.class, b.getId()); b2.setId(null); diff --git a/src/test/java/com/avaje/tests/basic/TestFetchId.java b/src/test/java/com/avaje/tests/basic/TestFetchId.java index 2e0908bfb..1b4a09d84 100644 --- a/src/test/java/com/avaje/tests/basic/TestFetchId.java +++ b/src/test/java/com/avaje/tests/basic/TestFetchId.java @@ -14,26 +14,26 @@ import java.util.concurrent.ExecutionException; import static org.assertj.core.api.Assertions.assertThat; public class TestFetchId extends BaseTestCase { - + @Test - public void testFetchId() throws InterruptedException, ExecutionException { - - ResetBasicData.reset(); - - Query query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .where().gt("id", 1) - .gt("details.id", 0) - .query(); - - List ids = Ebean.getServer(null).findIds(query, null); - assertThat(ids).isNotEmpty(); + public void testFetchId() throws InterruptedException, ExecutionException { - FutureIds futureIds = Ebean.getServer(null).findFutureIds(query,null); + ResetBasicData.reset(); - // wait for all the id's to be fetched - List idList = futureIds.get(); - assertThat(idList).isNotEmpty(); - } + Query query = Ebean.find(Order.class) + .setAutoTune(false) + .fetch("details") + .where().gt("id", 1) + .gt("details.id", 0) + .query(); + + List ids = Ebean.getServer(null).findIds(query, null); + assertThat(ids).isNotEmpty(); + + FutureIds futureIds = Ebean.getServer(null).findFutureIds(query, null); + + // wait for all the id's to be fetched + List idList = futureIds.get(); + assertThat(idList).isNotEmpty(); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestIUDVanilla.java b/src/test/java/com/avaje/tests/basic/TestIUDVanilla.java index 2b9d1e3d8..5fd6051a0 100644 --- a/src/test/java/com/avaje/tests/basic/TestIUDVanilla.java +++ b/src/test/java/com/avaje/tests/basic/TestIUDVanilla.java @@ -1,13 +1,12 @@ package com.avaje.tests.basic; -import java.sql.Timestamp; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EBasicVer; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Timestamp; public class TestIUDVanilla extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestInEmpty.java b/src/test/java/com/avaje/tests/basic/TestInEmpty.java index 846d183c0..91a4afd70 100644 --- a/src/test/java/com/avaje/tests/basic/TestInEmpty.java +++ b/src/test/java/com/avaje/tests/basic/TestInEmpty.java @@ -1,13 +1,12 @@ package com.avaje.tests.basic; -import java.util.List; - -import com.avaje.ebean.Query; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.StrictAssertions.assertThat; import static org.junit.Assert.assertEquals; @@ -18,7 +17,7 @@ public class TestInEmpty extends BaseTestCase { public void test_in_empty() { Query query = Ebean.find(Order.class).where().in("id", new Object[0]).gt("id", 0) - .query(); + .query(); List list = query.findList(); assertThat(query.getGeneratedSql()).contains("1=0"); @@ -29,7 +28,7 @@ public class TestInEmpty extends BaseTestCase { public void test_notIn_empty() { Query query = Ebean.find(Order.class).where().notIn("id", new Object[0]).gt("id", 0) - .query(); + .query(); query.findList(); assertThat(query.getGeneratedSql()).contains("1=1"); diff --git a/src/test/java/com/avaje/tests/basic/TestInheritRef.java b/src/test/java/com/avaje/tests/basic/TestInheritRef.java index 76c7a02ec..28c16ce99 100644 --- a/src/test/java/com/avaje/tests/basic/TestInheritRef.java +++ b/src/test/java/com/avaje/tests/basic/TestInheritRef.java @@ -1,20 +1,19 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Car; import com.avaje.tests.model.basic.Truck; import com.avaje.tests.model.basic.Vehicle; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestInheritRef extends BaseTestCase { - @Test - public void testAssocOne() { + @Test + public void testAssocOne() { Ebean.beginTransaction(); try { @@ -31,8 +30,8 @@ public class TestInheritRef extends BaseTestCase { Ebean.save(t); List list = Ebean.find(Vehicle.class) - .setAutoTune(false) - .findList(); + .setAutoTune(false) + .findList(); Assert.assertTrue(!list.isEmpty()); diff --git a/src/test/java/com/avaje/tests/basic/TestJodaType.java b/src/test/java/com/avaje/tests/basic/TestJodaType.java index 57c90eaff..5215a339a 100644 --- a/src/test/java/com/avaje/tests/basic/TestJodaType.java +++ b/src/test/java/com/avaje/tests/basic/TestJodaType.java @@ -1,9 +1,5 @@ package com.avaje.tests.basic; -import org.joda.time.LocalTime; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -11,21 +7,24 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.type.ScalarType; import com.avaje.tests.model.basic.TJodaEntity; +import org.joda.time.LocalTime; +import org.junit.Assert; +import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; public class TestJodaType extends BaseTestCase { @Test - public void test() { - - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); - BeanDescriptor beanDescriptor = server.getBeanDescriptor(TJodaEntity.class); - BeanProperty beanProperty = beanDescriptor.getBeanProperty("localTime"); - ScalarType scalarType = beanProperty.getScalarType(); - - Assert.assertNotNull(scalarType); - } + public void test() { + + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); + BeanDescriptor beanDescriptor = server.getBeanDescriptor(TJodaEntity.class); + BeanProperty beanProperty = beanDescriptor.getBeanProperty("localTime"); + ScalarType scalarType = beanProperty.getScalarType(); + + Assert.assertNotNull(scalarType); + } @Test public void test_insert_find() { diff --git a/src/test/java/com/avaje/tests/basic/TestJoinInheritance.java b/src/test/java/com/avaje/tests/basic/TestJoinInheritance.java index 96d1c9e56..d06b57527 100644 --- a/src/test/java/com/avaje/tests/basic/TestJoinInheritance.java +++ b/src/test/java/com/avaje/tests/basic/TestJoinInheritance.java @@ -1,84 +1,80 @@ package com.avaje.tests.basic; -import java.sql.Timestamp; -import java.util.Date; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; -import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Car; import com.avaje.tests.model.basic.Trip; import com.avaje.tests.model.basic.Vehicle; import com.avaje.tests.model.basic.VehicleDriver; +import org.junit.Test; + +import java.sql.Timestamp; +import java.util.Date; public class TestJoinInheritance extends BaseTestCase { - - /** - * Test join hierarchy assoc one. - * - * This test catches the problem where the discriminator column is select - * but is not skipped if the parent bean is already in the presistence context. - * - * Test case: We have several trips with different addresses but always the same - * driver and car (the cars could be different). So the driver will be loaded - * when the first trip is loaded but when the second trip is loaded the driver is - * found in the persistence context. So the bean is not read but the index in the - * result set is forwarded by the number of properties - however, the vehicle type - * column was not being skipped - but the query reads happily - only the data is - * then wrong in the address object. - */ + + /** + * Test join hierarchy assoc one. + *

+ * This test catches the problem where the discriminator column is select + * but is not skipped if the parent bean is already in the presistence context. + *

+ * Test case: We have several trips with different addresses but always the same + * driver and car (the cars could be different). So the driver will be loaded + * when the first trip is loaded but when the second trip is loaded the driver is + * found in the persistence context. So the bean is not read but the index in the + * result set is forwarded by the number of properties - however, the vehicle type + * column was not being skipped - but the query reads happily - only the data is + * then wrong in the address object. + */ @Test - public void testJoinHierarchyAssocOne() { - - Ebean.createUpdate(Vehicle.class, "delete from vehicle"); + public void testJoinHierarchyAssocOne() { + + Ebean.createUpdate(Vehicle.class, "delete from vehicle"); - Address address = new Address(); - address.setLine1("Street"); - address.setLine2("Street"); - address.setCity("City"); - - address.setCretime(new Timestamp(new Date().getTime())); - - Ebean.save(address); - - Car c = new Car(); - c.setLicenseNumber("C6788"); - c.setDriver("CarDriver"); - c.setRegistrationDate(new Date()); - Ebean.save(c); - - VehicleDriver driver = new VehicleDriver(); - - driver.setVehicle(c); - driver.setAddress(address); - driver.setLicenseIssuedOn(new Date()); - Ebean.save(driver); - - final String line1 = "Street1"; - final String line2 = "Street2"; - final String city = "City"; - - int nrDrivers = 2; - for (int i = 0; i < nrDrivers;i++){ - Address address1 = new Address(); - address1.setLine1(line1); - address1.setLine2(line2); - address1.setCity(city); - Ebean.save(address1); + Address address = new Address(); + address.setLine1("Street"); + address.setLine2("Street"); + address.setCity("City"); - Trip trip = new Trip(); - trip.setVehicleDriver(driver); - trip.setAddress(address1); - trip.setCretime(new Timestamp(new Date().getTime())); - Ebean.save(trip); - } + address.setCretime(new Timestamp(new Date().getTime())); - } + Ebean.save(address); + + Car c = new Car(); + c.setLicenseNumber("C6788"); + c.setDriver("CarDriver"); + c.setRegistrationDate(new Date()); + Ebean.save(c); + + VehicleDriver driver = new VehicleDriver(); + + driver.setVehicle(c); + driver.setAddress(address); + driver.setLicenseIssuedOn(new Date()); + Ebean.save(driver); + + final String line1 = "Street1"; + final String line2 = "Street2"; + final String city = "City"; + + int nrDrivers = 2; + for (int i = 0; i < nrDrivers; i++) { + Address address1 = new Address(); + address1.setLine1(line1); + address1.setLine2(line2); + address1.setCity(city); + Ebean.save(address1); + + Trip trip = new Trip(); + trip.setVehicleDriver(driver); + trip.setAddress(address1); + trip.setCretime(new Timestamp(new Date().getTime())); + Ebean.save(trip); + } + + } } diff --git a/src/test/java/com/avaje/tests/basic/TestLazyLoadEmptyOneToMany.java b/src/test/java/com/avaje/tests/basic/TestLazyLoadEmptyOneToMany.java index 45b58a749..091dd3586 100644 --- a/src/test/java/com/avaje/tests/basic/TestLazyLoadEmptyOneToMany.java +++ b/src/test/java/com/avaje/tests/basic/TestLazyLoadEmptyOneToMany.java @@ -1,15 +1,14 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestLazyLoadEmptyOneToMany extends BaseTestCase { @@ -24,11 +23,11 @@ public class TestLazyLoadEmptyOneToMany extends BaseTestCase { Ebean.save(c); Customer c1 = Ebean.find(Customer.class) - .setAutoTune(false) - .select("id") - .fetch("contacts", "id") - .where().idEq(c.getId()) - .findUnique(); + .setAutoTune(false) + .select("id") + .fetch("contacts", "id") + .where().idEq(c.getId()) + .findUnique(); List contacts = c1.getContacts(); int sz = contacts.size(); diff --git a/src/test/java/com/avaje/tests/basic/TestLazyLoadInCache.java b/src/test/java/com/avaje/tests/basic/TestLazyLoadInCache.java index f1cb4a1c5..271cdb80e 100644 --- a/src/test/java/com/avaje/tests/basic/TestLazyLoadInCache.java +++ b/src/test/java/com/avaje/tests/basic/TestLazyLoadInCache.java @@ -1,64 +1,63 @@ package com.avaje.tests.basic; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.Map; +import java.util.Set; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class TestLazyLoadInCache extends BaseTestCase { - @Test - public void testLoadInCache() { - - ResetBasicData.reset(); - - Map map = Ebean.find(Customer.class) - .select("id, name") - .setLoadBeanCache(true) - .setReadOnly(true) - .orderBy().asc("id") - .findMap(); - - assertTrue(!map.isEmpty()); - - Object id = map.keySet().iterator().next(); - - Customer cust1 = map.get(id); - - Customer cust1B = Ebean.find(Customer.class) - .setReadOnly(true) - .setId(id) - .findUnique(); - - assertTrue(cust1 != cust1B); - - Set loadedProps = Ebean.getBeanState(cust1).getLoadedProps(); - - assertTrue(loadedProps.contains("name")); - assertFalse(loadedProps.contains("status")); - - cust1.getStatus(); - - // a readOnly reference - Address billingAddress = cust1.getBillingAddress(); - BeanState billAddrState = Ebean.getBeanState(billingAddress); - assertTrue(billAddrState.isReference()); - assertTrue(billAddrState.isReadOnly()); - - // lazy load .. no longer a reference - billingAddress.getCity(); - assertFalse(billAddrState.isReference()); - - } + @Test + public void testLoadInCache() { + + ResetBasicData.reset(); + + Map map = Ebean.find(Customer.class) + .select("id, name") + .setLoadBeanCache(true) + .setReadOnly(true) + .orderBy().asc("id") + .findMap(); + + assertTrue(!map.isEmpty()); + + Object id = map.keySet().iterator().next(); + + Customer cust1 = map.get(id); + + Customer cust1B = Ebean.find(Customer.class) + .setReadOnly(true) + .setId(id) + .findUnique(); + + assertTrue(cust1 != cust1B); + + Set loadedProps = Ebean.getBeanState(cust1).getLoadedProps(); + + assertTrue(loadedProps.contains("name")); + assertFalse(loadedProps.contains("status")); + + cust1.getStatus(); + + // a readOnly reference + Address billingAddress = cust1.getBillingAddress(); + BeanState billAddrState = Ebean.getBeanState(billingAddress); + assertTrue(billAddrState.isReference()); + assertTrue(billAddrState.isReadOnly()); + + // lazy load .. no longer a reference + billingAddress.getCity(); + assertFalse(billAddrState.isReference()); + + } } diff --git a/src/test/java/com/avaje/tests/basic/TestLimitQuery.java b/src/test/java/com/avaje/tests/basic/TestLimitQuery.java index 39b97989c..f727496d4 100644 --- a/src/test/java/com/avaje/tests/basic/TestLimitQuery.java +++ b/src/test/java/com/avaje/tests/basic/TestLimitQuery.java @@ -27,12 +27,12 @@ public class TestLimitQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .where().gt("details.id", 0) - .setMaxRows(0) - .setFirstRow(3) - .order().asc("orderDate"); + .setAutoTune(false) + .fetch("details") + .where().gt("details.id", 0) + .setMaxRows(0) + .setFirstRow(3) + .order().asc("orderDate"); query.findList(); @@ -49,11 +49,11 @@ public class TestLimitQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .where().gt("details.id", 0) - .setMaxRows(3) - .setFirstRow(0); + .setAutoTune(false) + .fetch("details") + .where().gt("details.id", 0) + .setMaxRows(3) + .setFirstRow(0); query.findList(); @@ -72,10 +72,10 @@ public class TestLimitQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .where().gt("details.id", 0) - .query(); + .setAutoTune(false) + .fetch("details") + .where().gt("details.id", 0) + .query(); query.findList(); @@ -93,10 +93,10 @@ public class TestLimitQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .where().gt("details.id", 0) - .setMaxRows(10); + .setAutoTune(false) + .fetch("details") + .where().gt("details.id", 0) + .setMaxRows(10); //.findList(); List list = query.findList(); @@ -117,9 +117,9 @@ public class TestLimitQuery extends BaseTestCase { } query = Ebean.find(Order.class) - .setAutoTune(false) - .fetch("details") - .setMaxRows(10); + .setAutoTune(false) + .fetch("details") + .setMaxRows(10); query.findList(); diff --git a/src/test/java/com/avaje/tests/basic/TestLoadBeanCache.java b/src/test/java/com/avaje/tests/basic/TestLoadBeanCache.java index 6e950ee62..f3ee0cdde 100644 --- a/src/test/java/com/avaje/tests/basic/TestLoadBeanCache.java +++ b/src/test/java/com/avaje/tests/basic/TestLoadBeanCache.java @@ -1,34 +1,33 @@ package com.avaje.tests.basic; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Map; public class TestLoadBeanCache extends BaseTestCase { @Test - public void testLoad() { - - ResetBasicData.reset(); - - Map map = Ebean.find(Country.class) - .setLoadBeanCache(true) - .setUseQueryCache(true) - .setReadOnly(true) - .order("name") - .findMap(); - - Country loadedNz = map.get("NZ"); - - // this will hit the cache - Country nz = Ebean.find(Country.class, "NZ"); - - Assert.assertTrue(loadedNz == nz); - } + public void testLoad() { + + ResetBasicData.reset(); + + Map map = Ebean.find(Country.class) + .setLoadBeanCache(true) + .setUseQueryCache(true) + .setReadOnly(true) + .order("name") + .findMap(); + + Country loadedNz = map.get("NZ"); + + // this will hit the cache + Country nz = Ebean.find(Country.class, "NZ"); + + Assert.assertTrue(loadedNz == nz); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestLogTransLogOnError.java b/src/test/java/com/avaje/tests/basic/TestLogTransLogOnError.java index 58a8368d5..1789bf2df 100644 --- a/src/test/java/com/avaje/tests/basic/TestLogTransLogOnError.java +++ b/src/test/java/com/avaje/tests/basic/TestLogTransLogOnError.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.EBasicVer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestLogTransLogOnError extends BaseTestCase { @@ -21,7 +20,7 @@ public class TestLogTransLogOnError extends BaseTestCase { Ebean.beginTransaction(); try { - + Ebean.find(Customer.class).findList(); Ebean.find(Order.class).where().gt("id", 1).findList(); @@ -56,10 +55,10 @@ public class TestLogTransLogOnError extends BaseTestCase { EBasicVer newBean = new EBasicVer("aName"); newBean - .setDescription("something sdfjksdjflsjdflsjdflksjdfkjd fsjdfkjsdkfjsdkfjskdjfskjdf" - + " sjdf sdjflksjdfkjsdlfkjsdkfjs ksjdfksjdlfjsldf something sdfjksdjflsjdflsjdflksjdfkjd" - + "fsjdfkjsdkfjsdkfjskdjfskjdf sjdf sdjflksjdfkjsdlfkjsdkfjs ksjdfksjdlfjsldf something s" - + "dfjksdjflsjdflsjdflksjdfkjd fsjdfkjsdkfjsdkfjskdjfskjdf sjdf sdjflksjdfkjsdlfkjsdkfjs "); + .setDescription("something sdfjksdjflsjdflsjdflksjdfkjd fsjdfkjsdkfjsdkfjskdjfskjdf" + + " sjdf sdjflksjdfkjsdlfkjsdkfjs ksjdfksjdlfjsldf something sdfjksdjflsjdflsjdflksjdfkjd" + + "fsjdfkjsdkfjsdkfjskdjfskjdf sjdf sdjflksjdfkjsdlfkjsdkfjs ksjdfksjdlfjsldf something s" + + "dfjksdjflsjdflsjdflksjdfkjd fsjdfkjsdkfjsdkfjskdjfskjdf sjdf sdjflksjdfkjsdlfkjsdkfjs "); // t.log("--- next insert should error"); Ebean.save(newBean); diff --git a/src/test/java/com/avaje/tests/basic/TestM2MCascadeOne.java b/src/test/java/com/avaje/tests/basic/TestM2MCascadeOne.java index 611853d1c..bb63f5c2f 100644 --- a/src/test/java/com/avaje/tests/basic/TestM2MCascadeOne.java +++ b/src/test/java/com/avaje/tests/basic/TestM2MCascadeOne.java @@ -38,9 +38,9 @@ public class TestM2MCascadeOne extends BaseTestCase { public void testRawPredicate_with_ManyToManyPath() { Query query = Ebean.find(MUser.class) - .select("userid") - .where().raw("roles.roleid in (?)", 24) - .query(); + .select("userid") + .where().raw("roles.roleid in (?)", 24) + .query(); query.findList(); diff --git a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java index c82aa67ef..a43a8443d 100644 --- a/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java +++ b/src/test/java/com/avaje/tests/basic/TestM2MVanilla.java @@ -1,17 +1,16 @@ package com.avaje.tests.basic; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.ebean.SqlUpdate; import com.avaje.tests.model.basic.MRole; import com.avaje.tests.model.basic.MUser; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestM2MVanilla extends BaseTestCase { @@ -21,11 +20,11 @@ public class TestM2MVanilla extends BaseTestCase { SqlUpdate delInt = Ebean.createSqlUpdate("delete from mrole_muser"); SqlUpdate delRoles = Ebean.createSqlUpdate("delete from mrole"); SqlUpdate delUsers = Ebean.createSqlUpdate("delete from muser"); - + Ebean.execute(delInt); Ebean.execute(delRoles); Ebean.execute(delUsers); - + MRole r1 = new MRole(); r1.setRoleName("role1"); Ebean.save(r1); @@ -79,9 +78,9 @@ public class TestM2MVanilla extends BaseTestCase { Assert.assertTrue(!userInRolesList.isEmpty()); List list = Ebean.find(MUser.class) - .where().in("roles", roleList) - .filterMany("roles").eq("roleName", "role1") - .findList(); + .where().in("roles", roleList) + .filterMany("roles").eq("roleName", "role1") + .findList(); MUser mUser = list.get(0); List roles = mUser.getRoles(); diff --git a/src/test/java/com/avaje/tests/basic/TestManyLazyLoad.java b/src/test/java/com/avaje/tests/basic/TestManyLazyLoad.java index c2d8b5d62..d05a006f3 100644 --- a/src/test/java/com/avaje/tests/basic/TestManyLazyLoad.java +++ b/src/test/java/com/avaje/tests/basic/TestManyLazyLoad.java @@ -10,9 +10,7 @@ import org.junit.Test; import java.sql.Date; import java.util.List; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestManyLazyLoad extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestManyOneInterface.java b/src/test/java/com/avaje/tests/basic/TestManyOneInterface.java index e66644735..fc722e4a3 100644 --- a/src/test/java/com/avaje/tests/basic/TestManyOneInterface.java +++ b/src/test/java/com/avaje/tests/basic/TestManyOneInterface.java @@ -1,7 +1,5 @@ package com.avaje.tests.basic; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.ResetBasicData; @@ -9,24 +7,25 @@ import com.avaje.tests.model.interfaces.Address; import com.avaje.tests.model.interfaces.IAddress; import com.avaje.tests.model.interfaces.IPerson; import com.avaje.tests.model.interfaces.Person; +import org.junit.Test; public class TestManyOneInterface extends BaseTestCase { @Test - public void test() { - - ResetBasicData.reset(); - - IAddress a = new Address(); - - IPerson p = new Person(); - - p.setDefaultAddress(a); - - Ebean.save(a); - Ebean.save(p); - - //Assert.assertTrue(); + public void test() { - } + ResetBasicData.reset(); + + IAddress a = new Address(); + + IPerson p = new Person(); + + p.setDefaultAddress(a); + + Ebean.save(a); + Ebean.save(p); + + //Assert.assertTrue(); + + } } diff --git a/src/test/java/com/avaje/tests/basic/TestMappedSuper.java b/src/test/java/com/avaje/tests/basic/TestMappedSuper.java index 8ac108ddd..2e9bc6c11 100644 --- a/src/test/java/com/avaje/tests/basic/TestMappedSuper.java +++ b/src/test/java/com/avaje/tests/basic/TestMappedSuper.java @@ -9,27 +9,27 @@ import org.junit.Test; public class TestMappedSuper extends BaseTestCase { @Test - public void test() { - - TMapSuperEntity e = new TMapSuperEntity(); - e.setName("babana"); - - Ebean.save(e); - - // select includes a transient property - TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) - .where().idEq(e.getId()) - .select("id, name, myint, someObject, bananan") - .findUnique(); - - Assert.assertNotNull(e2); - - TMapSuperEntity eSaveDelete = new TMapSuperEntity(); - eSaveDelete.setName("babana"); - - Ebean.save(eSaveDelete); - - Ebean.delete(eSaveDelete); - } - + public void test() { + + TMapSuperEntity e = new TMapSuperEntity(); + e.setName("babana"); + + Ebean.save(e); + + // select includes a transient property + TMapSuperEntity e2 = Ebean.find(TMapSuperEntity.class) + .where().idEq(e.getId()) + .select("id, name, myint, someObject, bananan") + .findUnique(); + + Assert.assertNotNull(e2); + + TMapSuperEntity eSaveDelete = new TMapSuperEntity(); + eSaveDelete.setName("babana"); + + Ebean.save(eSaveDelete); + + Ebean.delete(eSaveDelete); + } + } diff --git a/src/test/java/com/avaje/tests/basic/TestMetaAnnotation.java b/src/test/java/com/avaje/tests/basic/TestMetaAnnotation.java index 31db7757a..8d782b9a5 100644 --- a/src/test/java/com/avaje/tests/basic/TestMetaAnnotation.java +++ b/src/test/java/com/avaje/tests/basic/TestMetaAnnotation.java @@ -12,16 +12,16 @@ import static org.junit.Assert.assertTrue; /** * Very simple test case to check if Ebean recognizes meta-annotation correctly. - * + * * @author Roland Praml, FOCONIS AG */ public class TestMetaAnnotation extends BaseTestCase { - private static final String spaces100 = new String(new char[100]).replace('\0', ' '); - private static final String spaces101 = new String(new char[101]).replace('\0', ' '); - + private static final String spaces100 = new String(new char[100]).replace('\0', ' '); + private static final String spaces101 = new String(new char[101]).replace('\0', ' '); + /** - * This test writes 100 spaces to "line1" which is annotated with @Size(max=100) + * This test writes 100 spaces to "line1" which is annotated with @Size(max=100) */ @Test public void testWrite100SpacesToLine1() { diff --git a/src/test/java/com/avaje/tests/basic/TestMultipleOneToOneIUD.java b/src/test/java/com/avaje/tests/basic/TestMultipleOneToOneIUD.java index 2c0758fa0..c1d5b0296 100644 --- a/src/test/java/com/avaje/tests/basic/TestMultipleOneToOneIUD.java +++ b/src/test/java/com/avaje/tests/basic/TestMultipleOneToOneIUD.java @@ -1,13 +1,12 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.OCar; import com.avaje.tests.model.basic.OEngine; import com.avaje.tests.model.basic.OGearBox; +import org.junit.Assert; +import org.junit.Test; public class TestMultipleOneToOneIUD extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestNonUpdateProperty.java b/src/test/java/com/avaje/tests/basic/TestNonUpdateProperty.java index ed33fd984..4f68a9e58 100644 --- a/src/test/java/com/avaje/tests/basic/TestNonUpdateProperty.java +++ b/src/test/java/com/avaje/tests/basic/TestNonUpdateProperty.java @@ -1,10 +1,9 @@ package com.avaje.tests.basic; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.MNonUpdPropEntity; +import org.junit.Test; public class TestNonUpdateProperty extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestOrderByAnnotation.java b/src/test/java/com/avaje/tests/basic/TestOrderByAnnotation.java index 786f394d3..a6ce21681 100644 --- a/src/test/java/com/avaje/tests/basic/TestOrderByAnnotation.java +++ b/src/test/java/com/avaje/tests/basic/TestOrderByAnnotation.java @@ -1,38 +1,37 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestOrderByAnnotation extends BaseTestCase { @Test - public void testOrderBy() { + public void testOrderBy() { - ResetBasicData.reset(); - Customer custTest = ResetBasicData.createCustAndOrder("testOrderByAnn"); + ResetBasicData.reset(); + Customer custTest = ResetBasicData.createCustAndOrder("testOrderByAnn"); - Customer customer = Ebean.find(Customer.class, custTest.getId()); - List orders = customer.getOrders(); + Customer customer = Ebean.find(Customer.class, custTest.getId()); + List orders = customer.getOrders(); - Assert.assertTrue(!orders.isEmpty()); + Assert.assertTrue(!orders.isEmpty()); - Query q1 = Ebean.find(Order.class) - .fetch("details"); + Query q1 = Ebean.find(Order.class) + .fetch("details"); - q1.findList(); - - String s1 = q1.getGeneratedSql(); + q1.findList(); - Assert.assertTrue(s1.contains("order by t0.id, t1.id asc, t1.order_qty asc, t1.cretime desc")); - } -} \ No newline at end of file + String s1 = q1.getGeneratedSql(); + + Assert.assertTrue(s1.contains("order by t0.id, t1.id asc, t1.order_qty asc, t1.cretime desc")); + } +} diff --git a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountFormula.java b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountFormula.java index f167e28a0..bbd4ce10e 100644 --- a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountFormula.java +++ b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountFormula.java @@ -1,14 +1,13 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestOrderTotalAmountFormula extends BaseTestCase { @@ -18,12 +17,12 @@ public class TestOrderTotalAmountFormula extends BaseTestCase { ResetBasicData.reset(); List l0 = Ebean.find(Customer.class) - .select("id, name") - .fetch("orders", "status, totalAmount") - .where() - .eq("orders.details.product.name", "Desk") - .like("contacts.firstName", "Ji%") - .findList(); + .select("id, name") + .fetch("orders", "status, totalAmount") + .where() + .eq("orders.details.product.name", "Desk") + .like("contacts.firstName", "Ji%") + .findList(); for (Customer c0 : l0) { c0.getId(); diff --git a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountReportBean.java b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountReportBean.java index e344946b1..824c07170 100644 --- a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountReportBean.java +++ b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountReportBean.java @@ -1,17 +1,16 @@ package com.avaje.tests.basic; -import java.util.List; - -import com.avaje.ebean.Query; -import com.avaje.ebean.RawSql; -import com.avaje.ebean.RawSqlBuilder; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import com.avaje.ebean.Query; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.OrderAggregate; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; @@ -24,14 +23,14 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { ResetBasicData.reset(); String sql = - "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + - "from o_order_detail \n" + - "group by order_id"; + "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + + "from o_order_detail \n" + + "group by order_id"; RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id").create(); List l0 = - Ebean.find(OrderAggregate.class) + Ebean.find(OrderAggregate.class) .setRawSql(rawSql) .findList(); @@ -40,9 +39,9 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { } List l2 = Ebean.createQuery(OrderAggregate.class) - .setRawSql(rawSql) - .where().gt("order.id", 0) - .having().lt("totalItems", 3).gt("totalAmount", 50).findList(); + .setRawSql(rawSql) + .where().gt("order.id", 0) + .having().lt("totalItems", 3).gt("totalAmount", 50).findList(); for (OrderAggregate r2 : l2) { Assert.assertTrue(r2.getTotalItems() < 3); @@ -56,16 +55,16 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { ResetBasicData.reset(); String sql = - "select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount \n" + - "from o_order_detail \n" + - "group by order_id"; + "select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount \n" + + "from o_order_detail \n" + + "group by order_id"; RawSql rawSql = RawSqlBuilder.parse(sql) - .columnMapping("order_id", "order.id") - .create(); + .columnMapping("order_id", "order.id") + .create(); Query query = Ebean.find(OrderAggregate.class) - .setRawSql(rawSql); + .setRawSql(rawSql); query.findList(); @@ -78,16 +77,16 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { ResetBasicData.reset(); String sql = - "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + - "from o_order_detail \n" + - "group by order_id"; + "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + + "from o_order_detail \n" + + "group by order_id"; RawSql rawSql = RawSqlBuilder.parse(sql) - .columnMapping("order_id", "order.id") - .create(); + .columnMapping("order_id", "order.id") + .create(); Query query = Ebean.find(OrderAggregate.class) - .setRawSql(rawSql); + .setRawSql(rawSql); query.findList(); @@ -123,10 +122,10 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { Query query = Ebean.getDefaultServer().createNamedQuery(OrderAggregate.class, "withMax"); List list = query - .where().gt("order.id", 1) - .having().gt("totalItems", 1) - .order().desc("totalAmount") - .findList(); + .where().gt("order.id", 1) + .having().gt("totalItems", 1) + .order().desc("totalAmount") + .findList(); assertThat(query.getGeneratedSql()).contains("count(*) as total_items, sum(order_qty*unit_price) as total_amount, max(order_qty*unit_price) as maxAmount from o_order_detail"); assertThat(query.getGeneratedSql()).contains("from o_order_detail where order_id > ? group by order_id having count(*) > ? order by sum(order_qty*unit_price) desc"); @@ -140,12 +139,12 @@ public class TestOrderTotalAmountReportBean extends BaseTestCase { Query query = Ebean.getDefaultServer().createNamedQuery(OrderAggregate.class, "withParam"); List list = query - .setParameter("minId", 2) - .where().isNotNull("order.id") - .having().lt("totalAmount", 100) - .order().desc("totalAmount") - .setMaxRows(10) - .findList(); + .setParameter("minId", 2) + .where().isNotNull("order.id") + .having().lt("totalAmount", 100) + .order().desc("totalAmount") + .setMaxRows(10) + .findList(); assertThat(query.getGeneratedSql()).contains("count(*) as totalItems, sum(order_qty*unit_price) as totalAmount, max(order_qty*unit_price) as maxAmount from o_order_detail"); assertThat(query.getGeneratedSql()).contains("from o_order_detail where id > ? and order_id is not null group by order_id having sum(order_qty*unit_price) < ? order by sum(order_qty*unit_price) desc"); diff --git a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountSql.java b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountSql.java index 2fa6ee997..744d9e45e 100644 --- a/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountSql.java +++ b/src/test/java/com/avaje/tests/basic/TestOrderTotalAmountSql.java @@ -1,14 +1,13 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlRow; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestOrderTotalAmountSql extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestPersistenceContext.java b/src/test/java/com/avaje/tests/basic/TestPersistenceContext.java index e28b0abce..e75c7d3f5 100644 --- a/src/test/java/com/avaje/tests/basic/TestPersistenceContext.java +++ b/src/test/java/com/avaje/tests/basic/TestPersistenceContext.java @@ -1,82 +1,81 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestPersistenceContext extends BaseTestCase { @Test - public void test() { - - ResetBasicData.reset(); + public void test() { - // implicit transaction with its own - // persistence context - Order oBefore = Ebean.find(Order.class, 1); + ResetBasicData.reset(); - Order order = null; - - // start a persistence context - Ebean.beginTransaction(); - try { - - order = Ebean.find(Order.class, 1); - - // not the same instance ...as a different - // persistence context - Assert.assertTrue(order != oBefore); - - - // finds an existing bean in the persistence context - // ... so doesn't even execute a query - Order o2 = Ebean.find(Order.class, 1); - Order o3 = Ebean.getReference(Order.class, 1); - - // all the same instance - Assert.assertTrue(order == o2); - Assert.assertTrue(order == o3); - - } finally { - Ebean.endTransaction(); - } + // implicit transaction with its own + // persistence context + Order oBefore = Ebean.find(Order.class, 1); - // implicit transaction with its own - // persistence context - Order oAfter = Ebean.find(Order.class, 1); + Order order = null; - Assert.assertTrue(oAfter != oBefore); - Assert.assertTrue(oAfter != order); - - - Order testOrder = ResetBasicData.createOrderCustAndOrder("testPC"); - Integer id = testOrder.getCustomer().getId(); - Integer orderId = testOrder.getId(); + // start a persistence context + Ebean.beginTransaction(); + try { - // start a persistence context - Ebean.beginTransaction(); - try { - Customer customer = Ebean.find(Customer.class) - .setUseCache(false) - .setId(id) - .findUnique(); - - System.gc(); - Order order2 = Ebean.find(Order.class, orderId); - Customer customer2 = order2.getCustomer(); + order = Ebean.find(Order.class, 1); - Assert.assertEquals(customer.getId(),customer2.getId()); + // not the same instance ...as a different + // persistence context + Assert.assertTrue(order != oBefore); + + + // finds an existing bean in the persistence context + // ... so doesn't even execute a query + Order o2 = Ebean.find(Order.class, 1); + Order o3 = Ebean.getReference(Order.class, 1); + + // all the same instance + Assert.assertTrue(order == o2); + Assert.assertTrue(order == o3); + + } finally { + Ebean.endTransaction(); + } + + // implicit transaction with its own + // persistence context + Order oAfter = Ebean.find(Order.class, 1); + + Assert.assertTrue(oAfter != oBefore); + Assert.assertTrue(oAfter != order); + + + Order testOrder = ResetBasicData.createOrderCustAndOrder("testPC"); + Integer id = testOrder.getCustomer().getId(); + Integer orderId = testOrder.getId(); + + // start a persistence context + Ebean.beginTransaction(); + try { + Customer customer = Ebean.find(Customer.class) + .setUseCache(false) + .setId(id) + .findUnique(); + + System.gc(); + Order order2 = Ebean.find(Order.class, orderId); + Customer customer2 = order2.getCustomer(); + + Assert.assertEquals(customer.getId(), customer2.getId()); + + Assert.assertTrue(customer == customer2); + + } finally { + Ebean.endTransaction(); + } + } - Assert.assertTrue(customer == customer2); - - } finally { - Ebean.endTransaction(); - } - } - } diff --git a/src/test/java/com/avaje/tests/basic/TestQuery.java b/src/test/java/com/avaje/tests/basic/TestQuery.java index 0a0c24c7e..31af63bec 100644 --- a/src/test/java/com/avaje/tests/basic/TestQuery.java +++ b/src/test/java/com/avaje/tests/basic/TestQuery.java @@ -1,13 +1,12 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestQuery extends BaseTestCase { @@ -17,7 +16,7 @@ public class TestQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class).setAutoTune(false).order().asc("orderDate") - .order().desc("id"); + .order().desc("id"); // .orderBy("orderDate"); int rc = query.findList().size(); @@ -32,14 +31,14 @@ public class TestQuery extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class).setAutoTune(false).setForUpdate(false) - .setMaxRows(1).order().asc("orderDate").order().desc("id"); + .setMaxRows(1).order().asc("orderDate").order().desc("id"); int rc = query.findList().size(); Assert.assertTrue(rc > 0); Assert.assertTrue(!query.getGeneratedSql().toLowerCase().contains("for update")); query = Ebean.find(Order.class).setAutoTune(false).setForUpdate(true).setMaxRows(1).order() - .asc("orderDate").order().desc("id"); + .asc("orderDate").order().desc("id"); rc = query.findList().size(); Assert.assertTrue(rc > 0); diff --git a/src/test/java/com/avaje/tests/basic/TestQueryWhereBetween.java b/src/test/java/com/avaje/tests/basic/TestQueryWhereBetween.java index ed782b45c..254f817de 100644 --- a/src/test/java/com/avaje/tests/basic/TestQueryWhereBetween.java +++ b/src/test/java/com/avaje/tests/basic/TestQueryWhereBetween.java @@ -1,15 +1,14 @@ package com.avaje.tests.basic; -import java.sql.Timestamp; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Timestamp; public class TestQueryWhereBetween extends BaseTestCase { @@ -21,7 +20,7 @@ public class TestQueryWhereBetween extends BaseTestCase { Timestamp t = new Timestamp(System.currentTimeMillis()); Query query = Ebean.find(Order.class).setAutoTune(false).where() - .betweenProperties("cretime", "updtime", t).order().asc("orderDate").order().desc("id"); + .betweenProperties("cretime", "updtime", t).order().asc("orderDate").order().desc("id"); query.findList(); diff --git a/src/test/java/com/avaje/tests/basic/TestQueryWithCache.java b/src/test/java/com/avaje/tests/basic/TestQueryWithCache.java index 950ac8662..ae387795b 100644 --- a/src/test/java/com/avaje/tests/basic/TestQueryWithCache.java +++ b/src/test/java/com/avaje/tests/basic/TestQueryWithCache.java @@ -13,9 +13,7 @@ import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestQueryWithCache extends BaseTestCase { @@ -51,7 +49,7 @@ public class TestQueryWithCache extends BaseTestCase { Country nz3 = Ebean.find(Country.class, "NZ"); Country nz4 = Ebean.find(Country.class).setId("NZ").setAutoTune(false).setUseCache(false) - .findUnique(); + .findUnique(); assertTrue(nz2 == nz2b); assertTrue(nz2 == nz3); diff --git a/src/test/java/com/avaje/tests/basic/TestReadOnlyPropagation.java b/src/test/java/com/avaje/tests/basic/TestReadOnlyPropagation.java index 2f3420db8..f6b81185d 100644 --- a/src/test/java/com/avaje/tests/basic/TestReadOnlyPropagation.java +++ b/src/test/java/com/avaje/tests/basic/TestReadOnlyPropagation.java @@ -1,12 +1,5 @@ package com.avaje.tests.basic; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; @@ -15,78 +8,84 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; public class TestReadOnlyPropagation extends BaseTestCase { @Test - public void testReadOnly() { - - ResetBasicData.reset(); - - Order order = Ebean.find(Order.class) - .setAutoTune(false) - .setUseCache(false) - .setReadOnly(true) - .setId(1) - .findUnique(); - - Assert.assertTrue(Ebean.getBeanState(order).isReadOnly()); + public void testReadOnly() { - - Customer customer = order.getCustomer(); - Assert.assertTrue(Ebean.getBeanState(customer).isReadOnly()); - - Address billingAddress = customer.getBillingAddress(); - Assert.assertTrue(Ebean.getBeanState(billingAddress).isReadOnly()); - - - List details = order.getDetails(); - BeanCollection bc = (BeanCollection)details; - - Assert.assertTrue(bc.isReadOnly()); - Assert.assertTrue(!bc.isPopulated()); - - bc.size(); - Assert.assertTrue(!bc.isEmpty()); - Assert.assertTrue(bc.isReadOnly()); - Assert.assertTrue(bc.isPopulated()); - try { - details.add(new OrderDetail()); - Assert.assertTrue(false); - } catch (IllegalStateException e){ - Assert.assertTrue(true); - } - try { - details.remove(0); - Assert.assertTrue(false); - } catch (IllegalStateException e){ - Assert.assertTrue(true); - } - try { - Iterator it = details.iterator(); - it.next(); - it.remove(); - Assert.assertTrue(false); - } catch (IllegalStateException e){ - Assert.assertTrue(true); - } - try { - ListIterator it = details.listIterator(); - it.next(); - it.remove(); - Assert.assertTrue(false); - } catch (IllegalStateException e){ - Assert.assertTrue(true); - } - try { - List subList = details.subList(0, 1); - subList.remove(0); - Assert.assertTrue(false); - } catch (UnsupportedOperationException e){ - Assert.assertTrue(true); - } + ResetBasicData.reset(); + + Order order = Ebean.find(Order.class) + .setAutoTune(false) + .setUseCache(false) + .setReadOnly(true) + .setId(1) + .findUnique(); + + Assert.assertTrue(Ebean.getBeanState(order).isReadOnly()); + + + Customer customer = order.getCustomer(); + Assert.assertTrue(Ebean.getBeanState(customer).isReadOnly()); + + Address billingAddress = customer.getBillingAddress(); + Assert.assertTrue(Ebean.getBeanState(billingAddress).isReadOnly()); + + + List details = order.getDetails(); + BeanCollection bc = (BeanCollection) details; + + Assert.assertTrue(bc.isReadOnly()); + Assert.assertTrue(!bc.isPopulated()); + + bc.size(); + Assert.assertTrue(!bc.isEmpty()); + Assert.assertTrue(bc.isReadOnly()); + Assert.assertTrue(bc.isPopulated()); + try { + details.add(new OrderDetail()); + Assert.assertTrue(false); + } catch (IllegalStateException e) { + Assert.assertTrue(true); + } + try { + details.remove(0); + Assert.assertTrue(false); + } catch (IllegalStateException e) { + Assert.assertTrue(true); + } + try { + Iterator it = details.iterator(); + it.next(); + it.remove(); + Assert.assertTrue(false); + } catch (IllegalStateException e) { + Assert.assertTrue(true); + } + try { + ListIterator it = details.listIterator(); + it.next(); + it.remove(); + Assert.assertTrue(false); + } catch (IllegalStateException e) { + Assert.assertTrue(true); + } + try { + List subList = details.subList(0, 1); + subList.remove(0); + Assert.assertTrue(false); + } catch (UnsupportedOperationException e) { + Assert.assertTrue(true); + } + + + } - - } - } diff --git a/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOne.java b/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOne.java index bb41f8f50..23be6218e 100644 --- a/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOne.java +++ b/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOne.java @@ -1,39 +1,38 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.PersistentFile; import com.avaje.tests.model.basic.PersistentFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestSaveDeleteOneToOne extends BaseTestCase { @Test - public void testCreateDeletePersistentFile() { - PersistentFile persistentFile = new PersistentFile("test.txt", - new PersistentFileContent("test".getBytes())); + public void testCreateDeletePersistentFile() { + PersistentFile persistentFile = new PersistentFile("test.txt", + new PersistentFileContent("test".getBytes())); - Ebean.save(persistentFile); - Ebean.delete(persistentFile); - } + Ebean.save(persistentFile); + Ebean.delete(persistentFile); + } @Test - public void testCreateLoadDeletePersistentFile() { - PersistentFile persistentFile = new PersistentFile("test.txt", - new PersistentFileContent("test".getBytes())); + public void testCreateLoadDeletePersistentFile() { + PersistentFile persistentFile = new PersistentFile("test.txt", + new PersistentFileContent("test".getBytes())); - Ebean.save(persistentFile); + Ebean.save(persistentFile); - persistentFile = Ebean.find(PersistentFile.class, persistentFile.getId()); - - PersistentFileContent persistentFileContent = persistentFile.getPersistentFileContent(); - - Assert.assertNotNull(persistentFileContent); - - Assert.assertNotNull("load byte content", persistentFileContent.getContent()); - - Ebean.delete(persistentFile); - } + persistentFile = Ebean.find(PersistentFile.class, persistentFile.getId()); + + PersistentFileContent persistentFileContent = persistentFile.getPersistentFileContent(); + + Assert.assertNotNull(persistentFileContent); + + Assert.assertNotNull("load byte content", persistentFileContent.getContent()); + + Ebean.delete(persistentFile); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOneMultiple.java b/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOneMultiple.java index 27e6370ad..70f841cda 100644 --- a/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOneMultiple.java +++ b/src/test/java/com/avaje/tests/basic/TestSaveDeleteOneToOneMultiple.java @@ -1,12 +1,11 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.PFile; import com.avaje.tests.model.basic.PFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestSaveDeleteOneToOneMultiple extends BaseTestCase { @@ -19,20 +18,20 @@ public class TestSaveDeleteOneToOneMultiple extends BaseTestCase { // } @Test - public void testCreateLoadDeletePFile() { - PFile persistentFile = new PFile("test.txt", - new PFileContent("test".getBytes())); + public void testCreateLoadDeletePFile() { + PFile persistentFile = new PFile("test.txt", + new PFileContent("test".getBytes())); - Ebean.save(persistentFile); + Ebean.save(persistentFile); - persistentFile = Ebean.find(PFile.class, persistentFile.getId()); - - PFileContent persistentFileContent = persistentFile.getFileContent(); - - Assert.assertNotNull(persistentFileContent); - - Assert.assertNotNull("load byte content", persistentFileContent.getContent()); - - Ebean.delete(persistentFile); - } + persistentFile = Ebean.find(PFile.class, persistentFile.getId()); + + PFileContent persistentFileContent = persistentFile.getFileContent(); + + Assert.assertNotNull(persistentFileContent); + + Assert.assertNotNull("load byte content", persistentFileContent.getContent()); + + Ebean.delete(persistentFile); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestSharedInstancePropagation.java b/src/test/java/com/avaje/tests/basic/TestSharedInstancePropagation.java index 929465f39..fba85a8f4 100644 --- a/src/test/java/com/avaje/tests/basic/TestSharedInstancePropagation.java +++ b/src/test/java/com/avaje/tests/basic/TestSharedInstancePropagation.java @@ -11,55 +11,53 @@ import org.junit.Test; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestSharedInstancePropagation extends BaseTestCase { - - /** - * Test that the sharedInstance status is propagated on lazy loading. - */ + + /** + * Test that the sharedInstance status is propagated on lazy loading. + */ @Test - public void testSharedListNavigate() { + public void testSharedListNavigate() { - ResetBasicData.reset(); - - Ebean.getServerCacheManager().clearAll(); + ResetBasicData.reset(); - Order order = Ebean.find(Order.class) - .setAutoTune(false) - .setReadOnly(true) - .setId(1) - .findUnique(); - - - assertNotNull(order); - assertTrue(Ebean.getBeanState(order).isReadOnly()); - - List details = order.getDetails(); - BeanCollection bc = (BeanCollection)details; - assertTrue(bc.isReadOnly()); - assertFalse(bc.isPopulated()); - - // lazy load - bc.size(); - - assertTrue(bc.isPopulated()); - assertTrue(!bc.isEmpty()); - OrderDetail detail = details.get(0); - - assertTrue(Ebean.getBeanState(detail).isReadOnly()); - assertFalse(Ebean.getBeanState(detail).isReference()); - - Product product = detail.getProduct(); + Ebean.getServerCacheManager().clearAll(); - assertTrue(Ebean.getBeanState(product).isReadOnly()); - - // lazy load - product.getName(); - assertFalse(Ebean.getBeanState(product).isReference()); - - } + Order order = Ebean.find(Order.class) + .setAutoTune(false) + .setReadOnly(true) + .setId(1) + .findUnique(); + + + assertNotNull(order); + assertTrue(Ebean.getBeanState(order).isReadOnly()); + + List details = order.getDetails(); + BeanCollection bc = (BeanCollection) details; + assertTrue(bc.isReadOnly()); + assertFalse(bc.isPopulated()); + + // lazy load + bc.size(); + + assertTrue(bc.isPopulated()); + assertTrue(!bc.isEmpty()); + OrderDetail detail = details.get(0); + + assertTrue(Ebean.getBeanState(detail).isReadOnly()); + assertFalse(Ebean.getBeanState(detail).isReference()); + + Product product = detail.getProduct(); + + assertTrue(Ebean.getBeanState(product).isReadOnly()); + + // lazy load + product.getName(); + assertFalse(Ebean.getBeanState(product).isReference()); + + } } diff --git a/src/test/java/com/avaje/tests/basic/TestTransient.java b/src/test/java/com/avaje/tests/basic/TestTransient.java index aa5df2e95..e116cca44 100644 --- a/src/test/java/com/avaje/tests/basic/TestTransient.java +++ b/src/test/java/com/avaje/tests/basic/TestTransient.java @@ -1,12 +1,11 @@ package com.avaje.tests.basic; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; public class TestTransient extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestUpdateManyToOne.java b/src/test/java/com/avaje/tests/basic/TestUpdateManyToOne.java index adca28095..a1c94cb78 100644 --- a/src/test/java/com/avaje/tests/basic/TestUpdateManyToOne.java +++ b/src/test/java/com/avaje/tests/basic/TestUpdateManyToOne.java @@ -1,14 +1,13 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestUpdateManyToOne extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestUuidInsert.java b/src/test/java/com/avaje/tests/basic/TestUuidInsert.java index 36cd874ac..20c1d0dc5 100644 --- a/src/test/java/com/avaje/tests/basic/TestUuidInsert.java +++ b/src/test/java/com/avaje/tests/basic/TestUuidInsert.java @@ -1,26 +1,25 @@ package com.avaje.tests.basic; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TUuidEntity; +import org.junit.Test; public class TestUuidInsert extends BaseTestCase { - @Test - public void test() { - - TUuidEntity e = new TUuidEntity(); - e.setName("bana"); - - Ebean.save(e); - - TUuidEntity e2 = Ebean.find(TUuidEntity.class, e.getId()); - e2.setName("apple"); - - Ebean.save(e2); - - Ebean.delete(e2); - } + @Test + public void test() { + + TUuidEntity e = new TUuidEntity(); + e.setName("bana"); + + Ebean.save(e); + + TUuidEntity e2 = Ebean.find(TUuidEntity.class, e.getId()); + e2.setName("apple"); + + Ebean.save(e2); + + Ebean.delete(e2); + } } diff --git a/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java b/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java index 1d11001be..5bf751c88 100644 --- a/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java +++ b/src/test/java/com/avaje/tests/basic/TestUuidInsertMasterDetail.java @@ -1,13 +1,12 @@ package com.avaje.tests.basic; -import java.util.ArrayList; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.UUOne; import com.avaje.tests.model.basic.UUTwo; +import org.junit.Test; + +import java.util.ArrayList; public class TestUuidInsertMasterDetail extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/TestWhereAnnotation.java b/src/test/java/com/avaje/tests/basic/TestWhereAnnotation.java index fe65799b5..bae636eaa 100644 --- a/src/test/java/com/avaje/tests/basic/TestWhereAnnotation.java +++ b/src/test/java/com/avaje/tests/basic/TestWhereAnnotation.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestWhereAnnotation extends BaseTestCase { @@ -26,7 +25,7 @@ public class TestWhereAnnotation extends BaseTestCase { Assert.assertTrue(!orders.isEmpty()); Query q1 = Ebean.find(Customer.class).setUseCache(false).fetch("orders").where() - .idEq(1).query(); + .idEq(1).query(); q1.findUnique(); String s1 = q1.getGeneratedSql(); diff --git a/src/test/java/com/avaje/tests/basic/delete/TestDeleteByIdList.java b/src/test/java/com/avaje/tests/basic/delete/TestDeleteByIdList.java index 29846f2fd..1cc18632b 100644 --- a/src/test/java/com/avaje/tests/basic/delete/TestDeleteByIdList.java +++ b/src/test/java/com/avaje/tests/basic/delete/TestDeleteByIdList.java @@ -1,10 +1,5 @@ package com.avaje.tests.basic.delete; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -12,6 +7,10 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestDeleteByIdList extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/delete/TestDeleteCascadeById.java b/src/test/java/com/avaje/tests/basic/delete/TestDeleteCascadeById.java index aa4553bf5..2d1f05bbb 100644 --- a/src/test/java/com/avaje/tests/basic/delete/TestDeleteCascadeById.java +++ b/src/test/java/com/avaje/tests/basic/delete/TestDeleteCascadeById.java @@ -1,10 +1,5 @@ package com.avaje.tests.basic.delete; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -12,6 +7,10 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestDeleteCascadeById extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/encrypt/BasicEncryptKey.java b/src/test/java/com/avaje/tests/basic/encrypt/BasicEncryptKey.java index eb0566ac3..e33b8779c 100644 --- a/src/test/java/com/avaje/tests/basic/encrypt/BasicEncryptKey.java +++ b/src/test/java/com/avaje/tests/basic/encrypt/BasicEncryptKey.java @@ -4,16 +4,15 @@ import com.avaje.ebean.config.EncryptKey; public class BasicEncryptKey implements EncryptKey { - private final String key; + private final String key; + + public BasicEncryptKey(String key) { + this.key = key; + } + + public String getStringValue() { + return key; + } - public BasicEncryptKey(String key) { - this.key = key; - } - - public String getStringValue() { - return key; - } - - } diff --git a/src/test/java/com/avaje/tests/basic/encrypt/BasicEncyptKeyManager.java b/src/test/java/com/avaje/tests/basic/encrypt/BasicEncyptKeyManager.java index f91b425e0..b50b7e869 100644 --- a/src/test/java/com/avaje/tests/basic/encrypt/BasicEncyptKeyManager.java +++ b/src/test/java/com/avaje/tests/basic/encrypt/BasicEncyptKeyManager.java @@ -5,16 +5,16 @@ import com.avaje.ebean.config.EncryptKeyManager; public class BasicEncyptKeyManager implements EncryptKeyManager { - /** - * Initialise the key manager. - */ - public void initialise() { - - } + /** + * Initialise the key manager. + */ + public void initialise() { - public EncryptKey getEncryptKey(String tableName, String columnName) { - // Must be 16 Chars for Oracle function - return new BasicEncryptKey("simple0123456789"); - } + } + + public EncryptKey getEncryptKey(String tableName, String columnName) { + // Must be 16 Chars for Oracle function + return new BasicEncryptKey("simple0123456789"); + } } diff --git a/src/test/java/com/avaje/tests/basic/encrypt/TestEncrypt.java b/src/test/java/com/avaje/tests/basic/encrypt/TestEncrypt.java index 6d685fa1a..005ae1e65 100644 --- a/src/test/java/com/avaje/tests/basic/encrypt/TestEncrypt.java +++ b/src/test/java/com/avaje/tests/basic/encrypt/TestEncrypt.java @@ -1,13 +1,5 @@ package com.avaje.tests.basic.encrypt; -import java.sql.Date; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlQuery; @@ -16,6 +8,13 @@ import com.avaje.ebean.Update; import com.avaje.ebean.config.dbplatform.DbEncrypt; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.tests.model.basic.EBasicEncrypt; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import java.sql.Date; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -32,8 +31,8 @@ public class TestEncrypt extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(EBasicEncrypt.class) - .where().startsWith("description", "Rob") - .findList(); + .where().startsWith("description", "Rob") + .findList(); List loggedSql = LoggedSqlCollector.stop(); assertThat(loggedSql).hasSize(1); @@ -46,7 +45,7 @@ public class TestEncrypt extends BaseTestCase { Update deleteAll = Ebean.createUpdate(EBasicEncrypt.class, "delete from EBasicEncrypt"); deleteAll.execute(); - + EBasicEncrypt e = new EBasicEncrypt(); e.setName("testname"); e.setDescription("testdesc"); @@ -86,7 +85,7 @@ public class TestEncrypt extends BaseTestCase { } else { List list = Ebean.find(EBasicEncrypt.class).where() - .eq("description", "moddesc").findList(); + .eq("description", "moddesc").findList(); Assert.assertEquals(1, list.size()); diff --git a/src/test/java/com/avaje/tests/basic/encrypt/TestEncryptBinary.java b/src/test/java/com/avaje/tests/basic/encrypt/TestEncryptBinary.java index 25d86ba06..85c02b8e0 100644 --- a/src/test/java/com/avaje/tests/basic/encrypt/TestEncryptBinary.java +++ b/src/test/java/com/avaje/tests/basic/encrypt/TestEncryptBinary.java @@ -1,15 +1,14 @@ package com.avaje.tests.basic.encrypt; -import java.sql.Timestamp; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlQuery; import com.avaje.ebean.SqlRow; import com.avaje.tests.model.basic.EBasicEncryptBinary; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Timestamp; public class TestEncryptBinary extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/event/TestPreInsertValidation.java b/src/test/java/com/avaje/tests/basic/event/TestPreInsertValidation.java index 141c8a499..baf763554 100644 --- a/src/test/java/com/avaje/tests/basic/event/TestPreInsertValidation.java +++ b/src/test/java/com/avaje/tests/basic/event/TestPreInsertValidation.java @@ -1,50 +1,49 @@ package com.avaje.tests.basic.event; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TWithPreInsert; +import org.junit.Assert; +import org.junit.Test; public class TestPreInsertValidation extends BaseTestCase { @Test - public void test() { - - TWithPreInsert e = new TWithPreInsert(); - e.setTitle("Mister"); - // the perInsert should populate the - // name with should not be null - Ebean.save(e); - - // the save worked and name set in preInsert - Assert.assertNotNull(e.getId()); - Assert.assertNotNull(e.getName()); - - TWithPreInsert e1 = Ebean.find(TWithPreInsert.class, e.getId()); - - e1.setTitle("Missus"); - Ebean.save(e1); - } - + public void test() { + + TWithPreInsert e = new TWithPreInsert(); + e.setTitle("Mister"); + // the perInsert should populate the + // name with should not be null + Ebean.save(e); + + // the save worked and name set in preInsert + Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getName()); + + TWithPreInsert e1 = Ebean.find(TWithPreInsert.class, e.getId()); + + e1.setTitle("Missus"); + Ebean.save(e1); + } + @Test public void testStatelessUpdate() { - + TWithPreInsert e = new TWithPreInsert(); e.setName("BeanForUpdateTest"); Ebean.save(e); - + TWithPreInsert bean2 = new TWithPreInsert(); bean2.setId(e.getId()); bean2.setName("stateless-update-name"); bean2.setTitle(null); - + Ebean.update(bean2); - + // title set on preUpdate Assert.assertNotNull(bean2.getTitle()); } - + } diff --git a/src/test/java/com/avaje/tests/basic/event/TestQueryAdapter.java b/src/test/java/com/avaje/tests/basic/event/TestQueryAdapter.java index 3aeed9058..4c0499f0a 100644 --- a/src/test/java/com/avaje/tests/basic/event/TestQueryAdapter.java +++ b/src/test/java/com/avaje/tests/basic/event/TestQueryAdapter.java @@ -1,36 +1,35 @@ package com.avaje.tests.basic.event; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.ResetBasicData; import com.avaje.tests.model.basic.TOne; +import org.junit.Assert; +import org.junit.Test; public class TestQueryAdapter extends BaseTestCase { @Test - public void testSimple() { - - ResetBasicData.reset(); - - TOne o = new TOne(); - o.setName("something"); - - Ebean.save(o); - - //Ebean.find(TOne.class, o.getId()); - - Query queryFindId = Ebean.find(TOne.class) - .setId(o.getId()); - - TOne one = queryFindId.findUnique(); - Assert.assertNotNull(one); - Assert.assertEquals(one.getId(), o.getId()); - String generatedSql = queryFindId.getGeneratedSql(); - Assert.assertTrue(generatedSql.contains(" 1=1")); - - } + public void testSimple() { + + ResetBasicData.reset(); + + TOne o = new TOne(); + o.setName("something"); + + Ebean.save(o); + + //Ebean.find(TOne.class, o.getId()); + + Query queryFindId = Ebean.find(TOne.class) + .setId(o.getId()); + + TOne one = queryFindId.findUnique(); + Assert.assertNotNull(one); + Assert.assertEquals(one.getId(), o.getId()); + String generatedSql = queryFindId.getGeneratedSql(); + Assert.assertTrue(generatedSql.contains(" 1=1")); + + } } diff --git a/src/test/java/com/avaje/tests/basic/join/TestSecondaryJoin.java b/src/test/java/com/avaje/tests/basic/join/TestSecondaryJoin.java index d878ad849..ef16a8ed7 100644 --- a/src/test/java/com/avaje/tests/basic/join/TestSecondaryJoin.java +++ b/src/test/java/com/avaje/tests/basic/join/TestSecondaryJoin.java @@ -1,14 +1,13 @@ package com.avaje.tests.basic.join; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestSecondaryJoin extends BaseTestCase { @@ -18,9 +17,9 @@ public class TestSecondaryJoin extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - // .select("*") - // .join("customer") - .findList(); + // .select("*") + // .join("customer") + .findList(); Order o0 = list.get(0); o0.setCustomerName("Banan"); diff --git a/src/test/java/com/avaje/tests/basic/lob/TestBasicClobFetchEager.java b/src/test/java/com/avaje/tests/basic/lob/TestBasicClobFetchEager.java index 4486e809f..d5254e70b 100644 --- a/src/test/java/com/avaje/tests/basic/lob/TestBasicClobFetchEager.java +++ b/src/test/java/com/avaje/tests/basic/lob/TestBasicClobFetchEager.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic.lob; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.EBasicClobFetchEager; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -25,9 +24,9 @@ public class TestBasicClobFetchEager extends BaseTestCase { EbeanServer server = Ebean.getServer(null); server.save(entity); - + String expectedSql = "select t0.id, t0.name, t0.title, t0.description, t0.last_update from ebasic_clob_fetch_eager t0 where t0.id = ?"; - + // Clob included in fetch as FetchType.EAGER set by annotation Query defaultQuery = Ebean.find(EBasicClobFetchEager.class).setId(entity.getId()); defaultQuery.findUnique(); @@ -35,9 +34,9 @@ public class TestBasicClobFetchEager extends BaseTestCase { assertThat(sql).contains(expectedSql); - + LoggedSqlCollector.start(); - + // Same as previous query - clob included by default based on annotation Ebean.find(EBasicClobFetchEager.class, entity.getId()); @@ -45,7 +44,6 @@ public class TestBasicClobFetchEager extends BaseTestCase { List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); assertThat(trimSql(loggedSql.get(0), 6)).contains(expectedSql); - // Explicitly select * including Clob @@ -57,22 +55,22 @@ public class TestBasicClobFetchEager extends BaseTestCase { assertThat(sql).contains(expectedSql); // Update description to test refresh - + EBasicClobFetchEager updateBean = new EBasicClobFetchEager(); updateBean.setId(entity.getId()); updateBean.setDescription("modified"); Ebean.update(updateBean); - - + + // Test refresh function - + Assert.assertEquals("initialClobValue", entity.getDescription()); LoggedSqlCollector.start(); - + // Refresh query includes all properties server.refresh(entity); - + // Assert all properties fetched in refresh loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); diff --git a/src/test/java/com/avaje/tests/basic/lob/TestBasicClobNoVer.java b/src/test/java/com/avaje/tests/basic/lob/TestBasicClobNoVer.java index 9443d9205..4ed721ae9 100644 --- a/src/test/java/com/avaje/tests/basic/lob/TestBasicClobNoVer.java +++ b/src/test/java/com/avaje/tests/basic/lob/TestBasicClobNoVer.java @@ -1,16 +1,15 @@ package com.avaje.tests.basic.lob; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.EBasicClobNoVer; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -25,11 +24,11 @@ public class TestBasicClobNoVer extends BaseTestCase { EbeanServer server = Ebean.getServer(null); server.save(entity); - + String sqlNoClob = "select t0.id, t0.name from ebasic_clob_no_ver t0 where t0.id = ?"; String sqlWithClob = "select t0.id, t0.name, t0.description from ebasic_clob_no_ver t0 where t0.id = ?"; - - + + // Clob by default is Fetch Lazy Query defaultQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId()); defaultQuery.findUnique(); @@ -37,7 +36,7 @@ public class TestBasicClobNoVer extends BaseTestCase { Assert.assertTrue("Clob is fetch lazy by default", sql.contains(sqlNoClob)); - + // Explicitly select * including Clob Query explicitQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId()).select("*"); @@ -47,22 +46,22 @@ public class TestBasicClobNoVer extends BaseTestCase { Assert.assertTrue("Explicitly include Clob", sql.contains(sqlWithClob)); // Update description to test refresh - + EBasicClobNoVer updateBean = new EBasicClobNoVer(); updateBean.setId(entity.getId()); updateBean.setDescription("modified"); Ebean.update(updateBean); - - + + // Test refresh function - + Assert.assertEquals("initialClobValue", entity.getDescription()); LoggedSqlCollector.start(); - + // Refresh query includes all properties server.refresh(entity); - + // Assert all properties fetched in refresh List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); diff --git a/src/test/java/com/avaje/tests/basic/lob/TestByteOnly.java b/src/test/java/com/avaje/tests/basic/lob/TestByteOnly.java index df7da089c..f7c968950 100644 --- a/src/test/java/com/avaje/tests/basic/lob/TestByteOnly.java +++ b/src/test/java/com/avaje/tests/basic/lob/TestByteOnly.java @@ -1,23 +1,22 @@ package com.avaje.tests.basic.lob; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TBytesOnly; +import org.junit.Test; public class TestByteOnly extends BaseTestCase { @Test public void test() { - byte[] content = new byte[] { 1, 1 }; + byte[] content = new byte[]{1, 1}; TBytesOnly e = new TBytesOnly(); e.setContent(content); Ebean.save(e); - byte[] content2 = new byte[] { 1, 1 }; + byte[] content2 = new byte[]{1, 1}; TBytesOnly e2 = Ebean.find(TBytesOnly.class, e.getId()); e2.setContent(content2); diff --git a/src/test/java/com/avaje/tests/basic/one2one/Booking.java b/src/test/java/com/avaje/tests/basic/one2one/Booking.java index 098a03116..5bed91968 100644 --- a/src/test/java/com/avaje/tests/basic/one2one/Booking.java +++ b/src/test/java/com/avaje/tests/basic/one2one/Booking.java @@ -17,37 +17,38 @@ import java.util.List; @Table(name = "drel_booking") public class Booking { - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; @Column(unique = true) Long bookingUid; - @Version - private int version; + @Version + private int version; - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "agent_invoice") - private Invoice agentInvoice; - - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "client_invoice") - private Invoice clientInvoice; - - @OneToMany(mappedBy = "booking") - private List invoices; + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "agent_invoice") + private Invoice agentInvoice; - public Booking(Long bookingUid) { - this.bookingUid = bookingUid; - } + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "client_invoice") + private Invoice clientInvoice; - public Long getId() { - return id; - } + @OneToMany(mappedBy = "booking") + private List invoices; - public void setId(Long id) { - this.id = id; - } + public Booking(Long bookingUid) { + this.bookingUid = bookingUid; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } public Long getBookingUid() { return bookingUid; @@ -58,34 +59,34 @@ public class Booking { } public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public Invoice getAgentInvoice() { - return agentInvoice; - } - - public void setAgentInvoice(Invoice agentInvoice) { - this.agentInvoice = agentInvoice; - } - - public Invoice getClientInvoice() { - return clientInvoice; - } - - public void setClientInvoice(Invoice clientInvoice) { - this.clientInvoice = clientInvoice; - } - - public List getInvoices() { - return invoices; - } + return version; + } - public void setInvoices(List invoices) { - this.invoices= invoices; - } + public void setVersion(int version) { + this.version = version; + } + + public Invoice getAgentInvoice() { + return agentInvoice; + } + + public void setAgentInvoice(Invoice agentInvoice) { + this.agentInvoice = agentInvoice; + } + + public Invoice getClientInvoice() { + return clientInvoice; + } + + public void setClientInvoice(Invoice clientInvoice) { + this.clientInvoice = clientInvoice; + } + + public List getInvoices() { + return invoices; + } + + public void setInvoices(List invoices) { + this.invoices = invoices; + } } diff --git a/src/test/java/com/avaje/tests/basic/one2one/Invoice.java b/src/test/java/com/avaje/tests/basic/one2one/Invoice.java index 64f002a96..dd609be1a 100644 --- a/src/test/java/com/avaje/tests/basic/one2one/Invoice.java +++ b/src/test/java/com/avaje/tests/basic/one2one/Invoice.java @@ -11,40 +11,41 @@ import javax.persistence.Table; import javax.persistence.Version; @Entity -@Table(name="drel_invoice") +@Table(name = "drel_invoice") public class Invoice { - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Long id; - - @Version - private int version; - - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "booking")//_xid", referencedColumnName = "booking_uid") - private Booking booking; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; - public Long getId() { - return id; - } + @Version + private int version; - public void setId(Long id) { - this.id = id; - } + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "booking")//_xid", referencedColumnName = "booking_uid") + private Booking booking; - public int getVersion() { - return version; - } + public Long getId() { + return id; + } - public void setVersion(int version) { - this.version = version; - } + public void setId(Long id) { + this.id = id; + } - public Booking getBooking() { - return booking; - } + public int getVersion() { + return version; + } - public void setBooking(Booking booking) { - this.booking = booking; - } + public void setVersion(int version) { + this.version = version; + } + + public Booking getBooking() { + return booking; + } + + public void setBooking(Booking booking) { + this.booking = booking; + } } diff --git a/src/test/java/com/avaje/tests/basic/one2one/TestOne2OneBookingInvoice.java b/src/test/java/com/avaje/tests/basic/one2one/TestOne2OneBookingInvoice.java index 6dddc3b8e..1361025f4 100644 --- a/src/test/java/com/avaje/tests/basic/one2one/TestOne2OneBookingInvoice.java +++ b/src/test/java/com/avaje/tests/basic/one2one/TestOne2OneBookingInvoice.java @@ -1,10 +1,9 @@ package com.avaje.tests.basic.one2one; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import org.junit.Assert; +import org.junit.Test; public class TestOne2OneBookingInvoice extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/one2one/Tire.java b/src/test/java/com/avaje/tests/basic/one2one/Tire.java index d67565d70..50ac16e82 100644 --- a/src/test/java/com/avaje/tests/basic/one2one/Tire.java +++ b/src/test/java/com/avaje/tests/basic/one2one/Tire.java @@ -13,40 +13,40 @@ import javax.persistence.Version; @Entity @Table(name = "tire") public class Tire { - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Long id; - @Version - private int version; - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "wheel") - private Wheel wheel; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; + @Version + private int version; + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "wheel") + private Wheel wheel; - public Tire() { - super(); - } + public Tire() { + super(); + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } - public Wheel getWheel() { - return wheel; - } + public Wheel getWheel() { + return wheel; + } - public void setWheel(Wheel wheel) { - this.wheel = wheel; - } -} \ No newline at end of file + public void setWheel(Wheel wheel) { + this.wheel = wheel; + } +} diff --git a/src/test/java/com/avaje/tests/basic/type/BSimpleWithGen.java b/src/test/java/com/avaje/tests/basic/type/BSimpleWithGen.java index 4776f7a2d..e51bec781 100644 --- a/src/test/java/com/avaje/tests/basic/type/BSimpleWithGen.java +++ b/src/test/java/com/avaje/tests/basic/type/BSimpleWithGen.java @@ -1,45 +1,44 @@ package com.avaje.tests.basic.type; -import java.util.List; -import java.util.Map; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Transient; +import java.util.List; +import java.util.Map; @Entity public class BSimpleWithGen { - @Id - Integer id; - - String name; - - @Transient - Map> someMap; + @Id + Integer id; - public Integer getId() { - return id; - } + String name; - public void setId(Integer id) { - this.id = id; - } + @Transient + Map> someMap; - public String getName() { - return name; - } + public Integer getId() { + return id; + } - public void setName(String name) { - this.name = name; - } + public void setId(Integer id) { + this.id = id; + } - public Map> getSomeMap() { - return someMap; - } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map> getSomeMap() { + return someMap; + } + + public void setSomeMap(Map> someMap) { + this.someMap = someMap; + } - public void setSomeMap(Map> someMap) { - this.someMap = someMap; - } - } diff --git a/src/test/java/com/avaje/tests/basic/type/TestEnumValueAnnotation.java b/src/test/java/com/avaje/tests/basic/type/TestEnumValueAnnotation.java index 4e065707b..8134a3009 100644 --- a/src/test/java/com/avaje/tests/basic/type/TestEnumValueAnnotation.java +++ b/src/test/java/com/avaje/tests/basic/type/TestEnumValueAnnotation.java @@ -1,9 +1,5 @@ package com.avaje.tests.basic.type; -import com.avaje.tests.model.basic.EBasicEnumInt; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlQuery; @@ -11,6 +7,9 @@ import com.avaje.ebean.SqlRow; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.basic.EBasic.Status; import com.avaje.tests.model.basic.EBasicEnumId; +import com.avaje.tests.model.basic.EBasicEnumInt; +import org.junit.Assert; +import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -90,9 +89,9 @@ public class TestEnumValueAnnotation extends BaseTestCase { EBasicEnumInt b2 = Ebean.find(EBasicEnumInt.class) - .where().eq("id", b.getId()) - .eq("status", EBasicEnumInt.Status.NEW) - .findUnique(); + .where().eq("id", b.getId()) + .eq("status", EBasicEnumInt.Status.NEW) + .findUnique(); assertNotNull(b2); } diff --git a/src/test/java/com/avaje/tests/basic/type/TestExtraScalarTypes.java b/src/test/java/com/avaje/tests/basic/type/TestExtraScalarTypes.java index d29750b0e..a1fad7d9c 100644 --- a/src/test/java/com/avaje/tests/basic/type/TestExtraScalarTypes.java +++ b/src/test/java/com/avaje/tests/basic/type/TestExtraScalarTypes.java @@ -1,17 +1,16 @@ package com.avaje.tests.basic.type; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.tests.model.basic.ESomeType; +import org.junit.Assert; +import org.junit.Test; + import java.util.Currency; import java.util.List; import java.util.Locale; import java.util.TimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.avaje.ebean.BaseTestCase; -import com.avaje.ebean.Ebean; -import com.avaje.tests.model.basic.ESomeType; - import static org.junit.Assert.assertTrue; public class TestExtraScalarTypes extends BaseTestCase { @@ -37,11 +36,11 @@ public class TestExtraScalarTypes extends BaseTestCase { Assert.assertNotNull(e2.getTimeZone()); List list = Ebean.find(ESomeType.class) - .setAutoTune(false).where() - .eq("locale", locale) - .eq("timeZone", tz.getID()) - .eq("currency", currency) - .findList(); + .setAutoTune(false).where() + .eq("locale", locale) + .eq("timeZone", tz.getID()) + .eq("currency", currency) + .findList(); assertTrue(!list.isEmpty()); } diff --git a/src/test/java/com/avaje/tests/basic/type/TestInetAddressType.java b/src/test/java/com/avaje/tests/basic/type/TestInetAddressType.java index 84eb3c21a..8f5107076 100644 --- a/src/test/java/com/avaje/tests/basic/type/TestInetAddressType.java +++ b/src/test/java/com/avaje/tests/basic/type/TestInetAddressType.java @@ -1,61 +1,60 @@ package com.avaje.tests.basic.type; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EWithInetAddr; +import org.junit.Assert; +import org.junit.Test; + +import java.net.InetAddress; +import java.net.UnknownHostException; public class TestInetAddressType extends BaseTestCase { @Test public void testIp4() throws UnknownHostException { - + insertUpdateDeleteFind("120.12.12.56"); } @Test public void testIp6() throws UnknownHostException { - + insertUpdateDeleteFind("2001:db8:85a3:0:0:8a2e:370:7334"); } - + private void insertUpdateDeleteFind(String ipAddress) throws UnknownHostException { - + EWithInetAddr bean1 = new EWithInetAddr(); bean1.setName("jim"); - + InetAddress address1 = InetAddress.getByName(ipAddress); bean1.setInetAddress(address1); - + Ebean.save(bean1); - + EWithInetAddr bean2 = Ebean.find(EWithInetAddr.class, bean1.getId()); InetAddress address2 = bean2.getInetAddress(); Assert.assertNotNull(address2.getHostAddress()); Assert.assertEquals(address1.getHostAddress(), address2.getHostAddress()); - + bean2.setName("modJim"); bean2.setInetAddress(InetAddress.getByName("120.12.20.80")); Ebean.save(bean2); Ebean.delete(bean2); } - + @Test public void use_null() throws UnknownHostException { - + EWithInetAddr bean1 = new EWithInetAddr(); bean1.setName("jim"); - + Ebean.save(bean1); - + EWithInetAddr bean2 = Ebean.find(EWithInetAddr.class, bean1.getId()); InetAddress address2 = bean2.getInetAddress(); Assert.assertNull(address2); } - + } diff --git a/src/test/java/com/avaje/tests/basic/type/TestQueryBooleanProperty.java b/src/test/java/com/avaje/tests/basic/type/TestQueryBooleanProperty.java index ff3e9b5da..7726880e4 100644 --- a/src/test/java/com/avaje/tests/basic/type/TestQueryBooleanProperty.java +++ b/src/test/java/com/avaje/tests/basic/type/TestQueryBooleanProperty.java @@ -1,10 +1,9 @@ package com.avaje.tests.basic.type; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TOne; +import org.junit.Test; public class TestQueryBooleanProperty extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/basic/type/TestSqlRowUUID.java b/src/test/java/com/avaje/tests/basic/type/TestSqlRowUUID.java index cfb91ee91..ab97f7b8f 100644 --- a/src/test/java/com/avaje/tests/basic/type/TestSqlRowUUID.java +++ b/src/test/java/com/avaje/tests/basic/type/TestSqlRowUUID.java @@ -1,15 +1,14 @@ package com.avaje.tests.basic.type; -import java.util.UUID; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlQuery; import com.avaje.ebean.SqlRow; import com.avaje.tests.model.basic.TUuidEntity; +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; public class TestSqlRowUUID extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java index 784958b30..919011958 100644 --- a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java @@ -53,7 +53,7 @@ public class TestBatchInsertSimple extends BaseTestCase { saveWithFullBatchMode(); } - @Transactional(batchSize=50) + @Transactional(batchSize = 50) public void saveWithFullBatchMode() { int numOfMasters = 4; @@ -162,9 +162,9 @@ public class TestBatchInsertSimple extends BaseTestCase { // escalate based on batchOnCascade value Ebean.saveAll(masters); - for (int i = 0; i < masters.size() ; i++) { + for (int i = 0; i < masters.size(); i++) { UTMaster utMaster = masters.get(i); - utMaster.setName(utMaster.getName()+"-Mod"); + utMaster.setName(utMaster.getName() + "-Mod"); if (i % 2 == 0) { // make the updates a little bit different utMaster.setDescription("Blah"); diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertWithInitialisedCollection.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertWithInitialisedCollection.java index 200dfc5bf..fb710a0c3 100644 --- a/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertWithInitialisedCollection.java +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertWithInitialisedCollection.java @@ -24,7 +24,7 @@ public class TestBatchInsertWithInitialisedCollection extends BaseTestCase { for (int i = 0; i < 3; i++) { OCachedBean bean = new OCachedBean(); - bean.setName("name "+i); + bean.setName("name " + i); list.add(bean); } diff --git a/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java index f7033f8c6..960613f51 100644 --- a/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java +++ b/src/test/java/com/avaje/tests/batchinsert/TestBatchOnCascadeExceptionHandling.java @@ -9,13 +9,14 @@ import com.avaje.ebeaninternal.server.persist.BatchControl; import com.avaje.tests.model.basic.EBasicWithUniqueCon; import com.avaje.tests.model.basic.EOptOneB; import com.avaje.tests.model.basic.EOptOneC; +import org.assertj.core.api.Assertions; +import org.junit.Test; + import javax.persistence.PersistenceException; import java.sql.SQLException; import java.sql.Savepoint; -import org.assertj.core.api.Assertions; -import org.junit.Test; + import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.StrictAssertions.assertThat; public class TestBatchOnCascadeExceptionHandling extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/batchload/TestBasicLazy.java b/src/test/java/com/avaje/tests/batchload/TestBasicLazy.java index 773cc31dd..e6c389e08 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBasicLazy.java +++ b/src/test/java/com/avaje/tests/batchload/TestBasicLazy.java @@ -1,13 +1,5 @@ package com.avaje.tests.batchload; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Expr; @@ -19,6 +11,13 @@ import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; public class TestBasicLazy extends BaseTestCase { @@ -28,7 +27,7 @@ public class TestBasicLazy extends BaseTestCase { ResetBasicData.reset(); Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id") - .findUnique(); + .findUnique(); Assert.assertNotNull(order); @@ -76,7 +75,7 @@ public class TestBasicLazy extends BaseTestCase { ResetBasicData.reset(); Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id") - .findUnique(); + .findUnique(); Assert.assertNotNull(order); @@ -204,4 +203,4 @@ public class TestBasicLazy extends BaseTestCase { Assert.fail(); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/batchload/TestBasicNavOnEmpty.java b/src/test/java/com/avaje/tests/batchload/TestBasicNavOnEmpty.java index ac3aee73b..554881d5a 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBasicNavOnEmpty.java +++ b/src/test/java/com/avaje/tests/batchload/TestBasicNavOnEmpty.java @@ -1,29 +1,28 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestBasicNavOnEmpty extends BaseTestCase { @Test - public void test() { - - Customer c = new Customer(); - c.setName("HelloRob"); - - Ebean.save(c); - - c = Ebean.find(Customer.class, c.getId()); - - List contacts = c.getContacts(); - Assert.assertEquals(0,contacts.size()); - } - + public void test() { + + Customer c = new Customer(); + c.setName("HelloRob"); + + Ebean.save(c); + + c = Ebean.find(Customer.class, c.getId()); + + List contacts = c.getContacts(); + Assert.assertEquals(0, contacts.size()); + } + } diff --git a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java index 71a6768d5..e668ae1b5 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java +++ b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithCacheHits.java @@ -47,13 +47,13 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase { assertEquals(statistics.getHitCount(), 1); UUOne c = Ebean.find(UUOne.class) - .where().idEq(inserted.get(2).getId()) - .findUnique(); + .where().idEq(inserted.get(2).getId()) + .findUnique(); assertNotNull(c); UUOne c2 = Ebean.find(UUOne.class) - .where().idEq(inserted.get(2).getId()) - .findUnique(); + .where().idEq(inserted.get(2).getId()) + .findUnique(); assertNotNull(c2); statistics = beanCache.getStatistics(true); assertEquals(statistics.getHitCount(), 1); @@ -61,11 +61,11 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase { LoggedSqlCollector.start(); List list = Ebean.find(UUOne.class) - //.setDefaultLazyLoadBatchSize(5) - .select("id") - .where().startsWith("name", "testBLWCH") - .order("name") - .findList(); + //.setDefaultLazyLoadBatchSize(5) + .select("id") + .where().startsWith("name", "testBLWCH") + .order("name") + .findList(); for (UUOne uuOne : list) { uuOne.getName(); diff --git a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithDeleted.java b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithDeleted.java index 76cc4bd87..46a856427 100644 --- a/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithDeleted.java +++ b/src/test/java/com/avaje/tests/batchload/TestBatchLazyWithDeleted.java @@ -1,17 +1,15 @@ package com.avaje.tests.batchload; -import java.util.List; - -import javax.persistence.EntityNotFoundException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.UUOne; import com.avaje.tests.model.basic.UUTwo; +import org.junit.Assert; +import org.junit.Test; + +import javax.persistence.EntityNotFoundException; +import java.util.List; public class TestBatchLazyWithDeleted extends BaseTestCase { @@ -46,10 +44,10 @@ public class TestBatchLazyWithDeleted extends BaseTestCase { Ebean.save(twoC); List list = Ebean.find(UUTwo.class) - .fetch("master", new FetchConfig().lazy(5)) - .where().startsWith("name", "two-bld-") - .order("name") - .findList(); + .fetch("master", new FetchConfig().lazy(5)) + .where().startsWith("name", "two-bld-") + .order("name") + .findList(); // delete a bean that will be batch lazy loaded but // is NOT the bean that will invoke the lazy loading diff --git a/src/test/java/com/avaje/tests/batchload/TestEmptyManyLazyLoad.java b/src/test/java/com/avaje/tests/batchload/TestEmptyManyLazyLoad.java index 810352e83..aba6a6bb4 100644 --- a/src/test/java/com/avaje/tests/batchload/TestEmptyManyLazyLoad.java +++ b/src/test/java/com/avaje/tests/batchload/TestEmptyManyLazyLoad.java @@ -1,13 +1,12 @@ package com.avaje.tests.batchload; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; public class TestEmptyManyLazyLoad extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/batchload/TestLazyJoin.java b/src/test/java/com/avaje/tests/batchload/TestLazyJoin.java index 6ce8a02c6..7afa59ad5 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLazyJoin.java +++ b/src/test/java/com/avaje/tests/batchload/TestLazyJoin.java @@ -1,10 +1,5 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -12,6 +7,10 @@ import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestLazyJoin extends BaseTestCase { @@ -21,10 +20,10 @@ public class TestLazyJoin extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .select("status") - .fetch("customer", "+lazy(10) name, status") - .fetch("customer.contacts") - .order().asc("id"); + .select("status") + .fetch("customer", "+lazy(10) name, status") + .fetch("customer.contacts") + .order().asc("id"); List list = query.findList(); diff --git a/src/test/java/com/avaje/tests/batchload/TestLazyJoin2.java b/src/test/java/com/avaje/tests/batchload/TestLazyJoin2.java index 9a9d81c23..27a832f8e 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLazyJoin2.java +++ b/src/test/java/com/avaje/tests/batchload/TestLazyJoin2.java @@ -1,19 +1,17 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; -import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestLazyJoin2 extends BaseTestCase { @@ -25,12 +23,12 @@ public class TestLazyJoin2 extends BaseTestCase { // This will use 3 SQL queries to build this object graph List l0 = Ebean.find(Order.class).select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) - .fetch("details.product", "sku, name") + .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetch("details.product", "sku, name") - .fetch("customer", "name", new FetchConfig().query(10)) - .fetch("customer.contacts", "firstName, lastName, mobile") - .fetch("customer.shippingAddress", "line1, city").order().asc("id").findList(); + .fetch("customer", "name", new FetchConfig().query(10)) + .fetch("customer.contacts", "firstName, lastName, mobile") + .fetch("customer.shippingAddress", "line1, city").order().asc("id").findList(); Order o0 = l0.get(0); Customer c0 = o0.getCustomer(); @@ -44,8 +42,8 @@ public class TestLazyJoin2 extends BaseTestCase { // where id in (?,?,?,?,?) List orders = Ebean.find(Order.class) - // .select("status") - .fetch("customer", new FetchConfig().query(3).lazy(10)).order().asc("id").findList(); + // .select("status") + .fetch("customer", new FetchConfig().query(3).lazy(10)).order().asc("id").findList(); // .join("customer.contacts"); // List list = query.findList(); @@ -62,8 +60,8 @@ public class TestLazyJoin2 extends BaseTestCase { Assert.assertNotNull(billingAddress); List list = Ebean.find(Order.class).fetch("customer", "name", new FetchConfig().lazy(5)) - .fetch("customer.contacts", "contactName, phone, email").fetch("customer.shippingAddress") - .where().eq("status", Order.Status.NEW).order().asc("id").findList(); + .fetch("customer.contacts", "contactName, phone, email").fetch("customer.shippingAddress") + .where().eq("status", Order.Status.NEW).order().asc("id").findList(); Order order2 = list.get(0); Customer customer2 = order2.getCustomer(); diff --git a/src/test/java/com/avaje/tests/batchload/TestLazyLoadEmptyCollection.java b/src/test/java/com/avaje/tests/batchload/TestLazyLoadEmptyCollection.java index 6a5196c50..9b1050b68 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLazyLoadEmptyCollection.java +++ b/src/test/java/com/avaje/tests/batchload/TestLazyLoadEmptyCollection.java @@ -1,15 +1,14 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestLazyLoadEmptyCollection extends BaseTestCase { @@ -27,9 +26,9 @@ public class TestLazyLoadEmptyCollection extends BaseTestCase { Ebean.save(c); List list = Ebean.find(Customer.class) - .fetch("contacts", new FetchConfig().query(0)) - .fetch("contacts.notes", new FetchConfig().query(100)) - .findList(); + .fetch("contacts", new FetchConfig().query(0)) + .fetch("contacts.notes", new FetchConfig().query(100)) + .findList(); for (Customer customer : list) { List contacts = customer.getContacts(); diff --git a/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistantBean.java b/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistantBean.java index 2431dae7f..1b26c7938 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistantBean.java +++ b/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistantBean.java @@ -1,15 +1,13 @@ package com.avaje.tests.batchload; -import java.util.UUID; - -import javax.persistence.EntityNotFoundException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.UUOne; +import org.junit.Assert; +import org.junit.Test; + +import javax.persistence.EntityNotFoundException; +import java.util.UUID; public class TestLazyLoadNonExistantBean extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistentBean.java b/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistentBean.java index 3ee53106a..63b03d406 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistentBean.java +++ b/src/test/java/com/avaje/tests/batchload/TestLazyLoadNonExistentBean.java @@ -1,15 +1,13 @@ package com.avaje.tests.batchload; -import java.util.UUID; - -import javax.persistence.EntityNotFoundException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.UUOne; +import org.junit.Assert; +import org.junit.Test; + +import javax.persistence.EntityNotFoundException; +import java.util.UUID; public class TestLazyLoadNonExistentBean extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/batchload/TestLoadOnDirty.java b/src/test/java/com/avaje/tests/batchload/TestLoadOnDirty.java index a18014f2b..9be79a5b1 100644 --- a/src/test/java/com/avaje/tests/batchload/TestLoadOnDirty.java +++ b/src/test/java/com/avaje/tests/batchload/TestLoadOnDirty.java @@ -1,17 +1,16 @@ package com.avaje.tests.batchload; -import java.util.List; - -import com.avaje.ebean.bean.EntityBean; -import com.avaje.ebean.bean.EntityBeanIntercept; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; +import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestLoadOnDirty extends BaseTestCase { @@ -23,8 +22,8 @@ public class TestLoadOnDirty extends BaseTestCase { List custs = Ebean.find(Customer.class).findList(); Customer customer = Ebean.find(Customer.class).setId(custs.get(0).getId()).select("name") - .setUseCache(false) - .findUnique(); + .setUseCache(false) + .findUnique(); BeanState beanState = Ebean.getBeanState(customer); Assert.assertTrue(!beanState.isNew()); @@ -63,10 +62,10 @@ public class TestLoadOnDirty extends BaseTestCase { List custs = Ebean.find(Customer.class).order("id").findList(); Customer customer = Ebean.find(Customer.class) - .setId(custs.get(0).getId()) - .select("id") - .setUseCache(false) - .findUnique(); + .setId(custs.get(0).getId()) + .select("id") + .setUseCache(false) + .findUnique(); BeanState beanState = Ebean.getBeanState(customer); beanState.setDisableLazyLoad(true); diff --git a/src/test/java/com/avaje/tests/batchload/TestQueryDisableLazyLoad.java b/src/test/java/com/avaje/tests/batchload/TestQueryDisableLazyLoad.java index 6c465edb8..fdd35e3a9 100644 --- a/src/test/java/com/avaje/tests/batchload/TestQueryDisableLazyLoad.java +++ b/src/test/java/com/avaje/tests/batchload/TestQueryDisableLazyLoad.java @@ -24,9 +24,9 @@ public class TestQueryDisableLazyLoad extends BaseTestCase { LoggedSqlCollector.start(); List l0 = Ebean.find(Order.class) - .setDisableLazyLoading(true) - .order().asc("id") - .findList(); + .setDisableLazyLoading(true) + .order().asc("id") + .findList(); assertThat(l0).isNotEmpty(); @@ -50,9 +50,9 @@ public class TestQueryDisableLazyLoad extends BaseTestCase { LoggedSqlCollector.start(); List l0 = Ebean.find(Order.class) - .setDisableLazyLoading(true) - .order().asc("id") - .findList(); + .setDisableLazyLoading(true) + .order().asc("id") + .findList(); assertThat(l0).isNotEmpty(); @@ -73,10 +73,10 @@ public class TestQueryDisableLazyLoad extends BaseTestCase { LoggedSqlCollector.start(); List l0 = Ebean.find(Order.class) - .setDisableLazyLoading(true) - .fetch("customer","smallnote") - .order().asc("id") - .findList(); + .setDisableLazyLoading(true) + .fetch("customer", "smallnote") + .order().asc("id") + .findList(); assertThat(l0).isNotEmpty(); diff --git a/src/test/java/com/avaje/tests/batchload/TestQueryJoin.java b/src/test/java/com/avaje/tests/batchload/TestQueryJoin.java index d87a2d8fa..dd30a94e9 100644 --- a/src/test/java/com/avaje/tests/batchload/TestQueryJoin.java +++ b/src/test/java/com/avaje/tests/batchload/TestQueryJoin.java @@ -1,10 +1,5 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; @@ -14,6 +9,10 @@ import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryJoin extends BaseTestCase { @@ -28,8 +27,8 @@ public class TestQueryJoin extends BaseTestCase { custCache.clear(); Query query = Ebean.find(Order.class).select("status") - // .join("details","+query(10)") - .fetch("customer", "+lazy(10) name, status").fetch("customer.contacts").orderBy().asc("id"); + // .join("details","+query(10)") + .fetch("customer", "+lazy(10) name, status").fetch("customer.contacts").orderBy().asc("id"); // .join("customer.billingAddress"); List list = query.findList(); diff --git a/src/test/java/com/avaje/tests/batchload/TestQueryJoinToAssocOne.java b/src/test/java/com/avaje/tests/batchload/TestQueryJoinToAssocOne.java index b4aadb6d5..315c5d40a 100644 --- a/src/test/java/com/avaje/tests/batchload/TestQueryJoinToAssocOne.java +++ b/src/test/java/com/avaje/tests/batchload/TestQueryJoinToAssocOne.java @@ -24,9 +24,9 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) - .fetch("details.product", "sku, name") - .findList(); + .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetch("details.product", "sku, name") + .findList(); assertThat(l0).isNotEmpty(); @@ -50,10 +50,10 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) - .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) - .fetch("details.product", "sku, name") - .findList(); + .select("status, shipDate") + .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetch("details.product", "sku, name") + .findList(); assertThat(l0).isNotEmpty(); @@ -76,12 +76,12 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) - .setDisableLazyLoading(true) - .select("status, shipDate") - .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) - .fetch("details.product", "sku, name") - .order().asc("id") - .findList(); + .setDisableLazyLoading(true) + .select("status, shipDate") + .fetch("details", "orderQty, unitPrice", new FetchConfig().query()) + .fetch("details.product", "sku, name") + .order().asc("id") + .findList(); assertThat(l0).isNotEmpty(); @@ -116,11 +116,11 @@ public class TestQueryJoinToAssocOne extends BaseTestCase { // This will use 2 SQL queries to build this object graph List l0 = Ebean.find(Order.class) - .setDisableLazyLoading(true) - .select("status, shipDate") - .fetch("details", "orderQty, unitPrice")//, new FetchConfig().query()) - .fetch("details.product", "sku, name") - .findList(); + .setDisableLazyLoading(true) + .select("status, shipDate") + .fetch("details", "orderQty, unitPrice")//, new FetchConfig().query()) + .fetch("details.product", "sku, name") + .findList(); assertThat(l0).isNotEmpty(); diff --git a/src/test/java/com/avaje/tests/batchload/TestSecondQueryNoRows.java b/src/test/java/com/avaje/tests/batchload/TestSecondQueryNoRows.java index 1c76187e8..64a588023 100644 --- a/src/test/java/com/avaje/tests/batchload/TestSecondQueryNoRows.java +++ b/src/test/java/com/avaje/tests/batchload/TestSecondQueryNoRows.java @@ -20,10 +20,10 @@ public class TestSecondQueryNoRows extends BaseTestCase { Ebean.save(cnew); Customer c = Ebean.find(Customer.class) - .setAutoTune(false) - .setId(cnew.getId()) - .fetch("contacts", new FetchConfig().query()) - .findUnique(); + .setAutoTune(false) + .setId(cnew.getId()) + .fetch("contacts", new FetchConfig().query()) + .findUnique(); assertNotNull(c); assertEquals(0, c.getContacts().size()); diff --git a/src/test/java/com/avaje/tests/batchload/TestSecondaryQueries.java b/src/test/java/com/avaje/tests/batchload/TestSecondaryQueries.java index 9cd1d4055..0c3fb7bfc 100644 --- a/src/test/java/com/avaje/tests/batchload/TestSecondaryQueries.java +++ b/src/test/java/com/avaje/tests/batchload/TestSecondaryQueries.java @@ -1,11 +1,5 @@ package com.avaje.tests.batchload; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -14,6 +8,11 @@ import com.avaje.ebeaninternal.api.SpiQuery; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -27,9 +26,9 @@ public class TestSecondaryQueries extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .select("status") - .fetchQuery("customer", "name") - .findList(); + .select("status") + .fetchQuery("customer", "name") + .findList(); List sql = LoggedSqlCollector.stop(); @@ -46,11 +45,11 @@ public class TestSecondaryQueries extends BaseTestCase { LoggedSqlCollector.start(); List orders = Ebean.find(Order.class) - .select("status") - .fetchLazy("customer", "name") - .setMaxRows(10) - .setUseCache(false) - .findList(); + .select("status") + .fetchLazy("customer", "name") + .setMaxRows(10) + .setUseCache(false) + .findList(); List sql = LoggedSqlCollector.stop(); @@ -77,83 +76,83 @@ public class TestSecondaryQueries extends BaseTestCase { Order testOrder = ResetBasicData.createOrderCustAndOrder("testSecQry10"); Integer custId = testOrder.getCustomer().getId(); - Query query = Ebean.find(Customer.class) - .select("name") - .fetch("contacts", "+query") - .setId(custId); + Query query = Ebean.find(Customer.class) + .select("name") + .fetch("contacts", "+query") + .setId(custId); - SpiQuery spiQuery = (SpiQuery)query; + SpiQuery spiQuery = (SpiQuery) query; spiQuery.setLogSecondaryQuery(true); - + Customer cust = query.findUnique(); - + Assert.assertNotNull(cust); String generatedSql = query.getGeneratedSql(); Assert.assertTrue(generatedSql.contains("from o_customer t0 where t0.id = ?")); - + List> loggedSecondaryQueries = spiQuery.getLoggedSecondaryQueries(); Assert.assertEquals(1, loggedSecondaryQueries.size()); - + SpiQuery secondaryQuery = loggedSecondaryQueries.get(0); String secondarySql = secondaryQuery.getGeneratedSql(); - + Assert.assertTrue(secondarySql.contains("from contact t0 where (t0.customer_id) in (?)")); } - - + + @Test public void testManyToOneWithManyPlusOneToMany() { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .select("status") - .fetch("customer", "name, status", new FetchConfig().query()) - .fetch("customer.contacts") - .fetch("details", new FetchConfig().query()) - .where().eq("status", Order.Status.NEW) - .query(); + .select("status") + .fetch("customer", "name, status", new FetchConfig().query()) + .fetch("customer.contacts") + .fetch("details", new FetchConfig().query()) + .where().eq("status", Order.Status.NEW) + .query(); // .fetch("customer", "+query name, status") // .fetch("details", "+query(10)") - - SpiQuery spiQuery = (SpiQuery)query; + + SpiQuery spiQuery = (SpiQuery) query; spiQuery.setLogSecondaryQuery(true); - + List list = query.findList(); Assert.assertTrue(!list.isEmpty()); for (Order order : list) { order.getCustomer().getStatus(); } - - + + String generatedSql = sqlOf(spiQuery, 2); //select t0.id c0, t0.status c1, t0.kcustomer_id c2 from o_order t0 where t0.status = ? ; --bind(NEW) Assert.assertEquals("select t0.id, t0.status, t0.kcustomer_id from o_order t0 where t0.status = ? ", generatedSql); - + List> secondaryQueries = spiQuery.getLoggedSecondaryQueries(); Assert.assertEquals(2, secondaryQueries.size()); - + SpiQuery custSecondaryQuery = secondaryQueries.get(0); String custSecondarySql = custSecondaryQuery.getGeneratedSql(); - - // select t0.id c0, t0.name c1, t0.status c2, - // t1.id c3, t1.first_name c4, t1.last_name c5, t1.phone c6, t1.mobile c7, t1.email c8, t1.cretime c9, t1.updtime c10, t1.customer_id c11, t1.group_id c12 - // from o_customer t0 + + // select t0.id c0, t0.name c1, t0.status c2, + // t1.id c3, t1.first_name c4, t1.last_name c5, t1.phone c6, t1.mobile c7, t1.email c8, t1.cretime c9, t1.updtime c10, t1.customer_id c11, t1.group_id c12 + // from o_customer t0 // left join contact t1 on t1.customer_id = t0.id // where t0.id = ? order by t0.id; --bind(1) - + Assert.assertTrue(custSecondarySql.contains("from o_customer t0 ")); Assert.assertTrue(custSecondarySql.contains("left join contact t1 on t1.customer_id = t0.id ")); Assert.assertTrue(custSecondarySql.contains("where t0.id ")); - + SpiQuery orderDetailsSecondaryQuery = secondaryQueries.get(1); String ordSecondarySql = orderDetailsSecondaryQuery.getGeneratedSql(); - // select ... - // from o_order_detail t0 + // select ... + // from o_order_detail t0 // where (t0.order_id) in (?,?,?,?,?) ; --bind(1,4,1,1,1) Assert.assertTrue(ordSecondarySql.contains(" from o_order_detail t0 where t0.id > 0 and (t0.order_id) in (?")); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheBasic.java b/src/test/java/com/avaje/tests/cache/TestCacheBasic.java index 54fa403bd..3995f1d24 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheBasic.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheBasic.java @@ -1,14 +1,13 @@ package com.avaje.tests.cache; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheStatistics; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestCacheBasic extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java b/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java index f02b97796..8272c3ab3 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheCollectionIds.java @@ -1,11 +1,5 @@ package com.avaje.tests.cache; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.cache.ServerCache; @@ -16,11 +10,16 @@ import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.OCachedBean; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestCacheCollectionIds extends BaseTestCase { ServerCacheManager cacheManager = Ebean.getServerCacheManager(); - + @Test public void test() { @@ -38,7 +37,7 @@ public class TestCacheCollectionIds extends BaseTestCase { custManyIdsCache.clear(); List list = Ebean.find(Customer.class).setAutoTune(false).setLoadBeanCache(true) - .order().asc("id").findList(); + .order().asc("id").findList(); Assert.assertTrue(list.size() > 1); // Assert.assertEquals(list.size(), @@ -104,18 +103,18 @@ public class TestCacheCollectionIds extends BaseTestCase { Ebean.save(cachedBean); - // used to just load the cache - trigger loading + // used to just load the cache - trigger loading OCachedBean dummyToLoad = Ebean.find(OCachedBean.class, cachedBean.getId()); dummyToLoad.getCountries().size(); - + ServerCache cachedBeanCountriesCache = cacheManager.getCollectionIdsCache(OCachedBean.class, "countries"); CachedManyIds cachedManyIds = (CachedManyIds) cachedBeanCountriesCache.get(cachedBean.getId()); - + // confirm the starting data and cache entry Assert.assertEquals(2, dummyToLoad.getCountries().size()); Assert.assertEquals(2, cachedManyIds.getIdList().size()); - + // act OCachedBean loadedBean = Ebean.find(OCachedBean.class, cachedBean.getId()); loadedBean.getCountries().clear(); @@ -135,7 +134,7 @@ public class TestCacheCollectionIds extends BaseTestCase { Assert.assertTrue(cachedManyIds.getIdList().contains("AU")); } - + /** * When updating a ManyToMany relations also the collection cache must be updated. * Alternate to above test where in this case the bean is dirty - loadedBean.setName("goodbye");. @@ -152,18 +151,18 @@ public class TestCacheCollectionIds extends BaseTestCase { Ebean.save(cachedBean); - // used to just load the cache - trigger loading + // used to just load the cache - trigger loading OCachedBean dummyToLoad = Ebean.find(OCachedBean.class, cachedBean.getId()); dummyToLoad.getCountries().size(); - + ServerCache cachedBeanCountriesCache = cacheManager.getCollectionIdsCache(OCachedBean.class, "countries"); CachedManyIds cachedManyIds = (CachedManyIds) cachedBeanCountriesCache.get(cachedBean.getId()); - + // confirm the starting data and cache entry Assert.assertEquals(2, dummyToLoad.getCountries().size()); Assert.assertEquals(2, cachedManyIds.getIdList().size()); - + // act - this time update the name property so the bean is dirty OCachedBean loadedBean = Ebean.find(OCachedBean.class, cachedBean.getId()); loadedBean.setName("goodbye"); @@ -216,8 +215,8 @@ public class TestCacheCollectionIds extends BaseTestCase { Assert.assertEquals("2 ids in the entry", 2, dummyEntry.getIdList().size()); Assert.assertTrue(dummyEntry.getIdList().contains("NZ")); Assert.assertTrue(dummyEntry.getIdList().contains("AU")); - - + + // act - this should invalidate our cache entry OCachedBean update = new OCachedBean(); update.setId(cachedBean.getId()); @@ -235,7 +234,7 @@ public class TestCacheCollectionIds extends BaseTestCase { Assert.assertEquals(1, cachedManyIds.getIdList().size()); Assert.assertFalse(cachedManyIds.getIdList().contains("NZ")); Assert.assertTrue(cachedManyIds.getIdList().contains("AU")); - + // assert countries good OCachedBean result = Ebean.find(OCachedBean.class, cachedBean.getId()); Assert.assertEquals(1, result.getCountries().size()); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheCustomer.java b/src/test/java/com/avaje/tests/cache/TestCacheCustomer.java index 5682b8353..2746911aa 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheCustomer.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheCustomer.java @@ -1,17 +1,16 @@ package com.avaje.tests.cache; -import java.util.List; - -import com.avaje.tests.model.basic.Country; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Contact; +import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestCacheCustomer extends BaseTestCase { @@ -40,7 +39,7 @@ public class TestCacheCustomer extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).setAutoTune(false).setLoadBeanCache(true) - .findList(); + .findList(); Assert.assertTrue(list.size() > 1); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheInterceptSaveWhenLazyLoaded.java b/src/test/java/com/avaje/tests/cache/TestCacheInterceptSaveWhenLazyLoaded.java index 680842972..ba0c82bf8 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheInterceptSaveWhenLazyLoaded.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheInterceptSaveWhenLazyLoaded.java @@ -27,15 +27,15 @@ public class TestCacheInterceptSaveWhenLazyLoaded extends BaseTestCase { try { Order foundOrder = Ebean.find(Order.class) - .where().eq("id", order.getId()) - .findUnique(); + .where().eq("id", order.getId()) + .findUnique(); foundOrder.setStatus(Order.Status.APPROVED); assertTrue(Ebean.getBeanState(foundOrder).isDirty()); Customer foundCustomer = Ebean.find(Customer.class) - .where().eq("id", customer.getId()) - .findUnique(); + .where().eq("id", customer.getId()) + .findUnique(); // the foundOrder is in this list foundCustomer.getOrders().size(); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheNaturalId.java b/src/test/java/com/avaje/tests/cache/TestCacheNaturalId.java index 21727cd2a..4fcc7a778 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheNaturalId.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheNaturalId.java @@ -10,9 +10,7 @@ import org.junit.Test; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestCacheNaturalId extends BaseTestCase { @@ -56,7 +54,7 @@ public class TestCacheNaturalId extends BaseTestCase { awaitL2Cache(); Contact c2 = Ebean.find(Contact.class).where().eq("email", "mychangedemail@what.com") - .findUnique(); + .findUnique(); ServerCacheStatistics stats2 = contactCache.getStatistics(false); diff --git a/src/test/java/com/avaje/tests/cache/TestCacheReferenceLazyLoad.java b/src/test/java/com/avaje/tests/cache/TestCacheReferenceLazyLoad.java index 79b873689..5249a48f3 100644 --- a/src/test/java/com/avaje/tests/cache/TestCacheReferenceLazyLoad.java +++ b/src/test/java/com/avaje/tests/cache/TestCacheReferenceLazyLoad.java @@ -1,13 +1,12 @@ package com.avaje.tests.cache; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.cache.ServerCacheManager; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestCacheReferenceLazyLoad extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/cache/TestExternalNotification.java b/src/test/java/com/avaje/tests/cache/TestExternalNotification.java index 4ea3cfb47..1f3a1bea5 100644 --- a/src/test/java/com/avaje/tests/cache/TestExternalNotification.java +++ b/src/test/java/com/avaje/tests/cache/TestExternalNotification.java @@ -58,7 +58,7 @@ public class TestExternalNotification extends BaseTestCase { assertTrue("cacheSize: " + cacheSize, cacheSize > 0); SqlUpdate sqlUpdate = Ebean - .createSqlUpdate("update o_country set name = :name where code = :code"); + .createSqlUpdate("update o_country set name = :name where code = :code"); sqlUpdate.setParameter("name", "Aotearoa"); sqlUpdate.setParameter("code", "NZ"); diff --git a/src/test/java/com/avaje/tests/cache/TestL2CacheWithSharedBean.java b/src/test/java/com/avaje/tests/cache/TestL2CacheWithSharedBean.java index 9fbd01a43..b2e746ee6 100644 --- a/src/test/java/com/avaje/tests/cache/TestL2CacheWithSharedBean.java +++ b/src/test/java/com/avaje/tests/cache/TestL2CacheWithSharedBean.java @@ -1,18 +1,17 @@ package com.avaje.tests.cache; -import com.avaje.ebeaninternal.server.autotune.model.Origin; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebeaninternal.api.SpiQuery; +import com.avaje.ebeaninternal.server.autotune.model.Origin; import com.avaje.ebeaninternal.server.autotune.service.TunedQueryInfo; import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail; import com.avaje.tests.model.basic.FeatureDescription; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; public class TestL2CacheWithSharedBean extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/cache/TestQueryCache.java b/src/test/java/com/avaje/tests/cache/TestQueryCache.java index 756295632..a9552e4fc 100644 --- a/src/test/java/com/avaje/tests/cache/TestQueryCache.java +++ b/src/test/java/com/avaje/tests/cache/TestQueryCache.java @@ -1,17 +1,16 @@ package com.avaje.tests.cache; -import java.util.List; - -import com.avaje.tests.model.cache.EColAB; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.cache.ServerCache; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import com.avaje.tests.model.cache.EColAB; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -24,22 +23,22 @@ public class TestQueryCache extends BaseTestCase { new EColAB("02", "10").save(); List list1 = - Ebean.getServer(null) - .find(EColAB.class) - .setUseQueryCache(true) - .where() - .eq("columnA", "01") - .eq("columnB", "20") - .findList(); + Ebean.getServer(null) + .find(EColAB.class) + .setUseQueryCache(true) + .where() + .eq("columnA", "01") + .eq("columnB", "20") + .findList(); List list2 = - Ebean.getServer(null) - .find(EColAB.class) - .setUseQueryCache(true) - .where() - .eq("columnA", "02") - .eq("columnB", "10") - .findList(); + Ebean.getServer(null) + .find(EColAB.class) + .setUseQueryCache(true) + .where() + .eq("columnA", "02") + .eq("columnB", "10") + .findList(); assertThat(list1.get(0).getColumnA()).isEqualTo("01"); assertThat(list1.get(0).getColumnB()).isEqualTo("20"); @@ -58,7 +57,7 @@ public class TestQueryCache extends BaseTestCase { customerCache.clear(); List list = Ebean.find(Customer.class).setUseQueryCache(true).setReadOnly(true).where() - .ilike("name", "Rob").findList(); + .ilike("name", "Rob").findList(); BeanCollection bc = (BeanCollection) list; Assert.assertFalse(bc.isReadOnly()); @@ -67,24 +66,24 @@ public class TestQueryCache extends BaseTestCase { Assert.assertTrue(Ebean.getBeanState(list.get(0)).isReadOnly()); List list2 = Ebean.find(Customer.class).setUseQueryCache(true).setReadOnly(true).where() - .ilike("name", "Rob").findList(); + .ilike("name", "Rob").findList(); List list2B = Ebean.find(Customer.class).setUseQueryCache(true) - // .setReadOnly(true) - .where().ilike("name", "Rob").findList(); + // .setReadOnly(true) + .where().ilike("name", "Rob").findList(); Assert.assertSame(list, list2); // readOnly defaults to true for query cache Assert.assertSame(list, list2B); - + // TODO: At this stage setReadOnly(false) does not // create a shallow copy of the List/Set/Map - + // List list3 = Ebean.find(Customer.class).setUseQueryCache(true).setReadOnly(false).where() // .ilike("name", "Rob").findList(); -// +// // Assert.assertNotSame(list, list3); // BeanCollection bc3 = (BeanCollection) list3; // Assert.assertFalse(bc3.isReadOnly()); diff --git a/src/test/java/com/avaje/tests/cache/TestQueryCacheCountry.java b/src/test/java/com/avaje/tests/cache/TestQueryCacheCountry.java index bf1366a86..02a1e9d54 100644 --- a/src/test/java/com/avaje/tests/cache/TestQueryCacheCountry.java +++ b/src/test/java/com/avaje/tests/cache/TestQueryCacheCountry.java @@ -1,25 +1,24 @@ package com.avaje.tests.cache; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheStatistics; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class TestQueryCacheCountry extends BaseTestCase { - + @Test public void test() { - + ResetBasicData.reset(); awaitL2Cache(); @@ -31,25 +30,25 @@ public class TestQueryCacheCountry extends BaseTestCase { beanCache.clear(); assertEquals(0, queryCache.getStatistics(false).getSize()); - + List countryList0 = Ebean.find(Country.class) .setUseQueryCache(true) .order().asc("name") .findList(); - + assertEquals(1, queryCache.getStatistics(false).getSize()); assertTrue(!countryList0.isEmpty()); - + List countryList1 = Ebean.find(Country.class) - .setUseQueryCache(true) - .order().asc("name") - .findList(); - + .setUseQueryCache(true) + .order().asc("name") + .findList(); + ServerCacheStatistics statistics = queryCache.getStatistics(false); assertEquals(1, statistics.getSize()); assertEquals(1, statistics.getHitCount()); Assert.assertSame(countryList1, countryList0); - + Country nz = Ebean.find(Country.class, "NZ"); nz.setName("New Zealandia"); Ebean.save(nz); @@ -57,12 +56,12 @@ public class TestQueryCacheCountry extends BaseTestCase { statistics = queryCache.getStatistics(false); assertEquals(0, statistics.getSize()); - + List countryList2 = Ebean.find(Country.class) - .setUseQueryCache(true) - .order().asc("name") - .findList(); - + .setUseQueryCache(true) + .order().asc("name") + .findList(); + Assert.assertNotSame(countryList2, countryList0); } diff --git a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedAddRemoveOrphan.java b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedAddRemoveOrphan.java index 7b58eb9ca..a172b09a1 100644 --- a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedAddRemoveOrphan.java +++ b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedAddRemoveOrphan.java @@ -1,34 +1,33 @@ package com.avaje.tests.cascade; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TSDetail; import com.avaje.tests.model.basic.TSMaster; +import org.junit.Assert; +import org.junit.Test; public class TestPrivateOwnedAddRemoveOrphan extends BaseTestCase { - - @Test - public void test(){ - - // setup - TSMaster master0 = new TSMaster(); - Ebean.save(master0); - - // act - TSMaster master1 = Ebean.find(master0.getClass(), master0.getId()); - - TSDetail tsDetail = new TSDetail(); - // Add then remove a bean that was never saved (to the DB) - master1.getDetails().add(tsDetail); - master1.getDetails().remove(tsDetail); - Ebean.save(master1); - - TSMaster master2 = Ebean.find(master1.getClass(), master1.getId()); - - Assert.assertTrue(master2.getDetails().isEmpty()); - } + @Test + public void test() { + + // setup + TSMaster master0 = new TSMaster(); + Ebean.save(master0); + + // act + TSMaster master1 = Ebean.find(master0.getClass(), master0.getId()); + + TSDetail tsDetail = new TSDetail(); + // Add then remove a bean that was never saved (to the DB) + master1.getDetails().add(tsDetail); + master1.getDetails().remove(tsDetail); + + Ebean.save(master1); + + TSMaster master2 = Ebean.find(master1.getClass(), master1.getId()); + + Assert.assertTrue(master2.getDetails().isEmpty()); + } } diff --git a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedIgnoreTransientOrphan.java b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedIgnoreTransientOrphan.java index c61047da5..c30823498 100644 --- a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedIgnoreTransientOrphan.java +++ b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedIgnoreTransientOrphan.java @@ -1,47 +1,46 @@ package com.avaje.tests.cascade; -import javax.persistence.OptimisticLockException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TSDetail; import com.avaje.tests.model.basic.TSMaster; +import org.junit.Assert; +import org.junit.Test; + +import javax.persistence.OptimisticLockException; public class TestPrivateOwnedIgnoreTransientOrphan extends BaseTestCase { - - @Test - public void test(){ - - /** new object **/ - TSMaster master0 = new TSMaster(); - - /** recovered after first save **/ - TSMaster master1 = null; - - /** recovered after transient child ignored **/ - TSMaster master2 = null; - - Ebean.save(master0); - - master1 = Ebean.find(master0.getClass(), master0.getId()); - - // Add then remove a bean that was never saved (to the DB) - master1.getDetails().add(new TSDetail()); - master1.getDetails().clear(); - try{ - Ebean.save(master1); - } catch (OptimisticLockException exception) { - // Occured when the "unsaved" bean was wrongly being deleted - Assert.fail("Optimistic lock exception wrongly thrown: " + exception.getMessage()); - return; - } - - master2 = master1 = Ebean.find(master1.getClass(), master1.getId()); - - Assert.assertTrue(master2.getDetails().isEmpty()); - } + @Test + public void test() { + + /** new object **/ + TSMaster master0 = new TSMaster(); + + /** recovered after first save **/ + TSMaster master1 = null; + + /** recovered after transient child ignored **/ + TSMaster master2 = null; + + Ebean.save(master0); + + master1 = Ebean.find(master0.getClass(), master0.getId()); + + // Add then remove a bean that was never saved (to the DB) + master1.getDetails().add(new TSDetail()); + master1.getDetails().clear(); + + try { + Ebean.save(master1); + } catch (OptimisticLockException exception) { + // Occured when the "unsaved" bean was wrongly being deleted + Assert.fail("Optimistic lock exception wrongly thrown: " + exception.getMessage()); + return; + } + + master2 = master1 = Ebean.find(master1.getClass(), master1.getId()); + + Assert.assertTrue(master2.getDetails().isEmpty()); + } } diff --git a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedNoCascadeRemove.java b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedNoCascadeRemove.java index f69f9ccac..e34df8bb7 100644 --- a/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedNoCascadeRemove.java +++ b/src/test/java/com/avaje/tests/cascade/TestPrivateOwnedNoCascadeRemove.java @@ -1,16 +1,15 @@ package com.avaje.tests.cascade; -import java.util.List; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; import com.avaje.tests.model.basic.TSDetailTwo; import com.avaje.tests.model.basic.TSMasterTwo; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; +import java.util.Set; public class TestPrivateOwnedNoCascadeRemove extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCKeyDelete.java b/src/test/java/com/avaje/tests/compositekeys/TestCKeyDelete.java index f932229a5..bbba58725 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCKeyDelete.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCKeyDelete.java @@ -1,12 +1,11 @@ package com.avaje.tests.compositekeys; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.CKeyParent; import com.avaje.tests.model.basic.CKeyParentId; +import org.junit.Assert; +import org.junit.Test; public class TestCKeyDelete extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java b/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java index 818f9372c..94302bb6d 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCKeyLazyLoad.java @@ -1,19 +1,18 @@ package com.avaje.tests.compositekeys; -import java.util.ArrayList; -import java.util.List; - -import com.avaje.ebean.PagedList; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import com.avaje.ebean.PagedList; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.CKeyAssoc; import com.avaje.tests.model.basic.CKeyDetail; import com.avaje.tests.model.basic.CKeyParent; import com.avaje.tests.model.basic.CKeyParentId; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestCKeyLazyLoad extends BaseTestCase { @@ -59,7 +58,7 @@ public class TestCKeyLazyLoad extends BaseTestCase { CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findUnique(); Assert.assertNotNull(found); - Assert.assertEquals(2,found.getDetails().size()); + Assert.assertEquals(2, found.getDetails().size()); List list = Ebean.find(CKeyParent.class).findList(); @@ -89,9 +88,9 @@ public class TestCKeyLazyLoad extends BaseTestCase { private void exerciseMaxRowsQuery_with_embeddedId() { PagedList siteUserPage = Ebean.find(CKeyParent.class).where() - .orderBy("name asc") - .setMaxRows(10) - .findPagedList(); + .orderBy("name asc") + .setMaxRows(10) + .findPagedList(); siteUserPage.getList(); } } diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCaoCompositeKeyWithAnnotationOverrides.java b/src/test/java/com/avaje/tests/compositekeys/TestCaoCompositeKeyWithAnnotationOverrides.java index af4036962..e4795aab2 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCaoCompositeKeyWithAnnotationOverrides.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCaoCompositeKeyWithAnnotationOverrides.java @@ -1,11 +1,10 @@ package com.avaje.tests.compositekeys; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.compositekeys.db.CaoBean; import com.avaje.tests.compositekeys.db.CaoKey; +import org.junit.Test; public class TestCaoCompositeKeyWithAnnotationOverrides extends BaseTestCase { @@ -17,12 +16,12 @@ public class TestCaoCompositeKeyWithAnnotationOverrides extends BaseTestCase { CaoKey key = new CaoKey(); key.setCustomer(123); key.setType(1); - + CaoBean bean = new CaoBean(); bean.setKey(key); bean.setDescription("some desc"); Ebean.save(bean); } - + } diff --git a/src/test/java/com/avaje/tests/compositekeys/TestCore.java b/src/test/java/com/avaje/tests/compositekeys/TestCore.java index 6b3bab57d..5c4e7f302 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestCore.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestCore.java @@ -3,7 +3,14 @@ package com.avaje.tests.compositekeys; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; -import com.avaje.tests.compositekeys.db.*; +import com.avaje.tests.compositekeys.db.Item; +import com.avaje.tests.compositekeys.db.ItemKey; +import com.avaje.tests.compositekeys.db.Region; +import com.avaje.tests.compositekeys.db.RegionKey; +import com.avaje.tests.compositekeys.db.SubType; +import com.avaje.tests.compositekeys.db.SubTypeKey; +import com.avaje.tests.compositekeys.db.Type; +import com.avaje.tests.compositekeys.db.TypeKey; import com.avaje.tests.lib.EbeanTestCase; import java.util.List; @@ -158,4 +165,4 @@ public class TestCore extends EbeanTestCase { assertNotNull(items); assertEquals(2, items.size()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java index c425d7f9e..eeefced8d 100644 --- a/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java +++ b/src/test/java/com/avaje/tests/compositekeys/TestOnCascadeDeleteChildrenWithCompositeKeys.java @@ -8,7 +8,15 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; import org.junit.Before; import org.junit.Test; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Embeddable; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -22,8 +30,8 @@ import static org.junit.Assert.assertEquals; public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { - - @Before public void before() { + @Before + public void before() { if (isMsSqlServer()) return; @@ -38,7 +46,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { /** * work fine when delete User one by one */ - @Test public void testDeleteById() { + @Test + public void testDeleteById() { if (isMsSqlServer()) return; @@ -52,7 +61,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { * Wrong SQL is generated when deleting user by list of ID * SQL generated: delete from user_role where (user_id) in ((?,?),(?,?)) */ - @Test public void testDeleteByIdList() { + @Test + public void testDeleteByIdList() { if (isMsSqlServer()) return; @@ -64,20 +74,20 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { Ebean.deleteAll(User.class, ids); // PersistenceException would be thrown here assertEquals(0, Ebean.find(User.class).findList().size()); } - + @Test public void testFindByParentIdList() { if (isMsSqlServer()) return; assertEquals(2, Ebean.find(User.class).findList().size()); - - SpiEbeanServer spiServer = (SpiEbeanServer)Ebean.getServer(null); - - BeanDescriptor beanDescriptor = - spiServer.getBeanDescriptor(TestOnCascadeDeleteChildrenWithCompositeKeys.User.class); - - BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany)beanDescriptor.getBeanProperty("userRoles"); + + SpiEbeanServer spiServer = (SpiEbeanServer) Ebean.getServer(null); + + BeanDescriptor beanDescriptor = + spiServer.getBeanDescriptor(TestOnCascadeDeleteChildrenWithCompositeKeys.User.class); + + BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany) beanDescriptor.getBeanProperty("userRoles"); List ids = new ArrayList<>(); ids.add(1L); @@ -87,18 +97,22 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { beanProperty.findIdsByParentId(1L, null, null, null); } - @Entity @Table(name = "em_user") public static class User { + @Entity + @Table(name = "em_user") + public static class User { private Long id; private String name; private Set userRoles; - public User() {} + public User() { + } public User(Long id) { this.id = id; } - @Id public Long getId() { + @Id + public Long getId() { return id; } @@ -114,7 +128,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.name = name; } - @OneToMany(cascade = CascadeType.REMOVE) public Set getUserRoles() { + @OneToMany(cascade = CascadeType.REMOVE) + public Set getUserRoles() { return userRoles; } @@ -123,13 +138,16 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { } } - @Entity @Table(name = "em_user_role") public static class UserRole implements Serializable { + @Entity + @Table(name = "em_user_role") + public static class UserRole implements Serializable { private static final long serialVersionUID = 1L; private UserRolePK pk; private User user; private Role role; - @EmbeddedId public UserRolePK getPk() { + @EmbeddedId + public UserRolePK getPk() { return pk; } @@ -137,7 +155,9 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.pk = pk; } - @ManyToOne @JoinColumn(name = "user_id", nullable = false, insertable = false, updatable = false) public User getUser() { + @ManyToOne + @JoinColumn(name = "user_id", nullable = false, insertable = false, updatable = false) + public User getUser() { return user; } @@ -145,7 +165,9 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.user = user; } - @ManyToOne @JoinColumn(name = "role_id", nullable = false, insertable = false, updatable = false) public Role getRole() { + @ManyToOne + @JoinColumn(name = "role_id", nullable = false, insertable = false, updatable = false) + public Role getRole() { return role; } @@ -153,16 +175,19 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.role = role; } - @Embeddable public static class UserRolePK implements Serializable { + @Embeddable + public static class UserRolePK implements Serializable { private static final long serialVersionUID = 1L; private Long userId; private Long roleId; - @Override public int hashCode() { + @Override + public int hashCode() { return userId == null || roleId == null ? 0 : (int) (userId + roleId); } - @Override public boolean equals(Object other) { + @Override + public boolean equals(Object other) { if (userId == null || roleId == null) return false; if (other instanceof UserRolePK) { UserRolePK otherPk = (UserRolePK) other; @@ -189,12 +214,15 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { } } - @Entity @Table(name = "em_role") public static class Role { + @Entity + @Table(name = "em_role") + public static class Role { private Long id; private String name; private Set userRoles; - @Id public Long getId() { + @Id + public Long getId() { return id; } @@ -210,7 +238,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.name = name; } - @OneToMany(cascade = CascadeType.REMOVE) public Set getUserRoles() { + @OneToMany(cascade = CascadeType.REMOVE) + public Set getUserRoles() { return userRoles; } @@ -218,4 +247,4 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase { this.userRoles = userRoles; } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/AuditInfo.java b/src/test/java/com/avaje/tests/compositekeys/db/AuditInfo.java index b07a40b1f..1986bb26c 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/AuditInfo.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/AuditInfo.java @@ -1,60 +1,49 @@ package com.avaje.tests.compositekeys.db; +import javax.persistence.Embeddable; import java.util.Date; -import javax.persistence.Embeddable; - @Embeddable -public class AuditInfo -{ - private Date lastUpdated; - private Date created; - private String updatedBy; - private String createdBy; +public class AuditInfo { + private Date lastUpdated; + private Date created; + private String updatedBy; + private String createdBy; - public AuditInfo() - { - created = new Date(); - createdBy = "dummy"; - } + public AuditInfo() { + created = new Date(); + createdBy = "dummy"; + } - public Date getLastUpdated() - { - return lastUpdated; - } + public Date getLastUpdated() { + return lastUpdated; + } - public void setLastUpdated(Date lastUpdated) - { - this.lastUpdated = lastUpdated; - } + public void setLastUpdated(Date lastUpdated) { + this.lastUpdated = lastUpdated; + } - public Date getCreated() - { - return created; - } + public Date getCreated() { + return created; + } - public void setCreated(Date created) - { - this.created = created; - } + public void setCreated(Date created) { + this.created = created; + } - public String getUpdatedBy() - { - return updatedBy; - } + public String getUpdatedBy() { + return updatedBy; + } - public void setUpdatedBy(String updatedBy) - { - this.updatedBy = updatedBy; - } + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } - public String getCreatedBy() - { - return createdBy; - } + public String getCreatedBy() { + return createdBy; + } - public void setCreatedBy(String createdBy) - { - this.createdBy = createdBy; - } + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } } diff --git a/src/test/java/com/avaje/tests/compositekeys/db/CaoBean.java b/src/test/java/com/avaje/tests/compositekeys/db/CaoBean.java index 647640d93..2d46b86a4 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/CaoBean.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/CaoBean.java @@ -11,9 +11,9 @@ import javax.persistence.Version; public class CaoBean { @Id - @AttributeOverrides({ - @AttributeOverride(name = "customer", column = @Column(name = "x_cust_id")) , - @AttributeOverride(name = "type", column = @Column(name = "x_type_id")) + @AttributeOverrides({ + @AttributeOverride(name = "customer", column = @Column(name = "x_cust_id")), + @AttributeOverride(name = "type", column = @Column(name = "x_type_id")) }) private CaoKey key; @@ -46,4 +46,4 @@ public class CaoBean { this.version = version; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/CaoKey.java b/src/test/java/com/avaje/tests/compositekeys/db/CaoKey.java index 2bb97b72e..6a32dadc9 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/CaoKey.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/CaoKey.java @@ -3,42 +3,41 @@ package com.avaje.tests.compositekeys.db; import javax.persistence.Embeddable; @Embeddable -public class CaoKey -{ - private int customer; +public class CaoKey { + private int customer; - private int type; + private int type; - public int getCustomer() { - return customer; - } + public int getCustomer() { + return customer; + } - public void setCustomer(int customer) { - this.customer = customer; - } + public void setCustomer(int customer) { + this.customer = customer; + } - public int getType() { - return type; - } + public int getType() { + return type; + } - public void setType(int type) { - this.type = type; + public void setType(int type) { + this.type = type; + } + + public int hashCode() { + int hc = 31 * 7 + customer; + hc = 31 * hc + type; + return hc; + } + + public boolean equals(Object o) { + if (this == o) { + return true; } - - public int hashCode() { - int hc = 31 * 7 + customer; - hc = 31 * hc + type; - return hc; + if (o instanceof CaoKey) { + CaoKey k = (CaoKey) o; + return k.customer == customer && k.type == type; } - - public boolean equals(Object o){ - if (this == o){ - return true; - } - if (o instanceof CaoKey){ - CaoKey k = (CaoKey)o; - return k.customer == customer && k.type == type; - } - return false; - } -} \ No newline at end of file + return false; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/Item.java b/src/test/java/com/avaje/tests/compositekeys/db/Item.java index 64537cf8d..972485d0d 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/Item.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/Item.java @@ -12,116 +12,109 @@ import javax.persistence.ManyToOne; import javax.persistence.Version; @Entity -public class Item -{ - @Id - private ItemKey key; +public class Item { + @Id + private ItemKey key; - private String description; + private String description; - private String units; + private String units; - private int type; + private int type; - private int region; + private int region; - @Embedded - @AttributeOverrides({ - @AttributeOverride(name = "lastUpdated", column = @Column(name = "DATE_MODIFIED")), - @AttributeOverride(name = "created", column = @Column(name = "DATE_CREATED")), - @AttributeOverride(name = "updatedBy", column = @Column(name = "MODIFIED_BY")), - @AttributeOverride(name = "createdBy", column = @Column(name = "CREATED_BY")) - }) - private AuditInfo auditInfo = new AuditInfo(); + @Embedded + @AttributeOverrides({ + @AttributeOverride(name = "lastUpdated", column = @Column(name = "DATE_MODIFIED")), + @AttributeOverride(name = "created", column = @Column(name = "DATE_CREATED")), + @AttributeOverride(name = "updatedBy", column = @Column(name = "MODIFIED_BY")), + @AttributeOverride(name = "createdBy", column = @Column(name = "CREATED_BY")) + }) + private AuditInfo auditInfo = new AuditInfo(); - @Version - private Long version; + @Version + private Long version; - @ManyToOne - @JoinColumns({ - @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), - @JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false) - }) - private Type eType; + @ManyToOne + @JoinColumns({ + @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), + @JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false) + }) + private Type eType; - @ManyToOne - @JoinColumns({ - @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), - @JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false) - }) - private Region eRegion; + @ManyToOne + @JoinColumns({ + @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), + @JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false) + }) + private Region eRegion; - public ItemKey getKey() { - return key; - } + public ItemKey getKey() { + return key; + } - public void setKey(ItemKey key) { - this.key = key; - } + public void setKey(ItemKey key) { + this.key = key; + } - public String getUnits() - { - return units; - } + public String getUnits() { + return units; + } - public void setUnits(String units) - { - this.units = units; - } + public void setUnits(String units) { + this.units = units; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public int getType() { - return type; - } + public int getType() { + return type; + } - public void setType(int type) { - this.type = type; - } + public void setType(int type) { + this.type = type; + } - public int getRegion() { - return region; - } + public int getRegion() { + return region; + } - public void setRegion(int region) { - this.region = region; - } + public void setRegion(int region) { + this.region = region; + } - public Long getVersion() { - return version; - } + public Long getVersion() { + return version; + } - public Type getEType() { - return eType; - } + public Type getEType() { + return eType; + } - public Region getERegion() { - return eRegion; - } + public Region getERegion() { + return eRegion; + } - public void setVersion(Long version) - { - this.version = version; - } + public void setVersion(Long version) { + this.version = version; + } - public void setEType(Type eType) - { - this.eType = eType; - } + public void setEType(Type eType) { + this.eType = eType; + } - public void setERegion(Region eRegion) - { - this.eRegion = eRegion; - } + public void setERegion(Region eRegion) { + this.eRegion = eRegion; + } - public AuditInfo getAuditInfo() - { - return auditInfo; - } + public AuditInfo getAuditInfo() { + return auditInfo; + } } diff --git a/src/test/java/com/avaje/tests/compositekeys/db/ItemKey.java b/src/test/java/com/avaje/tests/compositekeys/db/ItemKey.java index 34cf782d2..01a4cb07d 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/ItemKey.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/ItemKey.java @@ -4,60 +4,53 @@ import javax.persistence.Column; import javax.persistence.Embeddable; @Embeddable -public class ItemKey -{ - private int customer; +public class ItemKey { + private int customer; - @Column(name = "itemNumber") - private String itemNumber; + @Column(name = "itemNumber") + private String itemNumber; - public int getCustomer() { - return customer; + public int getCustomer() { + return customer; + } + + public void setCustomer(int customer) { + this.customer = customer; + } + + public String getItemNumber() { + return itemNumber; + } + + public void setItemNumber(String itemNumber) { + this.itemNumber = itemNumber; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ItemKey)) { + return false; } - public void setCustomer(int customer) { - this.customer = customer; + ItemKey itemKey = (ItemKey) o; + + if (customer != itemKey.customer) { + return false; + } + if (!itemNumber.equals(itemKey.itemNumber)) { + return false; } - public String getItemNumber() { - return itemNumber; - } + return true; + } - public void setItemNumber(String itemNumber) { - this.itemNumber = itemNumber; - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (!(o instanceof ItemKey)) - { - return false; - } - - ItemKey itemKey = (ItemKey) o; - - if (customer != itemKey.customer) - { - return false; - } - if (!itemNumber.equals(itemKey.itemNumber)) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = customer; - result = 31 * result + itemNumber.hashCode(); - return result; - } + @Override + public int hashCode() { + int result = customer; + result = 31 * result + itemNumber.hashCode(); + return result; + } } diff --git a/src/test/java/com/avaje/tests/compositekeys/db/Parcel.java b/src/test/java/com/avaje/tests/compositekeys/db/Parcel.java index d1688ac38..6d6a0e655 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/Parcel.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/Parcel.java @@ -5,31 +5,26 @@ import javax.persistence.Entity; import javax.persistence.Id; @Entity -public class Parcel -{ - @Id - @Column(name="parcelId") - private Long parcelId; +public class Parcel { + @Id + @Column(name = "parcelId") + private Long parcelId; - private String description; + private String description; - public Long getParcelId() - { - return parcelId; - } + public Long getParcelId() { + return parcelId; + } - public void setParcelId(Long parcelId) - { - this.parcelId = parcelId; - } + public void setParcelId(Long parcelId) { + this.parcelId = parcelId; + } - public String getDescription() - { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) - { - this.description = description; - } -} \ No newline at end of file + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/ParcelLocation.java b/src/test/java/com/avaje/tests/compositekeys/db/ParcelLocation.java index d0045eb9f..7671e1157 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/ParcelLocation.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/ParcelLocation.java @@ -7,46 +7,39 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; @Entity -public class ParcelLocation -{ - @Id - @Column(name="parcelLocId") - private Long parcelLocId; +public class ParcelLocation { + @Id + @Column(name = "parcelLocId") + private Long parcelLocId; - private String location; + private String location; - @OneToOne - @JoinColumn(name="parcelId", referencedColumnName = "parcelId") - private Parcel parcel; + @OneToOne + @JoinColumn(name = "parcelId", referencedColumnName = "parcelId") + private Parcel parcel; - public Long getParcelLocId() - { - return parcelLocId; - } + public Long getParcelLocId() { + return parcelLocId; + } - public void setParcelLocId(Long parcelLocId) - { - this.parcelLocId = parcelLocId; - } + public void setParcelLocId(Long parcelLocId) { + this.parcelLocId = parcelLocId; + } - public String getLocation() - { - return location; - } + public String getLocation() { + return location; + } - public void setLocation(String location) - { - this.location = location; - } + public void setLocation(String location) { + this.location = location; + } - public Parcel getParcel() - { - return parcel; - } + public Parcel getParcel() { + return parcel; + } - public void setParcel(Parcel parcel) - { - this.parcel = parcel; - } + public void setParcel(Parcel parcel) { + this.parcel = parcel; + } } diff --git a/src/test/java/com/avaje/tests/compositekeys/db/Region.java b/src/test/java/com/avaje/tests/compositekeys/db/Region.java index 2b39aa47e..6d65c9005 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/Region.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/Region.java @@ -1,57 +1,55 @@ package com.avaje.tests.compositekeys.db; -import java.util.List; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.OneToMany; import javax.persistence.Version; +import java.util.List; @Entity -public class Region -{ - @Id - private RegionKey key; +public class Region { + @Id + private RegionKey key; - private String description; + private String description; - @Version - private Long version; + @Version + private Long version; - @OneToMany - @JoinColumns({ - @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), - @JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false) - }) - private List items; - - public RegionKey getKey() { - return key; - } + @OneToMany + @JoinColumns({ + @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), + @JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false) + }) + private List items; - public void setKey(RegionKey key) { - this.key = key; - } + public RegionKey getKey() { + return key; + } - public String getDescription() { - return description; - } + public void setKey(RegionKey key) { + this.key = key; + } - public void setDescription(String description) { - this.description = description; - } + public String getDescription() { + return description; + } - public Long getVersion() { - return version; - } + public void setDescription(String description) { + this.description = description; + } - public void setVersion(Long version) { - this.version = version; - } + public Long getVersion() { + return version; + } - public List getItems() { - return items; - } -} \ No newline at end of file + public void setVersion(Long version) { + this.version = version; + } + + public List getItems() { + return items; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/RegionKey.java b/src/test/java/com/avaje/tests/compositekeys/db/RegionKey.java index 1b7f4c795..263ebc044 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/RegionKey.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/RegionKey.java @@ -3,42 +3,41 @@ package com.avaje.tests.compositekeys.db; import javax.persistence.Embeddable; @Embeddable -public class RegionKey -{ - private int customer; +public class RegionKey { + private int customer; - private int type; + private int type; - public int getCustomer() { - return customer; - } + public int getCustomer() { + return customer; + } - public void setCustomer(int customer) { - this.customer = customer; - } + public void setCustomer(int customer) { + this.customer = customer; + } - public int getType() { - return type; - } + public int getType() { + return type; + } - public void setType(int type) { - this.type = type; + public void setType(int type) { + this.type = type; + } + + public int hashCode() { + int hc = 31 * 7 + customer; + hc = 31 * hc + type; + return hc; + } + + public boolean equals(Object o) { + if (this == o) { + return true; } - - public int hashCode() { - int hc = 31 * 7 + customer; - hc = 31 * hc + type; - return hc; + if (o instanceof RegionKey) { + RegionKey k = (RegionKey) o; + return k.customer == customer && k.type == type; } - - public boolean equals(Object o){ - if (this == o){ - return true; - } - if (o instanceof RegionKey){ - RegionKey k = (RegionKey)o; - return k.customer == customer && k.type == type; - } - return false; - } -} \ No newline at end of file + return false; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/SubType.java b/src/test/java/com/avaje/tests/compositekeys/db/SubType.java index 6a4adf26b..73fa69912 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/SubType.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/SubType.java @@ -5,37 +5,36 @@ import javax.persistence.Entity; import javax.persistence.Version; @Entity -public class SubType -{ - @EmbeddedId - private SubTypeKey key; +public class SubType { + @EmbeddedId + private SubTypeKey key; - private String description; + private String description; - @Version - private Long version; + @Version + private Long version; - public SubTypeKey getKey() { - return key; - } + public SubTypeKey getKey() { + return key; + } - public void setKey(SubTypeKey key) { - this.key = key; - } + public void setKey(SubTypeKey key) { + this.key = key; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Long getVersion() { - return version; - } + public Long getVersion() { + return version; + } - public void setVersion(Long version) { - this.version = version; - } -} \ No newline at end of file + public void setVersion(Long version) { + this.version = version; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/SubTypeKey.java b/src/test/java/com/avaje/tests/compositekeys/db/SubTypeKey.java index 4ebc5ca27..a732ca06f 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/SubTypeKey.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/SubTypeKey.java @@ -3,32 +3,29 @@ package com.avaje.tests.compositekeys.db; import javax.persistence.Embeddable; @Embeddable -public class SubTypeKey -{ - private int subTypeId; +public class SubTypeKey { + private int subTypeId; - public int getSubTypeId() - { - return subTypeId; - } + public int getSubTypeId() { + return subTypeId; + } - public void setSubTypeId(int subTypeId) - { - this.subTypeId = subTypeId; - } - - public int hashCode() { - return 31 * 7 + subTypeId; - } - - public boolean equals(Object o){ - if (this == o){ - return true; - } - if (!(o instanceof SubTypeKey)) { - return false; - } - return subTypeId == ((SubTypeKey)o).subTypeId; - } - -} \ No newline at end of file + public void setSubTypeId(int subTypeId) { + this.subTypeId = subTypeId; + } + + public int hashCode() { + return 31 * 7 + subTypeId; + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof SubTypeKey)) { + return false; + } + return subTypeId == ((SubTypeKey) o).subTypeId; + } + +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/Type.java b/src/test/java/com/avaje/tests/compositekeys/db/Type.java index 135259bc5..8d818ce16 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/Type.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/Type.java @@ -1,7 +1,5 @@ package com.avaje.tests.compositekeys.db; -import java.util.List; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -9,61 +7,61 @@ import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Version; +import java.util.List; @Entity -public class Type -{ - @Id - private TypeKey key; +public class Type { + @Id + private TypeKey key; - private String description; + private String description; - @Version - private Long version; + @Version + private Long version; - @OneToMany - @JoinColumns({ - @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), - @JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false) - }) - private List items; + @OneToMany + @JoinColumns({ + @JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false), + @JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false) + }) + private List items; - @ManyToOne - private SubType subType; + @ManyToOne + private SubType subType; - public TypeKey getKey() { - return key; - } + public TypeKey getKey() { + return key; + } - public void setKey(TypeKey key) { - this.key = key; - } + public void setKey(TypeKey key) { + this.key = key; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Long getVersion() { - return version; - } + public Long getVersion() { + return version; + } - public void setVersion(Long version) { - this.version = version; - } + public void setVersion(Long version) { + this.version = version; + } - public List getItems() { - return items; - } + public List getItems() { + return items; + } - public SubType getSubType() { - return subType; - } + public SubType getSubType() { + return subType; + } - public void setSubType(SubType subType) { - this.subType = subType; - } -} \ No newline at end of file + public void setSubType(SubType subType) { + this.subType = subType; + } +} diff --git a/src/test/java/com/avaje/tests/compositekeys/db/TypeKey.java b/src/test/java/com/avaje/tests/compositekeys/db/TypeKey.java index 06ce60478..9963b5196 100644 --- a/src/test/java/com/avaje/tests/compositekeys/db/TypeKey.java +++ b/src/test/java/com/avaje/tests/compositekeys/db/TypeKey.java @@ -3,42 +3,41 @@ package com.avaje.tests.compositekeys.db; import javax.persistence.Embeddable; @Embeddable -public class TypeKey -{ - private int customer; +public class TypeKey { + private int customer; - private int type; + private int type; - public int getCustomer() { - return customer; - } + public int getCustomer() { + return customer; + } - public void setCustomer(int customer) { - this.customer = customer; - } + public void setCustomer(int customer) { + this.customer = customer; + } - public int getType() { - return type; - } + public int getType() { + return type; + } - public void setType(int type) { - this.type = type; + public void setType(int type) { + this.type = type; + } + + public int hashCode() { + int hc = 31 + customer; + hc = hc * 31 + type; + return hc; + } + + public boolean equals(Object o) { + if (this == o) { + return true; } - - public int hashCode() { - int hc = 31+customer; - hc = hc * 31 + type; - return hc; + if (o instanceof TypeKey) { + TypeKey k = (TypeKey) o; + return k.customer == customer && k.type == type; } - - public boolean equals(Object o){ - if (this == o){ - return true; - } - if (o instanceof TypeKey){ - TypeKey k = (TypeKey)o; - return k.customer == customer && k.type == type; - } - return false; - } -} \ No newline at end of file + return false; + } +} diff --git a/src/test/java/com/avaje/tests/config/TestTableName.java b/src/test/java/com/avaje/tests/config/TestTableName.java index a1ba89548..196691fd8 100644 --- a/src/test/java/com/avaje/tests/config/TestTableName.java +++ b/src/test/java/com/avaje/tests/config/TestTableName.java @@ -1,31 +1,30 @@ package com.avaje.tests.config; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.config.TableName; +import org.junit.Assert; +import org.junit.Test; public class TestTableName extends BaseTestCase { @Test - public void test() { - - TableName t = new TableName("a"); - Assert.assertEquals("a", t.getName()); - Assert.assertNull(t.getCatalog()); - Assert.assertNull(t.getSchema()); + public void test() { - t = new TableName("b.a"); - Assert.assertEquals("a", t.getName()); - Assert.assertEquals("b", t.getSchema()); - Assert.assertNull(t.getCatalog()); + TableName t = new TableName("a"); + Assert.assertEquals("a", t.getName()); + Assert.assertNull(t.getCatalog()); + Assert.assertNull(t.getSchema()); + + t = new TableName("b.a"); + Assert.assertEquals("a", t.getName()); + Assert.assertEquals("b", t.getSchema()); + Assert.assertNull(t.getCatalog()); + + t = new TableName("c.b.a"); + Assert.assertEquals("a", t.getName()); + Assert.assertEquals("b", t.getSchema()); + Assert.assertEquals("c", t.getCatalog()); - t = new TableName("c.b.a"); - Assert.assertEquals("a", t.getName()); - Assert.assertEquals("b", t.getSchema()); - Assert.assertEquals("c", t.getCatalog()); - // try { // TableName t2 = new TableName("d.c.b.a"); // Assert.assertNotNull(t2); @@ -33,16 +32,16 @@ public class TestTableName extends BaseTestCase { // } catch (RuntimeException e){ // Assert.assertTrue(true); // } - - + + // TableName lhs = new TableName("test.oe_order"); // TableName rhs = new TableName("test.oe_cust"); -// +// // UnderscoreNamingConvention nc = new UnderscoreNamingConvention(); // TableName intTab = nc.getM2MJoinTableName(lhs, rhs); -// +// // Assert.assertNull(intTab.getCatalog()); // Assert.assertEquals("test", intTab.getSchema()); // Assert.assertEquals("oe_order_cust", intTab.getName()); - } + } } diff --git a/src/test/java/com/avaje/tests/contructor/TestProtectedConstructor.java b/src/test/java/com/avaje/tests/contructor/TestProtectedConstructor.java index 4983a7140..668ab67a5 100644 --- a/src/test/java/com/avaje/tests/contructor/TestProtectedConstructor.java +++ b/src/test/java/com/avaje/tests/contructor/TestProtectedConstructor.java @@ -1,38 +1,37 @@ package com.avaje.tests.contructor; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.bean.EntityBean; import com.avaje.tests.model.basic.MProtectedConstructBean; +import org.junit.Assert; +import org.junit.Test; public class TestProtectedConstructor extends BaseTestCase { @Test public void test() { - + EbeanServer server = Ebean.getServer(null); - + // check that we can construc a bean with a protected constructor MProtectedConstructBean bean = server.createEntityBean(MProtectedConstructBean.class); Assert.assertNotNull(bean); // Note1 that the enhancement ClassAdapterEntity line 239 makes a default constructor publically accessible // Note2 the ClassAdpater will call DefaultConstructor.add() to add a default constructor if it doesn't exist - - - EntityBean entityBean = (EntityBean)bean; + + + EntityBean entityBean = (EntityBean) bean; Object newBeanInstance = entityBean._ebean_newInstance(); - + Assert.assertNotNull(newBeanInstance); BeanState beanState = Ebean.getBeanState(newBeanInstance); Assert.assertTrue(beanState.isNew()); Assert.assertNotSame(entityBean, newBeanInstance); - + } - + } diff --git a/src/test/java/com/avaje/tests/ddd/iud/TestDExhEntityEl.java b/src/test/java/com/avaje/tests/ddd/iud/TestDExhEntityEl.java index a2ca49cfd..5510a7e44 100644 --- a/src/test/java/com/avaje/tests/ddd/iud/TestDExhEntityEl.java +++ b/src/test/java/com/avaje/tests/ddd/iud/TestDExhEntityEl.java @@ -4,48 +4,48 @@ import junit.framework.TestCase; public class TestDExhEntityEl extends TestCase { - public void test() { - + public void test() { + // GlobalProperties.put("classes", DExhEntity.class.toString()); - + // Currency NZD = Currency.getInstance("NZD"); -// +// // CMoney cm = new CMoney(new Money("12"), NZD); -// +// // Rate rate = new Rate(0.1); // ExhangeCMoneyRate exh = new ExhangeCMoneyRate(rate, cm); -// +// // DExhEntity p = new DExhEntity(); // p.setExhange(exh); -// +// // SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); -// +// // BeanDescriptor descriptor = server.getBeanDescriptor(DExhEntity.class); -// +// // ElPropertyValue elExh = descriptor.getElGetValue("exhange"); // ElPropertyValue elExhRate = descriptor.getElGetValue("exhange.rate"); // ElPropertyValue elExhCMoney = descriptor.getElGetValue("exhange.cmoney"); // ElPropertyValue elExhCMoneyCur = descriptor.getElGetValue("exhange.cmoney.currency"); // ElPropertyValue elExhCMoneyAmt = descriptor.getElGetValue("exhange.cmoney.amount"); -// +// // EntityBean entityBean = (EntityBean)p; // Object e = elExh.elGetValue(entityBean); // Object er = elExhRate.elGetValue(entityBean); // Object ecm = elExhCMoney.elGetValue(entityBean); // Object ecmCurr = elExhCMoneyCur.elGetValue(entityBean); // Object ecmAmt = elExhCMoneyAmt.elGetValue(entityBean); -// +// // Assert.assertNotNull(e); // Assert.assertNotNull(er); // Assert.assertNotNull(ecm); -// +// // Assert.assertEquals(new Rate("0.1"), er); // Assert.assertEquals(NZD, ecmCurr); // Assert.assertEquals(new Money("12"), ecmAmt); -// +// // p.setExhange(null); // Assert.assertNull(p.getExhange()); -// +// // // won't trigger CMoney build as not all properties // // have been set yet... // elExhCMoneyAmt.elSetValue(entityBean, new Money("13"), true, false); @@ -60,6 +60,6 @@ public class TestDExhEntityEl extends TestCase { // // the compound object have been collected // Assert.assertNotNull(p.getExhange()); - } - + } + } diff --git a/src/test/java/com/avaje/tests/ddd/iud/TestDPersonEl.java b/src/test/java/com/avaje/tests/ddd/iud/TestDPersonEl.java index 7d91b8be9..35825ceda 100644 --- a/src/test/java/com/avaje/tests/ddd/iud/TestDPersonEl.java +++ b/src/test/java/com/avaje/tests/ddd/iud/TestDPersonEl.java @@ -14,9 +14,7 @@ import org.junit.Test; import java.io.IOException; import java.util.Currency; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class TestDPersonEl { diff --git a/src/test/java/com/avaje/tests/ddd/iud/TestDPersonIUD.java b/src/test/java/com/avaje/tests/ddd/iud/TestDPersonIUD.java index 1b128dd46..f08ecd836 100644 --- a/src/test/java/com/avaje/tests/ddd/iud/TestDPersonIUD.java +++ b/src/test/java/com/avaje/tests/ddd/iud/TestDPersonIUD.java @@ -4,47 +4,47 @@ import junit.framework.TestCase; public class TestDPersonIUD extends TestCase { - - public void test() { - + + public void test() { + // GlobalProperties.put("classes", DPerson.class.toString()); - + // Currency NZD = Currency.getInstance("NZD"); -// +// // DPerson p = new DPerson(); // p.setFirstName("first"); // p.setLastName("last"); // p.setSalary(new Money("12200")); // p.setCmoney(new CMoney(new Money("12"), NZD)); -// +// // p.setInterval(new Interval(System.currentTimeMillis()-20000, System.currentTimeMillis())); -// +// // Ebean.save(p); -// +// // Oid id = p.getId(); // Assert.assertNotNull(id); -// +// // DPerson p2 = Ebean.find(DPerson.class) // .setAutoTune(false) // .where().idEq(id) // .findUnique(); -// +// // Assert.assertNotNull(p2); // System.out.println(p2); // Assert.assertEquals(new Money(12200d), p2.getSalary()); // Assert.assertNotNull(p2.getCmoney()); // Assert.assertEquals(new Money("12"), p2.getCmoney().getAmount()); // Assert.assertEquals(NZD, p2.getCmoney().getCurrency()); -// -// +// +// // Query query = Ebean.find(DPerson.class) // .setAutoTune(false) // .where().gt("cmoney.amount",1) // .query(); -// +// // List list = query.findList(); // Assert.assertTrue(list.size() >= 1); - - - } + + + } } diff --git a/src/test/java/com/avaje/tests/ddl/MainDdlWithSchema.java b/src/test/java/com/avaje/tests/ddl/MainDdlWithSchema.java index fcfac1def..87cecce69 100644 --- a/src/test/java/com/avaje/tests/ddl/MainDdlWithSchema.java +++ b/src/test/java/com/avaje/tests/ddl/MainDdlWithSchema.java @@ -7,21 +7,21 @@ import com.avaje.tests.model.basic.EBasic; public class MainDdlWithSchema { - public static void main(String[] args) { + public static void main(String[] args) { - ServerConfig cfg = new ServerConfig(); - cfg.setName("h2"); - cfg.loadFromProperties(); - cfg.addClass(EBasic.class); + ServerConfig cfg = new ServerConfig(); + cfg.setName("h2"); + cfg.loadFromProperties(); + cfg.addClass(EBasic.class); - // .... other settings ... - //UnderscoreNamingConvention naming = new UnderscoreNamingConvention(); - //naming.setSchema("test"); - //cfg.setNamingConvention(naming); - cfg.setDdlGenerate(true); - cfg.setDdlRun(true); - EbeanServer ebean = EbeanServerFactory.create(cfg); - //ebean.createSqlUpdate("create schema foo").execute(); - System.out.println(ebean); - } + // .... other settings ... + //UnderscoreNamingConvention naming = new UnderscoreNamingConvention(); + //naming.setSchema("test"); + //cfg.setNamingConvention(naming); + cfg.setDdlGenerate(true); + cfg.setDdlRun(true); + EbeanServer ebean = EbeanServerFactory.create(cfg); + //ebean.createSqlUpdate("create schema foo").execute(); + System.out.println(ebean); + } } diff --git a/src/test/java/com/avaje/tests/delete/TestDeleteByIdWithPersistenceContext.java b/src/test/java/com/avaje/tests/delete/TestDeleteByIdWithPersistenceContext.java index d6aaaa490..9cf9172fa 100644 --- a/src/test/java/com/avaje/tests/delete/TestDeleteByIdWithPersistenceContext.java +++ b/src/test/java/com/avaje/tests/delete/TestDeleteByIdWithPersistenceContext.java @@ -1,15 +1,14 @@ package com.avaje.tests.delete; -import java.util.Arrays; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.tests.model.basic.Product; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; public class TestDeleteByIdWithPersistenceContext extends BaseTestCase { @@ -24,34 +23,34 @@ public class TestDeleteByIdWithPersistenceContext extends BaseTestCase { Ebean.delete(Product.class, 101); EbeanServer server = Ebean.getServer(null); - Product prod1 = createProduct(100,"apples"); + Product prod1 = createProduct(100, "apples"); server.insert(prod1); Product prod2 = createProduct(101, "bananas"); server.insert(prod2); - + server.beginTransaction(); // effectively load these into the persistence context server.find(Product.class, prod1.getId()); server.find(Product.class, prod2.getId()); - + server.deleteAll(Product.class, Arrays.asList(prod1.getId(), prod2.getId())); - + // are these found in the persistence context? Product shadow1 = server.find(Product.class, prod1.getId()); Product shadow2 = server.find(Product.class, prod2.getId()); - + Assert.assertNull(shadow1); Assert.assertNull(shadow2); - + server.endTransaction(); - + } - + private Product createProduct(Integer id, String name) { Product prod = new Product(); prod.setId(id); prod.setName(name); return prod; } - + } diff --git a/src/test/java/com/avaje/tests/delete/TestDeleteByQuery.java b/src/test/java/com/avaje/tests/delete/TestDeleteByQuery.java index b1963b0ba..1998bcb34 100644 --- a/src/test/java/com/avaje/tests/delete/TestDeleteByQuery.java +++ b/src/test/java/com/avaje/tests/delete/TestDeleteByQuery.java @@ -57,9 +57,9 @@ public class TestDeleteByQuery extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Customer.class) - .where().eq("name","Don Roberto") - .query().setForUpdate(true) - .delete(); + .where().eq("name", "Don Roberto") + .query().setForUpdate(true) + .delete(); List sql = LoggedSqlCollector.stop(); assertThat(sql).hasSize(1); diff --git a/src/test/java/com/avaje/tests/draftable/DocLinkTest.java b/src/test/java/com/avaje/tests/draftable/DocLinkTest.java index d5fe60989..67a11b18c 100644 --- a/src/test/java/com/avaje/tests/draftable/DocLinkTest.java +++ b/src/test/java/com/avaje/tests/draftable/DocLinkTest.java @@ -28,9 +28,9 @@ public class DocLinkTest extends BaseTestCase { Ebean.getDefaultServer().publish(Link.class, link1.getId()); Link link = Ebean.find(Link.class) - .setId(link1.getId()) - .select("name") - .findUnique(); + .setId(link1.getId()) + .select("name") + .findUnique(); assertThat(link).isNotNull(); @@ -103,7 +103,7 @@ public class DocLinkTest extends BaseTestCase { try { Ebean.deletePermanent(live); - assertTrue("never get here",false); + assertTrue("never get here", false); } catch (PersistenceException e) { // assert nice message when trying to delete live bean @@ -149,7 +149,7 @@ public class DocLinkTest extends BaseTestCase { // Expect a nice try { live.save(); - assertTrue("Never get here",false); + assertTrue("Never get here", false); } catch (PersistenceException e) { // we want to assert the message is nice and meaningful (and not a optimistic locking exception etc) @@ -207,9 +207,9 @@ public class DocLinkTest extends BaseTestCase { doc1.save(); Doc draftDoc1 = server.find(Doc.class) - .setId(doc1.getId()) - .asDraft() - .findUnique(); + .setId(doc1.getId()) + .asDraft() + .findUnique(); assertThat(draftDoc1.getLinks()).hasSize(2); @@ -248,9 +248,9 @@ public class DocLinkTest extends BaseTestCase { StrictAssertions.assertThat(live.isDraft()).isFalse(); Link draftLink = Ebean.find(Link.class) - .setId(link1.getId()) - .asDraft() - .findUnique(); + .setId(link1.getId()) + .asDraft() + .findUnique(); draftLink.setLocation("secondLocation"); draftLink.save(); @@ -258,9 +258,9 @@ public class DocLinkTest extends BaseTestCase { server.draftRestore(Link.class, link1.getId(), null); draftLink = Ebean.find(Link.class) - .setId(link1.getId()) - .asDraft() - .findUnique(); + .setId(link1.getId()) + .asDraft() + .findUnique(); StrictAssertions.assertThat(draftLink.getLocation()).isEqualTo("firstLocation"); @@ -279,9 +279,9 @@ public class DocLinkTest extends BaseTestCase { server.publish(Link.class, link1.getId(), null); Link draftLink = Ebean.find(Link.class) - .setId(link1.getId()) - .asDraft() - .findUnique(); + .setId(link1.getId()) + .asDraft() + .findUnique(); draftLink.setLocation("secondLocation"); draftLink.setComment("A good change"); @@ -296,4 +296,4 @@ public class DocLinkTest extends BaseTestCase { StrictAssertions.assertThat(links.get(0).getComment()).isNull(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java b/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java index 65574a832..abc3491da 100644 --- a/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java +++ b/src/test/java/com/avaje/tests/draftable/LinkQueryPublishTest.java @@ -34,7 +34,7 @@ public class LinkQueryPublishTest { ids.add(link3.getId()); PagedList pagedList = - server.find(Link.class).asDraft() + server.find(Link.class).asDraft() .where().idIn(ids) .setMaxRows(10) .findPagedList(); @@ -44,8 +44,8 @@ public class LinkQueryPublishTest { Query pubQuery = server.find(Link.class) - .where().idIn(ids) - .order().asc("id"); + .where().idIn(ids) + .order().asc("id"); List pubList = server.publish(pubQuery); @@ -56,4 +56,4 @@ public class LinkQueryPublishTest { } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/draftable/OrganisationTest.java b/src/test/java/com/avaje/tests/draftable/OrganisationTest.java index a02d8c1b5..dc097c05a 100644 --- a/src/test/java/com/avaje/tests/draftable/OrganisationTest.java +++ b/src/test/java/com/avaje/tests/draftable/OrganisationTest.java @@ -39,15 +39,15 @@ public class OrganisationTest { EbeanServer server = Ebean.getDefaultServer(); Document draftDoc = server.find(Document.class) - .asDraft() - .setId(doc.getId()) - .findUnique(); + .asDraft() + .setId(doc.getId()) + .findUnique(); assertNotNull(draftDoc); Document liveDoc = server.find(Document.class) - .setId(doc.getId()) - .findUnique(); + .setId(doc.getId()) + .findUnique(); assertNull(liveDoc); @@ -61,7 +61,6 @@ public class OrganisationTest { } - @Test public void testSaveWithCascade() { @@ -103,7 +102,7 @@ public class OrganisationTest { Document liveBean = server.publish(Document.class, doc.getId(), null); StrictAssertions.assertThat(liveBean.getBody()).isEqualTo("Body2"); StrictAssertions.assertThat(liveBean.getMedia().size()).isEqualTo(2); - assertThat(liveBean.getMedia()).extracting("name").contains("media2","media3"); + assertThat(liveBean.getMedia()).extracting("name").contains("media2", "media3"); } @@ -113,4 +112,4 @@ public class OrganisationTest { media.setName(name); return media; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/el/TestELBasic.java b/src/test/java/com/avaje/tests/el/TestELBasic.java index c73f54b7f..ade408b0e 100644 --- a/src/test/java/com/avaje/tests/el/TestELBasic.java +++ b/src/test/java/com/avaje/tests/el/TestELBasic.java @@ -1,8 +1,5 @@ package com.avaje.tests.el; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -14,59 +11,60 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; import com.avaje.ebeaninternal.server.el.ElPropertyChain; import com.avaje.ebeaninternal.server.el.ElPropertyDeploy; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; public class TestELBasic extends BaseTestCase { @Test - public void testEl() { - - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); - BeanDescriptor descriptor = server.getBeanDescriptor(Customer.class); - - ElPropertyDeploy elId = descriptor.getElPropertyDeploy("id"); - Assert.assertTrue(elId instanceof BeanProperty); - - ElPropertyDeploy elBillAddress = descriptor.getElPropertyDeploy("billingAddress"); - Assert.assertTrue(elBillAddress instanceof BeanPropertyAssocOne); - - ElPropertyDeploy elBillAddressId = descriptor.getElPropertyDeploy("billingAddress.id"); - Assert.assertTrue(elBillAddressId instanceof BeanFkeyProperty); - Assert.assertEquals("billing_address_id", elBillAddressId.getDbColumn()); - Assert.assertEquals("billingAddress.id", elBillAddressId.getName()); - Assert.assertNull(elBillAddressId.getElPrefix()); - - - ElPropertyDeploy elBillAddressCity = descriptor.getElPropertyDeploy("billingAddress.city"); - Assert.assertTrue(elBillAddressCity instanceof ElPropertyChain); - Assert.assertEquals("billingAddress",elBillAddressCity.getElPrefix()); - Assert.assertEquals("city",elBillAddressCity.getName()); - Assert.assertEquals("${billingAddress}city",elBillAddressCity.getElPlaceholder(false)); - Assert.assertEquals("city",elBillAddressCity.getDbColumn()); + public void testEl() { + + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); + BeanDescriptor descriptor = server.getBeanDescriptor(Customer.class); + + ElPropertyDeploy elId = descriptor.getElPropertyDeploy("id"); + Assert.assertTrue(elId instanceof BeanProperty); + + ElPropertyDeploy elBillAddress = descriptor.getElPropertyDeploy("billingAddress"); + Assert.assertTrue(elBillAddress instanceof BeanPropertyAssocOne); + + ElPropertyDeploy elBillAddressId = descriptor.getElPropertyDeploy("billingAddress.id"); + Assert.assertTrue(elBillAddressId instanceof BeanFkeyProperty); + Assert.assertEquals("billing_address_id", elBillAddressId.getDbColumn()); + Assert.assertEquals("billingAddress.id", elBillAddressId.getName()); + Assert.assertNull(elBillAddressId.getElPrefix()); + + + ElPropertyDeploy elBillAddressCity = descriptor.getElPropertyDeploy("billingAddress.city"); + Assert.assertTrue(elBillAddressCity instanceof ElPropertyChain); + Assert.assertEquals("billingAddress", elBillAddressCity.getElPrefix()); + Assert.assertEquals("city", elBillAddressCity.getName()); + Assert.assertEquals("${billingAddress}city", elBillAddressCity.getElPlaceholder(false)); + Assert.assertEquals("city", elBillAddressCity.getDbColumn()); // ElPropertyDeploy elBillAddressCountry = descriptor.getElPropertyDeploy("billingAddress.country"); - - ElPropertyDeploy elOrders = descriptor.getElPropertyDeploy("orders"); - Assert.assertTrue(elOrders instanceof BeanPropertyAssocMany); - - ElPropertyDeploy elOrderStatus = descriptor.getElPropertyDeploy("orders.status"); - Assert.assertTrue(elOrderStatus instanceof ElPropertyChain); - Assert.assertEquals("orders",elOrderStatus.getElPrefix()); - Assert.assertEquals("status",elOrderStatus.getName()); - Assert.assertEquals("${orders}status",elOrderStatus.getElPlaceholder(false)); - Assert.assertEquals("status",elOrderStatus.getDbColumn()); - ElPropertyDeploy elOrderCust = descriptor.getElPropertyDeploy("orders.customer"); - Assert.assertTrue(elOrderCust instanceof ElPropertyChain); + ElPropertyDeploy elOrders = descriptor.getElPropertyDeploy("orders"); + Assert.assertTrue(elOrders instanceof BeanPropertyAssocMany); + + ElPropertyDeploy elOrderStatus = descriptor.getElPropertyDeploy("orders.status"); + Assert.assertTrue(elOrderStatus instanceof ElPropertyChain); + Assert.assertEquals("orders", elOrderStatus.getElPrefix()); + Assert.assertEquals("status", elOrderStatus.getName()); + Assert.assertEquals("${orders}status", elOrderStatus.getElPlaceholder(false)); + Assert.assertEquals("status", elOrderStatus.getDbColumn()); + + ElPropertyDeploy elOrderCust = descriptor.getElPropertyDeploy("orders.customer"); + Assert.assertTrue(elOrderCust instanceof ElPropertyChain); + + ElPropertyDeploy elOrderDetails = descriptor.getElPropertyDeploy("orders.details"); + Assert.assertTrue(elOrderDetails instanceof ElPropertyChain); + + ElPropertyDeploy elOrderDetailsId = descriptor.getElPropertyDeploy("orders.details.id"); + Assert.assertTrue(elOrderDetailsId instanceof ElPropertyChain); + + } - ElPropertyDeploy elOrderDetails = descriptor.getElPropertyDeploy("orders.details"); - Assert.assertTrue(elOrderDetails instanceof ElPropertyChain); - ElPropertyDeploy elOrderDetailsId = descriptor.getElPropertyDeploy("orders.details.id"); - Assert.assertTrue(elOrderDetailsId instanceof ElPropertyChain); - - } - - - } diff --git a/src/test/java/com/avaje/tests/el/TestPathExpression.java b/src/test/java/com/avaje/tests/el/TestPathExpression.java index c9526b0db..22011e9fd 100644 --- a/src/test/java/com/avaje/tests/el/TestPathExpression.java +++ b/src/test/java/com/avaje/tests/el/TestPathExpression.java @@ -28,11 +28,11 @@ public class TestPathExpression { } @Test - public void pathSet() { - + public void pathSet() { + Customer c1 = new Customer(); - line1.pathSet(c1, "12 someplace"); - city.pathSet(c1, "Auckland"); + line1.pathSet(c1, "12 someplace"); + city.pathSet(c1, "Auckland"); billingId.pathSet(c1, 4); beanType.getExpressionPath("id").pathSet(c1, 42L); @@ -57,7 +57,7 @@ public class TestPathExpression { public void pathGet() { Address billingAddress = new Address(); - billingAddress.setId((short)12); + billingAddress.setId((short) 12); billingAddress.setLine1("line1"); billingAddress.setCity("Auckland"); @@ -69,7 +69,7 @@ public class TestPathExpression { Customer c0 = new Customer(); c0.setBillingAddress(billingAddress); - EntityBean e0 = (EntityBean)c0; + EntityBean e0 = (EntityBean) c0; assertEquals(line1.pathGet(e0), "line1"); assertEquals(city.pathGet(e0), "Auckland"); assertEquals(billingId.pathGet(e0), Short.valueOf("12")); diff --git a/src/test/java/com/avaje/tests/el/TestUnderscoreParam.java b/src/test/java/com/avaje/tests/el/TestUnderscoreParam.java index 5626f3be4..b79115345 100644 --- a/src/test/java/com/avaje/tests/el/TestUnderscoreParam.java +++ b/src/test/java/com/avaje/tests/el/TestUnderscoreParam.java @@ -13,8 +13,8 @@ public class TestUnderscoreParam { public void test() { Query query = Ebean.find(Customer.class) - .where().raw("name like ?", "Rob%") - .query(); + .where().raw("name like ?", "Rob%") + .query(); query.findList(); diff --git a/src/test/java/com/avaje/tests/enhancement/TestConstructorPutfieldReplacement.java b/src/test/java/com/avaje/tests/enhancement/TestConstructorPutfieldReplacement.java index cdf35e895..e2b4d6f07 100644 --- a/src/test/java/com/avaje/tests/enhancement/TestConstructorPutfieldReplacement.java +++ b/src/test/java/com/avaje/tests/enhancement/TestConstructorPutfieldReplacement.java @@ -1,30 +1,29 @@ package com.avaje.tests.enhancement; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.bean.EntityBean; import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.tests.model.basic.PFile; import com.avaje.tests.model.basic.PFileContent; +import org.junit.Assert; +import org.junit.Test; public class TestConstructorPutfieldReplacement extends BaseTestCase { @Test public void test() { - + PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes())); - EntityBean eb = (EntityBean)persistentFile; + EntityBean eb = (EntityBean) persistentFile; EntityBeanIntercept ebi = eb._ebean_getIntercept(); - + int namePos = ebi.findProperty("name"); int fileContentPos = ebi.findProperty("fileContent"); - + Assert.assertTrue(ebi.isLoadedProperty(namePos)); Assert.assertTrue(ebi.isLoadedProperty(fileContentPos)); - + } - + } diff --git a/src/test/java/com/avaje/tests/enhancement/TestEnhancementEquals.java b/src/test/java/com/avaje/tests/enhancement/TestEnhancementEquals.java index ae1a6f6b8..cbc37ab71 100644 --- a/src/test/java/com/avaje/tests/enhancement/TestEnhancementEquals.java +++ b/src/test/java/com/avaje/tests/enhancement/TestEnhancementEquals.java @@ -1,10 +1,9 @@ package com.avaje.tests.enhancement; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.tests.model.basic.Product; +import org.junit.Assert; +import org.junit.Test; /** * Note take care if you run this test in an IDE with a debugger as that can trigger the equals and @@ -12,17 +11,17 @@ import com.avaje.tests.model.basic.Product; */ public class TestEnhancementEquals extends BaseTestCase { - + @Test public void testEqualsBasedOnIdValue() { - + Product product1 = new Product(); product1.setId(345); product1.setName("blah"); Product product2 = new Product(); product2.setId(345); - + Assert.assertEquals("equal based on id", product1, product2); Assert.assertEquals("hashCode equal based on id", product1.hashCode(), product2.hashCode()); @@ -30,26 +29,26 @@ public class TestEnhancementEquals extends BaseTestCase { Assert.assertEquals("still equal based on identity", product1, product2); Assert.assertEquals("still hashCode equal based on id", product1.hashCode(), product2.hashCode()); } - + @Test public void testWhenEqualsTouchedFirst() { - + Product product1 = new Product(); product1.setName("blah"); int hashcode1 = product1.hashCode(); - + // equals has been called so the hashCode and 'identity' has been baked in product1.setId(345); int hashcode2 = product1.hashCode(); - Assert.assertEquals("hashCode can't change",hashcode1, hashcode2); - + Assert.assertEquals("hashCode can't change", hashcode1, hashcode2); + Product product2 = new Product(); product2.setId(345); - + Assert.assertFalse("Not equal now", product1.equals(product2)); Assert.assertTrue("Different hashCode", product1.hashCode() != product2.hashCode()); } - + } diff --git a/src/test/java/com/avaje/tests/family/TestInheritance.java b/src/test/java/com/avaje/tests/family/TestInheritance.java index 093a3ae0c..1403202d7 100644 --- a/src/test/java/com/avaje/tests/family/TestInheritance.java +++ b/src/test/java/com/avaje/tests/family/TestInheritance.java @@ -1,34 +1,27 @@ - package com.avaje.tests.family; -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Ignore; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanProperty; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne; -import com.avaje.tests.lib.EbeanTestCase; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.family.ChildPerson; import com.avaje.tests.model.family.GrandParentPerson; import com.avaje.tests.model.family.ParentPerson; +import org.junit.Test; +import static org.junit.Assert.*; public class TestInheritance extends BaseTestCase { - @Test + @Test public void testDescriptor() { BeanDescriptor desc = spiEbeanServer().getBeanDescriptor(GrandParentPerson.class); BeanProperty prop1 = desc.getBeanProperty("someBean"); BeanProperty prop2 = desc.getBeanProperty("effectiveBean"); - + assertEquals(BeanPropertyAssocOne.class, prop1.getClass()); assertEquals(BeanPropertyAssocOne.class, prop2.getClass()); } @@ -42,7 +35,7 @@ public class TestInheritance extends BaseTestCase { * +- parent2 Sandra (50) from Berlin * | '- child3 Roland(36) * +- parent3 Michael(60) - * + * */ @Test public void testInheritance() { @@ -50,11 +43,11 @@ public class TestInheritance extends BaseTestCase { EBasic someBean1 = new EBasic(); someBean1.setName("A Bean"); server().save(someBean1); - + EBasic someBean2 = new EBasic(); someBean2.setName("An other Bean"); server().save(someBean2); - + ChildPerson child1 = new ChildPerson(); child1.setAge(13); child1.setName("Fred"); @@ -97,7 +90,7 @@ public class TestInheritance extends BaseTestCase { grandparent1.getChildren().add(parent1); grandparent1.getChildren().add(parent2); grandparent1.getChildren().add(parent3); - + server().save(grandparent1); // Test setup complete, so retrieve bean from db @@ -107,33 +100,33 @@ public class TestInheritance extends BaseTestCase { parent1 = server().find(ParentPerson.class).setId(1).fetch("someBean").findUnique(); assertEquals("A Bean", parent1.getSomeBean().getName()); grandparent1 = server().find(GrandParentPerson.class) - .fetch("children","*") // FIXME If I do not fetch childrenBean, I will get an exception - .fetch("children.effectiveBean","*") - .fetch("children.children","*") - .fetch("children.children.effectiveBean","*") - .setId(grandparent1.getIdentifier()).where() - .or() - .in("effectiveBean.id",1) - .isNull("effectiveBean.id") - .endOr() - .findUnique(); + .fetch("children", "*") // FIXME If I do not fetch childrenBean, I will get an exception + .fetch("children.effectiveBean", "*") + .fetch("children.children", "*") + .fetch("children.children.effectiveBean", "*") + .setId(grandparent1.getIdentifier()).where() + .or() + .in("effectiveBean.id", 1) + .isNull("effectiveBean.id") + .endOr() + .findUnique(); assertNotNull(grandparent1); // check if aggregation works assertEquals(3, grandparent1.getChildCount().intValue()); assertEquals(150, grandparent1.getTotalAge().intValue()); - + // check normal properties assertEquals("Josef", grandparent1.getName()); assertEquals("Foo", grandparent1.getFamilyName()); assertEquals("Munich", grandparent1.getAddress()); assertEquals(1, grandparent1.getEffectiveBean().getId().intValue()); - + // now check children of grandparent parent1 = grandparent1.getChildren().get(0); parent2 = grandparent1.getChildren().get(1); parent3 = grandparent1.getChildren().get(2); - + assertNotNull(parent1); assertNotNull(parent2); assertNotNull(parent3); @@ -141,12 +134,12 @@ public class TestInheritance extends BaseTestCase { assertEquals("Maria", parent1.getName()); assertEquals("Bar", parent1.getFamilyName()); // overwritten family name assertEquals("Bar", parent1.getEffectiveFamilyName()); // test inheritance - assertNull(parent1.getAddress()); // no alternative address set + assertNull(parent1.getAddress()); // no alternative address set assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich assertEquals(2, parent1.getChildCount().intValue()); assertEquals(21, parent1.getTotalAge().intValue()); assertEquals("A Bean", parent1.getEffectiveBean().getName()); - + // parent2 assertEquals("Sandra", parent2.getName()); assertNull(parent2.getFamilyName()); @@ -156,7 +149,7 @@ public class TestInheritance extends BaseTestCase { assertEquals(1, parent2.getChildCount().intValue()); assertEquals(36, parent2.getTotalAge().intValue()); assertNull(parent2.getEffectiveBean()); - + // parent3 assertEquals("Michael", parent3.getName()); assertNull(parent3.getFamilyName()); @@ -166,54 +159,54 @@ public class TestInheritance extends BaseTestCase { assertEquals(0, parent3.getChildCount().intValue()); assertEquals(0, parent3.getTotalAge().intValue()); assertNull(parent3.getEffectiveBean()); - + child1 = parent1.getChildren().get(0); child2 = parent1.getChildren().get(1); - + child3 = parent2.getChildren().get(0); - + assertNotNull(child1); assertNotNull(child2); assertNotNull(child3); - + assertEquals("Bar", child1.getEffectiveFamilyName()); assertEquals("Munich", child1.getEffectiveAddress()); assertEquals("An other Bean", child1.getSomeBean().getName()); assertEquals("An other Bean", child1.getEffectiveBean().getName()); - + assertTrue(child1.getSomeBean() == child1.getEffectiveBean()); - + assertEquals("Baz", child2.getEffectiveFamilyName()); assertEquals("Munich", child2.getEffectiveAddress()); assertNull(child2.getSomeBean()); assertEquals("A Bean", child2.getEffectiveBean().getName()); - + assertEquals("Foo", child3.getEffectiveFamilyName()); assertEquals("Berlin", child3.getEffectiveAddress()); assertNull(child3.getEffectiveBean()); - + // Now start from bottom up child2 = server().find(ChildPerson.class).where().eq("name", "Julia").select("parent.name").findUnique(); assertEquals("Baz", child2.getEffectiveFamilyName()); assertEquals("Munich", child2.getEffectiveAddress()); assertNull(child2.getSomeBean()); assertEquals("A Bean", child2.getEffectiveBean().getName()); - + parent1 = child2.getParent(); assertEquals("Maria", parent1.getName()); assertEquals("Bar", parent1.getFamilyName()); // overwritten family name assertEquals("Bar", parent1.getEffectiveFamilyName()); // test inheritance - assertNull(parent1.getAddress()); // no alternative address set + assertNull(parent1.getAddress()); // no alternative address set assertEquals("Munich", parent1.getEffectiveAddress()); // -> inherit munich assertEquals(2, parent1.getChildCount().intValue()); assertEquals(21, parent1.getTotalAge().intValue()); assertEquals("A Bean", parent1.getEffectiveBean().getName()); - + grandparent1 = parent1.getParent(); // check if aggregation works assertEquals(3, grandparent1.getChildCount().intValue()); assertEquals(150, grandparent1.getTotalAge().intValue()); - + // check normal properties assertEquals("Josef", grandparent1.getName()); assertEquals("Foo", grandparent1.getFamilyName()); diff --git a/src/test/java/com/avaje/tests/genkey/TestGeneratedKeys.java b/src/test/java/com/avaje/tests/genkey/TestGeneratedKeys.java index 593a50495..2f313d942 100644 --- a/src/test/java/com/avaje/tests/genkey/TestGeneratedKeys.java +++ b/src/test/java/com/avaje/tests/genkey/TestGeneratedKeys.java @@ -1,37 +1,36 @@ package com.avaje.tests.genkey; -import org.junit.Assert; -import junit.framework.TestCase; - import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TOne; +import junit.framework.TestCase; +import org.junit.Assert; public class TestGeneratedKeys extends TestCase { - - public void testJdbcBatchInsert() { - - TOne c = new TOne(); - c.setName("Banana"); - c.setDescription("Test Gen Key"); - - TOne c1 = new TOne(); - c1.setName("Two"); - c1.setDescription("Test Gen Key Two"); - - Ebean.beginTransaction(); - try { - Ebean.save(c); - Ebean.save(c1); - } finally { - Ebean.commitTransaction(); - } - Integer id = c.getId(); - Assert.assertNotNull("Get Id back after insert", id); - Integer id1 = c1.getId(); - Assert.assertNotNull("Get Id back after insert", id1); + public void testJdbcBatchInsert() { + + TOne c = new TOne(); + c.setName("Banana"); + c.setDescription("Test Gen Key"); + + TOne c1 = new TOne(); + c1.setName("Two"); + c1.setDescription("Test Gen Key Two"); + + Ebean.beginTransaction(); + try { + Ebean.save(c); + Ebean.save(c1); + } finally { + Ebean.commitTransaction(); + } + Integer id = c.getId(); + Assert.assertNotNull("Get Id back after insert", id); + + Integer id1 = c1.getId(); + Assert.assertNotNull("Get Id back after insert", id1); + + } - } - } diff --git a/src/test/java/com/avaje/tests/genkey/TestSeqBatch.java b/src/test/java/com/avaje/tests/genkey/TestSeqBatch.java index 111ff7ddd..04117d5fc 100644 --- a/src/test/java/com/avaje/tests/genkey/TestSeqBatch.java +++ b/src/test/java/com/avaje/tests/genkey/TestSeqBatch.java @@ -1,39 +1,38 @@ package com.avaje.tests.genkey; -import com.avaje.ebean.config.dbplatform.IdType; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.config.dbplatform.IdType; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.tests.model.basic.TOne; +import org.junit.Assert; +import org.junit.Test; public class TestSeqBatch extends BaseTestCase { @Test - public void test() { - - EbeanServer server = Ebean.getServer(null); - SpiEbeanServer spiServer = (SpiEbeanServer)server; + public void test() { + + EbeanServer server = Ebean.getServer(null); + SpiEbeanServer spiServer = (SpiEbeanServer) server; IdType idType = spiServer.getDatabasePlatform().getDbIdentity().getIdType(); - if (IdType.SEQUENCE == idType){ - BeanDescriptor d = spiServer.getBeanDescriptor(TOne.class); - - Object id = d.nextId(null); - Assert.assertNotNull(id); + if (IdType.SEQUENCE == idType) { + BeanDescriptor d = spiServer.getBeanDescriptor(TOne.class); + + Object id = d.nextId(null); + Assert.assertNotNull(id); //System.out.println(id); - for (int i = 0; i < 16; i++) { - Object id2 = d.nextId(null); - Assert.assertNotNull(id2); + for (int i = 0; i < 16; i++) { + Object id2 = d.nextId(null); + Assert.assertNotNull(id2); //System.out.println(id2); - } - } - } - + } + } + } + } diff --git a/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java b/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java index f90f1957b..e929552b9 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java +++ b/src/test/java/com/avaje/tests/idkeys/TestGeneratedKeys.java @@ -13,131 +13,120 @@ import java.sql.Statement; /** * Test various key generation strategies. - * + *

* Notice: The strategy {@link javax.persistence.GenerationType#AUTO} is not easy to test as it is database dependent - * which of the strategies will be used. + * which of the strategies will be used. */ -public class TestGeneratedKeys extends EbeanTestCase -{ - /** - * Test key generation using a sequence. - * This should increment the used sequence by one. - * EBean should construct a select statement which uses the configured sequence to get the next value - *

- * Notice: Actually, this test depends on H2 as used database as we are going to fetch the current value from the sequence - */ - public void testSequence() throws SQLException - { - SpiEbeanServer server = (SpiEbeanServer)getServer(); - IdType idType = server.getDatabasePlatform().getDbIdentity().getIdType(); - String platformName = server.getDatabasePlatform().getName(); - if (!IdType.SEQUENCE.equals(idType)){ - // only run this test when SEQUENCE is being used - return; - } - if (!"h2".equals(platformName)){ - // readSequenceValue is H2 specific - return; - } - - Transaction tx = getServer().beginTransaction(); - - long sequenceStart = readSequenceValue(tx, GenKeySequence.SEQUENCE_NAME); - - GenKeySequence al = new GenKeySequence(); - al.setDescription("my description"); - getServer().save(al); - - - long sequenceCurrent = readSequenceValue(tx, GenKeySequence.SEQUENCE_NAME); - - assertNotNull(al.getId()); - assertFalse("sequence advanced", sequenceStart == sequenceCurrent); - assertEquals("sequence advanced by 20", sequenceStart + 20, sequenceCurrent); - +public class TestGeneratedKeys extends EbeanTestCase { + /** + * Test key generation using a sequence. + * This should increment the used sequence by one. + * EBean should construct a select statement which uses the configured sequence to get the next value + *

+ * Notice: Actually, this test depends on H2 as used database as we are going to fetch the current value from the sequence + */ + public void testSequence() throws SQLException { + SpiEbeanServer server = (SpiEbeanServer) getServer(); + IdType idType = server.getDatabasePlatform().getDbIdentity().getIdType(); + String platformName = server.getDatabasePlatform().getName(); + if (!IdType.SEQUENCE.equals(idType)) { + // only run this test when SEQUENCE is being used + return; + } + if (!"h2".equals(platformName)) { + // readSequenceValue is H2 specific + return; } - private long readSequenceValue(Transaction tx, String sequence) throws SQLException - { - Statement stm = null; - try - { - stm = tx.getConnection().createStatement(); - ResultSet rs = stm.executeQuery("select currval('" + sequence + "')"); - rs.next(); + Transaction tx = getServer().beginTransaction(); - return rs.getLong(1); - } - finally - { - if (stm != null) - { - try - { - stm.close(); - } - catch (SQLException e) - { - } - } + long sequenceStart = readSequenceValue(tx, GenKeySequence.SEQUENCE_NAME); + + GenKeySequence al = new GenKeySequence(); + al.setDescription("my description"); + getServer().save(al); + + + long sequenceCurrent = readSequenceValue(tx, GenKeySequence.SEQUENCE_NAME); + + assertNotNull(al.getId()); + assertFalse("sequence advanced", sequenceStart == sequenceCurrent); + assertEquals("sequence advanced by 20", sequenceStart + 20, sequenceCurrent); + + } + + private long readSequenceValue(Transaction tx, String sequence) throws SQLException { + Statement stm = null; + try { + stm = tx.getConnection().createStatement(); + ResultSet rs = stm.executeQuery("select currval('" + sequence + "')"); + rs.next(); + + return rs.getLong(1); + } finally { + if (stm != null) { + try { + stm.close(); + } catch (SQLException e) { } + } + } + } + + /** + * This test just checks if a generated value has been passed back from the database. + * EBean should simply fetch the generated key after inserting. + */ + public void testIdentity() throws SQLException { + + SpiEbeanServer server = (SpiEbeanServer) getServer(); + IdType idType = server.getDatabasePlatform().getDbIdentity().getIdType(); + + if (!IdType.IDENTITY.equals(idType)) { + // only run this test when SEQUENCE is being used + return; } - /** - * This test just checks if a generated value has been passed back from the database. - * EBean should simply fetch the generated key after inserting. - */ - public void testIdentity() throws SQLException - { + Transaction tx = getServer().beginTransaction(); - SpiEbeanServer server = (SpiEbeanServer)getServer(); - IdType idType = server.getDatabasePlatform().getDbIdentity().getIdType(); - - if (!IdType.IDENTITY.equals(idType)){ - // only run this test when SEQUENCE is being used - return; - } + GenKeyIdentity al = new GenKeyIdentity(); + al.setDescription("my description"); + getServer().save(al); - Transaction tx = getServer().beginTransaction(); + // For JDBC batching we won't get the id until after + // the batch has been flushed explicitly or via commit + //assertNotNull(al.getId()); - GenKeyIdentity al = new GenKeyIdentity(); - al.setDescription("my description"); - getServer().save(al); + tx.commit(); - // For JDBC batching we won't get the id until after - // the batch has been flushed explicitly or via commit - //assertNotNull(al.getId()); + assertNotNull(al.getId()); - tx.commit(); - - assertNotNull(al.getId()); + } - } + /** + * This should use the next value using max(col)+1 on the table + * + * AFAIK this is not supported by EBean yet + public void testTable() throws SQLException + { + EbeanServer server = Ebean.getServer(null); + Transaction tx = server.beginTransaction(); - /** - * This should use the next value using max(col)+1 on the table - * - * AFAIK this is not supported by EBean yet - public void testTable() throws SQLException - { - EbeanServer server = Ebean.getServer(null); - Transaction tx = server.beginTransaction(); + GenKeyTable al = new GenKeyTable(); + al.setDescription("my description"); + server.save(al); - GenKeyTable al = new GenKeyTable(); - al.setDescription("my description"); - server.save(al); + assertNotNull(al.getId()); + assertEquals(0L, al.getId().longValue()); - assertNotNull(al.getId()); - assertEquals(0L, al.getId().longValue()); + al = new GenKeyTable(); + al.setDescription("my description - another object"); + server.save(al); - al = new GenKeyTable(); - al.setDescription("my description - another object"); - server.save(al); + assertNotNull(al.getId()); + assertEquals(1L, al.getId().longValue()); - assertNotNull(al.getId()); - assertEquals(1L, al.getId().longValue()); - - tx.commit(); - } - */ -} \ No newline at end of file + tx.commit(); + } + */ +} diff --git a/src/test/java/com/avaje/tests/idkeys/TestLazyLoad.java b/src/test/java/com/avaje/tests/idkeys/TestLazyLoad.java index 70c501d38..504b29039 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestLazyLoad.java +++ b/src/test/java/com/avaje/tests/idkeys/TestLazyLoad.java @@ -1,41 +1,39 @@ package com.avaje.tests.idkeys; -import java.sql.SQLException; -import java.util.List; - import com.avaje.tests.lib.EbeanTestCase; import com.avaje.tests.model.basic.TOne; +import java.sql.SQLException; +import java.util.List; + /** * Test lazy loading */ -public class TestLazyLoad extends EbeanTestCase -{ - /** - * This test loads just a single property of the Entity AuditLog and later on access - * the description which should force a lazy load of this property - */ - public void testPartialLoad() throws SQLException - { - TOne log = new TOne(); - log.setName("test partial"); - log.setDescription("log"); +public class TestLazyLoad extends EbeanTestCase { + /** + * This test loads just a single property of the Entity AuditLog and later on access + * the description which should force a lazy load of this property + */ + public void testPartialLoad() throws SQLException { + TOne log = new TOne(); + log.setName("test partial"); + log.setDescription("log"); - getServer().save(log); + getServer().save(log); - assertNotNull(log.getId()); + assertNotNull(log.getId()); - List logs = getServer().find(TOne.class) - .select("id") - .where().eq("id", log.getId()) - .findList(); + List logs = getServer().find(TOne.class) + .select("id") + .where().eq("id", log.getId()) + .findList(); - assertNotNull(logs); - assertEquals(1, logs.size()); + assertNotNull(logs); + assertEquals(1, logs.size()); - TOne logLazy = logs.get(0); + TOne logLazy = logs.get(0); - String description = logLazy.getDescription(); - assertEquals(log.getDescription(), description); - } -} \ No newline at end of file + String description = logLazy.getDescription(); + assertEquals(log.getDescription(), description); + } +} diff --git a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java index f85756516..da8cedd62 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java +++ b/src/test/java/com/avaje/tests/idkeys/TestPropertyChangeSupport.java @@ -124,9 +124,9 @@ public class TestPropertyChangeSupport extends EbeanTestCase implements Property resetEvent(); List logs = getServer().find(AuditLog.class) - .where().eq("id", log.getId()) - .select("id") - .findList(); + .where().eq("id", log.getId()) + .select("id") + .findList(); assertNotNull(logs); assertEquals(1, logs.size()); @@ -167,4 +167,4 @@ public class TestPropertyChangeSupport extends EbeanTestCase implements Property throw new RuntimeException(e); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/idkeys/TestSimpleIdInsert.java b/src/test/java/com/avaje/tests/idkeys/TestSimpleIdInsert.java index 9e1bc2a1c..2a48b4d06 100644 --- a/src/test/java/com/avaje/tests/idkeys/TestSimpleIdInsert.java +++ b/src/test/java/com/avaje/tests/idkeys/TestSimpleIdInsert.java @@ -9,16 +9,16 @@ import org.junit.Test; public class TestSimpleIdInsert extends BaseTestCase { @Test - public void test() { + public void test() { - ESimple e = new ESimple(); - e.setName("name"); + ESimple e = new ESimple(); + e.setName("name"); - Ebean.save(e); + Ebean.save(e); - Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getId()); - } + } // // This test fails with jdbc drivers that don't // // support batch insert with getGeneratedKeys diff --git a/src/test/java/com/avaje/tests/idkeys/db/AuditLog.java b/src/test/java/com/avaje/tests/idkeys/db/AuditLog.java index d3d9281ea..37c1c352c 100644 --- a/src/test/java/com/avaje/tests/idkeys/db/AuditLog.java +++ b/src/test/java/com/avaje/tests/idkeys/db/AuditLog.java @@ -6,43 +6,36 @@ import javax.persistence.Id; @Entity // Just let Ebean define Identity mechanism for testing across all DB types //@SequenceGenerator(name = "AD_SEQ_NAME", sequenceName = "AD_SEQ") -public class AuditLog -{ - @Id - //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AD_SEQ_NAME") - private Long id; +public class AuditLog { + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AD_SEQ_NAME") + private Long id; - private String description; + private String description; - private String modifiedDescription; + private String modifiedDescription; - public Long getId() - { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) - { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getDescription() - { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) - { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getModifiedDescription() - { - return modifiedDescription; - } + public String getModifiedDescription() { + return modifiedDescription; + } - public void setModifiedDescription(String modifiedDescription) - { - this.modifiedDescription = modifiedDescription==null?null:"_" + modifiedDescription + "_"; - } -} \ No newline at end of file + public void setModifiedDescription(String modifiedDescription) { + this.modifiedDescription = modifiedDescription == null ? null : "_" + modifiedDescription + "_"; + } +} diff --git a/src/test/java/com/avaje/tests/idkeys/db/GenKeyIdentity.java b/src/test/java/com/avaje/tests/idkeys/db/GenKeyIdentity.java index 748cfe19b..ca56c2645 100644 --- a/src/test/java/com/avaje/tests/idkeys/db/GenKeyIdentity.java +++ b/src/test/java/com/avaje/tests/idkeys/db/GenKeyIdentity.java @@ -6,31 +6,26 @@ import javax.persistence.GenerationType; import javax.persistence.Id; @Entity -public class GenKeyIdentity -{ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; +public class GenKeyIdentity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - private String description; + private String description; - public Long getId() - { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) - { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getDescription() - { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) - { - this.description = description; - } -} \ No newline at end of file + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/test/java/com/avaje/tests/idkeys/db/GenKeySequence.java b/src/test/java/com/avaje/tests/idkeys/db/GenKeySequence.java index 5e1e352c7..c615a9bfc 100644 --- a/src/test/java/com/avaje/tests/idkeys/db/GenKeySequence.java +++ b/src/test/java/com/avaje/tests/idkeys/db/GenKeySequence.java @@ -8,33 +8,28 @@ import javax.persistence.SequenceGenerator; @Entity @SequenceGenerator(name = "SEQ_NAME", sequenceName = GenKeySequence.SEQUENCE_NAME) -public class GenKeySequence -{ - public final static String SEQUENCE_NAME = "SEQ"; +public class GenKeySequence { + public final static String SEQUENCE_NAME = "SEQ"; - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_NAME") - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_NAME") + private Long id; - private String description; + private String description; - public Long getId() - { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) - { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getDescription() - { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) - { - this.description = description; - } -} \ No newline at end of file + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/test/java/com/avaje/tests/idkeys/db/GenKeyTable.java b/src/test/java/com/avaje/tests/idkeys/db/GenKeyTable.java index 741578797..6282d656b 100644 --- a/src/test/java/com/avaje/tests/idkeys/db/GenKeyTable.java +++ b/src/test/java/com/avaje/tests/idkeys/db/GenKeyTable.java @@ -6,31 +6,26 @@ import javax.persistence.GenerationType; import javax.persistence.Id; @Entity -public class GenKeyTable -{ - @Id - @GeneratedValue(strategy = GenerationType.TABLE) - private Long id; +public class GenKeyTable { + @Id + @GeneratedValue(strategy = GenerationType.TABLE) + private Long id; - private String description; + private String description; - public Long getId() - { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) - { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getDescription() - { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) - { - this.description = description; - } -} \ No newline at end of file + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/test/java/com/avaje/tests/inheritance/InnerReport.java b/src/test/java/com/avaje/tests/inheritance/InnerReport.java index e6995e081..8936ade24 100644 --- a/src/test/java/com/avaje/tests/inheritance/InnerReport.java +++ b/src/test/java/com/avaje/tests/inheritance/InnerReport.java @@ -1,6 +1,10 @@ package com.avaje.tests.inheritance; -import javax.persistence.*; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; /** */ diff --git a/src/test/java/com/avaje/tests/inheritance/Stockforecast.java b/src/test/java/com/avaje/tests/inheritance/Stockforecast.java index 8f96ee497..2f1e22264 100644 --- a/src/test/java/com/avaje/tests/inheritance/Stockforecast.java +++ b/src/test/java/com/avaje/tests/inheritance/Stockforecast.java @@ -1,6 +1,11 @@ package com.avaje.tests.inheritance; -import javax.persistence.*; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; @Entity diff --git a/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java b/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java index 480c6d4f2..11e4fb18b 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java +++ b/src/test/java/com/avaje/tests/inheritance/TestDuplcateKeyException.java @@ -1,53 +1,50 @@ package com.avaje.tests.inheritance; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; -import com.avaje.ebean.TxRunnable; import com.avaje.tests.model.basic.AttributeHolder; import com.avaje.tests.model.basic.ListAttribute; import com.avaje.tests.model.basic.ListAttributeValue; +import org.junit.Assert; +import org.junit.Test; public class TestDuplcateKeyException extends BaseTestCase { - /** - * Test query. - *

This test covers the BUG 276. Cascade was not propagating to the ListAttribute because - * it was considered safe to skip as it didn't take into account any derived classes - * into account with e.g. collections and Cascade options

- */ + /** + * Test query. + *

This test covers the BUG 276. Cascade was not propagating to the ListAttribute because + * it was considered safe to skip as it didn't take into account any derived classes + * into account with e.g. collections and Cascade options

+ */ @Test - public void testQuery() { - - // Setup the data first - final ListAttributeValue value1 = new ListAttributeValue(); - - Ebean.save(value1); - - final ListAttribute listAttribute = new ListAttribute(); - listAttribute.add(value1); - Ebean.save(listAttribute); - - - - final AttributeHolder holder = new AttributeHolder(); - holder.add(listAttribute); - - try { - Ebean.execute(() -> { - //Ebean.currentTransaction().log("-- saving holder first time"); - // Alternatively turn off cascade Persist for this transaction - //Ebean.currentTransaction().setPersistCascade(false); - Ebean.save(holder); + public void testQuery() { + + // Setup the data first + final ListAttributeValue value1 = new ListAttributeValue(); + + Ebean.save(value1); + + final ListAttribute listAttribute = new ListAttribute(); + listAttribute.add(value1); + Ebean.save(listAttribute); + + + final AttributeHolder holder = new AttributeHolder(); + holder.add(listAttribute); + + try { + Ebean.execute(() -> { + //Ebean.currentTransaction().log("-- saving holder first time"); + // Alternatively turn off cascade Persist for this transaction + //Ebean.currentTransaction().setPersistCascade(false); + Ebean.save(holder); //Ebean.currentTransaction().log("-- saving holder second time"); - // we don't get this far before failing - //Ebean.save(holder); - }); - } catch (Exception e){ - Assert.assertEquals(e.getMessage(), "test rollback"); - } - } + // we don't get this far before failing + //Ebean.save(holder); + }); + } catch (Exception e) { + Assert.assertEquals(e.getMessage(), "test rollback"); + } + } } diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritInsert.java b/src/test/java/com/avaje/tests/inheritance/TestInheritInsert.java index d66f2d2c4..fd9686b2f 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritInsert.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritInsert.java @@ -1,23 +1,20 @@ package com.avaje.tests.inheritance; -import java.util.List; - -import com.avaje.tests.model.basic.CarAccessory; -import com.avaje.tests.model.basic.CarFuse; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Car; +import com.avaje.tests.model.basic.CarAccessory; +import com.avaje.tests.model.basic.CarFuse; import com.avaje.tests.model.basic.Truck; import com.avaje.tests.model.basic.Vehicle; import com.avaje.tests.model.basic.VehicleDriver; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.StrictAssertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestInheritInsert extends BaseTestCase { @@ -109,10 +106,10 @@ public class TestInheritInsert extends BaseTestCase { Query query = Ebean.find(Car.class) - .fetch("accessories") - .where() - .eq("id", car.getId()) - .query(); + .fetch("accessories") + .where() + .eq("id", car.getId()) + .query(); Car result = query.findUnique(); diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritanceBatchLazyLoad.java b/src/test/java/com/avaje/tests/inheritance/TestInheritanceBatchLazyLoad.java index 3f36fb198..72673263f 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritanceBatchLazyLoad.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritanceBatchLazyLoad.java @@ -28,14 +28,14 @@ public class TestInheritanceBatchLazyLoad { List list = Ebean.find(Vehicle.class) - .select("licenseNumber") - .where().startsWith("licenseNumber","VZVZ") - .order().asc("licenseNumber") - .findList(); + .select("licenseNumber") + .where().startsWith("licenseNumber", "VZVZ") + .order().asc("licenseNumber") + .findList(); assertThat(list).hasSize(2); - Car car = (Car)list.get(0); + Car car = (Car) list.get(0); car.getNotes(); } } diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritanceJoins.java b/src/test/java/com/avaje/tests/inheritance/TestInheritanceJoins.java index d239b497a..acd8483bc 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritanceJoins.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritanceJoins.java @@ -1,117 +1,115 @@ package com.avaje.tests.inheritance; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.Query; import com.avaje.tests.inheritance.model.CalculationResult; import com.avaje.tests.inheritance.model.Configurations; import com.avaje.tests.inheritance.model.GroupConfiguration; import com.avaje.tests.inheritance.model.ProductConfiguration; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestInheritanceJoins extends BaseTestCase { - @Test - public void testAssocOne() { + @Test + public void testAssocOne() { - EbeanServer server = Ebean.getDefaultServer(); - - ProductConfiguration pc = new ProductConfiguration(); - pc.setName("PC1"); - server.save(pc); + EbeanServer server = Ebean.getDefaultServer(); - GroupConfiguration gc = new GroupConfiguration(); - gc.setName("GC1"); - server.save(gc); + ProductConfiguration pc = new ProductConfiguration(); + pc.setName("PC1"); + server.save(pc); - CalculationResult r = new CalculationResult(); - r.setCharge(100.0); - r.setProductConfiguration(pc); - r.setGroupConfiguration(gc); - server.save(r); - } + GroupConfiguration gc = new GroupConfiguration(); + gc.setName("GC1"); + server.save(gc); - @Test - public void assocOne_when_null() { + CalculationResult r = new CalculationResult(); + r.setCharge(100.0); + r.setProductConfiguration(pc); + r.setGroupConfiguration(gc); + server.save(r); + } - EbeanServer server = Ebean.getDefaultServer(); + @Test + public void assocOne_when_null() { - GroupConfiguration gc = new GroupConfiguration(); - gc.setName("GC1"); - server.save(gc); + EbeanServer server = Ebean.getDefaultServer(); - CalculationResult r = new CalculationResult(); - r.setCharge(100.0); + GroupConfiguration gc = new GroupConfiguration(); + gc.setName("GC1"); + server.save(gc); - // @ManyToOne with inheritance and null - r.setProductConfiguration(null); - r.setGroupConfiguration(gc); - server.save(r); + CalculationResult r = new CalculationResult(); + r.setCharge(100.0); - CalculationResult result = server.find(CalculationResult.class, r.getId()); + // @ManyToOne with inheritance and null + r.setProductConfiguration(null); + r.setGroupConfiguration(gc); + server.save(r); + + CalculationResult result = server.find(CalculationResult.class, r.getId()); + + GroupConfiguration group = result.getGroupConfiguration(); + Assert.assertEquals(group.getId(), gc.getId()); + } + + @Test + public void testAssocOneWithNullAssoc() { - GroupConfiguration group = result.getGroupConfiguration(); - Assert.assertEquals(group.getId(), gc.getId()); - } - - @Test - public void testAssocOneWithNullAssoc() { - /* Ensures the fetch join to a property with inheritance work as a left join */ - EbeanServer server = Ebean.getServer(null); - - final ProductConfiguration pc = new ProductConfiguration(); - pc.setName("PC1"); - server.save(pc); + EbeanServer server = Ebean.getServer(null); - CalculationResult r = new CalculationResult(); - final Double charge = 100.0; - r.setCharge(charge); - r.setProductConfiguration(pc); - r.setGroupConfiguration(null); - server.save(r); - } + final ProductConfiguration pc = new ProductConfiguration(); + pc.setName("PC1"); + server.save(pc); - @Test - public void testAssocMany() { - Configurations configurations = new Configurations(); - - EbeanServer server = Ebean.getServer(null); - - server.save(configurations); + CalculationResult r = new CalculationResult(); + final Double charge = 100.0; + r.setCharge(charge); + r.setProductConfiguration(pc); + r.setGroupConfiguration(null); + server.save(r); + } + + @Test + public void testAssocMany() { + Configurations configurations = new Configurations(); + + EbeanServer server = Ebean.getServer(null); + + server.save(configurations); - final GroupConfiguration gc = new GroupConfiguration("GC1"); - configurations.add(gc); - - - server.save(gc); - - - Configurations configurationsQueried = server.find(Configurations.class, configurations.getId()); - - List groups = configurationsQueried.getGroupConfigurations(); - - Assert.assertTrue(!groups.isEmpty()); - } + final GroupConfiguration gc = new GroupConfiguration("GC1"); + configurations.add(gc); - @Test - public void testAssocManyWithNoneRelated() { - Configurations configurations = new Configurations(); - - EbeanServer server = Ebean.getServer(null); - - server.save(configurations); - - Configurations configurationsQueried = server.find(Configurations.class).fetch("groupConfigurations").where().idEq(configurations.getId()).findUnique(); - - Assert.assertNotNull(configurationsQueried); - } - -} \ No newline at end of file + + server.save(gc); + + + Configurations configurationsQueried = server.find(Configurations.class, configurations.getId()); + + List groups = configurationsQueried.getGroupConfigurations(); + + Assert.assertTrue(!groups.isEmpty()); + } + + @Test + public void testAssocManyWithNoneRelated() { + Configurations configurations = new Configurations(); + + EbeanServer server = Ebean.getServer(null); + + server.save(configurations); + + Configurations configurationsQueried = server.find(Configurations.class).fetch("groupConfigurations").where().idEq(configurations.getId()).findUnique(); + + Assert.assertNotNull(configurationsQueried); + } + +} diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java b/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java index 90d7abc60..1900c0167 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritanceOnMany.java @@ -43,7 +43,7 @@ public class TestInheritanceOnMany extends BaseTestCase { AnimalShelter shelter2 = Ebean.find(AnimalShelter.class, shelter.getId()); List animals = shelter2.getAnimals(); - BeanList beanList = (BeanList)animals; + BeanList beanList = (BeanList) animals; ModifyListenMode modifyListenMode = beanList.getModifyListenMode(); assertNotNull(modifyListenMode); diff --git a/src/test/java/com/avaje/tests/inheritance/TestInheritanceRawSql.java b/src/test/java/com/avaje/tests/inheritance/TestInheritanceRawSql.java index 7ced4d957..75a19eb0a 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestInheritanceRawSql.java +++ b/src/test/java/com/avaje/tests/inheritance/TestInheritanceRawSql.java @@ -1,52 +1,51 @@ package com.avaje.tests.inheritance; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Truck; import com.avaje.tests.model.basic.Vehicle; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestInheritanceRawSql extends BaseTestCase { @Test public void test() { - + Truck truck = new Truck(); truck.setCapacity(50D); truck.setLicenseNumber("ASB23"); - + Ebean.save(truck); - - + + String sql = "select dtype, id, license_number from vehicle where id = :id"; RawSqlBuilder rawSqlBuilder = RawSqlBuilder.parse(sql); - + RawSql rawSql = rawSqlBuilder.create(); - + List list = Ebean.find(Vehicle.class) - .setRawSql(rawSql) - .setParameter("id", truck.getId()) - .findList(); - + .setRawSql(rawSql) + .setParameter("id", truck.getId()) + .findList(); + Assert.assertEquals(1, list.size()); - + Vehicle vehicle2 = list.get(0); Assert.assertTrue(vehicle2 instanceof Truck); - Truck truck2 = (Truck)vehicle2; + Truck truck2 = (Truck) vehicle2; Assert.assertEquals("ASB23", truck2.getLicenseNumber()); - + // invoke lazy loading and set the capacity truck2.setCapacity(30D); - + // and now save Ebean.save(truck2); } - + } diff --git a/src/test/java/com/avaje/tests/inheritance/TestIntInherit.java b/src/test/java/com/avaje/tests/inheritance/TestIntInherit.java index 735519c06..20714f2d3 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestIntInherit.java +++ b/src/test/java/com/avaje/tests/inheritance/TestIntInherit.java @@ -1,48 +1,47 @@ package com.avaje.tests.inheritance; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TIntChild; import com.avaje.tests.model.basic.TIntRoot; +import org.junit.Assert; +import org.junit.Test; public class TestIntInherit extends BaseTestCase { @Test - public void testMe() { + public void testMe() { + + TIntRoot r = new TIntRoot(); + r.setName("root1"); + + TIntRoot r2 = new TIntRoot(); + r.setName("root2"); + + TIntChild c1 = new TIntChild(); + c1.setName("child1"); + c1.setChildProperty("cp1"); + + TIntChild c2 = new TIntChild(); + c2.setName("child2"); + c2.setChildProperty("cp2"); + + + Ebean.save(r); + Ebean.save(r2); + Ebean.save(c1); + Ebean.save(c2); + + TIntRoot result1 = Ebean.find(TIntRoot.class, r.getId()); + Assert.assertTrue(result1 instanceof TIntRoot); + + TIntRoot ref3 = Ebean.getReference(TIntRoot.class, c1.getId()); + Assert.assertTrue(ref3 instanceof TIntChild); + + TIntRoot result3 = Ebean.find(TIntRoot.class, c1.getId()); + Assert.assertTrue(result3 instanceof TIntChild); + + } - TIntRoot r = new TIntRoot(); - r.setName("root1"); - - TIntRoot r2 = new TIntRoot(); - r.setName("root2"); - - TIntChild c1 = new TIntChild(); - c1.setName("child1"); - c1.setChildProperty("cp1"); - - TIntChild c2 = new TIntChild(); - c2.setName("child2"); - c2.setChildProperty("cp2"); - - - Ebean.save(r); - Ebean.save(r2); - Ebean.save(c1); - Ebean.save(c2); - - TIntRoot result1 = Ebean.find(TIntRoot.class, r.getId()); - Assert.assertTrue(result1 instanceof TIntRoot); - - TIntRoot ref3 = Ebean.getReference(TIntRoot.class, c1.getId()); - Assert.assertTrue(ref3 instanceof TIntChild); - - TIntRoot result3 = Ebean.find(TIntRoot.class, c1.getId()); - Assert.assertTrue(result3 instanceof TIntChild); - - } - } diff --git a/src/test/java/com/avaje/tests/inheritance/TestSkippable.java b/src/test/java/com/avaje/tests/inheritance/TestSkippable.java index b30a33868..40e2657fe 100644 --- a/src/test/java/com/avaje/tests/inheritance/TestSkippable.java +++ b/src/test/java/com/avaje/tests/inheritance/TestSkippable.java @@ -1,73 +1,72 @@ package com.avaje.tests.inheritance; -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.AttributeHolder; import com.avaje.tests.model.basic.ListAttribute; import com.avaje.tests.model.basic.ListAttributeValue; +import org.junit.Assert; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestSkippable extends BaseTestCase { private static final Logger logger = LoggerFactory.getLogger(TestSkippable.class); - /** - * Test query. - *

This test covers the BUG 276. Cascade was not propagating to the ListAttribute because - * it was considered safe to skip as it didn't take into account any derived classes - * into account with e.g. collections and Cascade options

- */ + /** + * Test query. + *

This test covers the BUG 276. Cascade was not propagating to the ListAttribute because + * it was considered safe to skip as it didn't take into account any derived classes + * into account with e.g. collections and Cascade options

+ */ @Test - public void testQuery() { - - // Setup the data first - final ListAttributeValue value1 = new ListAttributeValue(); - final ListAttributeValue value2 = new ListAttributeValue(); - - Ebean.save(value1); - Ebean.save(value2); - - final ListAttribute listAttribute = new ListAttribute(); - listAttribute.add(value1); - Ebean.save(listAttribute); - logger.info(" -- seeded data"); - - final ListAttribute listAttributeDB = Ebean.find(ListAttribute.class, listAttribute.getId()); - Assert.assertNotNull(listAttributeDB); + public void testQuery() { - final ListAttributeValue value1_DB = listAttributeDB.getValues().iterator().next(); - Assert.assertTrue(value1.getId().equals(value1_DB.getId())); + // Setup the data first + final ListAttributeValue value1 = new ListAttributeValue(); + final ListAttributeValue value2 = new ListAttributeValue(); + + Ebean.save(value1); + Ebean.save(value2); + + final ListAttribute listAttribute = new ListAttribute(); + listAttribute.add(value1); + Ebean.save(listAttribute); + logger.info(" -- seeded data"); + + final ListAttribute listAttributeDB = Ebean.find(ListAttribute.class, listAttribute.getId()); + Assert.assertNotNull(listAttributeDB); + + final ListAttributeValue value1_DB = listAttributeDB.getValues().iterator().next(); + Assert.assertTrue(value1.getId().equals(value1_DB.getId())); logger.info(" -- asserted data in db"); - - - final AttributeHolder holder = new AttributeHolder(); - holder.add(listAttributeDB); - - Ebean.save(holder); - logger.info(" -- saved holder"); - - // Now change the M2M listAttribute.values and save the holder - // The save should cascade as follows - // holder.attributes..ListAttribute.values - listAttributeDB.getValues().clear(); - listAttributeDB.add(value2); - - // Save the holder - should cascade down to the listAtribute and save the values - Ebean.save(holder); - logger.info(" -- M2M detected delete of value1 and add of value2 ?"); - - final ListAttribute listAttributeDB_2 = Ebean.find(ListAttribute.class, listAttributeDB.getId()); - Assert.assertNotNull(listAttributeDB_2); - final ListAttributeValue value2_DB_2 = listAttributeDB_2.getValues().iterator().next(); - - + + final AttributeHolder holder = new AttributeHolder(); + holder.add(listAttributeDB); + + Ebean.save(holder); + logger.info(" -- saved holder"); + + // Now change the M2M listAttribute.values and save the holder + // The save should cascade as follows + // holder.attributes..ListAttribute.values + listAttributeDB.getValues().clear(); + listAttributeDB.add(value2); + + // Save the holder - should cascade down to the listAtribute and save the values + Ebean.save(holder); + logger.info(" -- M2M detected delete of value1 and add of value2 ?"); + + + final ListAttribute listAttributeDB_2 = Ebean.find(ListAttribute.class, listAttributeDB.getId()); + Assert.assertNotNull(listAttributeDB_2); + final ListAttributeValue value2_DB_2 = listAttributeDB_2.getValues().iterator().next(); + + Assert.assertEquals(value2.getId(), value2_DB_2.getId()); - Assert.assertTrue("Cascade failed", value2.getId().equals(value2_DB_2.getId())); - - } + Assert.assertTrue("Cascade failed", value2.getId().equals(value2_DB_2.getId())); + + } } diff --git a/src/test/java/com/avaje/tests/inheritance/cache/TestInheritanceCache.java b/src/test/java/com/avaje/tests/inheritance/cache/TestInheritanceCache.java index 9007f999a..26c05b1de 100644 --- a/src/test/java/com/avaje/tests/inheritance/cache/TestInheritanceCache.java +++ b/src/test/java/com/avaje/tests/inheritance/cache/TestInheritanceCache.java @@ -22,14 +22,14 @@ public class TestInheritanceCache extends BaseTestCase { Ebean.save(one); CInhRoot gotOne = Ebean.find(CInhRoot.class) - .setId(one.getId()) - .findUnique(); + .setId(one.getId()) + .findUnique(); assertThat(gotOne).isInstanceOf(CInhOne.class); CInhRoot gotOneFromCache = Ebean.find(CInhRoot.class) - .setId(one.getId()) - .findUnique(); + .setId(one.getId()) + .findUnique(); assertThat(gotOneFromCache).isInstanceOf(CInhOne.class); diff --git a/src/test/java/com/avaje/tests/inheritance/company/domain/AbstractBar.java b/src/test/java/com/avaje/tests/inheritance/company/domain/AbstractBar.java index 4baf6556e..1f79ff2f3 100644 --- a/src/test/java/com/avaje/tests/inheritance/company/domain/AbstractBar.java +++ b/src/test/java/com/avaje/tests/inheritance/company/domain/AbstractBar.java @@ -24,38 +24,38 @@ import javax.persistence.Version; //@MappedSuperclass public abstract class AbstractBar { - @Id - @GeneratedValue - private int barId; + @Id + @GeneratedValue + private int barId; - @ManyToOne(optional = false, fetch = FetchType.LAZY) - @JoinColumn(name = "foo_id", nullable = false) - private Foo foo; + @ManyToOne(optional = false, fetch = FetchType.LAZY) + @JoinColumn(name = "foo_id", nullable = false) + private Foo foo; - @Version - private int version; + @Version + private int version; - public void setBarId(int barId) { - this.barId = barId; - } + public void setBarId(int barId) { + this.barId = barId; + } - public int getBarId() { - return barId; - } + public int getBarId() { + return barId; + } - public Foo getFoo() { - return foo; - } + public Foo getFoo() { + return foo; + } - public void setFoo(Foo foo) { - this.foo = foo; - } + public void setFoo(Foo foo) { + this.foo = foo; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/company/domain/Foo.java b/src/test/java/com/avaje/tests/inheritance/company/domain/Foo.java index af26530f1..e7fa432ba 100644 --- a/src/test/java/com/avaje/tests/inheritance/company/domain/Foo.java +++ b/src/test/java/com/avaje/tests/inheritance/company/domain/Foo.java @@ -12,36 +12,36 @@ import javax.persistence.Version; @Entity @Table(name = "foo") public class Foo { - @Id - @GeneratedValue - private int fooId; + @Id + @GeneratedValue + private int fooId; - private String importantText; + private String importantText; - @Version - private int version; + @Version + private int version; - public void setFooId(int fooId) { - this.fooId = fooId; - } + public void setFooId(int fooId) { + this.fooId = fooId; + } - public int getFooId() { - return fooId; - } + public int getFooId() { + return fooId; + } - public String getImportantText() { - return importantText; - } + public String getImportantText() { + return importantText; + } - public void setImportantText(String importantText) { - this.importantText = importantText; - } + public void setImportantText(String importantText) { + this.importantText = importantText; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/company/domain/TestInheritAbstract.java b/src/test/java/com/avaje/tests/inheritance/company/domain/TestInheritAbstract.java index 120c78e17..a6ecbd779 100644 --- a/src/test/java/com/avaje/tests/inheritance/company/domain/TestInheritAbstract.java +++ b/src/test/java/com/avaje/tests/inheritance/company/domain/TestInheritAbstract.java @@ -9,44 +9,44 @@ import java.util.List; public class TestInheritAbstract extends TestCase { - public void testMe() { + public void testMe() { + + EbeanServer server = Ebean.getServer(null); + + List list0 = server.find(AbstractBar.class) + .findList(); + + Assert.assertNotNull(list0); + + List list1 = server.find(AbstractBar.class) + .fetch("foo", "importantText") + .findList(); + + Assert.assertNotNull(list1); + + Foo f = new Foo(); + f.setImportantText("blah"); + + server.save(f); + + ConcreteBar cb = new ConcreteBar(); + cb.setFoo(f); + server.save(cb); + + List list2 = server.find(AbstractBar.class) + .fetch("foo", "importantText") + .findList(); + + Assert.assertNotNull(list2); + Assert.assertTrue(!list2.isEmpty()); + + for (AbstractBar abstractBar : list2) { + Foo foo = abstractBar.getFoo(); + String importantText = foo.getImportantText(); + Assert.assertNotNull(importantText); + } + + + } - EbeanServer server = Ebean.getServer(null); - - List list0 = server.find(AbstractBar.class) - .findList(); - - Assert.assertNotNull(list0); - - List list1 = server.find(AbstractBar.class) - .fetch("foo", "importantText") - .findList(); - - Assert.assertNotNull(list1); - - Foo f = new Foo(); - f.setImportantText("blah"); - - server.save(f); - - ConcreteBar cb = new ConcreteBar(); - cb.setFoo(f); - server.save(cb); - - List list2 = server.find(AbstractBar.class) - .fetch("foo", "importantText") - .findList(); - - Assert.assertNotNull(list2); - Assert.assertTrue(!list2.isEmpty()); - - for (AbstractBar abstractBar : list2) { - Foo foo = abstractBar.getFoo(); - String importantText = foo.getImportantText(); - Assert.assertNotNull(importantText); - } - - - } - } diff --git a/src/test/java/com/avaje/tests/inheritance/model/AbstractBaseClass.java b/src/test/java/com/avaje/tests/inheritance/model/AbstractBaseClass.java index 482a995cb..3545ddc24 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/AbstractBaseClass.java +++ b/src/test/java/com/avaje/tests/inheritance/model/AbstractBaseClass.java @@ -4,13 +4,13 @@ import javax.persistence.MappedSuperclass; @MappedSuperclass public class AbstractBaseClass { - private String name; + private String name; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/model/CalculationResult.java b/src/test/java/com/avaje/tests/inheritance/model/CalculationResult.java index 76830e0c8..68966ad81 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/CalculationResult.java +++ b/src/test/java/com/avaje/tests/inheritance/model/CalculationResult.java @@ -8,48 +8,48 @@ import javax.persistence.ManyToOne; @Entity public class CalculationResult { - - @Id - @Column(name="id") - private Integer id; - - private double charge; - - @ManyToOne(cascade=CascadeType.PERSIST) - private ProductConfiguration productConfiguration; - @ManyToOne(cascade=CascadeType.PERSIST) - private GroupConfiguration groupConfiguration; - - public double getCharge() { - return charge; - } + @Id + @Column(name = "id") + private Integer id; - public void setCharge(double charge) { - this.charge = charge; - } + private double charge; - public ProductConfiguration getProductConfiguration() { - return productConfiguration; - } + @ManyToOne(cascade = CascadeType.PERSIST) + private ProductConfiguration productConfiguration; - public void setProductConfiguration(ProductConfiguration productConfiguration) { - this.productConfiguration = productConfiguration; - } + @ManyToOne(cascade = CascadeType.PERSIST) + private GroupConfiguration groupConfiguration; - public GroupConfiguration getGroupConfiguration() { - return groupConfiguration; - } + public double getCharge() { + return charge; + } - public void setGroupConfiguration(GroupConfiguration groupConfiguration) { - this.groupConfiguration = groupConfiguration; - } + public void setCharge(double charge) { + this.charge = charge; + } - public Integer getId() { - return id; - } + public ProductConfiguration getProductConfiguration() { + return productConfiguration; + } - public void setId(Integer id) { - this.id = id; - } + public void setProductConfiguration(ProductConfiguration productConfiguration) { + this.productConfiguration = productConfiguration; + } + + public GroupConfiguration getGroupConfiguration() { + return groupConfiguration; + } + + public void setGroupConfiguration(GroupConfiguration groupConfiguration) { + this.groupConfiguration = groupConfiguration; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/model/Configuration.java b/src/test/java/com/avaje/tests/inheritance/model/Configuration.java index 66700b2fa..79a994669 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/Configuration.java +++ b/src/test/java/com/avaje/tests/inheritance/model/Configuration.java @@ -13,35 +13,35 @@ import javax.persistence.ManyToOne; @ChangeLog @Entity -@Inheritance(strategy=InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING) -public class Configuration extends AbstractBaseClass{ - @Id - @Column(name="id") - private Integer id; - - - @ManyToOne - private Configurations configurations; - - - public Configuration(){ - super(); - } - - public Integer getId() { - return id; - } +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) +public class Configuration extends AbstractBaseClass { + @Id + @Column(name = "id") + private Integer id; - public void setId(Integer id) { - this.id = id; - } - public Configurations getConfigurations() { - return configurations; - } + @ManyToOne + private Configurations configurations; - public void setConfigurations(Configurations configurations) { - this.configurations = configurations; - } + + public Configuration() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Configurations getConfigurations() { + return configurations; + } + + public void setConfigurations(Configurations configurations) { + this.configurations = configurations; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/model/Configurations.java b/src/test/java/com/avaje/tests/inheritance/model/Configurations.java index 2664c9c3e..485541f8a 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/Configurations.java +++ b/src/test/java/com/avaje/tests/inheritance/model/Configurations.java @@ -1,11 +1,10 @@ package com.avaje.tests.inheritance.model; -import java.util.List; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; +import java.util.List; @Entity public class Configurations { diff --git a/src/test/java/com/avaje/tests/inheritance/model/GroupConfiguration.java b/src/test/java/com/avaje/tests/inheritance/model/GroupConfiguration.java index 808819c03..71ca65e87 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/GroupConfiguration.java +++ b/src/test/java/com/avaje/tests/inheritance/model/GroupConfiguration.java @@ -1,41 +1,40 @@ package com.avaje.tests.inheritance.model; -import java.util.List; - import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.OneToMany; +import java.util.List; @Entity @DiscriminatorValue("2") public class GroupConfiguration extends Configuration { - private String groupName; - - @OneToMany(mappedBy="groupConfiguration") - private List results; - - public GroupConfiguration(){ - super(); - } - - public GroupConfiguration(String name){ - super(); - this.groupName = name; - } - - public String getGroupName() { - return groupName; - } + private String groupName; - public void setGroupName(String groupName) { - this.groupName = groupName; - } + @OneToMany(mappedBy = "groupConfiguration") + private List results; - public List getResults() { - return results; - } + public GroupConfiguration() { + super(); + } - public void setResults(List results) { - this.results = results; - } + public GroupConfiguration(String name) { + super(); + this.groupName = name; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } } diff --git a/src/test/java/com/avaje/tests/inheritance/model/ProductConfiguration.java b/src/test/java/com/avaje/tests/inheritance/model/ProductConfiguration.java index bc1dd6a84..b5968f921 100644 --- a/src/test/java/com/avaje/tests/inheritance/model/ProductConfiguration.java +++ b/src/test/java/com/avaje/tests/inheritance/model/ProductConfiguration.java @@ -1,36 +1,35 @@ package com.avaje.tests.inheritance.model; -import java.util.List; - import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.OneToMany; +import java.util.List; @Entity @DiscriminatorValue("1") public class ProductConfiguration extends Configuration { - private String productName; - - @OneToMany(mappedBy="productConfiguration") - private List results; - - public ProductConfiguration(){ - super(); - } + private String productName; - public String getProductName() { - return productName; - } + @OneToMany(mappedBy = "productConfiguration") + private List results; - public void setProductName(String productName) { - this.productName = productName; - } + public ProductConfiguration() { + super(); + } - public List getResults() { - return results; - } + public String getProductName() { + return productName; + } - public void setResults(List results) { - this.results = results; - } + public void setProductName(String productName) { + this.productName = productName; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } } diff --git a/src/test/java/com/avaje/tests/insert/MainDbCopy.java b/src/test/java/com/avaje/tests/insert/MainDbCopy.java index cfd57e8d1..6860193ca 100644 --- a/src/test/java/com/avaje/tests/insert/MainDbCopy.java +++ b/src/test/java/com/avaje/tests/insert/MainDbCopy.java @@ -7,23 +7,23 @@ import com.avaje.tests.model.basic.EBasic.Status; public class MainDbCopy { - public static void main(String[] args) { - - EbeanServer defaultServer = Ebean.getServer(null); - - EBasic e = new EBasic(); - e.setName("blah"); - e.setStatus(Status.NEW); - e.setDescription(null); - - defaultServer.save(e); - - EBasic e1 = defaultServer.find(EBasic.class, e.getId()); - - EbeanServer serverDest = Ebean.getServer("mysql"); - - serverDest.insert(e1); - - - } + public static void main(String[] args) { + + EbeanServer defaultServer = Ebean.getServer(null); + + EBasic e = new EBasic(); + e.setName("blah"); + e.setStatus(Status.NEW); + e.setDescription(null); + + defaultServer.save(e); + + EBasic e1 = defaultServer.find(EBasic.class, e.getId()); + + EbeanServer serverDest = Ebean.getServer("mysql"); + + serverDest.insert(e1); + + + } } diff --git a/src/test/java/com/avaje/tests/insert/TestInsertCollection.java b/src/test/java/com/avaje/tests/insert/TestInsertCollection.java index 6ff223931..ec7d5cff5 100644 --- a/src/test/java/com/avaje/tests/insert/TestInsertCollection.java +++ b/src/test/java/com/avaje/tests/insert/TestInsertCollection.java @@ -1,43 +1,42 @@ package com.avaje.tests.insert; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestInsertCollection extends BaseTestCase { @Test public void test() { - + Customer cust1 = new Customer(); cust1.setName("jim"); - + Customer cust2 = new Customer(); cust2.setName("bob"); - + List customers = new ArrayList<>(); customers.add(cust1); customers.add(cust2); - + Ebean.insertAll(customers); - + Assert.assertNotNull(cust1.getId()); Assert.assertNotNull(cust2.getId()); - + Customer cust1Check = Ebean.find(Customer.class, cust1.getId()); Assert.assertEquals(cust1.getName(), cust1Check.getName()); Customer cust2Check = Ebean.find(Customer.class, cust2.getId()); Assert.assertEquals(cust2.getName(), cust2Check.getName()); - + cust1.setName("jim-changed"); cust2.setName("bob-changed"); - + Ebean.updateAll(customers); awaitL2Cache(); @@ -54,7 +53,7 @@ public class TestInsertCollection extends BaseTestCase { List saveList = new ArrayList<>(); saveList.add(cust1Check2); saveList.add(cust3); - + Ebean.saveAll(saveList); awaitL2Cache(); @@ -77,7 +76,6 @@ public class TestInsertCollection extends BaseTestCase { Assert.assertNull(Ebean.find(Customer.class, cust3.getId())); } - - - + + } diff --git a/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java b/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java index 16f83ee1b..0078679ce 100644 --- a/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java +++ b/src/test/java/com/avaje/tests/insert/TestInsertOnStringKey.java @@ -1,35 +1,34 @@ package com.avaje.tests.insert; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.tests.model.orderentity.OrderEntity; +import com.avaje.tests.model.orderentity.OrderItemEntity; +import org.junit.Test; + import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.junit.Test; - -import com.avaje.ebean.BaseTestCase; -import com.avaje.ebean.Ebean; -import com.avaje.tests.model.orderentity.OrderEntity; -import com.avaje.tests.model.orderentity.OrderItemEntity; - public class TestInsertOnStringKey extends BaseTestCase { @Test public void test() { - - + + OrderEntity orderEntity = new OrderEntity(); - orderEntity.setId("anyOrderId"+new Random().nextInt()); - + orderEntity.setId("anyOrderId" + new Random().nextInt()); + OrderItemEntity orderItemEntity = new OrderItemEntity(); - orderItemEntity.setId("anyOrderItemId"+new Random().nextInt()); + orderItemEntity.setId("anyOrderItemId" + new Random().nextInt()); orderItemEntity.setVariantId("anyVariantId"); orderItemEntity.setAmount(BigDecimal.ONE); - + orderEntity.setItems(toList(orderItemEntity)); - + Ebean.save(orderEntity); - + } private List toList(OrderItemEntity orderItemEntity) { @@ -37,5 +36,5 @@ public class TestInsertOnStringKey extends BaseTestCase { list.add(orderItemEntity); return list; } - + } diff --git a/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java b/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java index 69bb66d88..5962e7c9f 100644 --- a/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java +++ b/src/test/java/com/avaje/tests/iud/TestCarWheelIud.java @@ -13,44 +13,44 @@ import java.util.List; public class TestCarWheelIud extends BaseTestCase { @Test - public void test() { + public void test() { - Car car = new Car(); + Car car = new Car(); - Tire t1 = new Tire(); - Wheel w1 = new Wheel(); - w1.setCar(car); - w1.setTire(t1); + Tire t1 = new Tire(); + Wheel w1 = new Wheel(); + w1.setCar(car); + w1.setTire(t1); - Tire t2 = new Tire(); - Wheel w2 = new Wheel(); - w2.setCar(car); - w2.setTire(t2); + Tire t2 = new Tire(); + Wheel w2 = new Wheel(); + w2.setCar(car); + w2.setTire(t2); - Tire t3 = new Tire(); - Wheel w3 = new Wheel(); - w3.setCar(car); - w3.setTire(t3); + Tire t3 = new Tire(); + Wheel w3 = new Wheel(); + w3.setCar(car); + w3.setTire(t3); - Tire t4 = new Tire(); - Wheel w4 = new Wheel(); - w4.setCar(car); - w4.setTire(t4); - - List wheels = new ArrayList<>(); - wheels.add(w1); - wheels.add(w2); - wheels.add(w3); - wheels.add(w4); - - car.setWheels(wheels); + Tire t4 = new Tire(); + Wheel w4 = new Wheel(); + w4.setCar(car); + w4.setTire(t4); - Ebean.save(car); + List wheels = new ArrayList<>(); + wheels.add(w1); + wheels.add(w2); + wheels.add(w3); + wheels.add(w4); - // And I'm trying to delete this entry with code: - Car car2 = Ebean.find(Car.class, car.getId()); + car.setWheels(wheels); - Ebean.delete(car2); + Ebean.save(car); - } + // And I'm trying to delete this entry with code: + Car car2 = Ebean.find(Car.class, car.getId()); + + Ebean.delete(car2); + + } } diff --git a/src/test/java/com/avaje/tests/iud/TestInsertQueryUpdate.java b/src/test/java/com/avaje/tests/iud/TestInsertQueryUpdate.java index e4eaf5894..a80090543 100644 --- a/src/test/java/com/avaje/tests/iud/TestInsertQueryUpdate.java +++ b/src/test/java/com/avaje/tests/iud/TestInsertQueryUpdate.java @@ -1,34 +1,33 @@ package com.avaje.tests.iud; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EBasicVer; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Set; public class TestInsertQueryUpdate extends BaseTestCase { - + @Test public void test() { - + EBasicVer e0 = new EBasicVer("name0"); e0.setDescription("desc0"); Ebean.save(e0); - + EBasicVer e1 = Ebean.find(EBasicVer.class) - .select("name") - .setId(e0.getId()) - .findUnique(); - + .select("name") + .setId(e0.getId()) + .findUnique(); + BeanState beanState = Ebean.getBeanState(e1); Set loadedProps = beanState.getLoadedProps(); Assert.assertFalse(loadedProps.contains("description")); //lastUpdate - + e1.setName("name1"); Ebean.save(e1); diff --git a/src/test/java/com/avaje/tests/iud/TestInsertUpdateTrans.java b/src/test/java/com/avaje/tests/iud/TestInsertUpdateTrans.java index 6c71a44ab..d5bbdf3a7 100644 --- a/src/test/java/com/avaje/tests/iud/TestInsertUpdateTrans.java +++ b/src/test/java/com/avaje/tests/iud/TestInsertUpdateTrans.java @@ -1,45 +1,44 @@ package com.avaje.tests.iud; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EBasicVer; +import org.junit.Assert; +import org.junit.Test; public class TestInsertUpdateTrans extends BaseTestCase { @Test - public void test() { + public void test() { - Ebean.beginTransaction(); - try { + Ebean.beginTransaction(); + try { - EBasicVer e0 = new EBasicVer("onInsert"); - e0.setDescription("something"); - Ebean.save(e0); + EBasicVer e0 = new EBasicVer("onInsert"); + e0.setDescription("something"); + Ebean.save(e0); - Assert.assertNotNull(e0.getId()); - Assert.assertNotNull(e0.getLastUpdate()); - Assert.assertEquals("onInsert", e0.getName()); - - e0.setName("onUpdate"); - e0.setDescription("differentFromInsert"); - - Ebean.save(e0); - - EBasicVer e1 = Ebean.find(EBasicVer.class, e0.getId()); - - // we should fetch back the updated data (not inserted) - Assert.assertEquals(e0.getId(), e1.getId()); - Assert.assertEquals("onUpdate", e1.getName()); - Assert.assertEquals("differentFromInsert", e1.getDescription()); - - - Ebean.commitTransaction(); - - } finally { - Ebean.endTransaction(); - } - } + Assert.assertNotNull(e0.getId()); + Assert.assertNotNull(e0.getLastUpdate()); + Assert.assertEquals("onInsert", e0.getName()); + + e0.setName("onUpdate"); + e0.setDescription("differentFromInsert"); + + Ebean.save(e0); + + EBasicVer e1 = Ebean.find(EBasicVer.class, e0.getId()); + + // we should fetch back the updated data (not inserted) + Assert.assertEquals(e0.getId(), e1.getId()); + Assert.assertEquals("onUpdate", e1.getName()); + Assert.assertEquals("differentFromInsert", e1.getDescription()); + + + Ebean.commitTransaction(); + + } finally { + Ebean.endTransaction(); + } + } } diff --git a/src/test/java/com/avaje/tests/json/TestDbJson_List.java b/src/test/java/com/avaje/tests/json/TestDbJson_List.java index c1496d339..c751f4057 100644 --- a/src/test/java/com/avaje/tests/json/TestDbJson_List.java +++ b/src/test/java/com/avaje/tests/json/TestDbJson_List.java @@ -13,10 +13,7 @@ import java.util.List; import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestDbJson_List extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/json/TestJsonNodeBasic.java b/src/test/java/com/avaje/tests/json/TestJsonNodeBasic.java index e6ad3d8dd..462adaf70 100644 --- a/src/test/java/com/avaje/tests/json/TestJsonNodeBasic.java +++ b/src/test/java/com/avaje/tests/json/TestJsonNodeBasic.java @@ -69,7 +69,7 @@ public class TestJsonNodeBasic extends BaseTestCase { // parse JSON into whole bean with content EBasicJsonNode beanJsonRestored = Ebean.json().toBean(EBasicJsonNode.class, fullBeanJson); - assertEquals(99L,beanJsonRestored.getContent().path("docId").asLong()); + assertEquals(99L, beanJsonRestored.getContent().path("docId").asLong()); } @Test @@ -87,9 +87,9 @@ public class TestJsonNodeBasic extends BaseTestCase { Ebean.save(bean); EBasicJsonNode bean1 = Ebean.find(EBasicJsonNode.class) - .select("name") - .setId(bean.getId()) - .findUnique(); + .select("name") + .setId(bean.getId()) + .findUnique(); Set loadedProps = Ebean.getBeanState(bean1).getLoadedProps(); assertTrue(loadedProps.contains("name")); diff --git a/src/test/java/com/avaje/tests/json/TestJsonNodeBlob.java b/src/test/java/com/avaje/tests/json/TestJsonNodeBlob.java index 1bbd17c21..353594e17 100644 --- a/src/test/java/com/avaje/tests/json/TestJsonNodeBlob.java +++ b/src/test/java/com/avaje/tests/json/TestJsonNodeBlob.java @@ -54,9 +54,9 @@ public class TestJsonNodeBlob extends BaseTestCase { Ebean.save(bean); EBasicJsonNodeBlob bean1 = Ebean.find(EBasicJsonNodeBlob.class) - .select("name") - .setId(bean.getId()) - .findUnique(); + .select("name") + .setId(bean.getId()) + .findUnique(); Set loadedProps = Ebean.getBeanState(bean1).getLoadedProps(); assertTrue(loadedProps.contains("name")); diff --git a/src/test/java/com/avaje/tests/json/TestJsonNodeJsonb.java b/src/test/java/com/avaje/tests/json/TestJsonNodeJsonb.java index ab455814b..b9215f5c9 100644 --- a/src/test/java/com/avaje/tests/json/TestJsonNodeJsonb.java +++ b/src/test/java/com/avaje/tests/json/TestJsonNodeJsonb.java @@ -54,9 +54,9 @@ public class TestJsonNodeJsonb extends BaseTestCase { Ebean.save(bean); EBasicJsonNodeJsonB bean1 = Ebean.find(EBasicJsonNodeJsonB.class) - .select("name") - .setId(bean.getId()) - .findUnique(); + .select("name") + .setId(bean.getId()) + .findUnique(); Set loadedProps = Ebean.getBeanState(bean1).getLoadedProps(); assertTrue(loadedProps.contains("name")); diff --git a/src/test/java/com/avaje/tests/json/TestJsonNodeVarchar.java b/src/test/java/com/avaje/tests/json/TestJsonNodeVarchar.java index b4b341154..4b1ebab0b 100644 --- a/src/test/java/com/avaje/tests/json/TestJsonNodeVarchar.java +++ b/src/test/java/com/avaje/tests/json/TestJsonNodeVarchar.java @@ -54,9 +54,9 @@ public class TestJsonNodeVarchar extends BaseTestCase { Ebean.save(bean); EBasicJsonNodeVarchar bean1 = Ebean.find(EBasicJsonNodeVarchar.class) - .select("name") - .setId(bean.getId()) - .findUnique(); + .select("name") + .setId(bean.getId()) + .findUnique(); Set loadedProps = Ebean.getBeanState(bean1).getLoadedProps(); assertTrue(loadedProps.contains("name")); diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java index 2e6901c58..f6e018c40 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptyList.java @@ -4,7 +4,6 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.config.JsonConfig; import com.avaje.ebean.text.json.JsonWriteOptions; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.OrderDetail; import org.junit.Test; import java.util.ArrayList; diff --git a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java index bdf677d1f..2e35c79b2 100644 --- a/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java +++ b/src/test/java/com/avaje/tests/json/include/TestJsonExcludeEmptySet.java @@ -3,7 +3,6 @@ package com.avaje.tests.json.include; import com.avaje.ebean.Ebean; import com.avaje.ebean.config.JsonConfig; import com.avaje.ebean.text.json.JsonWriteOptions; -import com.avaje.tests.model.basic.Attribute; import com.avaje.tests.model.basic.AttributeHolder; import org.junit.Test; diff --git a/src/test/java/com/avaje/tests/json/transientproperties/TestJacksonIgnore.java b/src/test/java/com/avaje/tests/json/transientproperties/TestJacksonIgnore.java index 321213be3..10ee9e890 100644 --- a/src/test/java/com/avaje/tests/json/transientproperties/TestJacksonIgnore.java +++ b/src/test/java/com/avaje/tests/json/transientproperties/TestJacksonIgnore.java @@ -3,9 +3,7 @@ package com.avaje.tests.json.transientproperties; import com.avaje.ebean.Ebean; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; public class TestJacksonIgnore { diff --git a/src/test/java/com/avaje/tests/json/transientproperties/TestTransientObjectProperty.java b/src/test/java/com/avaje/tests/json/transientproperties/TestTransientObjectProperty.java index de82de942..9f2d3ccfe 100644 --- a/src/test/java/com/avaje/tests/json/transientproperties/TestTransientObjectProperty.java +++ b/src/test/java/com/avaje/tests/json/transientproperties/TestTransientObjectProperty.java @@ -14,10 +14,10 @@ public class TestTransientObjectProperty { EJsonTransientObject bean = Ebean.json().toBean(EJsonTransientObject.class, rawJson); - assertEquals("entityBeanName",bean.getName()); - assertEquals(true,bean.getBasic()); - assertEquals("transientBeanName",bean.getSomeBean().name); - assertEquals("foo",bean.getSomeBean().baz); + assertEquals("entityBeanName", bean.getName()); + assertEquals(true, bean.getBasic()); + assertEquals("transientBeanName", bean.getSomeBean().name); + assertEquals("foo", bean.getSomeBean().baz); String asJson = Ebean.json().toJson(bean); diff --git a/src/test/java/com/avaje/tests/level/Level1.java b/src/test/java/com/avaje/tests/level/Level1.java index b01bac056..9a0812265 100644 --- a/src/test/java/com/avaje/tests/level/Level1.java +++ b/src/test/java/com/avaje/tests/level/Level1.java @@ -1,56 +1,61 @@ package com.avaje.tests.level; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; import java.util.Set; @Entity public class Level1 { - @Id - Long id; + @Id + Long id; - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable( - name = "level1_level4", - joinColumns = @JoinColumn(name = "level1_id", referencedColumnName = "id"), - inverseJoinColumns = @JoinColumn(name = "level4_id", referencedColumnName = "id") - ) - Set level4s; + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable( + name = "level1_level4", + joinColumns = @JoinColumn(name = "level1_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "level4_id", referencedColumnName = "id") + ) + Set level4s; - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable( - name = "level1_level2", - joinColumns = @JoinColumn(name = "level1_id", referencedColumnName = "id"), - inverseJoinColumns = @JoinColumn(name = "level2_id", referencedColumnName = "id") - ) - Set level2s; + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable( + name = "level1_level2", + joinColumns = @JoinColumn(name = "level1_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "level2_id", referencedColumnName = "id") + ) + Set level2s; - String name; + String name; - public Level1(String name) { - this.name = name; - } + public Level1(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public Set getLevel2s() { - return level2s; - } + public Set getLevel2s() { + return level2s; + } - public Set getLevel4s() { - return level4s; - } + public Set getLevel4s() { + return level4s; + } } diff --git a/src/test/java/com/avaje/tests/level/Level2.java b/src/test/java/com/avaje/tests/level/Level2.java index 2b3eda913..8243a343d 100644 --- a/src/test/java/com/avaje/tests/level/Level2.java +++ b/src/test/java/com/avaje/tests/level/Level2.java @@ -1,44 +1,49 @@ package com.avaje.tests.level; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; import java.util.List; @Entity public class Level2 { - @Id - Long id; + @Id + Long id; - @ManyToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) - @JoinTable( - name = "level2_level3", - joinColumns = @JoinColumn(name = "level2_id", referencedColumnName = "id"), - inverseJoinColumns = @JoinColumn(name = "level3_id", referencedColumnName = "id") - ) - List level3s; + @ManyToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) + @JoinTable( + name = "level2_level3", + joinColumns = @JoinColumn(name = "level2_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "level3_id", referencedColumnName = "id") + ) + List level3s; - String name; + String name; - public Level2(String name) { - this.name = name; - } + public Level2(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public List getLevel3s() { - return level3s; - } + public List getLevel3s() { + return level3s; + } } diff --git a/src/test/java/com/avaje/tests/level/Level3.java b/src/test/java/com/avaje/tests/level/Level3.java index 74a38fa74..37f8198ff 100644 --- a/src/test/java/com/avaje/tests/level/Level3.java +++ b/src/test/java/com/avaje/tests/level/Level3.java @@ -5,28 +5,28 @@ import javax.persistence.Id; @Entity public class Level3 { - @Id - Long id; + @Id + Long id; - String name; + String name; - public Level3(String name) { - this.name = name; - } + public Level3(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } } diff --git a/src/test/java/com/avaje/tests/level/Level4.java b/src/test/java/com/avaje/tests/level/Level4.java index 72f2c306d..5408512e5 100644 --- a/src/test/java/com/avaje/tests/level/Level4.java +++ b/src/test/java/com/avaje/tests/level/Level4.java @@ -5,28 +5,28 @@ import javax.persistence.Id; @Entity public class Level4 { - @Id - Long id; + @Id + Long id; - String name; + String name; - public Level4(String name) { - this.name = name; - } + public Level4(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } } diff --git a/src/test/java/com/avaje/tests/level/test/ManyToManyTest.java b/src/test/java/com/avaje/tests/level/test/ManyToManyTest.java index 08a34f022..27fff78b0 100644 --- a/src/test/java/com/avaje/tests/level/test/ManyToManyTest.java +++ b/src/test/java/com/avaje/tests/level/test/ManyToManyTest.java @@ -66,30 +66,30 @@ public class ManyToManyTest extends BaseTestCase { // this query had the original problem List things = Ebean.find(Level1.class) - .fetch("level4s") - .fetch("level2s") - .fetch("level2s.level3s") - .order().asc("id") - .findList(); + .fetch("level4s") + .fetch("level2s") + .fetch("level2s.level3s") + .order().asc("id") + .findList(); validateObjectGraph(i, ii, iii, one, two, x1, x2, x3, x4, x5, things); things = Ebean.find(Level1.class) - .fetch("level2s") - .fetch("level2s.level3s") - .fetch("level4s") - .order().asc("id") - .findList(); + .fetch("level2s") + .fetch("level2s.level3s") + .fetch("level4s") + .order().asc("id") + .findList(); validateObjectGraph(i, ii, iii, one, two, x1, x2, x3, x4, x5, things); things = Ebean.find(Level1.class) - .fetch("level2s") - .fetch("level4s") - .order().asc("id") - .findList(); + .fetch("level2s") + .fetch("level4s") + .order().asc("id") + .findList(); validateObjectGraph(i, ii, iii, one, two, x1, x2, x3, x4, x5, things); diff --git a/src/test/java/com/avaje/tests/lib/EbeanTestCase.java b/src/test/java/com/avaje/tests/lib/EbeanTestCase.java index dd6af6da9..71b3c4abc 100644 --- a/src/test/java/com/avaje/tests/lib/EbeanTestCase.java +++ b/src/test/java/com/avaje/tests/lib/EbeanTestCase.java @@ -1,43 +1,42 @@ package com.avaje.tests.lib; -import com.avaje.ebeaninternal.api.SpiEbeanServer; -import junit.framework.TestCase; -import junit.framework.TestResult; - import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Transaction; +import com.avaje.ebeaninternal.api.SpiEbeanServer; +import junit.framework.TestCase; +import junit.framework.TestResult; /** * The base class for all Ebean test to get access to the Ebean server and do * some cleanup stuff after a test has run */ public abstract class EbeanTestCase extends TestCase { - - @Override - public void run(TestResult testResult) { - try { - super.run(testResult); - } finally { - Transaction tx = getServer().currentTransaction(); - if (tx != null && tx.isActive()) { - // transaction left running after the test, rollback it to make - // the environment ready for the next test - tx.rollback(); - } - } - } - public EbeanServer getServer() { - return Ebean.getServer(null); - } + @Override + public void run(TestResult testResult) { + try { + super.run(testResult); + } finally { + Transaction tx = getServer().currentTransaction(); + if (tx != null && tx.isActive()) { + // transaction left running after the test, rollback it to make + // the environment ready for the next test + tx.rollback(); + } + } + } + + public EbeanServer getServer() { + return Ebean.getServer(null); + } /** * MS SQL Server does not allow setting explicit values on identity columns * so tests that do this need to be skipped for SQL Server. */ public boolean isMsSqlServer() { - SpiEbeanServer spi = (SpiEbeanServer)Ebean.getDefaultServer(); + SpiEbeanServer spi = (SpiEbeanServer) Ebean.getDefaultServer(); return spi.getDatabasePlatform().getName().startsWith("mssqlserver"); } diff --git a/src/test/java/com/avaje/tests/lib/TestMessage.java b/src/test/java/com/avaje/tests/lib/TestMessage.java index 00c0b9024..164323d07 100644 --- a/src/test/java/com/avaje/tests/lib/TestMessage.java +++ b/src/test/java/com/avaje/tests/lib/TestMessage.java @@ -1,20 +1,19 @@ package com.avaje.tests.lib; +import com.avaje.ebeaninternal.server.core.Message; import org.junit.Assert; import org.junit.Test; -import com.avaje.ebeaninternal.server.core.Message; +public class TestMessage { -public class TestMessage { + @Test + public void testMessage() { - @Test - public void testMessage(){ - - String one = "one"; - String two = "two"; - - String m = Message.msg("fetch.error", one, two); - boolean b = m.startsWith("Query threw SQLException:one Query was:"); - Assert.assertTrue(b); - } + String one = "one"; + String two = "two"; + + String m = Message.msg("fetch.error", one, two); + boolean b = m.startsWith("Query threw SQLException:one Query was:"); + Assert.assertTrue(b); + } } diff --git a/src/test/java/com/avaje/tests/lifecycle/TestLifecycleAnnotatedBean.java b/src/test/java/com/avaje/tests/lifecycle/TestLifecycleAnnotatedBean.java index aab8519e7..81ddb2cf7 100644 --- a/src/test/java/com/avaje/tests/lifecycle/TestLifecycleAnnotatedBean.java +++ b/src/test/java/com/avaje/tests/lifecycle/TestLifecycleAnnotatedBean.java @@ -18,7 +18,7 @@ public class TestLifecycleAnnotatedBean extends BaseTestCase { bean.setName("PrePersist"); Ebean.save(bean); - + assertThat(bean.getBuffer()).contains("prePersist1"); assertThat(bean.getBuffer()).contains("prePersist2"); } @@ -55,7 +55,7 @@ public class TestLifecycleAnnotatedBean extends BaseTestCase { bean.setName("Persisted"); Ebean.save(bean); - + bean.setName("PreUpdate"); Ebean.save(bean); @@ -103,6 +103,7 @@ public class TestLifecycleAnnotatedBean extends BaseTestCase { assertThat(bean.getBuffer()).contains("postRemove1"); assertThat(bean.getBuffer()).contains("postRemove2"); } + @Test public void shouldExecutePostConstructMethodsWhenFindingBean() { @@ -118,22 +119,21 @@ public class TestLifecycleAnnotatedBean extends BaseTestCase { assertThat(loaded.getBuffer()).contains("postLoad1"); assertThat(loaded.getBuffer()).contains("postLoad2"); } - + @Test public void shouldExecutePostConstructMethodsWhenInstantiated() { EBasicWithLifecycle bean = Ebean.getDefaultServer().createEntityBean(EBasicWithLifecycle.class); bean.setName("PostConstruct"); - + assertThat(bean.getBuffer()).contains("postConstruct1"); assertThat(bean.getBuffer()).contains("postConstruct2"); // assert also that postLoad is not executed now assertThat(bean.getBuffer()).doesNotContain("postLoad1"); assertThat(bean.getBuffer()).doesNotContain("postLoad2"); } - - - + + @Test public void testLazyLoadBehaviour() { @@ -142,18 +142,18 @@ public class TestLifecycleAnnotatedBean extends BaseTestCase { Ebean.save(bean); - BeanDescriptor desc = ((SpiEbeanServer)server()).getBeanDescriptor(EBasicWithLifecycle.class); - EBasicWithLifecycle loaded = desc.createReference(false, false, bean.getId(), null); - + BeanDescriptor desc = ((SpiEbeanServer) server()).getBeanDescriptor(EBasicWithLifecycle.class); + EBasicWithLifecycle loaded = desc.createReference(false, false, bean.getId(), null); + // Here you see the big difference. // @PostLoad is executed always, also on lazy loaded beans assertThat(loaded.getBuffer()).contains("postConstruct1"); assertThat(loaded.getBuffer()).contains("postConstruct2"); - + // assert also that postLoad is not yet executed assertThat(loaded.getBuffer()).doesNotContain("postLoad1"); assertThat(loaded.getBuffer()).doesNotContain("postLoad2"); - + // now read name -> will load the bean assertThat(loaded.getName()).isEqualTo("LazyLoad"); assertThat(loaded.getBuffer()).contains("postLoad1"); diff --git a/src/test/java/com/avaje/tests/model/BaseModel.java b/src/test/java/com/avaje/tests/model/BaseModel.java index 8f28a7686..1dba311c2 100644 --- a/src/test/java/com/avaje/tests/model/BaseModel.java +++ b/src/test/java/com/avaje/tests/model/BaseModel.java @@ -1,24 +1,23 @@ package com.avaje.tests.model; -import java.sql.Timestamp; - -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; -import javax.persistence.Version; - import com.avaje.ebean.Model; import com.avaje.ebean.annotation.WhenCreated; import com.avaje.ebean.annotation.WhenModified; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Version; +import java.sql.Timestamp; + @MappedSuperclass public class BaseModel extends Model { @Id Long id; - + @Version Long version; - + @WhenCreated Timestamp whenCreated; diff --git a/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java b/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java index d93bd9e1b..1acc1b190 100644 --- a/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java +++ b/src/test/java/com/avaje/tests/model/array/TestDbArray_basic.java @@ -48,12 +48,12 @@ public class TestDbArray_basic extends BaseTestCase { if (isPostgres()) { Query query = Ebean.find(EArrayBean.class) - .where() - .arrayContains("otherIds", 96L, 97L) - .arrayContains("uids", bean.getUids().get(0)) - .arrayContains("phoneNumbers", "9823") - .arrayIsNotEmpty("phoneNumbers") - .query(); + .where() + .arrayContains("otherIds", 96L, 97L) + .arrayContains("uids", bean.getUids().get(0)) + .arrayContains("phoneNumbers", "9823") + .arrayIsNotEmpty("phoneNumbers") + .query(); List list = query.findList(); @@ -64,10 +64,10 @@ public class TestDbArray_basic extends BaseTestCase { assertThat(list).hasSize(1); query = Ebean.find(EArrayBean.class) - .where() - .arrayIsEmpty("otherIds") - .arrayNotContains("uids", bean.getUids().get(0)) - .query(); + .where() + .arrayIsEmpty("otherIds") + .arrayNotContains("uids", bean.getUids().get(0)) + .query(); query.findList(); assertThat(query.getGeneratedSql()).contains(" coalesce(cardinality(t0.other_ids),0) = 0"); @@ -146,4 +146,4 @@ public class TestDbArray_basic extends BaseTestCase { Ebean.saveAll(all); Ebean.deleteAll(all); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/basic/Address.java b/src/test/java/com/avaje/tests/model/basic/Address.java index aefa53bb5..2f9cf523f 100644 --- a/src/test/java/com/avaje/tests/model/basic/Address.java +++ b/src/test/java/com/avaje/tests/model/basic/Address.java @@ -1,5 +1,7 @@ package com.avaje.tests.model.basic; +import com.avaje.tests.model.basic.metaannotation.SizeMedium; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -7,9 +9,6 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Version; import javax.validation.constraints.Size; - -import com.avaje.tests.model.basic.metaannotation.SizeMedium; - import java.sql.Timestamp; /** diff --git a/src/test/java/com/avaje/tests/model/basic/CKeyDetail.java b/src/test/java/com/avaje/tests/model/basic/CKeyDetail.java index 5a10edaac..e11eb8621 100644 --- a/src/test/java/com/avaje/tests/model/basic/CKeyDetail.java +++ b/src/test/java/com/avaje/tests/model/basic/CKeyDetail.java @@ -17,7 +17,7 @@ public class CKeyDetail { // @JoinColumn(name="parent_one_key", referencedColumnName="one_key"), // @JoinColumn(name="parent_two_key", referencedColumnName="two_key") // }) - CKeyParent parent; + CKeyParent parent; public CKeyDetail() { diff --git a/src/test/java/com/avaje/tests/model/basic/Car.java b/src/test/java/com/avaje/tests/model/basic/Car.java index 55a28ff99..e97ebccb7 100644 --- a/src/test/java/com/avaje/tests/model/basic/Car.java +++ b/src/test/java/com/avaje/tests/model/basic/Car.java @@ -22,6 +22,7 @@ public class Car extends Vehicle { LARGE("L"); String value; + Size(String value) { this.value = value; } diff --git a/src/test/java/com/avaje/tests/model/basic/Customer.java b/src/test/java/com/avaje/tests/model/basic/Customer.java index 2163bb330..ac22eeb47 100644 --- a/src/test/java/com/avaje/tests/model/basic/Customer.java +++ b/src/test/java/com/avaje/tests/model/basic/Customer.java @@ -30,12 +30,12 @@ import java.util.concurrent.locks.ReentrantLock; * Customer entity bean. */ @NamedQueries( - value = { - @NamedQuery(name = "name", query = "select(name) order by name"), - @NamedQuery(name = "withStatus", query = "select(name,status) order by name") - } + value = { + @NamedQuery(name = "name", query = "select(name) order by name"), + @NamedQuery(name = "withStatus", query = "select(name,status) order by name") + } ) -@NamedQuery(name="withContacts", query = "fetch contacts (firstName, lastName) where id = :id") +@NamedQuery(name = "withContacts", query = "fetch contacts (firstName, lastName) where id = :id") @Cache(enableQueryCache = true) @DocStore @ChangeLog(inserts = ChangeLogInsertMode.EXCLUDE, updatesThatInclude = {"name", "status"}) diff --git a/src/test/java/com/avaje/tests/model/basic/EBasicWithLifecycle.java b/src/test/java/com/avaje/tests/model/basic/EBasicWithLifecycle.java index f3fe13160..002c8d0b1 100644 --- a/src/test/java/com/avaje/tests/model/basic/EBasicWithLifecycle.java +++ b/src/test/java/com/avaje/tests/model/basic/EBasicWithLifecycle.java @@ -106,7 +106,7 @@ public class EBasicWithLifecycle { public void postConstruct2() { buffer.append("postConstruct2"); } - + public Long getId() { return id; } diff --git a/src/test/java/com/avaje/tests/model/basic/MyLobSize.java b/src/test/java/com/avaje/tests/model/basic/MyLobSize.java index e5ef2e7f2..10ba9f858 100644 --- a/src/test/java/com/avaje/tests/model/basic/MyLobSize.java +++ b/src/test/java/com/avaje/tests/model/basic/MyLobSize.java @@ -22,8 +22,8 @@ public class MyLobSize { @Basic(fetch = FetchType.LAZY) @Lob //@Length(max=65535) - //@Length(max=65536) - String myLob; + //@Length(max=65536) + String myLob; @OneToMany(mappedBy = "parent") List details; diff --git a/src/test/java/com/avaje/tests/model/basic/Order.java b/src/test/java/com/avaje/tests/model/basic/Order.java index 8db2097d4..c1f35cc6a 100644 --- a/src/test/java/com/avaje/tests/model/basic/Order.java +++ b/src/test/java/com/avaje/tests/model/basic/Order.java @@ -60,8 +60,8 @@ public class Order implements Serializable { */ @Transient @Formula( - select = "z_b${ta}.total_amount", - join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id") + select = "z_b${ta}.total_amount", + join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id") Double totalAmount; /** @@ -69,8 +69,8 @@ public class Order implements Serializable { */ @Transient @Formula( - select = "z_b${ta}.total_items", - join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id") + select = "z_b${ta}.total_items", + join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id") Integer totalItems; @Enumerated(value = EnumType.ORDINAL) diff --git a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java index 5d441ee0a..07e5fbe20 100644 --- a/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java +++ b/src/test/java/com/avaje/tests/model/basic/ResetBasicData.java @@ -2,7 +2,6 @@ package com.avaje.tests.model.basic; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.TxRunnable; import com.avaje.tests.model.basic.Order.Status; import java.sql.Date; diff --git a/src/test/java/com/avaje/tests/model/basic/Truck.java b/src/test/java/com/avaje/tests/model/basic/Truck.java index 8fed33456..43b6f12f4 100644 --- a/src/test/java/com/avaje/tests/model/basic/Truck.java +++ b/src/test/java/com/avaje/tests/model/basic/Truck.java @@ -20,6 +20,7 @@ public class Truck extends Vehicle { HUGE("H"); String value; + Size(String value) { this.value = value; } diff --git a/src/test/java/com/avaje/tests/model/basic/metaannotation/SizeMedium.java b/src/test/java/com/avaje/tests/model/basic/metaannotation/SizeMedium.java index 72ef9773d..a07afcc13 100644 --- a/src/test/java/com/avaje/tests/model/basic/metaannotation/SizeMedium.java +++ b/src/test/java/com/avaje/tests/model/basic/metaannotation/SizeMedium.java @@ -1,20 +1,20 @@ package com.avaje.tests.model.basic.metaannotation; +import javax.validation.constraints.Size; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.constraints.Size; - /** * Meta-Annotation that defines @Size(max=100) + * * @author Roland Praml, FOCONIS AG */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented -@Size(max=100) +@Size(max = 100) public @interface SizeMedium { -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java b/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java index a3223937b..d1d516ae6 100644 --- a/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java +++ b/src/test/java/com/avaje/tests/model/basic/xtra/TestDeleteUnloadedChildren.java @@ -79,7 +79,7 @@ public class TestDeleteUnloadedChildren extends BaseTestCase { Ebean.beginTransaction(); try { EdExtendedParent extendedParent = Ebean.find(EdExtendedParent.class).where() - .eq("name", "My second computer").findUnique(); + .eq("name", "My second computer").findUnique(); extendedParent.getChildren().size(); Ebean.delete(extendedParent); Ebean.commitTransaction(); diff --git a/src/test/java/com/avaje/tests/model/bridge/BSiteUser.java b/src/test/java/com/avaje/tests/model/bridge/BSiteUser.java index ca6dc221e..949ec2ae0 100644 --- a/src/test/java/com/avaje/tests/model/bridge/BSiteUser.java +++ b/src/test/java/com/avaje/tests/model/bridge/BSiteUser.java @@ -39,10 +39,10 @@ public class BSiteUser { private BAccessLevel accessLevel; - @ManyToOne(optional=false) + @ManyToOne(optional = false) private final BSite site; - @ManyToOne(optional=false) + @ManyToOne(optional = false) private final BUser user; diff --git a/src/test/java/com/avaje/tests/model/bridge/BSiteUserB.java b/src/test/java/com/avaje/tests/model/bridge/BSiteUserB.java index cbb9fd80d..06b77acae 100644 --- a/src/test/java/com/avaje/tests/model/bridge/BSiteUserB.java +++ b/src/test/java/com/avaje/tests/model/bridge/BSiteUserB.java @@ -42,10 +42,10 @@ public class BSiteUserB { private BAccessLevel accessLevel; - @ManyToOne(optional=false) + @ManyToOne(optional = false) private final BSite site; - @ManyToOne(optional=false) + @ManyToOne(optional = false) private final BUser user; diff --git a/src/test/java/com/avaje/tests/model/bridge/BSiteUserC.java b/src/test/java/com/avaje/tests/model/bridge/BSiteUserC.java index 35823447a..ae50a78f7 100644 --- a/src/test/java/com/avaje/tests/model/bridge/BSiteUserC.java +++ b/src/test/java/com/avaje/tests/model/bridge/BSiteUserC.java @@ -40,11 +40,11 @@ public class BSiteUserC { private BAccessLevel accessLevel; - @ManyToOne(optional=false) + @ManyToOne(optional = false) @JoinColumn(name = "site_uid", insertable = false, updatable = false) private final BSite site; - @ManyToOne(optional=false) + @ManyToOne(optional = false) @JoinColumn(name = "user_uid", insertable = false, updatable = false) private final BUser user; diff --git a/src/test/java/com/avaje/tests/model/cache/EColAB.java b/src/test/java/com/avaje/tests/model/cache/EColAB.java index 3c6ec3b88..e6cae1c33 100644 --- a/src/test/java/com/avaje/tests/model/cache/EColAB.java +++ b/src/test/java/com/avaje/tests/model/cache/EColAB.java @@ -7,7 +7,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; -@Cache(enableQueryCache=true) +@Cache(enableQueryCache = true) @Entity @Table(name = "e_col_ab") public class EColAB extends Model { @@ -47,4 +47,4 @@ public class EColAB extends Model { public void setColumnB(String columnB) { this.columnB = columnB; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/carwheel/Car.java b/src/test/java/com/avaje/tests/model/carwheel/Car.java index 49997922c..d1f3a5445 100644 --- a/src/test/java/com/avaje/tests/model/carwheel/Car.java +++ b/src/test/java/com/avaje/tests/model/carwheel/Car.java @@ -1,7 +1,5 @@ package com.avaje.tests.model.carwheel; -import java.util.List; - import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -10,43 +8,44 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Version; +import java.util.List; @Entity @Table(name = "sa_car") public class Car { - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) - protected Long id; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + protected Long id; - @Version - private int version; + @Version + private int version; - @OneToMany(mappedBy = "car", cascade = CascadeType.ALL) - private List wheels; + @OneToMany(mappedBy = "car", cascade = CascadeType.ALL) + private List wheels; - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } - public List getWheels() { - return wheels; - } + public List getWheels() { + return wheels; + } - public void setWheels(List wheels) { - this.wheels = wheels; - } + public void setWheels(List wheels) { + this.wheels = wheels; + } } diff --git a/src/test/java/com/avaje/tests/model/carwheel/Tire.java b/src/test/java/com/avaje/tests/model/carwheel/Tire.java index 8a5ef7191..71e195828 100644 --- a/src/test/java/com/avaje/tests/model/carwheel/Tire.java +++ b/src/test/java/com/avaje/tests/model/carwheel/Tire.java @@ -11,27 +11,27 @@ import javax.persistence.Version; @Table(name = "sa_tire") public class Tire { - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) - protected Long id; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + protected Long id; - @Version - private int version; + @Version + private int version; - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } } diff --git a/src/test/java/com/avaje/tests/model/carwheel/Wheel.java b/src/test/java/com/avaje/tests/model/carwheel/Wheel.java index 611e35e67..df6613dbe 100644 --- a/src/test/java/com/avaje/tests/model/carwheel/Wheel.java +++ b/src/test/java/com/avaje/tests/model/carwheel/Wheel.java @@ -14,51 +14,51 @@ import javax.persistence.Version; @Table(name = "sa_wheel") public class Wheel { - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) - protected Long id; + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + protected Long id; - @Version - private int version; + @Version + private int version; - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "tire") - private Tire tire; + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "tire") + private Tire tire; - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "car") - private Car car; + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "car") + private Car car; - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public int getVersion() { - return version; - } + public int getVersion() { + return version; + } - public void setVersion(int version) { - this.version = version; - } + public void setVersion(int version) { + this.version = version; + } - public Tire getTire() { - return tire; - } + public Tire getTire() { + return tire; + } - public void setTire(Tire tire) { - this.tire = tire; - } + public void setTire(Tire tire) { + this.tire = tire; + } - public Car getCar() { - return car; - } + public Car getCar() { + return car; + } - public void setCar(Car car) { - this.car = car; - } + public void setCar(Car car) { + this.car = car; + } } diff --git a/src/test/java/com/avaje/tests/model/carwheeltruck/TCar.java b/src/test/java/com/avaje/tests/model/carwheeltruck/TCar.java index 24749a664..5c3464b80 100644 --- a/src/test/java/com/avaje/tests/model/carwheeltruck/TCar.java +++ b/src/test/java/com/avaje/tests/model/carwheeltruck/TCar.java @@ -1,7 +1,5 @@ package com.avaje.tests.model.carwheeltruck; -import java.util.List; - import javax.persistence.CascadeType; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorValue; @@ -10,6 +8,7 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.OneToMany; +import java.util.List; @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) diff --git a/src/test/java/com/avaje/tests/model/carwheeltruck/TTruck.java b/src/test/java/com/avaje/tests/model/carwheeltruck/TTruck.java index babe2df8e..b54138581 100644 --- a/src/test/java/com/avaje/tests/model/carwheeltruck/TTruck.java +++ b/src/test/java/com/avaje/tests/model/carwheeltruck/TTruck.java @@ -8,12 +8,12 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @Entity -@Inheritance(strategy=InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name="type") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "type") @DiscriminatorValue("truck") public class TTruck extends TCar { - @Column(name="truckLoad") + @Column(name = "truckLoad") Long load; public Long getLoad() { @@ -23,5 +23,5 @@ public class TTruck extends TCar { public void setLoad(Long load) { this.load = load; } - + } diff --git a/src/test/java/com/avaje/tests/model/carwheeltruck/TWheel.java b/src/test/java/com/avaje/tests/model/carwheeltruck/TWheel.java index 9c8acd1d9..ec6cb040f 100644 --- a/src/test/java/com/avaje/tests/model/carwheeltruck/TWheel.java +++ b/src/test/java/com/avaje/tests/model/carwheeltruck/TWheel.java @@ -10,7 +10,7 @@ public class TWheel { @Id Long id; - @ManyToOne(optional=false) + @ManyToOne(optional = false) TCar owner; public Long getId() { @@ -27,6 +27,6 @@ public class TWheel { public void setOwner(TCar owner) { this.owner = owner; - } - + } + } diff --git a/src/test/java/com/avaje/tests/model/carwheeltruck/TestTruckCarWheelInhertiance.java b/src/test/java/com/avaje/tests/model/carwheeltruck/TestTruckCarWheelInhertiance.java index 4525b7cfd..df68e66f7 100644 --- a/src/test/java/com/avaje/tests/model/carwheeltruck/TestTruckCarWheelInhertiance.java +++ b/src/test/java/com/avaje/tests/model/carwheeltruck/TestTruckCarWheelInhertiance.java @@ -1,9 +1,8 @@ package com.avaje.tests.model.carwheeltruck; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import org.junit.Test; import java.util.Random; @@ -13,7 +12,7 @@ public class TestTruckCarWheelInhertiance extends BaseTestCase { public void test() { TTruck truck = new TTruck(); - truck.setPlateNo("foo-"+new Random().nextInt()); + truck.setPlateNo("foo-" + new Random().nextInt()); TWheel wheel = new TWheel(); wheel.setOwner(truck); diff --git a/src/test/java/com/avaje/tests/model/composite/RCustomer.java b/src/test/java/com/avaje/tests/model/composite/RCustomer.java index 5d0c69243..8e9ecf819 100644 --- a/src/test/java/com/avaje/tests/model/composite/RCustomer.java +++ b/src/test/java/com/avaje/tests/model/composite/RCustomer.java @@ -5,40 +5,39 @@ import javax.persistence.EmbeddedId; import javax.persistence.Entity; /** - * * @author rnentjes */ @Entity public class RCustomer { - @EmbeddedId - private RCustomerKey key; + @EmbeddedId + private RCustomerKey key; - private String description; + private String description; - public RCustomer() { - } + public RCustomer() { + } - public RCustomer(RCustomerKey key, String description) { - this.key = key; - this.description = description; - } + public RCustomer(RCustomerKey key, String description) { + this.key = key; + this.description = description; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public RCustomerKey getKey() { - return key; - } + public RCustomerKey getKey() { + return key; + } - public void setKey(RCustomerKey key) { - this.key = key; - } + public void setKey(RCustomerKey key) { + this.key = key; + } } diff --git a/src/test/java/com/avaje/tests/model/composite/RCustomerKey.java b/src/test/java/com/avaje/tests/model/composite/RCustomerKey.java index 0da66fee8..afe0c5c63 100644 --- a/src/test/java/com/avaje/tests/model/composite/RCustomerKey.java +++ b/src/test/java/com/avaje/tests/model/composite/RCustomerKey.java @@ -4,62 +4,59 @@ package com.avaje.tests.model.composite; import javax.persistence.Embeddable; @Embeddable -public class RCustomerKey -{ - private String company; - private String name; +public class RCustomerKey { + private String company; + private String name; - public RCustomerKey() { + public RCustomerKey() { + } + + public RCustomerKey(String company, String name) { + this.company = company; + this.name = name; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; } - - public RCustomerKey(String company, String name) { - this.company = company; - this.name = name; + if (getClass() != obj.getClass()) { + return false; } - - public String getCompany() { - return company; + final RCustomerKey other = (RCustomerKey) obj; + if ((this.company == null) ? (other.company != null) : !this.company.equals(other.company)) { + return false; } - - public void setCompany(String company) { - this.company = company; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; } + return true; + } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final RCustomerKey other = (RCustomerKey) obj; - if ((this.company == null) ? (other.company != null) : !this.company.equals(other.company)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 89 * hash + (this.company != null ? this.company.hashCode() : 0); - hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - + @Override + public int hashCode() { + int hash = 3; + hash = 89 * hash + (this.company != null ? this.company.hashCode() : 0); + hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } } diff --git a/src/test/java/com/avaje/tests/model/composite/ROrder.java b/src/test/java/com/avaje/tests/model/composite/ROrder.java index 10466c06a..4c38d692a 100644 --- a/src/test/java/com/avaje/tests/model/composite/ROrder.java +++ b/src/test/java/com/avaje/tests/model/composite/ROrder.java @@ -11,101 +11,100 @@ import javax.persistence.Table; /** - * * @author rnentjes */ @Entity -@Table(name="r_orders") +@Table(name = "r_orders") public class ROrder { - @EmbeddedId - protected ROrderPK orderPK; + @EmbeddedId + protected ROrderPK orderPK; - @ManyToOne(cascade=CascadeType.PERSIST) - @JoinColumns({ - @JoinColumn(name="company", referencedColumnName="company", insertable=false, updatable=false), - @JoinColumn(name="customerName", referencedColumnName="name", insertable=false, updatable=false) - }) - private RCustomer customer; + @ManyToOne(cascade = CascadeType.PERSIST) + @JoinColumns({ + @JoinColumn(name = "company", referencedColumnName = "company", insertable = false, updatable = false), + @JoinColumn(name = "customerName", referencedColumnName = "name", insertable = false, updatable = false) + }) + private RCustomer customer; - @Column(name="customerName") - private String customerName; + @Column(name = "customerName") + private String customerName; - private String item; + private String item; - public ROrder() { - this(new ROrderPK()); - } + public ROrder() { + this(new ROrderPK()); + } - public ROrder(ROrderPK orderPK) { - this(orderPK, null); - } + public ROrder(ROrderPK orderPK) { + this(orderPK, null); + } - public ROrder(ROrderPK orderPK, String item) { - this.orderPK = orderPK; - this.item = item; - } + public ROrder(ROrderPK orderPK, String item) { + this.orderPK = orderPK; + this.item = item; + } - public ROrder(ROrderPK orderPK, String item, RCustomer customer) { - this.orderPK = orderPK; - this.item = item; - setCustomer(customer); - } + public ROrder(ROrderPK orderPK, String item, RCustomer customer) { + this.orderPK = orderPK; + this.item = item; + setCustomer(customer); + } - public ROrderPK getOrderPK() { - return orderPK; - } + public ROrderPK getOrderPK() { + return orderPK; + } - public void setOrderPK(ROrderPK orderPK) { - this.orderPK = orderPK; - } + public void setOrderPK(ROrderPK orderPK) { + this.orderPK = orderPK; + } - public String getItem() { - return item; - } + public String getItem() { + return item; + } - public void setItem(String item) { - this.item = item; - } + public void setItem(String item) { + this.item = item; + } - public RCustomer getCustomer() { - return customer; - } + public RCustomer getCustomer() { + return customer; + } - public String getCustomerName() { - return customerName; - } + public String getCustomerName() { + return customerName; + } - public void setCustomer(RCustomer customer) { - this.customer = customer; + public void setCustomer(RCustomer customer) { + this.customer = customer; // if (customer == null) { // customerName = null; // } else { // customerName = customer.getKey().getName(); // } - } + } - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ROrder other = (ROrder) obj; - if (this.orderPK != other.orderPK && (this.orderPK == null || !this.orderPK.equals(other.orderPK))) { - return false; - } - return true; + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; } + if (getClass() != obj.getClass()) { + return false; + } + final ROrder other = (ROrder) obj; + if (this.orderPK != other.orderPK && (this.orderPK == null || !this.orderPK.equals(other.orderPK))) { + return false; + } + return true; + } - @Override - public int hashCode() { - int hash = 3; - hash = 29 * hash + (this.orderPK != null ? this.orderPK.hashCode() : 0); - return hash; - } + @Override + public int hashCode() { + int hash = 3; + hash = 29 * hash + (this.orderPK != null ? this.orderPK.hashCode() : 0); + return hash; + } } diff --git a/src/test/java/com/avaje/tests/model/composite/ROrderPK.java b/src/test/java/com/avaje/tests/model/composite/ROrderPK.java index 66fc6031b..6bb1c57c1 100644 --- a/src/test/java/com/avaje/tests/model/composite/ROrderPK.java +++ b/src/test/java/com/avaje/tests/model/composite/ROrderPK.java @@ -4,68 +4,67 @@ package com.avaje.tests.model.composite; import javax.persistence.Embeddable; /** - * * @author rnentjes */ @Embeddable public class ROrderPK { - private static final long serialVersionUID = 7632735517186104883L; + private static final long serialVersionUID = 7632735517186104883L; - private String company; - private Integer orderNumber; + private String company; + private Integer orderNumber; - public ROrderPK() { - this(null,null); + public ROrderPK() { + this(null, null); + } + + public ROrderPK(String company, Integer orderNumber) { + this.company = company; + this.orderNumber = orderNumber; + } + + public Integer getOrderNumber() { + return orderNumber; + } + + public void setOrderNumber(Integer orderNumber) { + this.orderNumber = orderNumber; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; } - - public ROrderPK(String company, Integer orderNumber) { - this.company = company; - this.orderNumber = orderNumber; + if (getClass() != obj.getClass()) { + return false; } - - public Integer getOrderNumber() { - return orderNumber; + final ROrderPK other = (ROrderPK) obj; + if ((this.company == null) ? (other.company != null) : !this.company.equals(other.company)) { + return false; } - - public void setOrderNumber(Integer orderNumber) { - this.orderNumber = orderNumber; + if (this.orderNumber == null || !this.orderNumber.equals(other.orderNumber)) { + return false; } + return true; + } - public String getCompany() { - return company; - } - - public void setCompany(String company) { - this.company = company; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ROrderPK other = (ROrderPK) obj; - if ((this.company == null) ? (other.company != null) : !this.company.equals(other.company)) { - return false; - } - if (this.orderNumber == null || !this.orderNumber.equals(other.orderNumber)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 73 * hash + (this.company != null ? this.company.hashCode() : 0); - hash = 73 * hash + (this.orderNumber != null ? this.orderNumber.hashCode() : 0); - return hash; - } + @Override + public int hashCode() { + int hash = 3; + hash = 73 * hash + (this.company != null ? this.company.hashCode() : 0); + hash = 73 * hash + (this.orderNumber != null ? this.orderNumber.hashCode() : 0); + return hash; + } - } +} diff --git a/src/test/java/com/avaje/tests/model/converstation/Conversation.java b/src/test/java/com/avaje/tests/model/converstation/Conversation.java index b33d8b843..7bd9023e3 100644 --- a/src/test/java/com/avaje/tests/model/converstation/Conversation.java +++ b/src/test/java/com/avaje/tests/model/converstation/Conversation.java @@ -1,30 +1,33 @@ package com.avaje.tests.model.converstation; -import java.util.List; - -import javax.persistence.*; - import com.avaje.tests.model.BaseModel; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.util.List; + @Entity -@Table(name="c_conversation") +@Table(name = "c_conversation") public class Conversation extends BaseModel { String title; - @Column(name="isopen") + @Column(name = "isopen") boolean open; - + @ManyToOne Group group; - - @OneToMany(mappedBy="conversation") + + @OneToMany(mappedBy = "conversation") List participants; - - @OneToMany(mappedBy="conversation") + + @OneToMany(mappedBy = "conversation") List messages; - + public String getTitle() { return title; } @@ -56,5 +59,5 @@ public class Conversation extends BaseModel { public void setMessages(List messages) { this.messages = messages; } - + } diff --git a/src/test/java/com/avaje/tests/model/converstation/Group.java b/src/test/java/com/avaje/tests/model/converstation/Group.java index 4359d5ea4..2a5d2ff13 100644 --- a/src/test/java/com/avaje/tests/model/converstation/Group.java +++ b/src/test/java/com/avaje/tests/model/converstation/Group.java @@ -1,24 +1,23 @@ package com.avaje.tests.model.converstation; -import java.util.List; +import com.avaje.tests.model.BaseModel; import javax.persistence.Entity; import javax.persistence.OneToMany; import javax.persistence.Table; - -import com.avaje.tests.model.BaseModel; +import java.util.List; @Entity -@Table(name="c_group") +@Table(name = "c_group") public class Group extends BaseModel { boolean inactive; - + String name; - @OneToMany(mappedBy="group") + @OneToMany(mappedBy = "group") List users; - + public boolean isInactive() { return inactive; } @@ -42,5 +41,5 @@ public class Group extends BaseModel { public void setUsers(List users) { this.users = users; } - + } diff --git a/src/test/java/com/avaje/tests/model/converstation/Message.java b/src/test/java/com/avaje/tests/model/converstation/Message.java index ec0b34ebe..52af3bb58 100644 --- a/src/test/java/com/avaje/tests/model/converstation/Message.java +++ b/src/test/java/com/avaje/tests/model/converstation/Message.java @@ -1,26 +1,26 @@ package com.avaje.tests.model.converstation; +import com.avaje.tests.model.BaseModel; + import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.Table; -import com.avaje.tests.model.BaseModel; - @Entity -@Table(name="c_message") +@Table(name = "c_message") public class Message extends BaseModel { String title; - + String body; - + @ManyToOne Conversation conversation; - + @ManyToOne User user; - + public Conversation getConversation() { return conversation; } @@ -52,5 +52,5 @@ public class Message extends BaseModel { public void setUser(User user) { this.user = user; } - + } diff --git a/src/test/java/com/avaje/tests/model/converstation/Participation.java b/src/test/java/com/avaje/tests/model/converstation/Participation.java index 0cf30b28d..ba96b09ac 100644 --- a/src/test/java/com/avaje/tests/model/converstation/Participation.java +++ b/src/test/java/com/avaje/tests/model/converstation/Participation.java @@ -1,30 +1,30 @@ package com.avaje.tests.model.converstation; +import com.avaje.tests.model.BaseModel; + import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.Table; -import com.avaje.tests.model.BaseModel; - @Entity -@Table(name="c_participation") +@Table(name = "c_participation") public class Participation extends BaseModel { public enum Type { Moderator, Member } - + Integer rating; - + Type type; - - @ManyToOne(optional=false) + + @ManyToOne(optional = false) Conversation conversation; - - @ManyToOne(optional=false) + + @ManyToOne(optional = false) User user; - + public Conversation getConversation() { return conversation; } @@ -56,5 +56,5 @@ public class Participation extends BaseModel { public void setUser(User user) { this.user = user; } - + } diff --git a/src/test/java/com/avaje/tests/model/ddd/DExhEntity.java b/src/test/java/com/avaje/tests/model/ddd/DExhEntity.java index e002e79d2..a8117a7a3 100644 --- a/src/test/java/com/avaje/tests/model/ddd/DExhEntity.java +++ b/src/test/java/com/avaje/tests/model/ddd/DExhEntity.java @@ -1,47 +1,46 @@ package com.avaje.tests.model.ddd; -import java.sql.Timestamp; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Version; - import com.avaje.tests.model.ivo.ExhangeCMoneyRate; import com.avaje.tests.model.ivo.Oid; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; +import java.sql.Timestamp; + @Entity public class DExhEntity { - @Id - Oid oid; - - ExhangeCMoneyRate exhange; + @Id + Oid oid; - @Version - Timestamp lastUpdated; + ExhangeCMoneyRate exhange; - public Oid getOid() { - return oid; - } + @Version + Timestamp lastUpdated; - public void setOid(Oid oid) { - this.oid = oid; - } + public Oid getOid() { + return oid; + } - public ExhangeCMoneyRate getExhange() { - return exhange; - } + public void setOid(Oid oid) { + this.oid = oid; + } - public void setExhange(ExhangeCMoneyRate exhange) { - this.exhange = exhange; - } + public ExhangeCMoneyRate getExhange() { + return exhange; + } - public Timestamp getLastUpdated() { - return lastUpdated; - } + public void setExhange(ExhangeCMoneyRate exhange) { + this.exhange = exhange; + } + + public Timestamp getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(Timestamp lastUpdated) { + this.lastUpdated = lastUpdated; + } - public void setLastUpdated(Timestamp lastUpdated) { - this.lastUpdated = lastUpdated; - } - } diff --git a/src/test/java/com/avaje/tests/model/ddd/DPerson.java b/src/test/java/com/avaje/tests/model/ddd/DPerson.java index efa18b30d..4bf2d702d 100644 --- a/src/test/java/com/avaje/tests/model/ddd/DPerson.java +++ b/src/test/java/com/avaje/tests/model/ddd/DPerson.java @@ -1,83 +1,82 @@ package com.avaje.tests.model.ddd; -import javax.persistence.Entity; -import javax.persistence.Id; - -import org.joda.time.Interval; - import com.avaje.ebean.annotation.EmbeddedColumns; import com.avaje.tests.model.ivo.CMoney; import com.avaje.tests.model.ivo.Money; import com.avaje.tests.model.ivo.Oid; +import org.joda.time.Interval; + +import javax.persistence.Entity; +import javax.persistence.Id; @Entity public class DPerson { - @Id - Oid id; - - String firstName; - - String lastName; + @Id + Oid id; - Money salary; - - @EmbeddedColumns(columns="amount=a_amt, currency=a_curr") - CMoney cmoney; - - @EmbeddedColumns(columns="startMillis=i_start, endMillis=i_end") - Interval interval; - - public String toString() { - return id+" "+firstName+" "+lastName+" "+salary; - } - - public Oid getId() { - return id; - } + String firstName; - public void setId(Oid id) { - this.id = id; - } + String lastName; - public String getFirstName() { - return firstName; - } + Money salary; - public void setFirstName(String firstName) { - this.firstName = firstName; - } + @EmbeddedColumns(columns = "amount=a_amt, currency=a_curr") + CMoney cmoney; - public String getLastName() { - return lastName; - } + @EmbeddedColumns(columns = "startMillis=i_start, endMillis=i_end") + Interval interval; - public void setLastName(String lastName) { - this.lastName = lastName; - } + public String toString() { + return id + " " + firstName + " " + lastName + " " + salary; + } - public Money getSalary() { - return salary; - } + public Oid getId() { + return id; + } - public void setSalary(Money salary) { - this.salary = salary; - } + public void setId(Oid id) { + this.id = id; + } - public CMoney getCmoney() { - return cmoney; - } + public String getFirstName() { + return firstName; + } - public void setCmoney(CMoney cmoney) { - this.cmoney = cmoney; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public Interval getInterval() { - return interval; - } + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Money getSalary() { + return salary; + } + + public void setSalary(Money salary) { + this.salary = salary; + } + + public CMoney getCmoney() { + return cmoney; + } + + public void setCmoney(CMoney cmoney) { + this.cmoney = cmoney; + } + + public Interval getInterval() { + return interval; + } + + public void setInterval(Interval interval) { + this.interval = interval; + } - public void setInterval(Interval interval) { - this.interval = interval; - } - } diff --git a/src/test/java/com/avaje/tests/model/draftable/Document.java b/src/test/java/com/avaje/tests/model/draftable/Document.java index ea7d184ff..0647d937b 100644 --- a/src/test/java/com/avaje/tests/model/draftable/Document.java +++ b/src/test/java/com/avaje/tests/model/draftable/Document.java @@ -31,7 +31,7 @@ public class Document extends BaseDomain { */ //@PrivateOwned @OneToMany(mappedBy = "document")//, cascade = CascadeType.ALL) - List media; + List media; public String getTitle() { return title; diff --git a/src/test/java/com/avaje/tests/model/draftable/Link.java b/src/test/java/com/avaje/tests/model/draftable/Link.java index 14f57d8a2..ae937c7cd 100644 --- a/src/test/java/com/avaje/tests/model/draftable/Link.java +++ b/src/test/java/com/avaje/tests/model/draftable/Link.java @@ -35,7 +35,8 @@ public class Link extends BaseDomain { /** * Draft reset to null on publish. */ - @DraftReset @Column(name = "link_comment") + @DraftReset + @Column(name = "link_comment") String comment; /** diff --git a/src/test/java/com/avaje/tests/model/embedded/EEmbDatePeriod.java b/src/test/java/com/avaje/tests/model/embedded/EEmbDatePeriod.java index cabc2a3e6..a96b6e9d0 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EEmbDatePeriod.java +++ b/src/test/java/com/avaje/tests/model/embedded/EEmbDatePeriod.java @@ -1,28 +1,27 @@ package com.avaje.tests.model.embedded; -import java.util.Date; - import javax.persistence.Embeddable; +import java.util.Date; @Embeddable public class EEmbDatePeriod { - Date date1; - Date date2; + Date date1; + Date date2; - public Date getDate1() { - return date1; - } + public Date getDate1() { + return date1; + } - public void setDate1(Date date1) { - this.date1 = date1; - } + public void setDate1(Date date1) { + this.date1 = date1; + } - public Date getDate2() { - return date2; - } + public Date getDate2() { + return date2; + } - public void setDate2(Date date2) { - this.date2 = date2; - } + public void setDate2(Date date2) { + this.date2 = date2; + } } diff --git a/src/test/java/com/avaje/tests/model/embedded/EEmbInner.java b/src/test/java/com/avaje/tests/model/embedded/EEmbInner.java index 3d53220fb..6877732d1 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EEmbInner.java +++ b/src/test/java/com/avaje/tests/model/embedded/EEmbInner.java @@ -10,46 +10,46 @@ import javax.persistence.Version; @Table(name = "eemb_inner") public class EEmbInner { - @Id - Integer id; - - String nomeInner; - - @Version - private int updateCount; + @Id + Integer id; - @ManyToOne - EEmbOuter outer; + String nomeInner; - public Integer getId() { - return id; - } + @Version + private int updateCount; - public void setId(Integer id) { - this.id = id; - } + @ManyToOne + EEmbOuter outer; - public String getNomeInner() { - return nomeInner; - } + public Integer getId() { + return id; + } - public void setNomeInner(String nomeInner) { - this.nomeInner = nomeInner; - } + public void setId(Integer id) { + this.id = id; + } - public EEmbOuter getOuter() { - return outer; - } + public String getNomeInner() { + return nomeInner; + } - public void setOuter(EEmbOuter outer) { - this.outer = outer; - } + public void setNomeInner(String nomeInner) { + this.nomeInner = nomeInner; + } - public int getUpdateCount() { - return updateCount; - } + public EEmbOuter getOuter() { + return outer; + } - public void setUpdateCount(int updateCount) { - this.updateCount = updateCount; - } + public void setOuter(EEmbOuter outer) { + this.outer = outer; + } + + public int getUpdateCount() { + return updateCount; + } + + public void setUpdateCount(int updateCount) { + this.updateCount = updateCount; + } } diff --git a/src/test/java/com/avaje/tests/model/embedded/EEmbOuter.java b/src/test/java/com/avaje/tests/model/embedded/EEmbOuter.java index 60b1d5c1f..c247ccf67 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EEmbOuter.java +++ b/src/test/java/com/avaje/tests/model/embedded/EEmbOuter.java @@ -1,6 +1,6 @@ package com.avaje.tests.model.embedded; -import java.util.List; +import com.avaje.ebean.annotation.PrivateOwned; import javax.persistence.CascadeType; import javax.persistence.Embedded; @@ -9,62 +9,61 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Version; - -import com.avaje.ebean.annotation.PrivateOwned; +import java.util.List; @Entity @Table(name = "eemb_outer") public class EEmbOuter { - @Id - Integer id; - String nomeOuter; - @Version - private int updateCount; + @Id + Integer id; + String nomeOuter; + @Version + private int updateCount; - @OneToMany(cascade = CascadeType.ALL) - @PrivateOwned - List inners; + @OneToMany(cascade = CascadeType.ALL) + @PrivateOwned + List inners; - @Embedded - EEmbDatePeriod datePeriod; + @Embedded + EEmbDatePeriod datePeriod; - public Integer getId() { - return id; - } + public Integer getId() { + return id; + } - public void setId(Integer id) { - this.id = id; - } + public void setId(Integer id) { + this.id = id; + } - public String getNomeOuter() { - return nomeOuter; - } + public String getNomeOuter() { + return nomeOuter; + } - public void setNomeOuter(String nomeOuter) { - this.nomeOuter = nomeOuter; - } + public void setNomeOuter(String nomeOuter) { + this.nomeOuter = nomeOuter; + } - public List getInners() { - return inners; - } + public List getInners() { + return inners; + } - public void setInners(List inners) { - this.inners = inners; - } + public void setInners(List inners) { + this.inners = inners; + } - public EEmbDatePeriod getDatePeriod() { - return datePeriod; - } + public EEmbDatePeriod getDatePeriod() { + return datePeriod; + } - public void setDatePeriod(EEmbDatePeriod datePeriod) { - this.datePeriod = datePeriod; - } + public void setDatePeriod(EEmbDatePeriod datePeriod) { + this.datePeriod = datePeriod; + } - public int getUpdateCount() { - return updateCount; - } + public int getUpdateCount() { + return updateCount; + } - public void setUpdateCount(int updateCount) { - this.updateCount = updateCount; - } + public void setUpdateCount(int updateCount) { + this.updateCount = updateCount; + } } diff --git a/src/test/java/com/avaje/tests/model/embedded/EInvoice.java b/src/test/java/com/avaje/tests/model/embedded/EInvoice.java index 0636d69d5..6ee555878 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EInvoice.java +++ b/src/test/java/com/avaje/tests/model/embedded/EInvoice.java @@ -2,8 +2,6 @@ package com.avaje.tests.model.embedded; import com.avaje.ebean.annotation.Cache; -import java.util.Date; - import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; @@ -12,6 +10,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Version; +import java.util.Date; @Cache @Entity diff --git a/src/test/java/com/avaje/tests/model/embedded/EPerson.java b/src/test/java/com/avaje/tests/model/embedded/EPerson.java index fa122f0a3..131b2cc11 100644 --- a/src/test/java/com/avaje/tests/model/embedded/EPerson.java +++ b/src/test/java/com/avaje/tests/model/embedded/EPerson.java @@ -23,8 +23,8 @@ public class EPerson { @Embedded @AttributeOverrides({ - @AttributeOverride(name="city", column = @Column(name="addr_city")), - @AttributeOverride(name="status", column = @Column(name="addr_status")) + @AttributeOverride(name = "city", column = @Column(name = "addr_city")), + @AttributeOverride(name = "status", column = @Column(name = "addr_status")) }) EAddress address; diff --git a/src/test/java/com/avaje/tests/model/embedded/Eembeddable.java b/src/test/java/com/avaje/tests/model/embedded/Eembeddable.java index 225478d49..8af424cba 100644 --- a/src/test/java/com/avaje/tests/model/embedded/Eembeddable.java +++ b/src/test/java/com/avaje/tests/model/embedded/Eembeddable.java @@ -4,7 +4,7 @@ import javax.persistence.Embeddable; @Embeddable public class Eembeddable { - + String description; public String getDescription() { diff --git a/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java b/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java index c69c3a0b0..06f8f770c 100644 --- a/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java +++ b/src/test/java/com/avaje/tests/model/embedded/PrimaryRevision.java @@ -13,7 +13,7 @@ public class PrimaryRevision { // @AttributeOverrides({ // @AttributeOverride(name="primaryId", column = @Column(name="id")) // }) - @AttributeOverride(name="primaryId", column = @Column(name="id")) + @AttributeOverride(name = "primaryId", column = @Column(name = "id")) private RevisionId revisionId; String name; diff --git a/src/test/java/com/avaje/tests/model/family/ChildPerson.java b/src/test/java/com/avaje/tests/model/family/ChildPerson.java index 77032e59a..045988fa5 100644 --- a/src/test/java/com/avaje/tests/model/family/ChildPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ChildPerson.java @@ -1,38 +1,37 @@ - package com.avaje.tests.model.family; +import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; + import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.ManyToOne; -import com.avaje.ebean.annotation.Formula; -import com.avaje.tests.model.basic.EBasic; - @Entity public class ChildPerson extends InheritablePerson { private static final String PARENTS_JOIN = "join parent_person j1 on j1.identifier = ${ta}.parent_identifier " - + "join grand_parent_person j2 on j2.identifier = j1.parent_identifier"; + + "join grand_parent_person j2 on j2.identifier = j1.parent_identifier"; - @ManyToOne(cascade = CascadeType.ALL) - private ParentPerson parent; + @ManyToOne(cascade = CascadeType.ALL) + private ParentPerson parent; + + private String familyName; + + private String address; - private String familyName; - - private String address; - //@Coalesce({ "familyName", "parent.familyName", "parent.parent.familyName" }) - @Formula(select = "coalesce(${ta}.family_name, j1.family_name, j2.family_name)", join = PARENTS_JOIN ) + @Formula(select = "coalesce(${ta}.family_name, j1.family_name, j2.family_name)", join = PARENTS_JOIN) private String effectiveFamilyName; //@Coalesce({ "address", "parent.address", "parent.parent.address" }) - @Formula(select = "coalesce(${ta}.address, j1.address, j2.address)", join = PARENTS_JOIN ) + @Formula(select = "coalesce(${ta}.address, j1.address, j2.address)", join = PARENTS_JOIN) private String effectiveAddress; - + @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id, j2.some_bean_id)") @ManyToOne private EBasic effectiveBean; - + public ParentPerson getParent() { return parent; } diff --git a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java index 8e27aae3b..574503d02 100644 --- a/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/GrandParentPerson.java @@ -1,17 +1,15 @@ - package com.avaje.tests.model.family; -import java.util.ArrayList; -import java.util.List; +import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OrderBy; - -import com.avaje.ebean.annotation.Formula; -import com.avaje.tests.model.basic.EBasic; +import java.util.ArrayList; +import java.util.List; @Entity public class GrandParentPerson extends InheritablePerson { @@ -22,15 +20,15 @@ public class GrandParentPerson extends InheritablePerson { // This rather complex formulas should be built later by CustomAnnotationParser private static final String PARENT_PERSON_AGGREGATE_JOIN = "left join " - + "(select i1.parent_identifier, count(*) as child_count, sum(i1.age) as child_age from parent_person i1 group by i1.parent_identifier) " - + "as f1 on f1.parent_identifier = ${ta}.identifier"; + + "(select i1.parent_identifier, count(*) as child_count, sum(i1.age) as child_age from parent_person i1 group by i1.parent_identifier) " + + "as f1 on f1.parent_identifier = ${ta}.identifier"; //@Count("children") - @Formula(select = "coalesce(f1.child_count, 0)", join = PARENT_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f1.child_count, 0)", join = PARENT_PERSON_AGGREGATE_JOIN) private Integer childCount; //@Sum("children.age") - @Formula(select = "coalesce(f1.child_age, 0)", join = PARENT_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f1.child_age, 0)", join = PARENT_PERSON_AGGREGATE_JOIN) private Integer totalAge; private String familyName; @@ -42,7 +40,7 @@ public class GrandParentPerson extends InheritablePerson { @Formula(select = "coalesce(${ta}.some_bean_id,1)") @ManyToOne private EBasic effectiveBean; - + public List getChildren() { return children; } @@ -56,7 +54,7 @@ public class GrandParentPerson extends InheritablePerson { return totalAge; } - public String getFamilyName() { + public String getFamilyName() { return familyName; } diff --git a/src/test/java/com/avaje/tests/model/family/InheritablePerson.java b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java index 8a174932b..12a2ad027 100644 --- a/src/test/java/com/avaje/tests/model/family/InheritablePerson.java +++ b/src/test/java/com/avaje/tests/model/family/InheritablePerson.java @@ -1,25 +1,24 @@ - package com.avaje.tests.model.family; +import com.avaje.tests.model.basic.EBasic; + import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; -import com.avaje.tests.model.basic.EBasic; - @MappedSuperclass -public abstract class InheritablePerson { +public abstract class InheritablePerson { - @Id - private Integer identifier; + @Id + private Integer identifier; - private String name; + private String name; - private Integer age; + private Integer age; + + @ManyToOne + private EBasic someBean; - @ManyToOne - private EBasic someBean; - public Integer getIdentifier() { return identifier; } @@ -43,11 +42,11 @@ public abstract class InheritablePerson { public void setAge(Integer age) { this.age = age; } - + public void setSomeBean(EBasic someBean) { this.someBean = someBean; } - + public EBasic getSomeBean() { return someBean; } diff --git a/src/test/java/com/avaje/tests/model/family/ParentPerson.java b/src/test/java/com/avaje/tests/model/family/ParentPerson.java index 98d46b09e..3f3deba68 100644 --- a/src/test/java/com/avaje/tests/model/family/ParentPerson.java +++ b/src/test/java/com/avaje/tests/model/family/ParentPerson.java @@ -1,17 +1,15 @@ - package com.avaje.tests.model.family; -import java.util.ArrayList; -import java.util.List; +import com.avaje.ebean.annotation.Formula; +import com.avaje.tests.model.basic.EBasic; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OrderBy; - -import com.avaje.ebean.annotation.Formula; -import com.avaje.tests.model.basic.EBasic; +import java.util.ArrayList; +import java.util.List; @Entity @@ -19,8 +17,8 @@ public class ParentPerson extends InheritablePerson { //This rather complex formulas should be built later by CustomAnnotationParser private static final String CHILD_PERSON_AGGREGATE_JOIN = "left join " - + "(select i2.parent_identifier, count(*) as child_count, sum(i2.age) as child_age from child_person i2 group by i2.parent_identifier) " - + "as f2 on f2.parent_identifier = ${ta}.identifier"; + + "(select i2.parent_identifier, count(*) as child_count, sum(i2.age) as child_age from child_person i2 group by i2.parent_identifier) " + + "as f2 on f2.parent_identifier = ${ta}.identifier"; private static final String GRAND_PARENT_PERSON_JOIN = "join grand_parent_person j1 on j1.identifier = ${ta}.parent_identifier"; @@ -32,11 +30,11 @@ public class ParentPerson extends InheritablePerson { private List children = new ArrayList<>(); //@Count("children") - @Formula(select = "coalesce(f2.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_count, 0)", join = CHILD_PERSON_AGGREGATE_JOIN) private Integer childCount; //@Sum("children.age") - @Formula(select = "coalesce(f2.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN ) + @Formula(select = "coalesce(f2.child_age, 0)", join = CHILD_PERSON_AGGREGATE_JOIN) private Integer totalAge; private String familyName; @@ -44,14 +42,14 @@ public class ParentPerson extends InheritablePerson { private String address; //@Coalesce({ "familyName", "parent.familyName" }) - @Formula(select = "coalesce(${ta}.family_name, j1.family_name)", join = GRAND_PARENT_PERSON_JOIN ) + @Formula(select = "coalesce(${ta}.family_name, j1.family_name)", join = GRAND_PARENT_PERSON_JOIN) private String effectiveFamilyName; //@Coalesce({ "address", "parent.address" }) - @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN ) + @Formula(select = "coalesce(${ta}.address, j1.address)", join = GRAND_PARENT_PERSON_JOIN) private String effectiveAddress; - @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)", join = GRAND_PARENT_PERSON_JOIN ) + @Formula(select = "coalesce(${ta}.some_bean_id, j1.some_bean_id)", join = GRAND_PARENT_PERSON_JOIN) @ManyToOne private EBasic effectiveBean; diff --git a/src/test/java/com/avaje/tests/model/history/TestHistoryExclude.java b/src/test/java/com/avaje/tests/model/history/TestHistoryExclude.java index e14105f72..a040cdc43 100644 --- a/src/test/java/com/avaje/tests/model/history/TestHistoryExclude.java +++ b/src/test/java/com/avaje/tests/model/history/TestHistoryExclude.java @@ -25,6 +25,7 @@ public class TestHistoryExclude extends BaseTestCase { link.save(); } } + @Test public void testLazyLoad() { @@ -40,9 +41,9 @@ public class TestHistoryExclude extends BaseTestCase { prepare(); HeLink linkFound = Ebean.find(HeLink.class) - .asOf(new Timestamp(System.currentTimeMillis())) - .setId(link.getId()) - .findUnique(); + .asOf(new Timestamp(System.currentTimeMillis())) + .setId(link.getId()) + .findUnique(); assertThat(linkFound.getDocs().size()).isEqualTo(2); } diff --git a/src/test/java/com/avaje/tests/model/history/TestHistoryInclude.java b/src/test/java/com/avaje/tests/model/history/TestHistoryInclude.java index 825c7ece8..6b29ff349 100644 --- a/src/test/java/com/avaje/tests/model/history/TestHistoryInclude.java +++ b/src/test/java/com/avaje/tests/model/history/TestHistoryInclude.java @@ -41,9 +41,9 @@ public class TestHistoryInclude extends BaseTestCase { prepare(); HiLink linkFound = Ebean.find(HiLink.class) - .asOf(new Timestamp(System.currentTimeMillis())) - .setId(link.getId()) - .findUnique(); + .asOf(new Timestamp(System.currentTimeMillis())) + .setId(link.getId()) + .findUnique(); assertThat(linkFound.getDocs().size()).isEqualTo(2); } diff --git a/src/test/java/com/avaje/tests/model/info/InfoCompany.java b/src/test/java/com/avaje/tests/model/info/InfoCompany.java index 67448e4cf..27c84f35b 100644 --- a/src/test/java/com/avaje/tests/model/info/InfoCompany.java +++ b/src/test/java/com/avaje/tests/model/info/InfoCompany.java @@ -3,14 +3,18 @@ package com.avaje.tests.model.info; import com.avaje.ebean.Model; import com.avaje.ebean.annotation.JsonIgnore; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Version; import java.util.ArrayList; import java.util.List; @Entity public class InfoCompany extends Model { - public static final Finder find = new Finder<>(InfoCompany.class); + public static final Finder find = new Finder<>(InfoCompany.class); @Id Long id; diff --git a/src/test/java/com/avaje/tests/model/info/InfoCustomer.java b/src/test/java/com/avaje/tests/model/info/InfoCustomer.java index ed422e2fe..f0453c216 100644 --- a/src/test/java/com/avaje/tests/model/info/InfoCustomer.java +++ b/src/test/java/com/avaje/tests/model/info/InfoCustomer.java @@ -11,7 +11,7 @@ import javax.persistence.Version; @Entity public class InfoCustomer extends Model { - public static final Finder find = new Finder<>(InfoCustomer.class); + public static final Finder find = new Finder<>(InfoCustomer.class); @Id Long id; diff --git a/src/test/java/com/avaje/tests/model/inheritexposedtype/IXPhoto.java b/src/test/java/com/avaje/tests/model/inheritexposedtype/IXPhoto.java index 8d7a711e3..317e01e0b 100644 --- a/src/test/java/com/avaje/tests/model/inheritexposedtype/IXPhoto.java +++ b/src/test/java/com/avaje/tests/model/inheritexposedtype/IXPhoto.java @@ -4,7 +4,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @Entity -@DiscriminatorValue( "photo" ) +@DiscriminatorValue("photo") public class IXPhoto extends IXResource { } diff --git a/src/test/java/com/avaje/tests/model/inheritexposedtype/IXResource.java b/src/test/java/com/avaje/tests/model/inheritexposedtype/IXResource.java index 06f50f6d4..e35017aa6 100644 --- a/src/test/java/com/avaje/tests/model/inheritexposedtype/IXResource.java +++ b/src/test/java/com/avaje/tests/model/inheritexposedtype/IXResource.java @@ -1,21 +1,20 @@ package com.avaje.tests.model.inheritexposedtype; -import java.util.UUID; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import java.util.UUID; @Entity -@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class IXResource { @Id UUID id; - - @Column(insertable=false, updatable=false) + + @Column(insertable = false, updatable = false) String dtype; String name; diff --git a/src/test/java/com/avaje/tests/model/inheritexposedtype/test/TestInheritExposeDtype.java b/src/test/java/com/avaje/tests/model/inheritexposedtype/test/TestInheritExposeDtype.java index 284ba6a33..9134bcaef 100644 --- a/src/test/java/com/avaje/tests/model/inheritexposedtype/test/TestInheritExposeDtype.java +++ b/src/test/java/com/avaje/tests/model/inheritexposedtype/test/TestInheritExposeDtype.java @@ -1,16 +1,15 @@ package com.avaje.tests.model.inheritexposedtype.test; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.inheritexposedtype.IXPhoto; +import org.junit.Test; public class TestInheritExposeDtype extends BaseTestCase { @Test public void test() { - + IXPhoto p = new IXPhoto(); p.setName("the name"); Ebean.save(p); @@ -21,6 +20,6 @@ public class TestInheritExposeDtype extends BaseTestCase { // delete Ebean.delete(p); - + } } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/IMRelated.java b/src/test/java/com/avaje/tests/model/inheritmany/IMRelated.java index 5657ac3d1..b72f9b85f 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/IMRelated.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/IMRelated.java @@ -9,10 +9,10 @@ public class IMRelated { @Id Long id; - + String name; - - @ManyToOne(optional=false) + + @ManyToOne(optional = false) IMRoot owner; public Long getId() { diff --git a/src/test/java/com/avaje/tests/model/inheritmany/IMRoot.java b/src/test/java/com/avaje/tests/model/inheritmany/IMRoot.java index 49da888da..8d716af86 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/IMRoot.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/IMRoot.java @@ -1,12 +1,11 @@ package com.avaje.tests.model.inheritmany; -import java.util.List; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.OneToMany; +import java.util.List; @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @@ -14,8 +13,8 @@ public class IMRoot { @Id Long id; - - @OneToMany(mappedBy="owner") + + @OneToMany(mappedBy = "owner") List related; public Long getId() { @@ -33,5 +32,5 @@ public class IMRoot { public void setRelated(List related) { this.related = related; } - + } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/IMRootOne.java b/src/test/java/com/avaje/tests/model/inheritmany/IMRootOne.java index e70919bea..ecd871ad1 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/IMRootOne.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/IMRootOne.java @@ -16,5 +16,5 @@ public class IMRootOne extends IMRoot { public void setName(String name) { this.name = name; } - + } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/IMRootTwo.java b/src/test/java/com/avaje/tests/model/inheritmany/IMRootTwo.java index dd36be816..5c7f4f9a6 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/IMRootTwo.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/IMRootTwo.java @@ -1,9 +1,8 @@ package com.avaje.tests.model.inheritmany; -import java.util.Date; - import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; +import java.util.Date; @Entity @DiscriminatorValue("TWO") @@ -12,7 +11,7 @@ public class IMRootTwo extends IMRoot { String title; Date whenTitle; - + public String getTitle() { return title; } @@ -28,5 +27,5 @@ public class IMRootTwo extends IMRoot { public void setWhenTitle(Date whenTitle) { this.whenTitle = whenTitle; } - + } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/MBase.java b/src/test/java/com/avaje/tests/model/inheritmany/MBase.java index 5e21d5c5e..a163aaf9f 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/MBase.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/MBase.java @@ -16,5 +16,5 @@ public class MBase { public void setId(Long id) { this.id = id; } - + } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/MMedia.java b/src/test/java/com/avaje/tests/model/inheritmany/MMedia.java index 3db7d7403..d7c1400d9 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/MMedia.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/MMedia.java @@ -7,8 +7,8 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @Entity -@Inheritance(strategy=InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, name = "type") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "type") public class MMedia extends MBase { String url; @@ -21,5 +21,5 @@ public class MMedia extends MBase { this.url = url; } - -} \ No newline at end of file + +} diff --git a/src/test/java/com/avaje/tests/model/inheritmany/MPicture.java b/src/test/java/com/avaje/tests/model/inheritmany/MPicture.java index 9c505cace..f8ebed946 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/MPicture.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/MPicture.java @@ -18,5 +18,5 @@ public class MPicture extends MMedia { public void setNote(String note) { this.note = note; } - + } diff --git a/src/test/java/com/avaje/tests/model/inheritmany/MProfile.java b/src/test/java/com/avaje/tests/model/inheritmany/MProfile.java index dbadc848b..4bf29671c 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/MProfile.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/MProfile.java @@ -9,7 +9,7 @@ public class MProfile extends MBase { @ManyToOne(cascade = CascadeType.ALL) MPicture picture; - + String name; public MPicture getPicture() { diff --git a/src/test/java/com/avaje/tests/model/inheritmany/TestMediaInheritanceJoinToMany.java b/src/test/java/com/avaje/tests/model/inheritmany/TestMediaInheritanceJoinToMany.java index 3f020aefd..dbdbbf460 100644 --- a/src/test/java/com/avaje/tests/model/inheritmany/TestMediaInheritanceJoinToMany.java +++ b/src/test/java/com/avaje/tests/model/inheritmany/TestMediaInheritanceJoinToMany.java @@ -1,11 +1,10 @@ package com.avaje.tests.model.inheritmany; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; +import org.junit.Assert; +import org.junit.Test; import java.util.Random; @@ -15,32 +14,32 @@ public class TestMediaInheritanceJoinToMany extends BaseTestCase { @Test public void test() { - - - String name = "nopic"+new Random().nextInt(); - + + + String name = "nopic" + new Random().nextInt(); + MProfile profileWithNoPic = new MProfile(); profileWithNoPic.setName(name); - + Ebean.save(profileWithNoPic); - + Query query = Ebean.find(MProfile.class).fetch("picture").where().eq("name", name).query(); - + // assert we get the profile with a null picture MProfile profile = query.findUnique(); Assert.assertNotNull(profile); - - // select t0.id c0, t0.name c1, t1.type c2, t1.id c3, t1.url c4, t1.note c5 - // from profile t0 + + // select t0.id c0, t0.name c1, t1.type c2, t1.id c3, t1.url c4, t1.note c5 + // from profile t0 // left join media t1 on t1.id = t0.picture_id and t1.type = 'Picture' // where t0.name = ? ; --bind(nopic) - + // specifically t1.type = 'Picture' ... on on the join and not in the where - + String generatedSql = query.getGeneratedSql(); assertThat(generatedSql).contains("from mprofile t0 left join mmedia t1 on t1.id = t0.picture_id and t1.type = 'Picture' "); assertThat(generatedSql).contains("where t0.name = ? "); - + } - + } diff --git a/src/test/java/com/avaje/tests/model/interfaces/Address.java b/src/test/java/com/avaje/tests/model/interfaces/Address.java index 2bd2dd126..aa5a936ec 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/Address.java +++ b/src/test/java/com/avaje/tests/model/interfaces/Address.java @@ -7,38 +7,38 @@ import javax.persistence.Version; @Entity public class Address implements IAddress { - @Id - private long oid; - - @Version - private int version; - - private String street; - - public long getOid() { - return oid; - } + @Id + private long oid; - public void setOid(long oid) { - this.oid = oid; - } + @Version + private int version; - public int getVersion() { - return version; - } + private String street; - public void setVersion(int version) { - this.version = version; - } + public long getOid() { + return oid; + } - @Override - public String getStreet() { - return street; - } + public void setOid(long oid) { + this.oid = oid; + } - @Override - public void setStreet(String s) { - this.street = s; - } + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + @Override + public String getStreet() { + return street; + } + + @Override + public void setStreet(String s) { + this.street = s; + } } diff --git a/src/test/java/com/avaje/tests/model/interfaces/IAddress.java b/src/test/java/com/avaje/tests/model/interfaces/IAddress.java index 401209567..f179552ec 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/IAddress.java +++ b/src/test/java/com/avaje/tests/model/interfaces/IAddress.java @@ -1,6 +1,7 @@ package com.avaje.tests.model.interfaces; public interface IAddress { - String getStreet(); - void setStreet(String s); + String getStreet(); + + void setStreet(String s); } diff --git a/src/test/java/com/avaje/tests/model/interfaces/IPerson.java b/src/test/java/com/avaje/tests/model/interfaces/IPerson.java index b8bc2f9f1..fed13d9a1 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/IPerson.java +++ b/src/test/java/com/avaje/tests/model/interfaces/IPerson.java @@ -1,6 +1,7 @@ package com.avaje.tests.model.interfaces; public interface IPerson { - IAddress getDefaultAddress(); - void setDefaultAddress(IAddress address); + IAddress getDefaultAddress(); + + void setDefaultAddress(IAddress address); } diff --git a/src/test/java/com/avaje/tests/model/interfaces/Person.java b/src/test/java/com/avaje/tests/model/interfaces/Person.java index 695da1b8d..f55cb4436 100644 --- a/src/test/java/com/avaje/tests/model/interfaces/Person.java +++ b/src/test/java/com/avaje/tests/model/interfaces/Person.java @@ -7,39 +7,39 @@ import javax.persistence.Version; @Entity public class Person implements IPerson { - @Id - private long oid; - - @Version - private int version; - - @ManyToOne(targetEntity=Address.class) - private IAddress defaultAddress; - - @Override - public IAddress getDefaultAddress() { - return defaultAddress; - } + @Id + private long oid; - @Override - public void setDefaultAddress(IAddress address) { - this.defaultAddress = address; - } + @Version + private int version; - public long getOid() { - return oid; - } + @ManyToOne(targetEntity = Address.class) + private IAddress defaultAddress; - public void setOid(long oid) { - this.oid = oid; - } + @Override + public IAddress getDefaultAddress() { + return defaultAddress; + } - public int getVersion() { - return version; - } + @Override + public void setDefaultAddress(IAddress address) { + this.defaultAddress = address; + } - public void setVersion(int version) { - this.version = version; - } + public long getOid() { + return oid; + } + + public void setOid(long oid) { + this.oid = oid; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java b/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java index 6ed452d83..a018bc086 100644 --- a/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java +++ b/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java @@ -20,8 +20,8 @@ public class SimpleKnownImmutable implements KnownImmutable { } if (Integer.class.equals(cls) || Long.class.equals(cls) || Double.class.equals(cls) || Float.class.equals(cls) - || Short.class.equals(cls) || Byte.class.equals(cls) || Character.class.equals(cls) - || Boolean.class.equals(cls)) { + || Short.class.equals(cls) || Byte.class.equals(cls) || Character.class.equals(cls) + || Boolean.class.equals(cls)) { return true; } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/CMoneyCompoundType.java b/src/test/java/com/avaje/tests/model/ivo/converter/CMoneyCompoundType.java index 6d4b3e212..b95f1a264 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/CMoneyCompoundType.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/CMoneyCompoundType.java @@ -1,53 +1,53 @@ package com.avaje.tests.model.ivo.converter; -import java.util.Currency; - import com.avaje.ebean.config.CompoundTypeProperty; import com.avaje.tests.model.ivo.CMoney; import com.avaje.tests.model.ivo.Money; +import java.util.Currency; + public class CMoneyCompoundType {//implements CompoundType { - @SuppressWarnings({ "rawtypes" }) - private CompoundTypeProperty[] props = {new PropertyMoney(), new PropertyCurrency()}; - - public CMoney create(Object[] v) { - return new CMoney((Money)v[0], (Currency)v[1]); + @SuppressWarnings({"rawtypes"}) + private CompoundTypeProperty[] props = {new PropertyMoney(), new PropertyCurrency()}; + + public CMoney create(Object[] v) { + return new CMoney((Money) v[0], (Currency) v[1]); + } + + @SuppressWarnings("unchecked") + public CompoundTypeProperty[] getProperties() { + return props; + } + + static class PropertyMoney implements CompoundTypeProperty { + + public String getName() { + return "amount"; } - @SuppressWarnings("unchecked") - public CompoundTypeProperty[] getProperties() { - return props; + public Money getValue(CMoney valueObject) { + return valueObject.getAmount(); } - - static class PropertyMoney implements CompoundTypeProperty { - public String getName() { - return "amount"; - } - - public Money getValue(CMoney valueObject) { - return valueObject.getAmount(); - } - - public int getDbType() { - return 0; - } + public int getDbType() { + return 0; } - - static class PropertyCurrency implements CompoundTypeProperty { + } - public String getName() { - return "currency"; - } + static class PropertyCurrency implements CompoundTypeProperty { - public Currency getValue(CMoney valueObject) { - return valueObject.getCurrency(); - } - - public int getDbType() { - return 0; - } + public String getName() { + return "currency"; } + public Currency getValue(CMoney valueObject) { + return valueObject.getCurrency(); + } + + public int getDbType() { + return 0; + } + } + } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java b/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java index 7ccd33f12..ccd50ade8 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/ExhangeCompoundType.java @@ -8,45 +8,45 @@ import com.avaje.tests.model.ivo.Rate; public class ExhangeCompoundType implements CompoundType { - public ExhangeCMoneyRate create(Object[] propertyValues) { - return new ExhangeCMoneyRate((Rate)propertyValues[0], (CMoney)propertyValues[1]); + public ExhangeCMoneyRate create(Object[] propertyValues) { + return new ExhangeCMoneyRate((Rate) propertyValues[0], (CMoney) propertyValues[1]); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public CompoundTypeProperty[] getProperties() { + return new CompoundTypeProperty[]{new RateProp(), new CMoneyProp()}; + } + + static class RateProp implements CompoundTypeProperty { + + public String getName() { + return "rate"; } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public CompoundTypeProperty[] getProperties() { - return new CompoundTypeProperty[]{new RateProp(), new CMoneyProp()}; + public Rate getValue(ExhangeCMoneyRate valueObject) { + return valueObject.getRate(); } - static class RateProp implements CompoundTypeProperty { - - public String getName() { - return "rate"; - } - - public Rate getValue(ExhangeCMoneyRate valueObject) { - return valueObject.getRate(); - } - - public int getDbType() { - return 0; - } - + public int getDbType() { + return 0; } - - static class CMoneyProp implements CompoundTypeProperty { - public String getName() { - return "cmoney"; - } + } - public CMoney getValue(ExhangeCMoneyRate valueObject) { - return valueObject.getCmoney(); - } + static class CMoneyProp implements CompoundTypeProperty { - public int getDbType() { - return 0; - } - + public String getName() { + return "cmoney"; } - + + public CMoney getValue(ExhangeCMoneyRate valueObject) { + return valueObject.getCmoney(); + } + + public int getDbType() { + return 0; + } + + } + } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java b/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java index 82780da7d..91f2e7bda 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/JodaIntervalCompoundType.java @@ -1,50 +1,49 @@ package com.avaje.tests.model.ivo.converter; -import org.joda.time.Interval; - import com.avaje.ebean.config.CompoundType; import com.avaje.ebean.config.CompoundTypeProperty; +import org.joda.time.Interval; -public class JodaIntervalCompoundType implements CompoundType{ +public class JodaIntervalCompoundType implements CompoundType { - public Interval create(Object[] propertyValues) { - return new Interval((Long)propertyValues[0], (Long)propertyValues[1]); + public Interval create(Object[] propertyValues) { + return new Interval((Long) propertyValues[0], (Long) propertyValues[1]); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public CompoundTypeProperty[] getProperties() { + return new CompoundTypeProperty[]{new Start(), new End()}; + } + + static class Start implements CompoundTypeProperty { + + public String getName() { + return "startMillis"; } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public CompoundTypeProperty[] getProperties() { - return new CompoundTypeProperty[]{new Start(), new End()}; - } - - static class Start implements CompoundTypeProperty { - - public String getName() { - return "startMillis"; - } - - public Long getValue(Interval valueObject) { - return valueObject.getStartMillis(); - } - - public int getDbType() { - return java.sql.Types.TIMESTAMP; - } + public Long getValue(Interval valueObject) { + return valueObject.getStartMillis(); } - static class End implements CompoundTypeProperty { - - public String getName() { - return "endMillis"; - } - - public Long getValue(Interval valueObject) { - return valueObject.getEndMillis(); - } - - public int getDbType() { - return java.sql.Types.TIMESTAMP; - } - + public int getDbType() { + return java.sql.Types.TIMESTAMP; } + } + + static class End implements CompoundTypeProperty { + + public String getName() { + return "endMillis"; + } + + public Long getValue(Interval valueObject) { + return valueObject.getEndMillis(); + } + + public int getDbType() { + return java.sql.Types.TIMESTAMP; + } + + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/MoneyTypeConverter.java b/src/test/java/com/avaje/tests/model/ivo/converter/MoneyTypeConverter.java index 2d50f54fd..b11801b9b 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/MoneyTypeConverter.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/MoneyTypeConverter.java @@ -1,20 +1,20 @@ package com.avaje.tests.model.ivo.converter; -import java.math.BigDecimal; - import com.avaje.tests.model.ivo.Money; +import java.math.BigDecimal; + /** * Converts between Money and BigDecimal. */ public class MoneyTypeConverter {//implements ScalarTypeConverter{ - public BigDecimal unwrapValue(Money beanType) { - return beanType.getAmount(); - } + public BigDecimal unwrapValue(Money beanType) { + return beanType.getAmount(); + } + + public Money wrapValue(BigDecimal scalarType) { + return new Money(scalarType); + } - public Money wrapValue(BigDecimal scalarType) { - return new Money(scalarType); - } - } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java b/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java index cb5abdb42..9388ad121 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/OidTypeConverter.java @@ -1,22 +1,21 @@ - package com.avaje.tests.model.ivo.converter; import com.avaje.tests.model.ivo.Oid; public class OidTypeConverter {//implements ScalarTypeConverter,Long> { - public Oid wrapValue(Long scalarType) { - if (scalarType == null){ - return null; - } - return new Oid<>(scalarType); + public Oid wrapValue(Long scalarType) { + if (scalarType == null) { + return null; } + return new Oid<>(scalarType); + } - public Long unwrapValue(Oid beanType) { - if (beanType == null){ - return null; - } - return beanType.getValue(); + public Long unwrapValue(Oid beanType) { + if (beanType == null) { + return null; } + return beanType.getValue(); + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/RateTypeConverter.java b/src/test/java/com/avaje/tests/model/ivo/converter/RateTypeConverter.java index cbbb9e105..a545db1ec 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/RateTypeConverter.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/RateTypeConverter.java @@ -1,20 +1,20 @@ package com.avaje.tests.model.ivo.converter; -import java.math.BigDecimal; - import com.avaje.tests.model.ivo.Rate; +import java.math.BigDecimal; + /** * Converts between Rate and BigDecimal. */ public class RateTypeConverter {//implements ScalarTypeConverter{ - public BigDecimal unwrapValue(Rate beanType) { - return beanType.getValue(); - } + public BigDecimal unwrapValue(Rate beanType) { + return beanType.getValue(); + } + + public Rate wrapValue(BigDecimal scalarType) { + return new Rate(scalarType); + } - public Rate wrapValue(BigDecimal scalarType) { - return new Rate(scalarType); - } - } diff --git a/src/test/java/com/avaje/tests/model/ivo/converter/SysTimeConverter.java b/src/test/java/com/avaje/tests/model/ivo/converter/SysTimeConverter.java index 9ef18f73a..20762ee03 100644 --- a/src/test/java/com/avaje/tests/model/ivo/converter/SysTimeConverter.java +++ b/src/test/java/com/avaje/tests/model/ivo/converter/SysTimeConverter.java @@ -1,24 +1,24 @@ package com.avaje.tests.model.ivo.converter; -import java.sql.Timestamp; - import com.avaje.ebean.config.ScalarTypeConverter; import com.avaje.tests.model.ivo.SysTime; +import java.sql.Timestamp; + public class SysTimeConverter implements ScalarTypeConverter { - - public SysTime getNullValue() { - return null; - } - public Timestamp unwrapValue(SysTime beanType) { - return new Timestamp(beanType.getMillis()); - } + public SysTime getNullValue() { + return null; + } + + public Timestamp unwrapValue(SysTime beanType) { + return new Timestamp(beanType.getMillis()); + } + + public SysTime wrapValue(Timestamp scalarType) { + return new SysTime(scalarType.getTime()); + } - public SysTime wrapValue(Timestamp scalarType) { - return new SysTime(scalarType.getTime()); - } - } diff --git a/src/test/java/com/avaje/tests/model/joda/TestJodaInsertUpdate.java b/src/test/java/com/avaje/tests/model/joda/TestJodaInsertUpdate.java index 3541845f3..4f5cfbe2f 100644 --- a/src/test/java/com/avaje/tests/model/joda/TestJodaInsertUpdate.java +++ b/src/test/java/com/avaje/tests/model/joda/TestJodaInsertUpdate.java @@ -6,9 +6,7 @@ import org.joda.time.DateTime; import org.joda.time.LocalDateTime; import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import static org.junit.Assert.*; public class TestJodaInsertUpdate extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/model/json/EBasicHstore.java b/src/test/java/com/avaje/tests/model/json/EBasicHstore.java index 775559a44..bd1359845 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicHstore.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicHstore.java @@ -18,7 +18,7 @@ public class EBasicHstore { // fallback to varchar(800) for non-Postgres @DbHstore(length = 800) - Map map; + Map map; @Version Long version; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java index ab841aebe..2b1dbdda4 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonList.java @@ -29,7 +29,7 @@ public class EBasicJsonList { List beanList; @DbJson(length = 700) - Map beanMap = new LinkedHashMap<>(); + Map beanMap = new LinkedHashMap<>(); @DbJson(length = 500) PlainBean plainBean; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonMap.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonMap.java index 6a68998e7..f0f1b7ca9 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonMap.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonMap.java @@ -19,7 +19,7 @@ public class EBasicJsonMap { String name; @DbJson - Map content; + Map content; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapBlob.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapBlob.java index b01873056..5d5440b25 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapBlob.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapBlob.java @@ -20,7 +20,7 @@ public class EBasicJsonMapBlob { String name; @DbJson(storage = DbJsonType.BLOB) - Map content; + Map content; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapClob.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapClob.java index 18fa707ce..9fb5e1b0b 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapClob.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapClob.java @@ -20,7 +20,7 @@ public class EBasicJsonMapClob { String name; @DbJson(storage = DbJsonType.CLOB) - Map content; + Map content; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapJsonB.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapJsonB.java index c8ece036f..e9ac6398f 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapJsonB.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapJsonB.java @@ -19,7 +19,7 @@ public class EBasicJsonMapJsonB { String name; @DbJsonB - Map content; + Map content; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapVarchar.java b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapVarchar.java index 648574201..399285366 100644 --- a/src/test/java/com/avaje/tests/model/json/EBasicJsonMapVarchar.java +++ b/src/test/java/com/avaje/tests/model/json/EBasicJsonMapVarchar.java @@ -20,7 +20,7 @@ public class EBasicJsonMapVarchar { String name; @DbJson(storage = DbJsonType.VARCHAR)//, length = 2200) - Map content; + Map content; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/m2m/DCredit.java b/src/test/java/com/avaje/tests/model/m2m/DCredit.java index a03291c23..727f5b90a 100644 --- a/src/test/java/com/avaje/tests/model/m2m/DCredit.java +++ b/src/test/java/com/avaje/tests/model/m2m/DCredit.java @@ -9,19 +9,19 @@ import javax.persistence.ManyToMany; import java.util.List; @Entity -public class DCredit extends Model { +public class DCredit extends Model { - @Id - Long id; + @Id + Long id; String credit; @ManyToMany(cascade = CascadeType.PERSIST) List droles; - public DCredit(String credit) { - this.credit = credit; - } + public DCredit(String credit) { + this.credit = credit; + } public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/m2m/DRot.java b/src/test/java/com/avaje/tests/model/m2m/DRot.java index 67bda421b..bd1dc12ab 100644 --- a/src/test/java/com/avaje/tests/model/m2m/DRot.java +++ b/src/test/java/com/avaje/tests/model/m2m/DRot.java @@ -10,14 +10,14 @@ import java.util.List; @Entity -public class DRot extends Model { +public class DRot extends Model { - @Id - Long id; + @Id + Long id; - final String name; - - @ManyToMany(cascade = CascadeType.ALL) + final String name; + + @ManyToMany(cascade = CascadeType.ALL) List croles; public DRot(String name) { diff --git a/src/test/java/com/avaje/tests/model/m2m/MnyTopic.java b/src/test/java/com/avaje/tests/model/m2m/MnyTopic.java index d4772c099..36b2452d5 100644 --- a/src/test/java/com/avaje/tests/model/m2m/MnyTopic.java +++ b/src/test/java/com/avaje/tests/model/m2m/MnyTopic.java @@ -21,8 +21,8 @@ public class MnyTopic { @ManyToMany @JoinTable(name = "subtopics", - joinColumns = @JoinColumn(name = "topic", referencedColumnName = "id"), - inverseJoinColumns = @JoinColumn(name = "subtopic", referencedColumnName = "id")) + joinColumns = @JoinColumn(name = "topic", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "subtopic", referencedColumnName = "id")) List subTopics; public MnyTopic() { diff --git a/src/test/java/com/avaje/tests/model/m2m/Role.java b/src/test/java/com/avaje/tests/model/m2m/Role.java index 16d42cde3..240b82592 100644 --- a/src/test/java/com/avaje/tests/model/m2m/Role.java +++ b/src/test/java/com/avaje/tests/model/m2m/Role.java @@ -1,8 +1,5 @@ package com.avaje.tests.model.m2m; -import java.util.Set; -import java.util.UUID; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -11,6 +8,8 @@ import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Version; +import java.util.Set; +import java.util.UUID; /** * The Class Role. diff --git a/src/test/java/com/avaje/tests/model/m2m/Tenant.java b/src/test/java/com/avaje/tests/model/m2m/Tenant.java index 4baa2fb68..577700ebf 100644 --- a/src/test/java/com/avaje/tests/model/m2m/Tenant.java +++ b/src/test/java/com/avaje/tests/model/m2m/Tenant.java @@ -1,8 +1,5 @@ package com.avaje.tests.model.m2m; -import java.util.Set; -import java.util.UUID; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,6 +7,8 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Version; +import java.util.Set; +import java.util.UUID; /** * The Class Tenant. diff --git a/src/test/java/com/avaje/tests/model/m2o/Empl.java b/src/test/java/com/avaje/tests/model/m2o/Empl.java index ad997f5ff..cdceeffc7 100644 --- a/src/test/java/com/avaje/tests/model/m2o/Empl.java +++ b/src/test/java/com/avaje/tests/model/m2o/Empl.java @@ -17,7 +17,7 @@ public class Empl { Integer age; - @OneToMany(mappedBy="employee" , cascade= CascadeType.ALL) + @OneToMany(mappedBy = "employee", cascade = CascadeType.ALL) List addresses; @ManyToOne(cascade = CascadeType.ALL) diff --git a/src/test/java/com/avaje/tests/model/map/MpRole.java b/src/test/java/com/avaje/tests/model/map/MpRole.java index 7b4ac2a4f..915b65e3c 100644 --- a/src/test/java/com/avaje/tests/model/map/MpRole.java +++ b/src/test/java/com/avaje/tests/model/map/MpRole.java @@ -1,13 +1,14 @@ package com.avaje.tests.model.map; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.Id; @Entity public class MpRole { @Id private Long id; - + private String code; private Long organizationId; @@ -35,4 +36,4 @@ public class MpRole { public void setOrganizationId(Long organizationId) { this.organizationId = organizationId; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/mappedsuper/ASimpleBean.java b/src/test/java/com/avaje/tests/model/mappedsuper/ASimpleBean.java index 1123034fa..7ef37046c 100644 --- a/src/test/java/com/avaje/tests/model/mappedsuper/ASimpleBean.java +++ b/src/test/java/com/avaje/tests/model/mappedsuper/ASimpleBean.java @@ -8,7 +8,7 @@ public class ASimpleBean extends NotEnhancedMappedSuper { @Id Long id; - + String name; public Long getId() { @@ -26,5 +26,5 @@ public class ASimpleBean extends NotEnhancedMappedSuper { public void setName(String name) { this.name = name; } - + } diff --git a/src/test/java/com/avaje/tests/model/mappedsuper/NotEnhancedMappedSuper.java b/src/test/java/com/avaje/tests/model/mappedsuper/NotEnhancedMappedSuper.java index 37d579f32..0d3d085fd 100644 --- a/src/test/java/com/avaje/tests/model/mappedsuper/NotEnhancedMappedSuper.java +++ b/src/test/java/com/avaje/tests/model/mappedsuper/NotEnhancedMappedSuper.java @@ -7,9 +7,9 @@ import javax.persistence.Transient; public class NotEnhancedMappedSuper { public static String SOMETHING = "Hello"; - + private transient Long one; - + @Transient private Long two; @@ -28,5 +28,5 @@ public class NotEnhancedMappedSuper { public void setTwo(Long two) { this.two = two; } - + } diff --git a/src/test/java/com/avaje/tests/model/noid/NoIdBean.java b/src/test/java/com/avaje/tests/model/noid/NoIdBean.java index e5565748b..628dabfd2 100644 --- a/src/test/java/com/avaje/tests/model/noid/NoIdBean.java +++ b/src/test/java/com/avaje/tests/model/noid/NoIdBean.java @@ -7,7 +7,7 @@ import javax.persistence.Table; import java.sql.Timestamp; @Entity -@Table(name="noidbean") +@Table(name = "noidbean") public class NoIdBean { String name; diff --git a/src/test/java/com/avaje/tests/model/noid/TestInsertNoIdBean.java b/src/test/java/com/avaje/tests/model/noid/TestInsertNoIdBean.java index af954a29e..06290fc07 100644 --- a/src/test/java/com/avaje/tests/model/noid/TestInsertNoIdBean.java +++ b/src/test/java/com/avaje/tests/model/noid/TestInsertNoIdBean.java @@ -20,7 +20,7 @@ public class TestInsertNoIdBean extends BaseTestCase { int rowCount = Ebean.find(NoIdBean.class).findCount(); - assertTrue("rowCount:"+rowCount, rowCount > 0); + assertTrue("rowCount:" + rowCount, rowCount > 0); } } diff --git a/src/test/java/com/avaje/tests/model/onetoone/Account.java b/src/test/java/com/avaje/tests/model/onetoone/Account.java index ba4ab835f..cb993a4ef 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/Account.java +++ b/src/test/java/com/avaje/tests/model/onetoone/Account.java @@ -7,17 +7,18 @@ import javax.persistence.OneToOne; import javax.persistence.Table; @Entity -@Table(name="oto_account") +@Table(name = "oto_account") public class Account extends BaseModel { - public static final Find find = new Find(){}; - + public static final Find find = new Find() { + }; + String name; - - @OneToOne(mappedBy = "account",optional = true) + + @OneToOne(mappedBy = "account", optional = true) User user; - + public String getName() { return name; } @@ -33,5 +34,5 @@ public class Account extends BaseModel { public void setUser(User user) { this.user = user; } - + } diff --git a/src/test/java/com/avaje/tests/model/onetoone/OtoChild.java b/src/test/java/com/avaje/tests/model/onetoone/OtoChild.java index 458fa95c3..fe1bd0519 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/OtoChild.java +++ b/src/test/java/com/avaje/tests/model/onetoone/OtoChild.java @@ -6,12 +6,12 @@ import javax.persistence.OneToOne; @Entity public class OtoChild { - + @Id Integer id; - + String name; - + @OneToOne OtoMaster master; @@ -38,5 +38,5 @@ public class OtoChild { public void setMaster(OtoMaster master) { this.master = master; } - -} \ No newline at end of file + +} diff --git a/src/test/java/com/avaje/tests/model/onetoone/OtoMaster.java b/src/test/java/com/avaje/tests/model/onetoone/OtoMaster.java index 683600b84..3b9f1a711 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/OtoMaster.java +++ b/src/test/java/com/avaje/tests/model/onetoone/OtoMaster.java @@ -10,9 +10,9 @@ public class OtoMaster { @Id Long id; - + String name; - + @OneToOne(cascade = CascadeType.ALL, mappedBy = "master") OtoChild child; diff --git a/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneCascadeSave.java b/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneCascadeSave.java index f5ad02677..2a15ecf7d 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneCascadeSave.java +++ b/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneCascadeSave.java @@ -1,18 +1,17 @@ package com.avaje.tests.model.onetoone; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; +import org.junit.Assert; +import org.junit.Test; public class TestOneToOneCascadeSave extends BaseTestCase { @Test public void test() { - - - OtoMaster master = new OtoMaster(); + + + OtoMaster master = new OtoMaster(); master.setName("CName"); OtoChild child = new OtoChild(); @@ -26,11 +25,11 @@ public class TestOneToOneCascadeSave extends BaseTestCase { Ebean.save(master); Assert.assertNotNull(child.getId()); - + OtoChild child2 = Ebean.find(OtoChild.class, child.getId()); OtoMaster master2 = child2.getMaster(); Assert.assertNotNull(master2); - + } - + } diff --git a/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneOptionalRelationship.java b/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneOptionalRelationship.java index 14ef7f009..8b8b88ba4 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneOptionalRelationship.java +++ b/src/test/java/com/avaje/tests/model/onetoone/TestOneToOneOptionalRelationship.java @@ -14,64 +14,64 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase { Account account = new Account(); account.setName("AC234"); - account.save(); + account.save(); LoggedSqlCollector.start(); - + Account fetchedAccount = Account.find.byId(account.getId()); Assert.assertNotNull(fetchedAccount); - + List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); - // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 - // from oto_account t0 - // join oto_user t1 on t1.account_id = t0.id - // where t0.id = ? + // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 + // from oto_account t0 + // join oto_user t1 on t1.account_id = t0.id + // where t0.id = ? String sql = trimSql(loggedSql.get(0), 1); Assert.assertTrue(sql.contains("select t0.id, t0.name")); Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?")); } - + @Test public void testWithUser() { - + Account account = new Account(); account.setName("AC678"); account.save(); - + User user = new User(); user.setName("Geoff"); user.setAccount(account); user.save(); - + LoggedSqlCollector.start(); - + Account fetchedAccount = Account.find.byId(account.getId()); Assert.assertNotNull(fetchedAccount); - + Assert.assertNotNull(fetchedAccount.getUser()); Assert.assertEquals(user.getId(), fetchedAccount.getUser().getId()); Assert.assertEquals(user.getName(), fetchedAccount.getUser().getName()); - + List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(2, loggedSql.size()); - // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 - // from oto_account t0 - // join oto_user t1 on t1.account_id = t0.id - // where t0.id = ? + // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 + // from oto_account t0 + // join oto_user t1 on t1.account_id = t0.id + // where t0.id = ? String sql = trimSql(loggedSql.get(0), 1); Assert.assertTrue(sql.contains("select t0.id, t0.name")); Assert.assertTrue(sql.contains(" from oto_account t0 left join oto_user t1 on t1.account_id = t0.id where t0.id = ?")); - + String lazyLoadSql = trimSql(loggedSql.get(1), 5); Assert.assertTrue(lazyLoadSql.contains("select t0.id, t0.name, t0.version, t0.when_created, t0.when_modified, t0.account_id from oto_user t0 where t0.id = ?")); } - + @Test public void testWithUserFetch() { @@ -79,28 +79,28 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase { Account account = new Account(); account.setName("AC786"); account.save(); - + User user = new User(); user.setName("Jane"); user.setAccount(account); user.save(); - + LoggedSqlCollector.start(); - + Account fetchedAccount = Account.find.fetch("user").setId(account.getId()).findUnique(); Assert.assertNotNull(fetchedAccount); - + Assert.assertNotNull(fetchedAccount.getUser()); Assert.assertEquals(user.getId(), fetchedAccount.getUser().getId()); Assert.assertEquals(user.getName(), fetchedAccount.getUser().getName()); - + List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); - // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 - // from oto_account t0 - // join oto_user t1 on t1.account_id = t0.id - // where t0.id = ? + // select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t1.id c5 + // from oto_account t0 + // join oto_user t1 on t1.account_id = t0.id + // where t0.id = ? String sql = trimSql(loggedSql.get(0), 1); Assert.assertTrue(sql.contains("select t0.id, t0.name")); diff --git a/src/test/java/com/avaje/tests/model/onetoone/User.java b/src/test/java/com/avaje/tests/model/onetoone/User.java index e1cfd8b6c..30d8f0c1c 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/User.java +++ b/src/test/java/com/avaje/tests/model/onetoone/User.java @@ -1,19 +1,20 @@ package com.avaje.tests.model.onetoone; +import com.avaje.tests.model.BaseModel; + import javax.persistence.Entity; import javax.persistence.OneToOne; import javax.persistence.Table; -import com.avaje.tests.model.BaseModel; - @Entity -@Table(name="oto_user") +@Table(name = "oto_user") public class User extends BaseModel { - public static final Find find = new Find(){}; + public static final Find find = new Find() { + }; String name; - + @OneToOne(optional = false) Account account; @@ -32,5 +33,5 @@ public class User extends BaseModel { public void setAccount(Account account) { this.account = account; } - + } diff --git a/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java b/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java index c274dfb4b..e2b097bb8 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java +++ b/src/test/java/com/avaje/tests/model/onetoone/album/Cover.java @@ -5,7 +5,6 @@ import com.avaje.ebean.annotation.SoftDelete; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.PreRemove; diff --git a/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java b/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java index adde5f4fe..73153fc4a 100644 --- a/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java +++ b/src/test/java/com/avaje/tests/model/onetoone/album/DeleteById_SoftDelete_Tests.java @@ -49,9 +49,9 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase { assertNull(findWhenSoft); Cover cover1 = Ebean.find(Cover.class) - .setIncludeSoftDeletes() - .setId(cover.getId()) - .findUnique(); + .setIncludeSoftDeletes() + .setId(cover.getId()) + .findUnique(); cover1.setDeleted(false); diff --git a/src/test/java/com/avaje/tests/model/orderentity/OrderEntity.java b/src/test/java/com/avaje/tests/model/orderentity/OrderEntity.java index 981288c52..c402c8883 100644 --- a/src/test/java/com/avaje/tests/model/orderentity/OrderEntity.java +++ b/src/test/java/com/avaje/tests/model/orderentity/OrderEntity.java @@ -1,7 +1,5 @@ package com.avaje.tests.model.orderentity; -import java.util.List; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -9,13 +7,14 @@ import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; +import java.util.List; @Entity @Table(name = "s_orders") -public class OrderEntity { +public class OrderEntity { /** - * Rob Note: Ideally this would be a UUID rather than a String type - then Ebean would automatically + * Rob Note: Ideally this would be a UUID rather than a String type - then Ebean would automatically * assign a UUID based id generator and 'do the right thing'. */ @Id @@ -40,6 +39,6 @@ public class OrderEntity { public void setItems(List items) { this.items = items; } - - + + } diff --git a/src/test/java/com/avaje/tests/model/orderentity/OrderItemEntity.java b/src/test/java/com/avaje/tests/model/orderentity/OrderItemEntity.java index 897a9fe6b..9d85ac551 100644 --- a/src/test/java/com/avaje/tests/model/orderentity/OrderItemEntity.java +++ b/src/test/java/com/avaje/tests/model/orderentity/OrderItemEntity.java @@ -1,20 +1,19 @@ package com.avaje.tests.model.orderentity; -import java.math.BigDecimal; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import java.math.BigDecimal; @Entity @Table(name = "s_order_items") public class OrderItemEntity { /** - * Rob Note: Ideally this would be a UUID rather than a String type - then Ebean would automatically + * Rob Note: Ideally this would be a UUID rather than a String type - then Ebean would automatically * assign a UUID based id generator and 'do the right thing'. */ @Id @@ -72,4 +71,4 @@ public class OrderItemEntity { this.amount = amount; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/prnt/MPrinter.java b/src/test/java/com/avaje/tests/model/prnt/MPrinter.java index b75ff1021..6117ea3c6 100644 --- a/src/test/java/com/avaje/tests/model/prnt/MPrinter.java +++ b/src/test/java/com/avaje/tests/model/prnt/MPrinter.java @@ -1,6 +1,12 @@ package com.avaje.tests.model.prnt; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.Version; @Entity public class MPrinter { @@ -13,19 +19,28 @@ public class MPrinter { String name; - @Column(name="flags", nullable=false) - long allFlags=0L; + @Column(name = "flags", nullable = false) + long allFlags = 0L; - @Column(name="dwid",nullable=false) MSomeOther dataWarehouseId; + @Column(name = "dwid", nullable = false) + MSomeOther dataWarehouseId; - @JoinColumn(name="current_state_id") + @JoinColumn(name = "current_state_id") @ManyToOne MPrinterState currentState; - @JoinColumn(name="last_swap_cyan_id") @OneToOne private MPrinterState lastTonerSwapCyan; - @JoinColumn(name="last_swap_magenta_id") @OneToOne private MPrinterState lastTonerSwapMagenta; - @JoinColumn(name="last_swap_yellow_id") @OneToOne private MPrinterState lastTonerSwapYellow; - @JoinColumn(name="last_swap_black_id") @OneToOne private MPrinterState lastTonerSwapBlack; + @JoinColumn(name = "last_swap_cyan_id") + @OneToOne + private MPrinterState lastTonerSwapCyan; + @JoinColumn(name = "last_swap_magenta_id") + @OneToOne + private MPrinterState lastTonerSwapMagenta; + @JoinColumn(name = "last_swap_yellow_id") + @OneToOne + private MPrinterState lastTonerSwapYellow; + @JoinColumn(name = "last_swap_black_id") + @OneToOne + private MPrinterState lastTonerSwapBlack; public Long getId() { return id; diff --git a/src/test/java/com/avaje/tests/model/prnt/MPrinterListener.java b/src/test/java/com/avaje/tests/model/prnt/MPrinterListener.java index 2423ab97a..4d1e8ef31 100644 --- a/src/test/java/com/avaje/tests/model/prnt/MPrinterListener.java +++ b/src/test/java/com/avaje/tests/model/prnt/MPrinterListener.java @@ -18,7 +18,7 @@ public class MPrinterListener extends BeanPersistAdapter { public boolean preUpdate(BeanPersistRequest request) { logger.info("preUpdate ..."); - logger.info("preUpdate ..."+request.getUpdatedValues()); + logger.info("preUpdate ..." + request.getUpdatedValues()); request.getUpdatedProperties(); return super.preUpdate(request); } diff --git a/src/test/java/com/avaje/tests/model/prnt/MPrinterState.java b/src/test/java/com/avaje/tests/model/prnt/MPrinterState.java index 891916fcf..88594cfd2 100644 --- a/src/test/java/com/avaje/tests/model/prnt/MPrinterState.java +++ b/src/test/java/com/avaje/tests/model/prnt/MPrinterState.java @@ -1,6 +1,11 @@ package com.avaje.tests.model.prnt; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Version; @Entity public class MPrinterState { @@ -13,9 +18,10 @@ public class MPrinterState { long flags; - @Column(name="dwid",nullable=false) MSomeOther dataWarehouseId; + @Column(name = "dwid", nullable = false) + MSomeOther dataWarehouseId; - @JoinColumn(name="printer_id") + @JoinColumn(name = "printer_id") @ManyToOne MPrinter printer; diff --git a/src/test/java/com/avaje/tests/model/pview/Paggview.java b/src/test/java/com/avaje/tests/model/pview/Paggview.java index 4ea8bf0ce..963392f6d 100644 --- a/src/test/java/com/avaje/tests/model/pview/Paggview.java +++ b/src/test/java/com/avaje/tests/model/pview/Paggview.java @@ -30,5 +30,5 @@ public class Paggview { public void setAmount(Integer amount) { this.amount = amount; } - + } diff --git a/src/test/java/com/avaje/tests/model/pview/Pview.java b/src/test/java/com/avaje/tests/model/pview/Pview.java index 126bdaaab..e7a073f9d 100644 --- a/src/test/java/com/avaje/tests/model/pview/Pview.java +++ b/src/test/java/com/avaje/tests/model/pview/Pview.java @@ -1,8 +1,5 @@ package com.avaje.tests.model.pview; -import java.util.List; -import java.util.UUID; - import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -13,6 +10,8 @@ import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; +import java.util.List; +import java.util.UUID; @Entity @Table(name = "pp") @@ -27,7 +26,7 @@ public class Pview { @Column(length = 100, nullable = false) private String value; - @JoinTable(name = "pp_to_ww", joinColumns = { @JoinColumn(name = "pp_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "ww_id", referencedColumnName = "id") }) + @JoinTable(name = "pp_to_ww", joinColumns = {@JoinColumn(name = "pp_id", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "ww_id", referencedColumnName = "id")}) @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) private List wviews; diff --git a/src/test/java/com/avaje/tests/model/pview/TestPview.java b/src/test/java/com/avaje/tests/model/pview/TestPview.java index 28e809efd..380afd96d 100644 --- a/src/test/java/com/avaje/tests/model/pview/TestPview.java +++ b/src/test/java/com/avaje/tests/model/pview/TestPview.java @@ -14,16 +14,16 @@ public class TestPview extends BaseTestCase { public void test() { Wview wview = Ebean.getReference(Wview.class, UUID.randomUUID()); - + Query query = Ebean.find(Paggview.class); query.select("amount"); query.where().eq("pview.wviews", wview); query.orderBy("pview.value"); query.findList(); String generatedSql = sqlOf(query, 1); - + Assert.assertTrue(generatedSql.contains("select distinct t0.amount, t1.value from paggview t0 join pp u1 on u1.id = t0.pview_id join pp_to_ww u2z_ on u2z_.pp_id = u1.id join wview u2 on u2.id = u2z_.ww_id left join pp t1 on t1.id = t0.pview_id where u2.id = ? order by t1.value")); - + } - + } diff --git a/src/test/java/com/avaje/tests/model/pview/Wview.java b/src/test/java/com/avaje/tests/model/pview/Wview.java index a33cac601..74d4956cf 100644 --- a/src/test/java/com/avaje/tests/model/pview/Wview.java +++ b/src/test/java/com/avaje/tests/model/pview/Wview.java @@ -1,12 +1,11 @@ package com.avaje.tests.model.pview; -import java.util.UUID; - import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; +import java.util.UUID; @Entity @Table(name = "wview") @@ -36,4 +35,4 @@ public class Wview { this.name = name; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/selfref/BaseResourceFile.java b/src/test/java/com/avaje/tests/model/selfref/BaseResourceFile.java index 40c30035f..27f31354c 100644 --- a/src/test/java/com/avaje/tests/model/selfref/BaseResourceFile.java +++ b/src/test/java/com/avaje/tests/model/selfref/BaseResourceFile.java @@ -1,14 +1,13 @@ package com.avaje.tests.model.selfref; -import java.util.UUID; - import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.MappedSuperclass; +import java.util.UUID; @MappedSuperclass public abstract class BaseResourceFile { - + private static final long serialVersionUID = 1L; @Id diff --git a/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java b/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java index 5a328da44..20e87c0ab 100644 --- a/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java +++ b/src/test/java/com/avaje/tests/model/selfref/ResourceFile.java @@ -1,7 +1,6 @@ package com.avaje.tests.model.selfref; -import java.util.HashSet; -import java.util.Set; +import com.avaje.ebean.annotation.PrivateOwned; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -11,13 +10,13 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; - -import com.avaje.ebean.annotation.PrivateOwned; +import java.util.HashSet; +import java.util.Set; @Entity @Table(name = "resourcefile") public class ResourceFile extends BaseResourceFile { - + private static final long serialVersionUID = 1L; @ManyToOne(fetch = FetchType.LAZY, optional = true) @@ -54,4 +53,4 @@ public class ResourceFile extends BaseResourceFile { public void setAlternatives(Set alternatives) { this.alternatives = alternatives; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/selfref/SelfParent.java b/src/test/java/com/avaje/tests/model/selfref/SelfParent.java index 3c0c27db4..c3ef61b7d 100644 --- a/src/test/java/com/avaje/tests/model/selfref/SelfParent.java +++ b/src/test/java/com/avaje/tests/model/selfref/SelfParent.java @@ -1,41 +1,40 @@ package com.avaje.tests.model.selfref; -import java.util.List; - import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Version; +import java.util.List; @Entity -@Table(name="self_parent") +@Table(name = "self_parent") public class SelfParent { @Id Long id; - + @Version Long version; - + String name; - + @ManyToOne() SelfParent parent; - - @OneToMany(mappedBy="parent") + + @OneToMany(mappedBy = "parent") List children; public SelfParent(String name, SelfParent parent) { - this.name = name; + this.name = name; this.parent = parent; } - + public SelfParent() { - + } - + public Long getId() { return id; } @@ -74,5 +73,5 @@ public class SelfParent { public void setChildren(List children) { this.children = children; - } + } } diff --git a/src/test/java/com/avaje/tests/model/selfref/SelfRefExample.java b/src/test/java/com/avaje/tests/model/selfref/SelfRefExample.java index 713142f79..0495fa9ce 100644 --- a/src/test/java/com/avaje/tests/model/selfref/SelfRefExample.java +++ b/src/test/java/com/avaje/tests/model/selfref/SelfRefExample.java @@ -1,13 +1,12 @@ package com.avaje.tests.model.selfref; -import java.util.List; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OrderBy; +import java.util.List; @Entity public class SelfRefExample { @@ -38,8 +37,7 @@ public class SelfRefExample { } /** - * @param id - * the id to set + * @param id the id to set */ public void setId(Long id) { this.id = id; @@ -53,8 +51,7 @@ public class SelfRefExample { } /** - * @param name - * the name to set + * @param name the name to set */ public void setName(String name) { this.name = name; @@ -68,8 +65,7 @@ public class SelfRefExample { } /** - * @param parent - * the parent to set + * @param parent the parent to set */ public void setParent(SelfRefExample parent) { this.parent = parent; @@ -83,8 +79,7 @@ public class SelfRefExample { } /** - * @param children - * the children to set + * @param children the children to set */ public void setChildren(List children) { this.children = children; diff --git a/src/test/java/com/avaje/tests/model/selfref/TestResourceFileSelfRef.java b/src/test/java/com/avaje/tests/model/selfref/TestResourceFileSelfRef.java index f49d7e829..995de0ef4 100644 --- a/src/test/java/com/avaje/tests/model/selfref/TestResourceFileSelfRef.java +++ b/src/test/java/com/avaje/tests/model/selfref/TestResourceFileSelfRef.java @@ -1,16 +1,15 @@ package com.avaje.tests.model.selfref; import com.avaje.ebean.BaseTestCase; -import org.junit.Test; - import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; +import org.junit.Test; public class TestResourceFileSelfRef extends BaseTestCase { @Test public void test() { - + EbeanServer server = Ebean.getServer(null); ResourceFile childFile1 = new ResourceFile(); diff --git a/src/test/java/com/avaje/tests/model/selfref/TestSelfRefExample.java b/src/test/java/com/avaje/tests/model/selfref/TestSelfRefExample.java index 1d7a671ec..145bad703 100644 --- a/src/test/java/com/avaje/tests/model/selfref/TestSelfRefExample.java +++ b/src/test/java/com/avaje/tests/model/selfref/TestSelfRefExample.java @@ -1,17 +1,15 @@ package com.avaje.tests.model.selfref; -import java.util.List; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.Assert.assertEquals; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; +import org.junit.Test; import javax.persistence.PersistenceException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; public class TestSelfRefExample extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java b/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java index 9da8647eb..18842464e 100644 --- a/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java +++ b/src/test/java/com/avaje/tests/model/selfref/TestTextJsonSelfRef.java @@ -1,14 +1,12 @@ package com.avaje.tests.model.selfref; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; -import com.avaje.ebean.TxRunnable; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestTextJsonSelfRef extends BaseTestCase { @@ -37,13 +35,13 @@ public class TestTextJsonSelfRef extends BaseTestCase { }); List customers = Ebean.find(SelfRefCustomer.class).orderBy("id desc").findList(); - + // Check that there are no 'reference' beans here - for (SelfRefCustomer cust: customers) { + for (SelfRefCustomer cust : customers) { BeanState beanState = Ebean.getBeanState(cust); Assert.assertFalse(beanState.isReference()); } - + // JsonWriteOptions options = JsonWriteOptions.parsePath("(id,name,referredBy(id))"); // String customerContent = Ebean.createJsonContext().toJson(customers);//, false, options); // System.out.println("Customers: " + customerContent); @@ -54,4 +52,4 @@ public class TestTextJsonSelfRef extends BaseTestCase { // customerContent); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/model/softdelete/ESoftDelBook.java b/src/test/java/com/avaje/tests/model/softdelete/ESoftDelBook.java index a6556c3db..02a372099 100644 --- a/src/test/java/com/avaje/tests/model/softdelete/ESoftDelBook.java +++ b/src/test/java/com/avaje/tests/model/softdelete/ESoftDelBook.java @@ -5,7 +5,6 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; - import java.util.List; @Entity @@ -46,6 +45,7 @@ public class ESoftDelBook extends BaseSoftDelete { public void setLendBy(ESoftDelUser lendBy) { this.lendBy = lendBy; } + public ESoftDelUser getLendBy() { return lendBy; } diff --git a/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java b/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java index 5f4c1cbec..8fa8ff87b 100644 --- a/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java +++ b/src/test/java/com/avaje/tests/model/survey/TestOrderByFetch.java @@ -42,11 +42,11 @@ public class TestOrderByFetch extends BaseTestCase { Ebean.save(survey); Survey foundSurvey = Ebean.find(Survey.class) - .setDisableLazyLoading(true) - .fetch("categories") - .fetch("categories.groups") - .fetch("categories.groups.questions") - .findUnique(); + .setDisableLazyLoading(true) + .fetch("categories") + .fetch("categories.groups") + .fetch("categories.groups.questions") + .findUnique(); assertEquals(1, foundSurvey.getCategories().size()); diff --git a/src/test/java/com/avaje/tests/model/tevent/TestAssocOneNullTraverse.java b/src/test/java/com/avaje/tests/model/tevent/TestAssocOneNullTraverse.java index b03df5547..171b113bc 100644 --- a/src/test/java/com/avaje/tests/model/tevent/TestAssocOneNullTraverse.java +++ b/src/test/java/com/avaje/tests/model/tevent/TestAssocOneNullTraverse.java @@ -13,8 +13,8 @@ public class TestAssocOneNullTraverse extends BaseTestCase { Ebean.save(event); Ebean.find(TEvent.class) - .fetch("one.logs") - .findList(); + .fetch("one.logs") + .findList(); } // @Test diff --git a/src/test/java/com/avaje/tests/model/types/SomeFileBean.java b/src/test/java/com/avaje/tests/model/types/SomeFileBean.java index 39a4aaa3b..2a4d3512c 100644 --- a/src/test/java/com/avaje/tests/model/types/SomeFileBean.java +++ b/src/test/java/com/avaje/tests/model/types/SomeFileBean.java @@ -1,6 +1,9 @@ package com.avaje.tests.model.types; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Version; import java.io.File; @Entity diff --git a/src/test/java/com/avaje/tests/model/types/SomeNewTypesBean.java b/src/test/java/com/avaje/tests/model/types/SomeNewTypesBean.java index cc3015ddd..ad7c49ebd 100644 --- a/src/test/java/com/avaje/tests/model/types/SomeNewTypesBean.java +++ b/src/test/java/com/avaje/tests/model/types/SomeNewTypesBean.java @@ -5,7 +5,17 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Version; import java.nio.file.Path; -import java.time.*; +import java.time.DayOfWeek; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.Year; +import java.time.YearMonth; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; @Entity public class SomeNewTypesBean { diff --git a/src/test/java/com/avaje/tests/model/types/SomePeriodBean.java b/src/test/java/com/avaje/tests/model/types/SomePeriodBean.java index 398e41017..d37d8ff65 100644 --- a/src/test/java/com/avaje/tests/model/types/SomePeriodBean.java +++ b/src/test/java/com/avaje/tests/model/types/SomePeriodBean.java @@ -3,7 +3,8 @@ package com.avaje.tests.model.types; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Version; -import java.time.*; +import java.time.MonthDay; +import java.time.Period; @Entity public class SomePeriodBean { diff --git a/src/test/java/com/avaje/tests/model/view/EOrderAgg.java b/src/test/java/com/avaje/tests/model/view/EOrderAgg.java index ee36547d4..c4fd3cf03 100644 --- a/src/test/java/com/avaje/tests/model/view/EOrderAgg.java +++ b/src/test/java/com/avaje/tests/model/view/EOrderAgg.java @@ -15,7 +15,8 @@ import javax.persistence.OneToOne; @View(name = "order_agg_vw", dependentTables = {"o_order", "o_order_detail"}) public class EOrderAgg { - @Id @Column(name = "order_id") + @Id + @Column(name = "order_id") Long id; @OneToOne diff --git a/src/test/java/com/avaje/tests/model/view/TestViewBaseEntity.java b/src/test/java/com/avaje/tests/model/view/TestViewBaseEntity.java index 32ba8db6f..9f1809a93 100644 --- a/src/test/java/com/avaje/tests/model/view/TestViewBaseEntity.java +++ b/src/test/java/com/avaje/tests/model/view/TestViewBaseEntity.java @@ -20,8 +20,8 @@ public class TestViewBaseEntity extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(EOrderAgg.class) - .where().gt("orderTotal", 20) - .query(); + .where().gt("orderTotal", 20) + .query(); List list = query.findList(); @@ -35,9 +35,9 @@ public class TestViewBaseEntity extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(EOrderAgg.class) - //.fetch("order", "id") - .where().gt("orderTotal", 20) - .query(); + //.fetch("order", "id") + .where().gt("orderTotal", 20) + .query(); List list = query.findList(); for (EOrderAgg agg : list) { @@ -53,10 +53,10 @@ public class TestViewBaseEntity extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(EOrderAgg.class) - .fetch("order") - .fetch("order.details") - .where().gt("orderTotal", 20) - .query(); + .fetch("order") + .fetch("order.details") + .where().gt("orderTotal", 20) + .query(); List list = query.findList(); for (EOrderAgg agg : list) { diff --git a/src/test/java/com/avaje/tests/model/zero/WithZeroParent.java b/src/test/java/com/avaje/tests/model/zero/WithZeroParent.java index 010c935c4..f8f78687a 100644 --- a/src/test/java/com/avaje/tests/model/zero/WithZeroParent.java +++ b/src/test/java/com/avaje/tests/model/zero/WithZeroParent.java @@ -1,6 +1,11 @@ package com.avaje.tests.model.zero; -import javax.persistence.*; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; import java.util.List; @Entity @@ -18,6 +23,7 @@ public class WithZeroParent { public void setId(int id) { this.id = id; } + public int getId() { return id; } @@ -38,4 +44,4 @@ public class WithZeroParent { this.children = children; } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextOnUpdateDuringTxn.java b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextOnUpdateDuringTxn.java index b85678f0c..c3305ddbb 100644 --- a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextOnUpdateDuringTxn.java +++ b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextOnUpdateDuringTxn.java @@ -12,32 +12,32 @@ public class TestPersistenceContextOnUpdateDuringTxn extends BaseTestCase { @Test public void test() { - + EbeanServer server = Ebean.getServer(null); - + server.beginTransaction(); try { - + EBasic bean1 = new EBasic(); bean1.setName("hello"); - + server.save(bean1); - + EBasic updatedEntity = new EBasic(); updatedEntity.setId(bean1.getId()); updatedEntity.setName("hello-changed"); - + server.update(updatedEntity); - + // actually the bean is not in the persistence context so ... the assert is fine - EBasic loadedEntity = server.find(EBasic.class,bean1.getId()); + EBasic loadedEntity = server.find(EBasic.class, bean1.getId()); assertThat(loadedEntity.getName()).isEqualTo("hello-changed"); } finally { server.endTransaction(); } - + } - + } diff --git a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextQueryScope.java b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextQueryScope.java index 1a2cd85ce..5c37cf90a 100644 --- a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextQueryScope.java +++ b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextQueryScope.java @@ -6,7 +6,8 @@ import com.avaje.ebean.SqlUpdate; import com.avaje.tests.model.basic.EBasicVer; import org.junit.Test; -import static com.avaje.ebean.PersistenceContextScope.*; +import static com.avaje.ebean.PersistenceContextScope.QUERY; +import static com.avaje.ebean.PersistenceContextScope.TRANSACTION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; @@ -35,24 +36,24 @@ public class TestPersistenceContextQueryScope extends BaseTestCase { // fetch the bean again... but doesn't hit DB as it // is in the PersistenceContext which is transaction scoped EBasicVer bean2 = Ebean.find(EBasicVer.class) - .setId(bean.getId()) - .setUseCache(false) // ignore L2 cache - .findUnique(); + .setId(bean.getId()) + .setUseCache(false) // ignore L2 cache + .findUnique(); // QUERY scope hits the DB (doesn't use the existing transactions persistence context) // ... also explicitly not use bean cache EBasicVer bean3 = Ebean.find(EBasicVer.class) - .setId(bean.getId()) - .setUseCache(false) // ignore L2 cache - .setPersistenceContextScope(QUERY) - .findUnique(); + .setId(bean.getId()) + .setUseCache(false) // ignore L2 cache + .setPersistenceContextScope(QUERY) + .findUnique(); // TRANsACTION scope ... same as bean2 and does not hit the DB EBasicVer bean5 = Ebean.find(EBasicVer.class) - .setId(bean.getId()) - .setUseCache(false) // ignore L2 cache - .setPersistenceContextScope(TRANSACTION) - .findUnique(); + .setId(bean.getId()) + .setUseCache(false) // ignore L2 cache + .setPersistenceContextScope(TRANSACTION) + .findUnique(); assertEquals("first", bean.getName()); assertEquals("first", bean1.getName()); diff --git a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java index 09d15e5fd..40c7e361a 100644 --- a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java +++ b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextScopeUsingOrders.java @@ -24,12 +24,12 @@ public class TestPersistenceContextScopeUsingOrders extends BaseTestCase { ResetBasicData.reset(); List orders = Ebean.find(Order.class) - // Use QUERY or TRANSACTION scope (just not NONE) - .setPersistenceContextScope(QUERY) - .fetch("customer", "id, name") - .where().istartsWith("customer.name", "rob").eq("customer.id", 1) - .orderBy().asc("customer.name") - .findList(); + // Use QUERY or TRANSACTION scope (just not NONE) + .setPersistenceContextScope(QUERY) + .fetch("customer", "id, name") + .where().istartsWith("customer.name", "rob").eq("customer.id", 1) + .orderBy().asc("customer.name") + .findList(); assertTrue(!orders.isEmpty()); diff --git a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextServerConfig.java b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextServerConfig.java index f3dac5fd1..d7768576b 100644 --- a/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextServerConfig.java +++ b/src/test/java/com/avaje/tests/persistencecontext/TestPersistenceContextServerConfig.java @@ -21,7 +21,7 @@ public class TestPersistenceContextServerConfig extends BaseTestCase { @Test public void test_config() { - SpiEbeanServer ebeanServer = (SpiEbeanServer)create(); + SpiEbeanServer ebeanServer = (SpiEbeanServer) create(); Query query = ebeanServer.find(EBasicVer.class); @@ -38,10 +38,10 @@ public class TestPersistenceContextServerConfig extends BaseTestCase { config.setName("withPCQuery"); Properties properties = new Properties(); - properties.setProperty("datasource.withPCQuery.username","sa"); - properties.setProperty("datasource.withPCQuery.password",""); - properties.setProperty("datasource.withPCQuery.databaseUrl","jdbc:h2:mem:withPCQuery;"); - properties.setProperty("datasource.withPCQuery.databaseDriver","org.h2.Driver"); + properties.setProperty("datasource.withPCQuery.username", "sa"); + properties.setProperty("datasource.withPCQuery.password", ""); + properties.setProperty("datasource.withPCQuery.databaseUrl", "jdbc:h2:mem:withPCQuery;"); + properties.setProperty("datasource.withPCQuery.databaseDriver", "org.h2.Driver"); config.loadFromProperties(properties); config.setPersistenceContextScope(PersistenceContextScope.QUERY); diff --git a/src/test/java/com/avaje/tests/query/TestAddOrderByWithFirstRowsMaxRows.java b/src/test/java/com/avaje/tests/query/TestAddOrderByWithFirstRowsMaxRows.java index 0f94b37a4..7a28eeab5 100644 --- a/src/test/java/com/avaje/tests/query/TestAddOrderByWithFirstRowsMaxRows.java +++ b/src/test/java/com/avaje/tests/query/TestAddOrderByWithFirstRowsMaxRows.java @@ -25,9 +25,9 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .setFirstRow(3) - .orderBy().asc("id") - .findList(); + .setFirstRow(3) + .orderBy().asc("id") + .findList(); List loggedSql = LoggedSqlCollector.stop(); @@ -44,8 +44,8 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .setMaxRows(10) - .findList(); + .setMaxRows(10) + .findList(); List loggedSql = LoggedSqlCollector.stop(); @@ -62,10 +62,10 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .setFirstRow(3) - .setMaxRows(10) - .orderBy().asc("id") - .findList(); + .setFirstRow(3) + .setMaxRows(10) + .orderBy().asc("id") + .findList(); List loggedSql = LoggedSqlCollector.stop(); @@ -83,8 +83,8 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { // maxRows 1 with no first rows means Ebean does not automatically // add the order by id to the query Ebean.find(Order.class) - .setMaxRows(1) - .findList(); + .setMaxRows(1) + .findList(); List loggedSql = LoggedSqlCollector.stop(); @@ -100,9 +100,9 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); PagedList pagedList = - Ebean.find(Order.class) - .setMaxRows(10) - .findPagedList(); + Ebean.find(Order.class) + .setMaxRows(10) + .findPagedList(); pagedList.getList(); @@ -120,10 +120,10 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .setFirstRow(10) - .setMaxRows(10) - .findPagedList() - .getList(); + .setFirstRow(10) + .setMaxRows(10) + .findPagedList() + .getList(); List loggedSql = LoggedSqlCollector.stop(); @@ -140,10 +140,10 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .order().asc("orderDate") - .setMaxRows(10) - .findPagedList() - .getList(); + .order().asc("orderDate") + .setMaxRows(10) + .findPagedList() + .getList(); List loggedSql = LoggedSqlCollector.stop(); @@ -159,11 +159,11 @@ public class TestAddOrderByWithFirstRowsMaxRows extends BaseTestCase { LoggedSqlCollector.start(); Ebean.find(Order.class) - .order().asc("orderDate") - .order().desc("id") - .setMaxRows(10) - .findPagedList() - .getList(); + .order().asc("orderDate") + .order().desc("id") + .setMaxRows(10) + .findPagedList() + .getList(); List loggedSql = LoggedSqlCollector.stop(); diff --git a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java index fa86f7b4d..bfa0e0468 100644 --- a/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java +++ b/src/test/java/com/avaje/tests/query/TestAutofetchTuneWithJoin.java @@ -27,10 +27,10 @@ public class TestAutofetchTuneWithJoin extends BaseTestCase { ResetBasicData.reset(); Query q = Ebean.find(Order.class) - .setAutoTune(true) - //.fetch("customer") - //.fetch("customer.contacts") - .where().lt("id", 3).query(); + .setAutoTune(true) + //.fetch("customer") + //.fetch("customer.contacts") + .where().lt("id", 3).query(); List list = q.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestConnectionCloseOnSqlerr.java b/src/test/java/com/avaje/tests/query/TestConnectionCloseOnSqlerr.java index 24caa19f2..1182b6976 100644 --- a/src/test/java/com/avaje/tests/query/TestConnectionCloseOnSqlerr.java +++ b/src/test/java/com/avaje/tests/query/TestConnectionCloseOnSqlerr.java @@ -1,12 +1,11 @@ package com.avaje.tests.query; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; public class TestConnectionCloseOnSqlerr extends BaseTestCase { @@ -23,7 +22,7 @@ public class TestConnectionCloseOnSqlerr extends BaseTestCase { for (int i = 0; i < 100; i++) { try { Query q0 = Ebean.find(Customer.class).where().icontains("namexxx", "Rob") - .query(); + .query(); q0.findList(); } catch (Exception e) { @@ -53,7 +52,7 @@ public class TestConnectionCloseOnSqlerr extends BaseTestCase { try { Ebean.beginTransaction(); Query q0 = Ebean.find(Customer.class).where().icontains("namexxx", "Rob") - .query(); + .query(); q0.findList(); Ebean.commitTransaction(); diff --git a/src/test/java/com/avaje/tests/query/TestDefaultFetchLazy.java b/src/test/java/com/avaje/tests/query/TestDefaultFetchLazy.java index 61bf4c6ba..2bf7da6c3 100644 --- a/src/test/java/com/avaje/tests/query/TestDefaultFetchLazy.java +++ b/src/test/java/com/avaje/tests/query/TestDefaultFetchLazy.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.MyLobSize; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Set; public class TestDefaultFetchLazy extends BaseTestCase { @@ -40,7 +39,7 @@ public class TestDefaultFetchLazy extends BaseTestCase { // the details is also tuned Query queryMany = Ebean.find(MyLobSize.class).fetch("details")// ,"+query") - .where().gt("id", 0).query(); + .where().gt("id", 0).query(); queryMany.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestExprNestedDisjunction.java b/src/test/java/com/avaje/tests/query/TestExprNestedDisjunction.java index 402879b28..74adeff5a 100644 --- a/src/test/java/com/avaje/tests/query/TestExprNestedDisjunction.java +++ b/src/test/java/com/avaje/tests/query/TestExprNestedDisjunction.java @@ -19,10 +19,10 @@ public class TestExprNestedDisjunction extends BaseTestCase { java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31"); Query q = Ebean.find(Customer.class).where() - .disjunction() - .conjunction().startsWith("name", "r").eq("anniversary", onAfter).endJunction() - .conjunction().eq("status", Customer.Status.ACTIVE).gt("id", 0).endJunction() - .orderBy().asc("name"); + .disjunction() + .conjunction().startsWith("name", "r").eq("anniversary", onAfter).endJunction() + .conjunction().eq("status", Customer.Status.ACTIVE).gt("id", 0).endJunction() + .orderBy().asc("name"); q.findList(); String s = q.getGeneratedSql(); @@ -40,13 +40,13 @@ public class TestExprNestedDisjunction extends BaseTestCase { java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31"); Query q = Ebean.find(Customer.class) - .where() - .or() - .and() - .startsWith("name", "r").eq("anniversary", onAfter).endAnd() - .and() - .eq("status", Customer.Status.ACTIVE).gt("id", 0).endAnd() - .orderBy().asc("name"); + .where() + .or() + .and() + .startsWith("name", "r").eq("anniversary", onAfter).endAnd() + .and() + .eq("status", Customer.Status.ACTIVE).gt("id", 0).endAnd() + .orderBy().asc("name"); q.findList(); String s = q.getGeneratedSql(); @@ -63,12 +63,12 @@ public class TestExprNestedDisjunction extends BaseTestCase { java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31"); Query q = Ebean.find(Customer.class) - .where() - .not() - .gt("id", 1) - .eq("anniversary", onAfter) - .endNot() - .orderBy().asc("name"); + .where() + .not() + .gt("id", 1) + .eq("anniversary", onAfter) + .endNot() + .orderBy().asc("name"); q.findList(); String s = q.getGeneratedSql(); @@ -84,13 +84,13 @@ public class TestExprNestedDisjunction extends BaseTestCase { java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31"); Query q = Ebean.find(Customer.class) - .where() - .or() - .eq("status", Customer.Status.ACTIVE) - .not() - .gt("id", 1) - .eq("anniversary", onAfter) - .orderBy().asc("name"); + .where() + .or() + .eq("status", Customer.Status.ACTIVE) + .not() + .gt("id", 1) + .eq("anniversary", onAfter) + .orderBy().asc("name"); q.findList(); String s = q.getGeneratedSql(); @@ -106,15 +106,15 @@ public class TestExprNestedDisjunction extends BaseTestCase { java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31"); Query q = Ebean.find(Customer.class) - .where() - .or() - .eq("status", Customer.Status.ACTIVE) - .not() - .gt("id", 1) - .eq("anniversary", onAfter) - .endNot() - .endOr() - .orderBy().asc("name"); + .where() + .or() + .eq("status", Customer.Status.ACTIVE) + .not() + .gt("id", 1) + .eq("anniversary", onAfter) + .endNot() + .endOr() + .orderBy().asc("name"); q.findList(); String s = q.getGeneratedSql(); diff --git a/src/test/java/com/avaje/tests/query/TestImplicitJoinOnParentRelationship.java b/src/test/java/com/avaje/tests/query/TestImplicitJoinOnParentRelationship.java index 2168aa808..eaf2dc026 100644 --- a/src/test/java/com/avaje/tests/query/TestImplicitJoinOnParentRelationship.java +++ b/src/test/java/com/avaje/tests/query/TestImplicitJoinOnParentRelationship.java @@ -1,13 +1,12 @@ package com.avaje.tests.query; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestImplicitJoinOnParentRelationship extends BaseTestCase { @@ -17,37 +16,37 @@ public class TestImplicitJoinOnParentRelationship extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id, name") - .where().eq("orders.details.product.name", "Desk") - .query(); - + .select("id, name") + .where().eq("orders.details.product.name", "Desk") + .query(); + query.findList(); String expectedSql = "select distinct t0.id, t0.name from o_customer t0 join o_order u1 on u1.kcustomer_id = t0.id join o_order_detail u2 on u2.order_id = u1.id join o_product u3 on u3.id = u2.product_id where u3.name = ? "; Assert.assertEquals(expectedSql, sqlOf(query, 1)); - - // select distinct t0.id c0, t0.name c1 - // from o_customer t0 - // join o_order u1 on u1.kcustomer_id = t0.id - // join o_order_detail u2 on u2.order_id = u1.id - // join o_product u3 on u3.id = u2.product_id - // where u3.name = ? - + + // select distinct t0.id c0, t0.name c1 + // from o_customer t0 + // join o_order u1 on u1.kcustomer_id = t0.id + // join o_order_detail u2 on u2.order_id = u1.id + // join o_product u3 on u3.id = u2.product_id + // where u3.name = ? + } - - + + @Test public void testWithDisjunction() { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id, name") - .where().disjunction().eq("orders.details.product.name", "Desk").eq("id", 4).endJunction() - .query(); - + .select("id, name") + .where().disjunction().eq("orders.details.product.name", "Desk").eq("id", 4).endJunction() + .query(); + query.findList(); - + String expectedSql = "select distinct t0.id, t0.name from o_customer t0 left join o_order u1 on u1.kcustomer_id = t0.id left join o_order_detail u2 on u2.order_id = u1.id left join o_product u3 on u3.id = u2.product_id where (u3.name = ? or t0.id = ? ) "; Assert.assertEquals(expectedSql, sqlOf(query, 1)); } @@ -58,9 +57,9 @@ public class TestImplicitJoinOnParentRelationship extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .select("id, name") - .where().or().eq("orders.details.product.name", "Desk").eq("id", 4).endJunction() - .query(); + .select("id, name") + .where().or().eq("orders.details.product.name", "Desk").eq("id", 4).endJunction() + .query(); query.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestInvalidFetchPath.java b/src/test/java/com/avaje/tests/query/TestInvalidFetchPath.java index 2299eeae0..eeef34fa1 100644 --- a/src/test/java/com/avaje/tests/query/TestInvalidFetchPath.java +++ b/src/test/java/com/avaje/tests/query/TestInvalidFetchPath.java @@ -13,23 +13,23 @@ public class TestInvalidFetchPath extends BaseTestCase { public void invalidFetchPathAndProperties_expect_error() { Ebean.find(Customer.class) - .fetch("notValidPath", "notHaveProps") - .findList(); + .fetch("notValidPath", "notHaveProps") + .findList(); } @Test(expected = PersistenceException.class) public void invalidFetchPath_expect_error() { Ebean.find(Customer.class) - .fetch("notValidPath") - .findList(); + .fetch("notValidPath") + .findList(); } @Test public void fetchWithInvalidPropertyName_expect_allowed() { Ebean.find(Customer.class) - .fetch("billingAddress", "invalidPropertyName") - .findList(); + .fetch("billingAddress", "invalidPropertyName") + .findList(); } } diff --git a/src/test/java/com/avaje/tests/query/TestJoinOptOneCascade.java b/src/test/java/com/avaje/tests/query/TestJoinOptOneCascade.java index f7711bd80..f45ac9500 100644 --- a/src/test/java/com/avaje/tests/query/TestJoinOptOneCascade.java +++ b/src/test/java/com/avaje/tests/query/TestJoinOptOneCascade.java @@ -1,12 +1,11 @@ package com.avaje.tests.query; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.EOptOneA; +import org.junit.Assert; +import org.junit.Test; public class TestJoinOptOneCascade extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestLimitAlterFetchMany.java b/src/test/java/com/avaje/tests/query/TestLimitAlterFetchMany.java index e426c1142..c90925420 100644 --- a/src/test/java/com/avaje/tests/query/TestLimitAlterFetchMany.java +++ b/src/test/java/com/avaje/tests/query/TestLimitAlterFetchMany.java @@ -1,14 +1,13 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestLimitAlterFetchMany extends BaseTestCase { @@ -23,9 +22,9 @@ public class TestLimitAlterFetchMany extends BaseTestCase { // limit offset clause Query query = Ebean.find(Customer.class) - // this will automatically get converted to a - // query join ... due to the maxRows - .fetch("contacts").setMaxRows(5); + // this will automatically get converted to a + // query join ... due to the maxRows + .fetch("contacts").setMaxRows(5); List list = query.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestLimitQuery.java b/src/test/java/com/avaje/tests/query/TestLimitQuery.java index 1f7550671..8bb4998d0 100644 --- a/src/test/java/com/avaje/tests/query/TestLimitQuery.java +++ b/src/test/java/com/avaje/tests/query/TestLimitQuery.java @@ -17,14 +17,14 @@ public class TestLimitQuery extends BaseTestCase { ResetBasicData.reset(); List customers = Ebean.find(Customer.class) - .setAutoTune(false) - .setFirstRow(0) - .setMaxRows(10) - .where().like("name", "%A%") - .findList(); + .setAutoTune(false) + .setFirstRow(0) + .setMaxRows(10) + .where().like("name", "%A%") + .findList(); // should at least find the "Cust NoAddress" customer Assert.assertTrue(!customers.isEmpty()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/avaje/tests/query/TestManyWhereJoin.java b/src/test/java/com/avaje/tests/query/TestManyWhereJoin.java index 310fa03f1..edbca4f22 100644 --- a/src/test/java/com/avaje/tests/query/TestManyWhereJoin.java +++ b/src/test/java/com/avaje/tests/query/TestManyWhereJoin.java @@ -1,8 +1,5 @@ package com.avaje.tests.query; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -10,6 +7,8 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Product; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestManyWhereJoin extends BaseTestCase { @@ -19,19 +18,19 @@ public class TestManyWhereJoin extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class).select("id,status") - // the where on a 'many' (like orders) requires an - // additional join and distinct which is independent - // of a fetch join (if there is a fetch join) - .where().eq("orders.status", Order.Status.NEW) - // .where().eq("orders.details.product.name", "Desk") - .query(); + // the where on a 'many' (like orders) requires an + // additional join and distinct which is independent + // of a fetch join (if there is a fetch join) + .where().eq("orders.status", Order.Status.NEW) + // .where().eq("orders.details.product.name", "Desk") + .query(); query.findList(); String sql = sqlOf(query, 1); - - // select distinct t0.id c0, t0.status c1 - // from o_customer t0 - // join o_order u1 on u1.kcustomer_id = t0.id + + // select distinct t0.id c0, t0.status c1 + // from o_customer t0 + // join o_order u1 on u1.kcustomer_id = t0.id // where u1.status = ? ; --bind(NEW) Assert.assertTrue(sql.contains("select distinct ")); @@ -39,30 +38,30 @@ public class TestManyWhereJoin extends BaseTestCase { Assert.assertTrue(sql.contains(".status = ?")); Assert.assertTrue(sql.contains("select distinct t0.id, t0.status from o_customer t0 join o_order u1 on u1.kcustomer_id = t0.id where u1.status = ?")); } - + @Test public void testWithFetchJoinAndWhere() { ResetBasicData.reset(); Query query = Ebean.find(Customer.class).select("id,status") - .fetch("orders") - // the where on a 'many' (like orders) requires an - // additional join and distinct which is independent - // of a fetch join (if there is a fetch join) - .where().eq("orders.status", Order.Status.NEW) - // .where().eq("orders.details.product.name", "Desk") - .query(); + .fetch("orders") + // the where on a 'many' (like orders) requires an + // additional join and distinct which is independent + // of a fetch join (if there is a fetch join) + .where().eq("orders.status", Order.Status.NEW) + // .where().eq("orders.details.product.name", "Desk") + .query(); query.findList(); String sql = sqlOf(query, 3); - - // select distinct t0.id c0, t0.status c1, - // t1.id c2, t1.status c3, t1.order_date c4, t1.ship_date c5, t2.name c6, t1.cretime c7, t1.updtime c8, t1.kcustomer_id c9, t0.id - // from o_customer t0 + + // select distinct t0.id c0, t0.status c1, + // t1.id c2, t1.status c3, t1.order_date c4, t1.ship_date c5, t2.name c6, t1.cretime c7, t1.updtime c8, t1.kcustomer_id c9, t0.id + // from o_customer t0 // left join o_order t1 on t1.kcustomer_id = t0.id // left join o_customer t2 on t2.id = t1.kcustomer_id - // join o_order u1 on u1.kcustomer_id = t0.id + // join o_order u1 on u1.kcustomer_id = t0.id // where t1.order_date is not null and u1.status = ? // order by t0.id; --bind(NEW) @@ -71,94 +70,94 @@ public class TestManyWhereJoin extends BaseTestCase { Assert.assertTrue(sql.contains("join o_order u1 on ")); Assert.assertTrue(sql.contains(" u1.status = ?")); } - + @Test public void testUsingForeignKey() { - + ResetBasicData.reset(); - + Long productId = 1L; - + Query query = Ebean.find(Order.class) .where().eq("details.product.id", productId) .orderBy("cretime asc"); - + query.findList(); String sql = sqlOf(query, 3); - - // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, t0.cretime - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id - // join o_order_detail u1 on u1.order_id = t0.id - // where u1.product_id = ? + + // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, t0.cretime + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id + // join o_order_detail u1 on u1.order_id = t0.id + // where u1.product_id = ? // order by t0.cretime; --bind(1) - + Assert.assertTrue(sql.contains("select distinct t0.id, t0.status,")); Assert.assertTrue(sql.contains(" join o_order_detail u1 on u1.order_id = t0.id")); Assert.assertTrue(sql.contains(" where u1.product_id = ?")); } - + /** * Same as previous test but use a reference bean. */ @Test public void testUsingForeignKeyReferenceBean() { - + ResetBasicData.reset(); - + Product product = Ebean.getReference(Product.class, 1L); - + Query query = Ebean.find(Order.class) //.fetch("details") .where().eq("details.product", product) .orderBy("cretime asc"); - + query.findList(); String sql = sqlOf(query, 3); - - // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, t0.cretime - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id - // join o_order_detail u1 on u1.order_id = t0.id - // where u1.product_id = ? + + // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, t0.cretime + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id + // join o_order_detail u1 on u1.order_id = t0.id + // where u1.product_id = ? // order by t0.cretime - + Assert.assertTrue(sql.contains("select distinct t0.id, t0.status,")); Assert.assertTrue(sql.contains(" join o_order_detail u1 on u1.order_id = t0.id")); Assert.assertTrue(sql.contains(" where u1.product_id = ?")); } - + /** * Additionally add a fetch join. */ @Test public void testUsingForeignKeyAndFetch() { - + ResetBasicData.reset(); - + Product product = Ebean.getReference(Product.class, 1L); - + Query query = Ebean.find(Order.class) .fetch("details") .where().eq("details.product", product) .orderBy("cretime asc"); - + query.findList(); String sql = sqlOf(query, 3); - - // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t2.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, - // t1.id c8, t1.order_qty c9, t1.ship_qty c10, t1.unit_price c11, t1.cretime c12, t1.updtime c13, t1.order_id c14, t1.product_id c15, t0.cretime, t0.id, t1.id, t1.order_qty, t1.cretime - // from o_order t0 - // join o_customer t2 on t2.id = t0.kcustomer_id + + // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t2.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, + // t1.id c8, t1.order_qty c9, t1.ship_qty c10, t1.unit_price c11, t1.cretime c12, t1.updtime c13, t1.order_id c14, t1.product_id c15, t0.cretime, t0.id, t1.id, t1.order_qty, t1.cretime + // from o_order t0 + // join o_customer t2 on t2.id = t0.kcustomer_id // left join o_order_detail t1 on t1.order_id = t0.id - // join o_order_detail u1 on u1.order_id = t0.id - // where t1.id > 0 and u1.product_id = ? + // join o_order_detail u1 on u1.order_id = t0.id + // where t1.id > 0 and u1.product_id = ? // order by t0.cretime, t0.id, t1.id asc, t1.order_qty asc, t1.cretime desc; --bind(1) Assert.assertTrue(sql.contains("select distinct t0.id, t0.status,")); Assert.assertTrue(sql.contains(" join o_order_detail u1 on u1.order_id = t0.id")); Assert.assertTrue(sql.contains(" u1.product_id = ?")); - + // additional join for fetching the many details Assert.assertTrue(sql.contains(" left join o_order_detail t1 on t1.order_id = t0.id")); } diff --git a/src/test/java/com/avaje/tests/query/TestManyWhereJoinM2M.java b/src/test/java/com/avaje/tests/query/TestManyWhereJoinM2M.java index 7ba3316df..af8c90171 100644 --- a/src/test/java/com/avaje/tests/query/TestManyWhereJoinM2M.java +++ b/src/test/java/com/avaje/tests/query/TestManyWhereJoinM2M.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.MRole; import com.avaje.tests.model.basic.MUser; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -52,10 +51,10 @@ public class TestManyWhereJoinM2M extends BaseTestCase { Ebean.commitTransaction(); Query query = Ebean.find(MUser.class).fetch("roles") - // the where on a 'many' (like orders) requires an - // additional join and distinct which is independent - // of a fetch join (if there is a fetch join) - .where().eq("roles.roleName", "role2special").query(); + // the where on a 'many' (like orders) requires an + // additional join and distinct which is independent + // of a fetch join (if there is a fetch join) + .where().eq("roles.roleName", "role2special").query(); query.findList(); @@ -72,8 +71,8 @@ public class TestManyWhereJoinM2M extends BaseTestCase { private void isEmpty() { Query query = Ebean.find(MUser.class) - .where().isEmpty("roles") - .query(); + .where().isEmpty("roles") + .query(); List usersWithNoRoles = query.findList(); @@ -84,9 +83,9 @@ public class TestManyWhereJoinM2M extends BaseTestCase { private void isNotEmpty() { Query query = Ebean.find(MUser.class) - .select("userName") - .where().isNotEmpty("roles") - .query(); + .select("userName") + .where().isNotEmpty("roles") + .query(); List usersWithRoles = query.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestMyAdHocSqlSelect.java b/src/test/java/com/avaje/tests/query/TestMyAdHocSqlSelect.java index 2428626e7..981439d96 100644 --- a/src/test/java/com/avaje/tests/query/TestMyAdHocSqlSelect.java +++ b/src/test/java/com/avaje/tests/query/TestMyAdHocSqlSelect.java @@ -22,15 +22,15 @@ public class TestMyAdHocSqlSelect extends BaseTestCase { String sql = "select order_id, count(*) as detailCount from o_order_detail group by order_id"; RawSql rawSql = RawSqlBuilder - .parse(sql) - .columnMapping("order_id", "order.id") - .create(); + .parse(sql) + .columnMapping("order_id", "order.id") + .create(); Query query = Ebean.find(MyAdHoc.class) - .setRawSql(rawSql) - .where().gt("order_id", 0) - .having().gt("detailCount", 0) - .query(); + .setRawSql(rawSql) + .where().gt("order_id", 0) + .having().gt("detailCount", 0) + .query(); assertNotNull(query.findList()); assertThat(query.getGeneratedSql()).contains(" group by order_id having count(*) > ?"); @@ -44,16 +44,16 @@ public class TestMyAdHocSqlSelect extends BaseTestCase { String sql = "select order_id, count(*) as detail_count from o_order_detail group by order_id"; RawSql rawSql = RawSqlBuilder - .parse(sql) - .columnMapping("order_id", "order.id") - .columnMapping("detail_count", "detailCount") - .create(); + .parse(sql) + .columnMapping("order_id", "order.id") + .columnMapping("detail_count", "detailCount") + .create(); Query query = Ebean.find(MyAdHoc.class) - .setRawSql(rawSql) - .where().gt("order_id", 0) - .having().gt("detailCount", 0) - .query(); + .setRawSql(rawSql) + .where().gt("order_id", 0) + .having().gt("detailCount", 0) + .query(); assertNotNull(query.findList()); assertThat(query.getGeneratedSql()).contains(" group by order_id having count(*) > ?"); diff --git a/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java b/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java index 59858862e..8331d5b15 100644 --- a/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java +++ b/src/test/java/com/avaje/tests/query/TestOneToManyCorrectGrouping.java @@ -3,7 +3,6 @@ package com.avaje.tests.query; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; -import com.avaje.ebean.QueryEachConsumer; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; @@ -22,9 +21,9 @@ public class TestOneToManyCorrectGrouping extends BaseTestCase { ResetBasicData.reset(); Query customerQuery = Ebean.find(Customer.class) - .fetch("orders") - .where().le("id", 2) - .query(); + .fetch("orders") + .where().le("id", 2) + .query(); final AtomicInteger count = new AtomicInteger(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryAlias.java b/src/test/java/com/avaje/tests/query/TestQueryAlias.java index 69225e3ea..8635537b8 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryAlias.java +++ b/src/test/java/com/avaje/tests/query/TestQueryAlias.java @@ -1,13 +1,12 @@ package com.avaje.tests.query; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.CKeyParent; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestQueryAlias extends BaseTestCase { @@ -17,8 +16,8 @@ public class TestQueryAlias extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(CKeyParent.class) - .select("id.oneKey").alias("st0") - .setAutoTune(false).where().query(); + .select("id.oneKey").alias("st0") + .setAutoTune(false).where().query(); Query pq = Ebean.find(CKeyParent.class).alias("myt0").where().in("id.oneKey", sq).query(); @@ -43,8 +42,8 @@ public class TestQueryAlias extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(CKeyParent.class) - .select("id.oneKey").alias("st0") - .setAutoTune(false).where().query(); + .select("id.oneKey").alias("st0") + .setAutoTune(false).where().query(); Query pq = Ebean.find(CKeyParent.class).alias("myt0").where().notIn("id.oneKey", sq).query(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryExists.java b/src/test/java/com/avaje/tests/query/TestQueryExists.java index 9633f840c..09e46b7fa 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryExists.java +++ b/src/test/java/com/avaje/tests/query/TestQueryExists.java @@ -21,14 +21,14 @@ public class TestQueryExists extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .where().raw("exists (select 1 from o_order_detail where order_id = t0.id)") - .query(); + .where().raw("exists (select 1 from o_order_detail where order_id = t0.id)") + .query(); List ordersThatHave = query.findList(); Query query2 = Ebean.find(Order.class) - .where().raw("not exists (select 1 from o_order_detail where order_id = t0.id)") - .query(); + .where().raw("not exists (select 1 from o_order_detail where order_id = t0.id)") + .query(); List ordersThatDontHave = query2.findList(); @@ -45,14 +45,14 @@ public class TestQueryExists extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .where().raw("exists (select 1 from contact where customer_id = t0.id)") - .query(); + .where().raw("exists (select 1 from contact where customer_id = t0.id)") + .query(); List customersWithContacts = query.findList(); Query query2 = Ebean.find(Customer.class) - .where().raw("not exists (select 1 FROM contact where customer_id = t0.id)") - .query(); + .where().raw("not exists (select 1 FROM contact where customer_id = t0.id)") + .query(); query2.findList(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFetchJoinWithOrder.java b/src/test/java/com/avaje/tests/query/TestQueryFetchJoinWithOrder.java index 34fba6cc3..12d091703 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFetchJoinWithOrder.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFetchJoinWithOrder.java @@ -1,16 +1,15 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryFetchJoinWithOrder extends BaseTestCase { @@ -20,26 +19,26 @@ public class TestQueryFetchJoinWithOrder extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - .fetch("details", new FetchConfig().query()) - .order().asc("id") - .order().desc("details.id").findList(); + .fetch("details", new FetchConfig().query()) + .order().asc("id") + .order().desc("details.id").findList(); Assert.assertNotNull(list); List list2 = Ebean.find(Order.class) - .fetch("customer", new FetchConfig().query(5)) - .fetch("customer.contacts") - .order().asc("id") - .order().asc("customer.contacts.lastName") - .findList(); + .fetch("customer", new FetchConfig().query(5)) + .fetch("customer.contacts") + .order().asc("id") + .order().asc("customer.contacts.lastName") + .findList(); Assert.assertNotNull(list2); List list3 = Ebean.find(Customer.class) - .fetch("orders") - .filterMany("orders").eq("status", Order.Status.NEW) - .order().desc("orders.id") - .findList(); + .fetch("orders") + .filterMany("orders").eq("status", Order.Status.NEW) + .order().desc("orders.id") + .findList(); Assert.assertNotNull(list3); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFetchManyTwoDeep.java b/src/test/java/com/avaje/tests/query/TestQueryFetchManyTwoDeep.java index af0148973..9cf3dde30 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFetchManyTwoDeep.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFetchManyTwoDeep.java @@ -1,10 +1,5 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -13,6 +8,10 @@ import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.OrderShipment; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryFetchManyTwoDeep extends BaseTestCase { @@ -23,13 +22,13 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase { // test that join to order.details is not included in the initial query (included in query join) Query query = Ebean.find(Customer.class) - .setAutoTune(false) - .fetch("orders") - .fetch("orders.details"); + .setAutoTune(false) + .fetch("orders") + .fetch("orders.details"); - SpiQuery spiQuery = (SpiQuery)query; + SpiQuery spiQuery = (SpiQuery) query; spiQuery.setLogSecondaryQuery(true); - + List list = query.findList(); Assert.assertTrue("has rows", !list.isEmpty()); Assert.assertTrue(query.getGeneratedSql().contains("from o_customer t0 ")); @@ -37,64 +36,64 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase { Assert.assertTrue(query.getGeneratedSql().contains("left join o_customer t2 on t2.id = t1.kcustomer_id")); Assert.assertFalse(query.getGeneratedSql().contains("join or_order_ship")); - //select t0.id c0, t0.status c1, t0.name c2, t0.smallnote c3, t0.anniversary c4, t0.cretime c5, t0.updtime c6, t0.billing_address_id c7, t0.shipping_address_id c8, t1.id c9, t1.status c10, t1.order_date c11, t1.ship_date c12, - // t2.name c13, t1.cretime c14, t1.updtime c15, t1.kcustomer_id c16 - // from o_customer t0 + //select t0.id c0, t0.status c1, t0.name c2, t0.smallnote c3, t0.anniversary c4, t0.cretime c5, t0.updtime c6, t0.billing_address_id c7, t0.shipping_address_id c8, t1.id c9, t1.status c10, t1.order_date c11, t1.ship_date c12, + // t2.name c13, t1.cretime c14, t1.updtime c15, t1.kcustomer_id c16 + // from o_customer t0 // left join o_order t1 on t1.kcustomer_id = t0.id // left join o_customer t2 on t2.id = t1.kcustomer_id // where t1.order_date is not null order by t0.id; --bind() - - + + List> secondaryQueries = spiQuery.getLoggedSecondaryQueries(); Assert.assertNotNull(secondaryQueries); Assert.assertEquals(1, secondaryQueries.size()); - + SpiQuery secondaryQuery = secondaryQueries.get(0); String secondarySql = secondaryQuery.getGeneratedSql(); Assert.assertTrue(secondarySql.contains("from o_order_detail t0 where t0.id > 0 and (t0.order_id) in")); - - // select t0.order_id c0, t0.id c1, t0.order_qty c2, t0.ship_qty c3, t0.unit_price c4, t0.cretime c5, t0.updtime c6, t0.order_id c7, t0.product_id c8 - // from o_order_detail t0 - // where (t0.order_id) in (?,?,?,?,?) - + + // select t0.order_id c0, t0.id c1, t0.order_qty c2, t0.ship_qty c3, t0.unit_price c4, t0.cretime c5, t0.updtime c6, t0.order_id c7, t0.product_id c8 + // from o_order_detail t0 + // where (t0.order_id) in (?,?,?,?,?) + } - + @Test public void testFetchOptionalManyToOneThenDownToMany() { - + ResetBasicData.reset(); - + // test that join to order.details is not included Query shipQuery = Ebean.find(OrderShipment.class) - .setAutoTune(false) - .fetch("order") - .fetch("order.details"); + .setAutoTune(false) + .fetch("order") + .fetch("order.details"); List shipList = shipQuery.findList(); Assert.assertTrue("has rows", !shipList.isEmpty()); - + String generatedSql = shipQuery.getGeneratedSql(); - // select ... - // from or_order_ship t0 + // select ... + // from or_order_ship t0 // left join o_order t1 on t1.id = t0.order_id // left join o_customer t3 on t3.id = t1.kcustomer_id // left join o_order_detail t2 on t2.order_id = t1.id // where t2.id > 0 ; --bind() - + Assert.assertTrue(generatedSql.contains("from or_order_ship t0")); // Relationship from OrderShipment to Order is optional so outer join here Assert.assertTrue(generatedSql.contains("left join o_order t1 on t1.id = t0.order_id")); Assert.assertTrue(generatedSql.contains("left join o_customer t3 on t3.id = t1.kcustomer_id")); Assert.assertTrue(generatedSql.contains("left join o_order_detail t2 on t2.order_id = t1.id")); - - + + // If OrderShipment to Order is not optional you get inner joins up to o_order_detail (which is a many) - - // select ... - // from or_order_ship t0 - // join o_order t1 on t1.id = t0.order_id - // join o_customer t3 on t3.id = t1.kcustomer_id + + // select ... + // from or_order_ship t0 + // join o_order t1 on t1.id = t0.order_id + // join o_customer t3 on t3.id = t1.kcustomer_id // left join o_order_detail t2 on t2.order_id = t1.id // where t2.id > 0 ; --bind() } @@ -102,61 +101,61 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase { @Test public void testFetchMandatoryManyToOneThenDownToMany() { - + ResetBasicData.reset(); - + // test that join to order.details is not included Query query = Ebean.find(Contact.class) - .setAutoTune(false) - .fetch("customer") - .fetch("customer.orders"); + .setAutoTune(false) + .fetch("customer") + .fetch("customer.orders"); List shipList = query.findList(); Assert.assertTrue("has rows", !shipList.isEmpty()); - + String generatedSql = query.getGeneratedSql(); // select ... - // from contact t0 - // join o_customer t1 on t1.id = t0.customer_id + // from contact t0 + // join o_customer t1 on t1.id = t0.customer_id // left join o_order t2 on t2.kcustomer_id = t1.id // left join o_customer t3 on t3.id = t2.kcustomer_id // where t2.order_date is not null ; --bind() - + Assert.assertTrue(generatedSql.contains("from contact t0 ")); // Relationship from Contact to Customer is mandatory so inner join here Assert.assertTrue(generatedSql.contains("join o_customer t1 on t1.id = t0.customer_id")); // outer join on many relationship 'orders' Assert.assertTrue(generatedSql.contains("left join o_order t2 on t2.kcustomer_id = t1.id")); - + } - + @Test public void testFetchMandatoryManyToOneWithPredicate() { - + ResetBasicData.reset(); - + // test that join to order.details is not included Query query = Ebean.find(Contact.class) - .setAutoTune(false) - .fetch("customer") - .where().ilike("customer.name", "Rob%") - .query(); + .setAutoTune(false) + .fetch("customer") + .where().ilike("customer.name", "Rob%") + .query(); List list = query.findList(); Assert.assertTrue("has rows", !list.isEmpty()); - + String generatedSql = query.getGeneratedSql(); - // select ... - // from contact t0 - // join o_customer t1 on t1.id = t0.customer_id + // select ... + // from contact t0 + // join o_customer t1 on t1.id = t0.customer_id // where lower(t1.name) like ? ; --bind(rob%) - + Assert.assertTrue(generatedSql.contains("from contact t0 ")); Assert.assertTrue(generatedSql.contains("join o_customer t1 on t1.id = t0.customer_id")); Assert.assertTrue(generatedSql.contains("where lower(t1.name) like ?")); - + } } diff --git a/src/test/java/com/avaje/tests/query/TestQueryFetchSkipPath.java b/src/test/java/com/avaje/tests/query/TestQueryFetchSkipPath.java index 4c90a6ed3..cd6ff0b78 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFetchSkipPath.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFetchSkipPath.java @@ -1,9 +1,5 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Contact; @@ -11,6 +7,9 @@ import com.avaje.tests.model.basic.ContactNote; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestQueryFetchSkipPath extends BaseTestCase { @@ -21,11 +20,11 @@ public class TestQueryFetchSkipPath extends BaseTestCase { List list = Ebean.find(Order.class) - // .setAutoTune(true) - .setAutoTune(false).select("status") - // .fetch("customer","id") - // .fetch("customer.contacts","id") - .fetch("customer.contacts.notes", "title").findList(); + // .setAutoTune(true) + .setAutoTune(false).select("status") + // .fetch("customer","id") + // .fetch("customer.contacts","id") + .fetch("customer.contacts.notes", "title").findList(); for (Order order : list) { order.getStatus(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFilterMany.java b/src/test/java/com/avaje/tests/query/TestQueryFilterMany.java index 44ba772a4..9995229dc 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFilterMany.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFilterMany.java @@ -25,11 +25,11 @@ public class TestQueryFilterMany extends BaseTestCase { LoggedSqlCollector.start(); Customer customer = Ebean.find(Customer.class) - .fetch("orders", new FetchConfig().lazy()) - .filterMany("orders").eq("status", Order.Status.NEW) - .where().ieq("name", "Rob") - .order().asc("id").setMaxRows(1) - .findList().get(0); + .fetch("orders", new FetchConfig().lazy()) + .filterMany("orders").eq("status", Order.Status.NEW) + .where().ieq("name", "Rob") + .order().asc("id").setMaxRows(1) + .findList().get(0); customer.getOrders().size(); @@ -48,9 +48,9 @@ public class TestQueryFilterMany extends BaseTestCase { ResetBasicData.reset(); LoggedSqlCollector.start(); Ebean.find(Customer.class) - .filterMany("contacts").isNotNull("firstName") - .filterMany("contacts.notes").istartsWith("title", "foo") - .findList(); + .filterMany("contacts").isNotNull("firstName") + .filterMany("contacts.notes").istartsWith("title", "foo") + .findList(); List sql = LoggedSqlCollector.stop(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnM2M.java b/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnM2M.java index e5136f52a..3fe6548ab 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnM2M.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnM2M.java @@ -1,10 +1,9 @@ package com.avaje.tests.query; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.MUser; +import org.junit.Test; public class TestQueryFilterManyOnM2M extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnSecondary.java b/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnSecondary.java index dc0dfc83d..0838c7ca8 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnSecondary.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFilterManyOnSecondary.java @@ -1,10 +1,5 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -14,6 +9,10 @@ import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.Product; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryFilterManyOnSecondary extends BaseTestCase { @@ -23,10 +22,10 @@ public class TestQueryFilterManyOnSecondary extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .fetch("orders", new FetchConfig().query()) - .where().ilike("name", "Rob%").gt("id", 0) - .filterMany("orders").eq("status", Order.Status.NEW) - .query(); + .fetch("orders", new FetchConfig().query()) + .where().ilike("name", "Rob%").gt("id", 0) + .filterMany("orders").eq("status", Order.Status.NEW) + .query(); List list = query.findList(); for (Customer customer : list) { @@ -37,19 +36,19 @@ public class TestQueryFilterManyOnSecondary extends BaseTestCase { } } - - + + @Test public void testFilterManyWithPathPredicate() { - + ResetBasicData.reset(); - + Query query = Ebean.find(Order.class) .fetch("details", new FetchConfig().query()) - .fetch("details.product","name") + .fetch("details.product", "name") .filterMany("details").ilike("product.name", "c%") .query(); - + List orders = query.findList(); for (Order order : orders) { List details = order.getDetails(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFilterManySimple.java b/src/test/java/com/avaje/tests/query/TestQueryFilterManySimple.java index 7ffaaaf86..ca80c8ebb 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFilterManySimple.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFilterManySimple.java @@ -1,16 +1,15 @@ package com.avaje.tests.query; -import java.sql.Date; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.sql.Date; +import java.util.List; public class TestQueryFilterManySimple extends BaseTestCase { @@ -23,12 +22,12 @@ public class TestQueryFilterManySimple extends BaseTestCase { Date lastWeek = Date.valueOf("2010-01-01"); List list = Ebean - .find(Customer.class) - // .join("orders", new JoinConfig().lazy()) - // .join("orders", new JoinConfig().query()) - .fetch("orders").fetch("contacts", new FetchConfig().query()).where().ilike("name", "rob%") - .filterMany("orders").eq("status", Order.Status.NEW).gt("orderDate", lastWeek) - .filterMany("contacts").isNotNull("firstName").findList(); + .find(Customer.class) + // .join("orders", new JoinConfig().lazy()) + // .join("orders", new JoinConfig().query()) + .fetch("orders").fetch("contacts", new FetchConfig().query()).where().ilike("name", "rob%") + .filterMany("orders").eq("status", Order.Status.NEW).gt("orderDate", lastWeek) + .filterMany("contacts").isNotNull("firstName").findList(); // invoke lazy loading list.get(0).getOrders().size(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindEach.java b/src/test/java/com/avaje/tests/query/TestQueryFindEach.java index 1db5af130..2f58399e7 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindEach.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindEach.java @@ -1,6 +1,10 @@ package com.avaje.tests.query; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.FetchConfig; +import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Assert; @@ -18,10 +22,10 @@ public class TestQueryFindEach extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query - = server.find(Customer.class) - .setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + = server.find(Customer.class) + .setAutoTune(false) + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); @@ -32,11 +36,11 @@ public class TestQueryFindEach extends BaseTestCase { Assert.assertEquals(2, counter.get()); } - + /** * Test the behaviour when an exception is thrown inside the findVisit(). */ - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testVisitThrowingException() { ResetBasicData.reset(); @@ -44,8 +48,8 @@ public class TestQueryFindEach extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class).setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java b/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java index 943d1b1a5..8d8f4ef18 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindEachWhile.java @@ -1,6 +1,10 @@ package com.avaje.tests.query; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.FetchConfig; +import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Assert; @@ -18,10 +22,10 @@ public class TestQueryFindEachWhile extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query - = server.find(Customer.class) - .setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + = server.find(Customer.class) + .setAutoTune(false) + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); @@ -33,11 +37,11 @@ public class TestQueryFindEachWhile extends BaseTestCase { Assert.assertEquals(2, counter.get()); } - + /** * Test the behaviour when an exception is thrown inside the findVisit(). */ - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testVisitThrowingException() { ResetBasicData.reset(); @@ -45,8 +49,8 @@ public class TestQueryFindEachWhile extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class).setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java b/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java index 1d219807e..057bd69c6 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindIterate.java @@ -1,16 +1,18 @@ package com.avaje.tests.query; -import javax.persistence.PersistenceException; - -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Query; +import com.avaje.ebean.QueryIterator; +import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderShipment; +import com.avaje.tests.model.basic.ResetBasicData; import org.avaje.ebeantest.LoggedSqlCollector; import org.junit.Test; -import com.avaje.tests.model.basic.Customer; -import com.avaje.tests.model.basic.ResetBasicData; - +import javax.persistence.PersistenceException; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -28,7 +30,7 @@ public class TestQueryFindIterate extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class) - .setMaxRows(2); + .setMaxRows(2); final AtomicInteger count = new AtomicInteger(); @@ -53,11 +55,11 @@ public class TestQueryFindIterate extends BaseTestCase { EbeanServer server = Ebean.getServer(null); QueryIterator queryIterator = server.find(Customer.class) - .where() - .isNotNull("name") - .setMaxRows(3) - .order().asc("id") - .findIterate(); + .where() + .isNotNull("name") + .setMaxRows(3) + .order().asc("id") + .findIterate(); try { // check that hasNext does not move to the next bean @@ -88,9 +90,9 @@ public class TestQueryFindIterate extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class) - .setAutoTune(false) - //.fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + .setAutoTune(false) + //.fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger count = new AtomicInteger(); @@ -105,16 +107,16 @@ public class TestQueryFindIterate extends BaseTestCase { ResetBasicData.reset(); Ebean.find(Order.class) - //.select("orderDate") - .where().gt("id",0).le("id",10) - .findEach(order -> { - Customer customer = order.getCustomer(); - // invoke lazy loading on customer, order details and order shipments - order.getId(); - customer.getName(); - order.getDetails().size(); - order.getShipments().size(); - }); + //.select("orderDate") + .where().gt("id", 0).le("id", 10) + .findEach(order -> { + Customer customer = order.getCustomer(); + // invoke lazy loading on customer, order details and order shipments + order.getId(); + customer.getName(); + order.getDetails().size(); + order.getShipments().size(); + }); } @@ -129,7 +131,7 @@ public class TestQueryFindIterate extends BaseTestCase { .setLazyLoadBatchSize(10) .select("status, orderDate") .fetch("customer", "name") - .where().gt("id",0).le("id",10) + .where().gt("id", 0).le("id", 10) .setUseCache(false) .findEach(order -> { Customer customer = order.getCustomer(); @@ -161,29 +163,29 @@ public class TestQueryFindIterate extends BaseTestCase { Ebean.getServerCacheManager().getQueryCache(OrderShipment.class).clear(); Ebean.find(Order.class) - .setLazyLoadBatchSize(10) - .setUseCache(false) - .select("status, orderDate") - .fetch("customer", "name") - .fetch("details") - .where().gt("id",0).le("id",10) - .order().asc("id") - .findEach(order -> { - Customer customer = order.getCustomer(); - order.getId(); - customer.getName(); - order.getDetails().size(); - order.getShipments().size(); - }); + .setLazyLoadBatchSize(10) + .setUseCache(false) + .select("status, orderDate") + .fetch("customer", "name") + .fetch("details") + .where().gt("id", 0).le("id", 10) + .order().asc("id") + .findEach(order -> { + Customer customer = order.getCustomer(); + order.getId(); + customer.getName(); + order.getDetails().size(); + order.getShipments().size(); + }); List loggedSql = LoggedSqlCollector.stop(); - assertEquals("Got SQL: "+loggedSql, 2, loggedSql.size()); + assertEquals("Got SQL: " + loggedSql, 2, loggedSql.size()); assertThat(trimSql(loggedSql.get(0), 7).contains("select t0.id, t0.status, t0.order_date, t1.id, t1.name, t2.id, t2.order_qty, t2.ship_qty")); assertThat(trimSql(loggedSql.get(1), 7).contains("select t0.order_id, t0.id, t0.ship_time, t0.cretime, t0.updtime, t0.version, t0.order_id from or_order_ship")); } - @Test(expected=PersistenceException.class) + @Test(expected = PersistenceException.class) public void testWithExceptionInQuery() { ResetBasicData.reset(); @@ -192,9 +194,9 @@ public class TestQueryFindIterate extends BaseTestCase { // intentionally a query with incorrect type binding Query query = server.find(Customer.class) - .setAutoTune(false) - .where().gt("id","JUNK_NOT_A_LONG") - .setMaxRows(2); + .setAutoTune(false) + .where().gt("id", "JUNK_NOT_A_LONG") + .setMaxRows(2); // this throws an exception immediately query.findEach(bean -> { @@ -207,9 +209,9 @@ public class TestQueryFindIterate extends BaseTestCase { } assertTrue("Never get here as exception thrown", false); } - - - @Test(expected=IllegalStateException.class) + + + @Test(expected = IllegalStateException.class) public void testWithExceptionInLoop() { ResetBasicData.reset(); @@ -217,9 +219,9 @@ public class TestQueryFindIterate extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class) - .setAutoTune(false) - .where().gt("id", 0) - .setMaxRows(2); + .setAutoTune(false) + .where().gt("id", 0) + .setMaxRows(2); query.findEach(customer -> { if (customer != null) { diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindMapTypedKey.java b/src/test/java/com/avaje/tests/query/TestQueryFindMapTypedKey.java index 6648eb5f1..9dfa3b575 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindMapTypedKey.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindMapTypedKey.java @@ -20,8 +20,8 @@ public class TestQueryFindMapTypedKey extends BaseTestCase { ResetBasicData.reset(); Map productsBySku = Ebean.find(Product.class) - .setMapKey("sku") - .findMap(); + .setMapKey("sku") + .findMap(); assertThat(productsBySku).isNotEmpty(); @@ -29,9 +29,9 @@ public class TestQueryFindMapTypedKey extends BaseTestCase { assertNotNull(desk); Map map = Ebean.find(Customer.class) - .select("id, name") - .setMapKey("name") - .findMap(); + .select("id, name") + .setMapKey("name") + .findMap(); assertNotNull(map); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindPagedList.java b/src/test/java/com/avaje/tests/query/TestQueryFindPagedList.java index eb98592a4..ef4812e8b 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindPagedList.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindPagedList.java @@ -16,9 +16,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestQueryFindPagedList extends BaseTestCase { @@ -35,8 +33,8 @@ public class TestQueryFindPagedList extends BaseTestCase { ResetBasicData.reset(); PagedList pagedList = Ebean.find(Order.class) - .setMaxRows(4) - .findPagedList(); + .setMaxRows(4) + .findPagedList(); LoggedSqlCollector.start(); @@ -45,7 +43,7 @@ public class TestQueryFindPagedList extends BaseTestCase { assertTrue(!orders.isEmpty()); List loggedSql = LoggedSqlCollector.stop(); - assertEquals("Only 1 SQL statement, no count query",1, loggedSql.size()); + assertEquals("Only 1 SQL statement, no count query", 1, loggedSql.size()); } @@ -55,8 +53,8 @@ public class TestQueryFindPagedList extends BaseTestCase { ResetBasicData.reset(); PagedList pagedList = Ebean.find(Order.class) - .setMaxRows(3) - .findPagedList(); + .setMaxRows(3) + .findPagedList(); Future rowCount = pagedList.getFutureCount(); List orders = pagedList.getList(); @@ -78,8 +76,8 @@ public class TestQueryFindPagedList extends BaseTestCase { // fetch less that total orders (page size 3) PagedList pagedList = Ebean.find(Order.class) - .setMaxRows(3) - .findPagedList(); + .setMaxRows(3) + .findPagedList(); pagedList.loadCount(); List orders = pagedList.getList(); @@ -92,9 +90,9 @@ public class TestQueryFindPagedList extends BaseTestCase { // fetch less that total orders (page size 3) PagedList pagedList2 = Ebean.find(Order.class) - .setFirstRow(1) - .setMaxRows(3) - .findPagedList(); + .setFirstRow(1) + .setMaxRows(3) + .findPagedList(); pagedList2.loadCount(); List orders2 = pagedList2.getList(); @@ -107,31 +105,31 @@ public class TestQueryFindPagedList extends BaseTestCase { PagedList pagedList3 = Ebean.find(Order.class) - .setFirstRow(2) - .setMaxRows(150) - .findPagedList(); + .setFirstRow(2) + .setMaxRows(150) + .findPagedList(); assertFalse(pagedList3.hasNext()); assertTrue(pagedList3.hasPrev()); List list3 = pagedList3.getList(); String xtoYofZ = pagedList3.getDisplayXtoYofZ(" to ", " of "); - assertThat(xtoYofZ).isEqualTo("3 to "+totalRowCount+" of "+totalRowCount); + assertThat(xtoYofZ).isEqualTo("3 to " + totalRowCount + " of " + totalRowCount); assertThat(list3.size()).isEqualTo(totalRowCount - 2); PagedList pagedList4 = Ebean.find(Order.class) - .setFirstRow(0) - .setMaxRows(totalRowCount) - .findPagedList(); + .setFirstRow(0) + .setMaxRows(totalRowCount) + .findPagedList(); assertFalse(pagedList4.hasNext()); assertFalse(pagedList4.hasPrev()); - assertThat(pagedList4.getDisplayXtoYofZ(" to ", " of ")).isEqualTo("1 to "+totalRowCount+" of "+totalRowCount); + assertThat(pagedList4.getDisplayXtoYofZ(" to ", " of ")).isEqualTo("1 to " + totalRowCount + " of " + totalRowCount); PagedList pagedList5 = Ebean.find(Order.class) - .setFirstRow(0) - .setMaxRows(totalRowCount - 1) - .findPagedList(); + .setFirstRow(0) + .setMaxRows(totalRowCount - 1) + .findPagedList(); assertTrue(pagedList5.hasNext()); assertFalse(pagedList5.hasPrev()); @@ -151,7 +149,7 @@ public class TestQueryFindPagedList extends BaseTestCase { assertTrue(!orders.isEmpty()); List loggedSql = LoggedSqlCollector.stop(); - assertEquals("Only 1 SQL statement, no count query",1, loggedSql.size()); + assertEquals("Only 1 SQL statement, no count query", 1, loggedSql.size()); } @Test @@ -235,10 +233,10 @@ public class TestQueryFindPagedList extends BaseTestCase { ResetBasicData.reset(); PagedList pagedList = Ebean.find(Order.class) - .alias("b") - .where().raw("b.id > 0") - .setMaxRows(6) - .findPagedList(); + .alias("b") + .where().raw("b.id > 0") + .setMaxRows(6) + .findPagedList(); LoggedSqlCollector.start(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java b/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java index 451d73024..224d8ae7d 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java @@ -1,14 +1,13 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Article; import com.avaje.tests.model.basic.Section; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryFindReadOnly extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java b/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java index e863e8598..b7bf1372c 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java +++ b/src/test/java/com/avaje/tests/query/TestQueryFindVisit.java @@ -5,7 +5,6 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.FetchConfig; import com.avaje.ebean.Query; -import com.avaje.ebean.QueryEachConsumer; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Assert; @@ -23,8 +22,8 @@ public class TestQueryFindVisit extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class).setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); @@ -32,11 +31,11 @@ public class TestQueryFindVisit extends BaseTestCase { Assert.assertEquals(2, counter.get()); } - + /** * Test the behaviour when an exception is thrown inside the findVisit(). */ - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testVisitThrowingException() { ResetBasicData.reset(); @@ -44,8 +43,8 @@ public class TestQueryFindVisit extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Query query = server.find(Customer.class).setAutoTune(false) - .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") - .setMaxRows(2); + .fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id") + .setMaxRows(2); final AtomicInteger counter = new AtomicInteger(0); diff --git a/src/test/java/com/avaje/tests/query/TestQueryInAssocOne.java b/src/test/java/com/avaje/tests/query/TestQueryInAssocOne.java index 85e2cfa3d..318c81b1b 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryInAssocOne.java +++ b/src/test/java/com/avaje/tests/query/TestQueryInAssocOne.java @@ -1,16 +1,15 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryInAssocOne extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestQueryJoinBatchSize.java b/src/test/java/com/avaje/tests/query/TestQueryJoinBatchSize.java index 56f9158b8..1eeefff5c 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryJoinBatchSize.java +++ b/src/test/java/com/avaje/tests/query/TestQueryJoinBatchSize.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestQueryJoinBatchSize extends BaseTestCase { @@ -19,18 +18,18 @@ public class TestQueryJoinBatchSize extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - .fetch("customer", new FetchConfig().queryFirst(3).lazy(2)) - //.fetch("orders.details", new FetchConfig().query()) - //.fetch("orders.shipments", new FetchConfig().query()) - .findList(); - + .fetch("customer", new FetchConfig().queryFirst(3).lazy(2)) + //.fetch("orders.details", new FetchConfig().query()) + //.fetch("orders.shipments", new FetchConfig().query()) + .findList(); + for (Order order : list) { Customer customer = order.getCustomer(); customer.getName(); } } - + // @Test // public void test() { // diff --git a/src/test/java/com/avaje/tests/query/TestQueryJoinMulipleMany.java b/src/test/java/com/avaje/tests/query/TestQueryJoinMulipleMany.java index 55e0eef9f..1df94308c 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryJoinMulipleMany.java +++ b/src/test/java/com/avaje/tests/query/TestQueryJoinMulipleMany.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryJoinMulipleMany extends BaseTestCase { @@ -19,7 +18,7 @@ public class TestQueryJoinMulipleMany extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class).fetch("customer").fetch("customer.contacts").where() - .gt("id", 0).findList(); + .gt("id", 0).findList(); Assert.assertNotNull(list); diff --git a/src/test/java/com/avaje/tests/query/TestQueryMultiManyOrder.java b/src/test/java/com/avaje/tests/query/TestQueryMultiManyOrder.java index 4525c0a37..f5c60cca2 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryMultiManyOrder.java +++ b/src/test/java/com/avaje/tests/query/TestQueryMultiManyOrder.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryMultiManyOrder extends BaseTestCase { @@ -19,7 +18,7 @@ public class TestQueryMultiManyOrder extends BaseTestCase { ResetBasicData.reset(); Query q = Ebean.find(Order.class).fetch("shipments").fetch("details") - .fetch("details.product").fetch("customer").where().gt("id", 0).query(); + .fetch("details.product").fetch("customer").where().gt("id", 0).query(); List list = q.findList(); String sql = q.getGeneratedSql(); diff --git a/src/test/java/com/avaje/tests/query/TestQueryNullAssocOne.java b/src/test/java/com/avaje/tests/query/TestQueryNullAssocOne.java index 90c9367bc..e8167628b 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryNullAssocOne.java +++ b/src/test/java/com/avaje/tests/query/TestQueryNullAssocOne.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryNullAssocOne extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestQueryPathJoinAndOrder.java b/src/test/java/com/avaje/tests/query/TestQueryPathJoinAndOrder.java index 7c0016533..95a93d41c 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryPathJoinAndOrder.java +++ b/src/test/java/com/avaje/tests/query/TestQueryPathJoinAndOrder.java @@ -1,14 +1,13 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryPathJoinAndOrder extends BaseTestCase { @@ -18,7 +17,7 @@ public class TestQueryPathJoinAndOrder extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).select("id,name, status").fetch("contacts") - .order().asc("id").order().desc("contacts.firstName").setMaxRows(3).findList(); + .order().asc("id").order().desc("contacts.firstName").setMaxRows(3).findList(); Assert.assertNotNull(list); diff --git a/src/test/java/com/avaje/tests/query/TestQueryPlanCacheRowCount.java b/src/test/java/com/avaje/tests/query/TestQueryPlanCacheRowCount.java index fd74211ce..248d32f21 100644 --- a/src/test/java/com/avaje/tests/query/TestQueryPlanCacheRowCount.java +++ b/src/test/java/com/avaje/tests/query/TestQueryPlanCacheRowCount.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryPlanCacheRowCount extends BaseTestCase { @@ -19,7 +18,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class).where().eq("status", Order.Status.NEW).ge("id", 1) - .order().desc("id"); + .order().desc("id"); int rc0 = query.findCount(); @@ -46,7 +45,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase { // should still hit query plan cache Query query2 = Ebean.find(Order.class).where().eq("status", Order.Status.NEW) - .ge("id", idGt).order().desc("id"); + .ge("id", idGt).order().desc("id"); int rc2 = query2.findCount(); diff --git a/src/test/java/com/avaje/tests/query/TestRefToLazyLoadMany.java b/src/test/java/com/avaje/tests/query/TestRefToLazyLoadMany.java index f4310b8ae..eb611305a 100644 --- a/src/test/java/com/avaje/tests/query/TestRefToLazyLoadMany.java +++ b/src/test/java/com/avaje/tests/query/TestRefToLazyLoadMany.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRefToLazyLoadMany extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/TestRowCount.java b/src/test/java/com/avaje/tests/query/TestRowCount.java index ae7196f04..da4f110e2 100644 --- a/src/test/java/com/avaje/tests/query/TestRowCount.java +++ b/src/test/java/com/avaje/tests/query/TestRowCount.java @@ -1,15 +1,14 @@ package com.avaje.tests.query; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRowCount extends BaseTestCase { @@ -19,7 +18,7 @@ public class TestRowCount extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class).fetch("details").where().gt("id", 1) - .gt("details.id", 1).order("id desc"); + .gt("details.id", 1).order("id desc"); int rc = query.findCount(); diff --git a/src/test/java/com/avaje/tests/query/TestSubQuery.java b/src/test/java/com/avaje/tests/query/TestSubQuery.java index e7d26851d..0dcb2d382 100644 --- a/src/test/java/com/avaje/tests/query/TestSubQuery.java +++ b/src/test/java/com/avaje/tests/query/TestSubQuery.java @@ -1,11 +1,5 @@ package com.avaje.tests.query; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -14,6 +8,10 @@ import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; import com.avaje.tests.model.basic.Vehicle; import com.avaje.tests.model.basic.VehicleDriver; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; import static org.assertj.core.api.StrictAssertions.assertThat; @@ -28,7 +26,7 @@ public class TestSubQuery extends BaseTestCase { productIds.add(3); Query sq = Ebean.createQuery(Order.class).select("id").where() - .in("details.product.id", productIds).query(); + .in("details.product.id", productIds).query(); Ebean.find(Order.class).where().in("id", sq).findList(); } @@ -37,7 +35,7 @@ public class TestSubQuery extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(CKeyParent.class).select("id.oneKey") - .setAutoTune(false).where().query(); + .setAutoTune(false).where().query(); Query pq = Ebean.find(CKeyParent.class).where().in("id.oneKey", sq).query(); @@ -52,23 +50,23 @@ public class TestSubQuery extends BaseTestCase { /** * show that ebean is not using the correct table name in the subquery (sq) - * + * * public void testInheritance1() { ResetBasicData.reset(); - * + * * Query sq = Ebean.createQuery(Vehicle.class) .select("id") * .setAutoTune(false) .where() .query(); - * + * * Query pq = Ebean.find(VehicleDriver.class) * .where().in("vehicle.id", sq) .query(); - * + * * pq.findList(); - * + * * String sql = pq.getGeneratedSql(); System.err.println(sql); - * + * * String golden = "(t0.vehicle_id) in (select t0.id from t0.vehicle t0)"; if * (sql.indexOf(golden) < 0) { System.out.println("failed sql:"+sql); * fail("golden string not found"); } - * + * * } */ @@ -80,7 +78,7 @@ public class TestSubQuery extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(VehicleDriver.class).select("vehicle") - .setAutoTune(false).where().query(); + .setAutoTune(false).where().query(); Query pq = Ebean.find(Vehicle.class).where().in("id", sq).query(); @@ -105,7 +103,7 @@ public class TestSubQuery extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(VehicleDriver.class).select("vehicle") - .setAutoTune(false).where().eq("vehicle.licenseNumber", "abc").query(); + .setAutoTune(false).where().eq("vehicle.licenseNumber", "abc").query(); Query pq = Ebean.find(Vehicle.class).where().in("id", sq).query(); @@ -126,7 +124,7 @@ public class TestSubQuery extends BaseTestCase { ResetBasicData.reset(); Query sq = Ebean.createQuery(VehicleDriver.class).select("vehicle.id") - .setAutoTune(false).where().query(); + .setAutoTune(false).where().query(); Query pq = Ebean.find(Vehicle.class).where().in("id", sq).query(); diff --git a/src/test/java/com/avaje/tests/query/TestThreeLevelQueryJoin.java b/src/test/java/com/avaje/tests/query/TestThreeLevelQueryJoin.java index 2e043c136..4d1e28dba 100644 --- a/src/test/java/com/avaje/tests/query/TestThreeLevelQueryJoin.java +++ b/src/test/java/com/avaje/tests/query/TestThreeLevelQueryJoin.java @@ -1,12 +1,11 @@ package com.avaje.tests.query; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; public class TestThreeLevelQueryJoin extends BaseTestCase { @@ -16,10 +15,10 @@ public class TestThreeLevelQueryJoin extends BaseTestCase { ResetBasicData.reset(); Ebean.find(Customer.class).fetch("orders", new FetchConfig().query()) - .fetch("orders.details", new FetchConfig().query()) - .fetch("orders.shipments", new FetchConfig().query()) - .fetch("shippingAddress", new FetchConfig().query()) - .fetch("billingAddress", new FetchConfig().query()).findList(); + .fetch("orders.details", new FetchConfig().query()) + .fetch("orders.shipments", new FetchConfig().query()) + .fetch("shippingAddress", new FetchConfig().query()) + .fetch("billingAddress", new FetchConfig().query()).findList(); } diff --git a/src/test/java/com/avaje/tests/query/TestWhereRawClause.java b/src/test/java/com/avaje/tests/query/TestWhereRawClause.java index 38a25d562..b9abda112 100644 --- a/src/test/java/com/avaje/tests/query/TestWhereRawClause.java +++ b/src/test/java/com/avaje/tests/query/TestWhereRawClause.java @@ -1,14 +1,13 @@ package com.avaje.tests.query; -import com.avaje.ebean.Query; -import com.avaje.tests.model.basic.Order; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Expr; +import com.avaje.ebean.Query; +import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; import java.sql.Timestamp; @@ -23,10 +22,10 @@ public class TestWhereRawClause extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .where() - .raw("(status = ? or (orderDate < ? and shipDate is null) or customer.name like ?)", - Order.Status.APPROVED, new Timestamp(System.currentTimeMillis()), "Rob") - .query(); + .where() + .raw("(status = ? or (orderDate < ? and shipDate is null) or customer.name like ?)", + Order.Status.APPROVED, new Timestamp(System.currentTimeMillis()), "Rob") + .query(); query.findList(); @@ -39,10 +38,10 @@ public class TestWhereRawClause extends BaseTestCase { ResetBasicData.reset(); Ebean.find(OrderDetail.class) - .where() - .not(Expr.eq("id", 1)) - .raw("orderQty < shipQty") - .findList(); + .where() + .not(Expr.eq("id", 1)) + .raw("orderQty < shipQty") + .findList(); } @@ -52,12 +51,12 @@ public class TestWhereRawClause extends BaseTestCase { ResetBasicData.reset(); Ebean.find(OrderDetail.class) - .where() - .ne("id", 42) - .raw("orderQty < ?", 100) - .gt("id", 1) - .raw("unitPrice > ? and product.id > ?", 2, 3) - .findList(); + .where() + .ne("id", 42) + .raw("orderQty < ?", 100) + .gt("id", 1) + .raw("unitPrice > ? and product.id > ?", 2, 3) + .findList(); } } diff --git a/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java b/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java index d633d1f78..3e47dba7b 100644 --- a/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java +++ b/src/test/java/com/avaje/tests/query/aggregation/TestAggregationCount.java @@ -65,12 +65,12 @@ public class TestAggregationCount extends BaseTestCase { public void testFull() { Query query2 = Ebean.find(TEventOne.class) - .select("name, count, totalUnits, totalAmount") - .where() - .startsWith("logs.description", "a") - .having() - .ge("count", 1) - .orderBy().asc("name"); + .select("name, count, totalUnits, totalAmount") + .where() + .startsWith("logs.description", "a") + .having() + .ge("count", 1) + .orderBy().asc("name"); List list = query2.findList(); for (TEventOne eventOne : list) { @@ -94,7 +94,7 @@ public class TestAggregationCount extends BaseTestCase { public void testSelectOnly() { Query query0 = Ebean.find(TEventOne.class) - .select("name, count, totalUnits, totalAmount"); + .select("name, count, totalUnits, totalAmount"); query0.findList(); assertThat(query0.getGeneratedSql()).contains("select t0.id c0, t0.name c1, count(u1.*) c2, sum(u1.units) c3, sum(u1.units * u1.amount) c4 from tevent_one t0"); @@ -105,8 +105,8 @@ public class TestAggregationCount extends BaseTestCase { public void testSelectWhere() { Query query0 = Ebean.find(TEventOne.class) - .select("name, count, totalUnits, totalAmount") - .where().gt("logs.description", "a").query(); + .select("name, count, totalUnits, totalAmount") + .where().gt("logs.description", "a").query(); query0.findList(); assertThat(query0.getGeneratedSql()).contains("select t0.id c0, t0.name c1, count(u1.*) c2, sum(u1.units) c3, sum(u1.units * u1.amount) c4 from tevent_one t0"); @@ -117,9 +117,9 @@ public class TestAggregationCount extends BaseTestCase { public void testSelectHavingOrderBy() { Query query1 = Ebean.find(TEventOne.class) - .select("name, count, totalUnits, totalAmount") - .having().ge("count", 1) - .orderBy().asc("name"); + .select("name, count, totalUnits, totalAmount") + .having().ge("count", 1) + .orderBy().asc("name"); query1.findList(); assertThat(query1.getGeneratedSql()).contains("having count(u1.*) >= ? order by t0.name"); diff --git a/src/test/java/com/avaje/tests/query/autotune/TestAutoTuneProfiling.java b/src/test/java/com/avaje/tests/query/autotune/TestAutoTuneProfiling.java index c4491e3be..17c7ccdb3 100644 --- a/src/test/java/com/avaje/tests/query/autotune/TestAutoTuneProfiling.java +++ b/src/test/java/com/avaje/tests/query/autotune/TestAutoTuneProfiling.java @@ -57,9 +57,9 @@ public class TestAutoTuneProfiling extends BaseTestCase { private Order findById(long id) { return Ebean.find(Order.class) - .select("status, orderDate, shipDate") - .setId(id) - .findUnique(); + .select("status, orderDate, shipDate") + .setId(id) + .findUnique(); } private void useOrderDate() { diff --git a/src/test/java/com/avaje/tests/query/embedded/TestMultipleEmbeddedLoading.java b/src/test/java/com/avaje/tests/query/embedded/TestMultipleEmbeddedLoading.java index 6fcd55427..7ed43bf02 100644 --- a/src/test/java/com/avaje/tests/query/embedded/TestMultipleEmbeddedLoading.java +++ b/src/test/java/com/avaje/tests/query/embedded/TestMultipleEmbeddedLoading.java @@ -20,7 +20,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase { @Test public void testSimpleCase() { - + // prepare test EAddress ship = new EAddress(); ship.setStreet("1 Banana St"); @@ -37,52 +37,52 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase { invoice.setState(State.New); invoice.setShipAddress(ship); invoice.setBillAddress(bill); - + // act: save and fetch Ebean.save(invoice); - + EInvoice invoice2 = Ebean.find(EInvoice.class, invoice.getId()); - + // assert fetched bean populated as expected assertEquals(invoice.getId(), invoice2.getId()); assertEquals(invoice.getState(), invoice2.getState()); assertEquals(invoice.getInvoiceDate(), invoice2.getInvoiceDate()); assertEquals("2 Apple St", invoice.getBillAddress().getStreet()); assertEquals("2 Apple St", invoice2.getBillAddress().getStreet()); - + // act: only update one of the embedded fields invoice2.getBillAddress().setStreet("3 Pineapple St"); // bean should be dirty Ebean.save(invoice2); awaitL2Cache(); - + EInvoice invoice3 = Ebean.find(EInvoice.class, invoice.getId()); - + // assert field has updated value assertEquals("3 Pineapple St", invoice3.getBillAddress().getStreet()); - - + + // fetch a partial EInvoice invoicePartial = Ebean.find(EInvoice.class) - .select("state, date") - .where().idEq(invoice.getId()) - .findUnique(); - + .select("state, date") + .where().idEq(invoice.getId()) + .findUnique(); + // lazy load of embedded bean EAddress billAddress = invoicePartial.getBillAddress(); - + assertNotNull(billAddress); assertEquals("3 Pineapple St", billAddress.getStreet()); - + EbeanServer server = Ebean.getServer(null); ServerCacheManager serverCacheManager = server.getServerCacheManager(); - + // get cache, clear the cache and statistics ServerCache beanCache = serverCacheManager.getBeanCache(EInvoice.class); beanCache.clear(); beanCache.getStatistics(true); - + // fetch and load the cache EInvoice invoice4 = Ebean.find(EInvoice.class, invoice.getId()); assertNotNull(invoice4); @@ -95,16 +95,16 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase { // fetch out of the cache this time EInvoice invoice5 = Ebean.find(EInvoice.class, invoice.getId()); assertNotNull(invoice5); - + statistics = beanCache.getStatistics(false); assertEquals(1, statistics.getSize()); assertEquals(1, statistics.getHitCount()); billAddress = invoice5.getBillAddress(); - + assertNotNull(billAddress); assertEquals("3 Pineapple St", billAddress.getStreet()); } - + } diff --git a/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterJoin.java b/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterJoin.java index 8e49dbc3c..8355bbd62 100644 --- a/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterJoin.java +++ b/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterJoin.java @@ -1,15 +1,14 @@ package com.avaje.tests.query.joins; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.MRole; import com.avaje.tests.model.basic.MUser; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestDisjunctWhereOuterJoin extends BaseTestCase { @@ -46,10 +45,10 @@ public class TestDisjunctWhereOuterJoin extends BaseTestCase { Query query = Ebean.find(MUser.class) - .where().disjunction() - .eq("roles.roleName", "role2specialB") // user0 - .eq("roles.roleName", "role3B") // nobody - .endJunction().query(); + .where().disjunction() + .eq("roles.roleName", "role2specialB") // user0 + .eq("roles.roleName", "role3B") // nobody + .endJunction().query(); List list = query.findList(); Assert.assertSame(1, list.size()); // list should contain user0 diff --git a/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterOnMany.java b/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterOnMany.java index bc1a1abed..c5ddb5801 100644 --- a/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterOnMany.java +++ b/src/test/java/com/avaje/tests/query/joins/TestDisjunctWhereOuterOnMany.java @@ -1,15 +1,14 @@ package com.avaje.tests.query.joins; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.UUOne; import com.avaje.tests.model.basic.UUTwo; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestDisjunctWhereOuterOnMany extends BaseTestCase { @@ -33,32 +32,32 @@ public class TestDisjunctWhereOuterOnMany extends BaseTestCase { Ebean.save(master1); Ebean.save(detail1); Ebean.save(master2); - - + + // Have outer join so that "testDisjOuter_2_name" is found Query query = Ebean.find(UUOne.class) .where().disjunction() - .eq("name", "testDisjOuter_2_name") - .eq("comments.name", "testDisjOuter_CHILD_1") - .endJunction() - .query(); - + .eq("name", "testDisjOuter_2_name") + .eq("comments.name", "testDisjOuter_CHILD_1") + .endJunction() + .query(); + List list = query.findList(); int rowCount = query.findCount(); - - // select distinct t0.id c0, t0.name c1 - // from uuone t0 - // join uutwo u1 on u1.master_id = t0.id + + // select distinct t0.id c0, t0.name c1 + // from uuone t0 + // join uutwo u1 on u1.master_id = t0.id // left join uutwo t1 on t1.master_id = t0.id - // where (t0.name = ? or u1.name = ? ) ; + // where (t0.name = ? or u1.name = ? ) ; // --bind(testDisjOuter_2_name,testDisjOuter_CHILD_1) - + Assert.assertEquals(2, list.size()); Assert.assertEquals(2, rowCount); - + String expectedSql = "select distinct t0.id, t0.name from uuone t0 left join uutwo u1 on u1.master_id = t0.id where (t0.name = ? or u1.name = ? ) "; Assert.assertEquals(expectedSql, sqlOf(query, 1)); - + } - + } diff --git a/src/test/java/com/avaje/tests/query/joins/TestQueryJoinManyNonRoot.java b/src/test/java/com/avaje/tests/query/joins/TestQueryJoinManyNonRoot.java index aaa39ebca..c86203174 100644 --- a/src/test/java/com/avaje/tests/query/joins/TestQueryJoinManyNonRoot.java +++ b/src/test/java/com/avaje/tests/query/joins/TestQueryJoinManyNonRoot.java @@ -1,14 +1,16 @@ package com.avaje.tests.query.joins; -import java.util.List; - -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.FetchConfig; +import com.avaje.ebean.Query; +import com.avaje.tests.model.basic.Order; +import com.avaje.tests.model.basic.ResetBasicData; import org.avaje.ebeantest.LoggedSqlCollector; import org.junit.Assert; import org.junit.Test; -import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.ResetBasicData; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -23,9 +25,9 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { LoggedSqlCollector.start(); List orders = Ebean.find(Order.class) - .select("id, status, orderDate") - .where().gt("details.orderQty", 0) - .findList(); + .select("id, status, orderDate") + .where().gt("details.orderQty", 0) + .findList(); assertTrue(!orders.isEmpty()); @@ -41,9 +43,9 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { ResetBasicData.reset(); Query q = Ebean.find(Order.class) - .fetch("customer") - .fetch("customer.contacts") - .where().gt("id", 0).query(); + .fetch("customer") + .fetch("customer.contacts") + .where().gt("id", 0).query(); List list = q.findList(); String sql = q.getGeneratedSql(); @@ -51,15 +53,15 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { assertTrue(!list.isEmpty()); assertTrue(sql.contains("join o_customer t1 on t1.id ")); assertTrue(sql.contains("left join contact t2 on")); - - // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, - // t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15, - // t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25 - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id + + // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, + // t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15, + // t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25 + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id // left join contact t2 on t2.customer_id = t1.id // where t0.id > ? ; --bind(0) - + } @Test @@ -68,11 +70,11 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { ResetBasicData.reset(); Query q = Ebean.find(Order.class) - .fetch("details") - .fetch("details.product") - .fetch("customer") - .fetch("customer.contacts") - .where().gt("id", 0).query(); + .fetch("details") + .fetch("details.product") + .fetch("customer") + .fetch("customer.contacts") + .where().gt("id", 0).query(); List list = q.findList(); String sql = q.getGeneratedSql(); @@ -92,15 +94,15 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase { ResetBasicData.reset(); Query q = Ebean.find(Order.class) - .fetch("customer") - .fetch("customer.contacts") - .fetch("details", new FetchConfig().query(10)) - .fetch("details.product") - .where().gt("id", 0).query(); + .fetch("customer") + .fetch("customer.contacts") + .fetch("details", new FetchConfig().query(10)) + .fetch("details.product") + .where().gt("id", 0).query(); List list = q.findList(); String sql = q.getGeneratedSql(); - + for (Order order : list) { order.getCustomer().getContacts().size(); } diff --git a/src/test/java/com/avaje/tests/query/joins/TestQueryJoinQueryNonRoot.java b/src/test/java/com/avaje/tests/query/joins/TestQueryJoinQueryNonRoot.java index 88c78a6d4..1309684c7 100644 --- a/src/test/java/com/avaje/tests/query/joins/TestQueryJoinQueryNonRoot.java +++ b/src/test/java/com/avaje/tests/query/joins/TestQueryJoinQueryNonRoot.java @@ -1,10 +1,5 @@ package com.avaje.tests.query.joins; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -14,6 +9,10 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue; import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryJoinQueryNonRoot extends BaseTestCase { @@ -29,10 +28,10 @@ public class TestQueryJoinQueryNonRoot extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Order.class) - .fetch("customer") - .fetch("customer.contacts", "firstName", new FetchConfig().query().lazy(10)) - .fetch("customer.contacts.group") - .where().lt("id", 3).findList(); + .fetch("customer") + .fetch("customer.contacts", "firstName", new FetchConfig().query().lazy(10)) + .fetch("customer.contacts.group") + .where().lt("id", 3).findList(); Assert.assertNotNull(list); Assert.assertTrue(!list.isEmpty()); @@ -53,6 +52,6 @@ public class TestQueryJoinQueryNonRoot extends BaseTestCase { // Assert.assertTrue(list2.size() > 0); } - + } diff --git a/src/test/java/com/avaje/tests/query/joins/TestQueryManyToOneWhereClauseJoin.java b/src/test/java/com/avaje/tests/query/joins/TestQueryManyToOneWhereClauseJoin.java index ab0ee7d70..8cb8b9a6c 100644 --- a/src/test/java/com/avaje/tests/query/joins/TestQueryManyToOneWhereClauseJoin.java +++ b/src/test/java/com/avaje/tests/query/joins/TestQueryManyToOneWhereClauseJoin.java @@ -1,13 +1,12 @@ package com.avaje.tests.query.joins; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestQueryManyToOneWhereClauseJoin extends BaseTestCase { @@ -21,18 +20,18 @@ public class TestQueryManyToOneWhereClauseJoin extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .where().ilike("customer.name", "rob%") - .query(); + .where().ilike("customer.name", "rob%") + .query(); query.findList(); - - //select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 + + //select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 String expectedSql = "from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id where lower(t1.name) like ? "; Assert.assertTrue(query.getGeneratedSql().contains(expectedSql)); - // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id + // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id // where lower(t1.name) like ? ; --bind(rob%) } @@ -45,22 +44,22 @@ public class TestQueryManyToOneWhereClauseJoin extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .where().disjunction().ilike("customer.name", "rob%").gt("id", 1).endJunction() - .query(); + .where().disjunction().ilike("customer.name", "rob%").gt("id", 1).endJunction() + .query(); query.findList(); - - //select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 + + //select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 String expectedSql = "from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id where (lower(t1.name) like ? "; Assert.assertTrue(query.getGeneratedSql().contains(expectedSql)); - - // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id + + // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7 + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id // where (lower(t1.name) like ? or t0.id > ? ) ; --bind(rob%,1) - + } - + /** * Testing ManyToOne relationship with predicate and fetch. @@ -71,23 +70,23 @@ public class TestQueryManyToOneWhereClauseJoin extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .fetch("customer") - .fetch("customer.contacts") - .where().ilike("customer.name", "rob%") - .query(); + .fetch("customer") + .fetch("customer.contacts") + .where().ilike("customer.name", "rob%") + .query(); query.findList(); - + String generatedSql = query.getGeneratedSql(); Assert.assertTrue(generatedSql.contains("from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id")); Assert.assertTrue(generatedSql.contains("left join contact t2 on t2.customer_id = t1.id")); Assert.assertTrue(generatedSql.contains("where lower(t1.name) like ?")); - - // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, - // t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15, - // t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25 - // from o_order t0 - // join o_customer t1 on t1.id = t0.kcustomer_id + + // select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6, + // t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15, + // t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25 + // from o_order t0 + // join o_customer t1 on t1.id = t0.kcustomer_id // left join contact t2 on t2.customer_id = t1.id // where lower(t1.name) like ? ; --bind(rob%) } diff --git a/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java b/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java index 92a93822c..c8ac80101 100644 --- a/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java +++ b/src/test/java/com/avaje/tests/query/lazy/TestQueryDefaultBatchSize.java @@ -2,7 +2,6 @@ package com.avaje.tests.query.lazy; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; -import com.avaje.ebean.QueryEachConsumer; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; @@ -20,8 +19,8 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { ResetBasicData.reset(); Ebean.find(Order.class) - .setLazyLoadBatchSize(2) - .findEach(bean -> doStuff(bean)); + .setLazyLoadBatchSize(2) + .findEach(bean -> doStuff(bean)); } @Test @@ -30,12 +29,12 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { ResetBasicData.reset(); Ebean.find(Order.class) - .fetch("details", "id") - .fetch("details.product", "sku") - .fetch("customer") - .fetch("customer.contacts") - .setLazyLoadBatchSize(2) - .findEach(bean -> doStuff(bean)); + .fetch("details", "id") + .fetch("details.product", "sku") + .fetch("customer") + .fetch("customer.contacts") + .setLazyLoadBatchSize(2) + .findEach(bean -> doStuff(bean)); } @Test @@ -44,9 +43,9 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { ResetBasicData.reset(); List orders = - Ebean.find(Order.class) - .setLazyLoadBatchSize(2) - .findList(); + Ebean.find(Order.class) + .setLazyLoadBatchSize(2) + .findList(); for (Order order : orders) { doStuff(order); @@ -59,13 +58,13 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { ResetBasicData.reset(); List orders = - Ebean.find(Order.class) - .fetch("details", "id") - .fetch("details.product", "sku") - .fetch("customer") - .fetch("customer.contacts") - .setLazyLoadBatchSize(2) - .findList(); + Ebean.find(Order.class) + .fetch("details", "id") + .fetch("details.product", "sku") + .fetch("customer") + .fetch("customer.contacts") + .setLazyLoadBatchSize(2) + .findList(); for (Order order : orders) { doStuff(order); @@ -78,8 +77,8 @@ public class TestQueryDefaultBatchSize extends BaseTestCase { ResetBasicData.reset(); List orders = Ebean.find(Order.class) - .setLazyLoadBatchSize(100) - .findList(); + .setLazyLoadBatchSize(100) + .findList(); for (Order order : orders) { List details = order.getDetails(); diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByClear.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByClear.java index 4338c6d7f..49a38515e 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByClear.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByClear.java @@ -5,14 +5,10 @@ import com.avaje.ebean.Ebean; import com.avaje.ebean.OrderBy; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; -import org.avaje.ebeantest.LoggedSqlCollector; import org.junit.Assert; import org.junit.Test; -import java.util.List; - import static org.junit.Assert.assertTrue; public class TestOrderByClear extends BaseTestCase { @@ -23,7 +19,7 @@ public class TestOrderByClear extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Order.class) - .orderBy().asc("orderDate"); + .orderBy().asc("orderDate"); OrderBy orderBy = query.orderBy(); diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByOnComplex.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByOnComplex.java index b31bd1eb7..e78f01b86 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByOnComplex.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByOnComplex.java @@ -1,13 +1,12 @@ package com.avaje.tests.query.orderby; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestOrderByOnComplex extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinct.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinct.java index 4e94b3b33..a2bc000a1 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinct.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinct.java @@ -1,19 +1,18 @@ package com.avaje.tests.query.orderby; -import java.util.List; -import java.util.Set; - -import com.avaje.tests.model.basic.Customer; -import com.avaje.tests.model.basic.ResetBasicData; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; +import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.MRole; import com.avaje.tests.model.basic.MUser; import com.avaje.tests.model.basic.MUserType; +import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; +import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; @@ -26,100 +25,99 @@ public class TestOrderByWithDistinct extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .where() - .eq("junk","blah") - .eq("name","jim") - .orderBy("id desc,path.that.does.not.exist,contacts.group.name asc"); + .where() + .eq("junk", "blah") + .eq("name", "jim") + .orderBy("id desc,path.that.does.not.exist,contacts.group.name asc"); Set unknownProperties = query.validate(); assertThat(unknownProperties).isNotEmpty(); assertThat(unknownProperties).hasSize(2); - assertThat(unknownProperties).contains("junk","path.that.does.not.exist"); + assertThat(unknownProperties).contains("junk", "path.that.does.not.exist"); } - @Test - public void test() { - /* + @Test + public void test() { + /* * Original conversation: * https://groups.google.com/forum/?fromgroups=#!topic/ebean/uuvi1btdCDQ%5B1-25-false%5D - * + * * This test exposes what may be a general problem with columns required by the order by phrase being omitted from the select. * I'm not sure this exposes all causes of the problem. */ - - MUserType ut = new MUserType("md"); - Ebean.save(ut); - MUser user1 = new MUser("one"); - user1.setUserType(ut); - Ebean.save(user1); - MUser user2 = new MUser("two"); - user2.setUserType(ut); - Ebean.save(user2); - - MRole roleA = new MRole("A"); - Ebean.save(roleA); - MRole roleB = new MRole("B"); - Ebean.save(roleB); - - user1.addRole(roleA); - Ebean.save(user1); - user2.addRole(roleB); - Ebean.save(user2); - - Query query = Ebean.find(MUser.class) - .fetch("userType","name") - .where() - .eq("roles.roleName", "A") - .orderBy("userType.name, userName"); - List list = query.findList(); - - // select distinct t0.userid c0, t0.user_name c1, t1.id c2, t1.name c3 - // from muser t0 - // left join muser_type t1 on t1.id = t0.user_type_id - // join mrole_muser u1z_ on u1z_.muser_userid = t0.userid - // join mrole u1 on u1.roleid = u1z_.mrole_roleid - // where u1.role_name = ? - // order by t1.name, t0.user_name; --bind(A) - - Assert.assertEquals(1, list.size()); - Assert.assertEquals(user1, list.get(0)); + + MUserType ut = new MUserType("md"); + Ebean.save(ut); + MUser user1 = new MUser("one"); + user1.setUserType(ut); + Ebean.save(user1); + MUser user2 = new MUser("two"); + user2.setUserType(ut); + Ebean.save(user2); + + MRole roleA = new MRole("A"); + Ebean.save(roleA); + MRole roleB = new MRole("B"); + Ebean.save(roleB); + + user1.addRole(roleA); + Ebean.save(user1); + user2.addRole(roleB); + Ebean.save(user2); + + Query query = Ebean.find(MUser.class) + .fetch("userType", "name") + .where() + .eq("roles.roleName", "A") + .orderBy("userType.name, userName"); + List list = query.findList(); + + // select distinct t0.userid c0, t0.user_name c1, t1.id c2, t1.name c3 + // from muser t0 + // left join muser_type t1 on t1.id = t0.user_type_id + // join mrole_muser u1z_ on u1z_.muser_userid = t0.userid + // join mrole u1 on u1.roleid = u1z_.mrole_roleid + // where u1.role_name = ? + // order by t1.name, t0.user_name; --bind(A) + + Assert.assertEquals(1, list.size()); + Assert.assertEquals(user1, list.get(0)); String generatedSql = query.getGeneratedSql(); Assert.assertTrue(generatedSql.contains("select distinct t0.userid")); // using distinct Assert.assertTrue(generatedSql.contains("order by t1.name,")); // name in order by Assert.assertTrue(generatedSql.contains("t1.name"));// name in select - - - - // repeat with slight variation, not sure this really produces a different execution path - // this problem also manifests when autofetch eliminates properties from the select that aren't used in the objects - // still need them to be present for purpose of order by - // so here I'm "simulating" a scenario where autofetch has dropped userType.name - query = Ebean.find(MUser.class) - .setAutoTune(false) - .select("userName") - .fetch("userType","name") - .where() - .eq("roles.roleName", "A") - .orderBy("userType.name"); - list = query.findList(); - - Assert.assertEquals(1, list.size()); - Assert.assertEquals(user1, list.get(0)); - - // select distinct t0.userid c0, t0.user_name c1, t1.id c2, t1.name c3 - // from muser t0 - // left join muser_type t1 on t1.id = t0.user_type_id - // join mrole_muser u1z_ on u1z_.muser_userid = t0.userid - // join mrole u1 on u1.roleid = u1z_.mrole_roleid - // where u1.role_name = ? - // order by t1.name; --bind(A) - - generatedSql = query.getGeneratedSql(); + + + // repeat with slight variation, not sure this really produces a different execution path + // this problem also manifests when autofetch eliminates properties from the select that aren't used in the objects + // still need them to be present for purpose of order by + // so here I'm "simulating" a scenario where autofetch has dropped userType.name + query = Ebean.find(MUser.class) + .setAutoTune(false) + .select("userName") + .fetch("userType", "name") + .where() + .eq("roles.roleName", "A") + .orderBy("userType.name"); + list = query.findList(); + + Assert.assertEquals(1, list.size()); + Assert.assertEquals(user1, list.get(0)); + + // select distinct t0.userid c0, t0.user_name c1, t1.id c2, t1.name c3 + // from muser t0 + // left join muser_type t1 on t1.id = t0.user_type_id + // join mrole_muser u1z_ on u1z_.muser_userid = t0.userid + // join mrole u1 on u1.roleid = u1z_.mrole_roleid + // where u1.role_name = ? + // order by t1.name; --bind(A) + + generatedSql = query.getGeneratedSql(); Assert.assertTrue(generatedSql.contains("select distinct t0.userid")); // using distinct Assert.assertTrue(generatedSql.contains("order by t1.name")); // name in order by Assert.assertTrue(generatedSql.contains("t1.name"));// name in select - - } + + } } diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinctTake2.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinctTake2.java index c697f9468..244ef7369 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinctTake2.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithDistinctTake2.java @@ -1,40 +1,39 @@ package com.avaje.tests.query.orderby; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; +import org.junit.Assert; +import org.junit.Test; public class TestOrderByWithDistinctTake2 extends BaseTestCase { @Test public void testRegex() { - + String test = "helloasc asc ASC desc DESC boodesc desc ASC"; - + test = test.replaceAll("(?i)\\b asc\\b|\\b desc\\b", ""); Assert.assertEquals("helloasc boodesc", test); } - - + + @Test public void test() { - + Query query = Ebean.find(Customer.class) .select("id") .where().ilike("contacts.firstName", "R%") .order("name desc"); - + query.findList(); - + String generatedSql = sqlOf(query); - - // select distinct t0.id c0, t0.name - // from o_customer t0 join contact u1 on u1.customer_id = t0.id - // where lower(u1.first_name) like ? + + // select distinct t0.id c0, t0.name + // from o_customer t0 join contact u1 on u1.customer_id = t0.id + // where lower(u1.first_name) like ? // order by t0.name; --bind(r%) Assert.assertTrue("t0.name added to the select clause", generatedSql.contains("select distinct t0.id, t0.name")); @@ -42,17 +41,17 @@ public class TestOrderByWithDistinctTake2 extends BaseTestCase { Assert.assertTrue(generatedSql.contains("from o_customer t0 join contact u1 on u1.customer_id = t0.id")); Assert.assertTrue(generatedSql.contains("where lower(u1.first_name) like ?")); } - + @Test public void testWithAscAndDesc() { - + Query query = Ebean.find(Customer.class) .select("id") .where().ilike("contacts.firstName", "R%") .order("name asc,id desc"); - + query.findList(); - + String generatedSql = sqlOf(query); Assert.assertTrue("t0.name added to the select clause", generatedSql.contains("select distinct t0.id, t0.name, t0.id")); @@ -60,5 +59,5 @@ public class TestOrderByWithDistinctTake2 extends BaseTestCase { Assert.assertTrue(generatedSql.contains("from o_customer t0 join contact u1 on u1.customer_id = t0.id")); Assert.assertTrue(generatedSql.contains("where lower(u1.first_name) like ?")); } - + } diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithFunction.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithFunction.java index 2858e871a..a937dff13 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithFunction.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithFunction.java @@ -1,13 +1,12 @@ package com.avaje.tests.query.orderby; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; public class TestOrderByWithFunction extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithMany.java b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithMany.java index 4f8ebff01..8bfd502d5 100644 --- a/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithMany.java +++ b/src/test/java/com/avaje/tests/query/orderby/TestOrderByWithMany.java @@ -1,17 +1,16 @@ package com.avaje.tests.query.orderby; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestOrderByWithMany extends BaseTestCase { @@ -109,7 +108,7 @@ public class TestOrderByWithMany extends BaseTestCase { private void checkBoth() { Query query = Ebean.find(Order.class).fetch("shipments").order() - .desc("customer.name, shipments.shipTime"); + .desc("customer.name, shipments.shipTime"); query.findList(); @@ -121,7 +120,7 @@ public class TestOrderByWithMany extends BaseTestCase { private void checkPrepend() { Query query = Ebean.find(Order.class).fetch("shipments").order() - .desc("shipments.shipTime"); + .desc("shipments.shipTime"); query.findList(); @@ -133,7 +132,7 @@ public class TestOrderByWithMany extends BaseTestCase { private void checkAlreadyIncluded() { Query query = Ebean.find(Order.class).fetch("shipments").order() - .desc("id, shipments.shipTime"); + .desc("id, shipments.shipTime"); query.findList(); @@ -145,7 +144,7 @@ public class TestOrderByWithMany extends BaseTestCase { private void checkAlreadyIncluded2() { Query query = Ebean.find(Order.class).fetch("shipments").order() - .desc("orderDate, id, shipments.shipTime"); + .desc("orderDate, id, shipments.shipTime"); query.findList(); diff --git a/src/test/java/com/avaje/tests/query/other/TestFindIdsWithInheritance.java b/src/test/java/com/avaje/tests/query/other/TestFindIdsWithInheritance.java index fb65a46ee..f891cf146 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindIdsWithInheritance.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindIdsWithInheritance.java @@ -1,30 +1,29 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Truck; import com.avaje.tests.model.basic.Vehicle; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestFindIdsWithInheritance extends BaseTestCase { @Test public void testQuery() { - + Truck truck = new Truck(); truck.setLicenseNumber("TK123"); - + Ebean.save(truck); - + List ids = Ebean.find(Vehicle.class).findIds(); Assert.assertNotNull(ids); - + Ebean.delete(truck); - + } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java index f5ae9ad73..7e4e10c22 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindIterateHeapDump.java @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicInteger; @SuppressWarnings("restriction") public class TestFindIterateHeapDump extends BaseTestCase { - + // All that heap dumping code from : // https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java private static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic"; @@ -58,13 +58,13 @@ public class TestFindIterateHeapDump extends BaseTestCase { final AtomicInteger counter = new AtomicInteger(); server.find(EBasic.class) - .findEach(bean -> { + .findEach(bean -> { - int count = counter.incrementAndGet(); - if (count == 1) { - dumpHeap("heap-dump13-initial.snapshot", true); - } - }); + int count = counter.incrementAndGet(); + if (count == 1) { + dumpHeap("heap-dump13-initial.snapshot", true); + } + }); // try { // while (iterate.hasNext()) { diff --git a/src/test/java/com/avaje/tests/query/other/TestFindPartialWithConstructorSetFields.java b/src/test/java/com/avaje/tests/query/other/TestFindPartialWithConstructorSetFields.java index 4e4ae9e25..979a01e08 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindPartialWithConstructorSetFields.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindPartialWithConstructorSetFields.java @@ -4,11 +4,9 @@ import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Test; -import java.sql.Date; import java.util.List; import java.util.Set; @@ -19,7 +17,7 @@ public class TestFindPartialWithConstructorSetFields extends BaseTestCase { @Test public void test() { - + ResetBasicData.reset(); List list = Ebean.find(Order.class) @@ -51,5 +49,5 @@ public class TestFindPartialWithConstructorSetFields extends BaseTestCase { } } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestFindWhereUsingEnumerated.java b/src/test/java/com/avaje/tests/query/other/TestFindWhereUsingEnumerated.java index 60b9106cb..f07f14f66 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFindWhereUsingEnumerated.java +++ b/src/test/java/com/avaje/tests/query/other/TestFindWhereUsingEnumerated.java @@ -1,11 +1,10 @@ package com.avaje.tests.query.other; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.MNonEnum; import com.avaje.tests.model.basic.MNonUpdPropEntity; +import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -22,11 +21,11 @@ public class TestFindWhereUsingEnumerated extends BaseTestCase { Ebean.save(e); MNonUpdPropEntity unique = Ebean.find(MNonUpdPropEntity.class).where() - .eq("nonEnum", MNonEnum.END) - .eq("name", "TheNonEnumIsEnd") - .findUnique(); + .eq("nonEnum", MNonEnum.END) + .eq("name", "TheNonEnumIsEnd") + .findUnique(); assertThat(unique).isNotNull(); } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestFormulaWithFindCount.java b/src/test/java/com/avaje/tests/query/other/TestFormulaWithFindCount.java index f4cc122ef..b053a6672 100644 --- a/src/test/java/com/avaje/tests/query/other/TestFormulaWithFindCount.java +++ b/src/test/java/com/avaje/tests/query/other/TestFormulaWithFindCount.java @@ -1,27 +1,26 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.ExpressionList; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestFormulaWithFindCount extends BaseTestCase { @Test public void testFindCount() { - + ResetBasicData.reset(); - + EbeanServer server = Ebean.getServer(null); - + ExpressionList ex = server.find(Order.class).select("id, status ,totalAmount").where().gt("totalAmount", 1d); List list = ex.findList(); @@ -29,7 +28,7 @@ public class TestFormulaWithFindCount extends BaseTestCase { Double amount = order.getTotalAmount(); Assert.assertNotNull(amount); } - + ExpressionList expressionList = server.find(Order.class).where().gt("totalAmount", 1d); int rowCount = expressionList.findCount(); Assert.assertEquals(list.size(), rowCount); diff --git a/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java b/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java index b1b1cfe5f..f085bc07b 100644 --- a/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java +++ b/src/test/java/com/avaje/tests/query/other/TestManyLazyLoadingQuery.java @@ -1,10 +1,5 @@ package com.avaje.tests.query.other; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; @@ -14,6 +9,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -21,56 +20,55 @@ public class TestManyLazyLoadingQuery extends BaseTestCase { @Test public void test() { - + ResetBasicData.reset(); - - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); - + + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); + BeanDescriptor descOrder = server.getBeanDescriptor(Order.class); - BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany)descOrder.getBeanProperty("details"); - + BeanPropertyAssocMany beanProperty = (BeanPropertyAssocMany) descOrder.getBeanProperty("details"); + List parentIds = new ArrayList<>(); parentIds.add(1); - - - List orders = - Ebean.find(Order.class) - .where().lt("id", 4) - .findList(); - + + + List orders = + Ebean.find(Order.class) + .where().lt("id", 4) + .findList(); + for (Order order : orders) { List details = order.getDetails(); System.out.println(details.size()); } - - - + + // start transaction to keep PC going to lazy query Ebean.beginTransaction(); try { Ebean.find(Order.class, 1); - - SpiQuery query0 = (SpiQuery)Ebean.find(OrderDetail.class); - + + SpiQuery query0 = (SpiQuery) Ebean.find(OrderDetail.class); + query0.setLazyLoadForParents(beanProperty); - + beanProperty.addWhereParentIdIn(query0, parentIds, false); - + query0.findList(); assertThat(query0.getGeneratedSql()).contains(" from o_order_detail t0 where (t0.order_id) in ("); } finally { Ebean.endTransaction(); } - + List details = Ebean.find(OrderDetail.class) .where().eq("order.id", 1) .findList(); - + for (OrderDetail orderDetail : details) { - System.out.println(orderDetail); + System.out.println(orderDetail); } - + } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestManyToManyLazyLoading.java b/src/test/java/com/avaje/tests/query/other/TestManyToManyLazyLoading.java index 3bdad0fc0..aac6b3cd4 100644 --- a/src/test/java/com/avaje/tests/query/other/TestManyToManyLazyLoading.java +++ b/src/test/java/com/avaje/tests/query/other/TestManyToManyLazyLoading.java @@ -1,31 +1,30 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.MRole; import com.avaje.tests.model.basic.MUser; +import org.junit.Test; -public class TestManyToManyLazyLoading extends BaseTestCase { +import java.util.List; + +public class TestManyToManyLazyLoading extends BaseTestCase { @Test public void test() { - + createData(); - + List users = Ebean.find(MUser.class).findList(); - + for (MUser user : users) { List roles = user.getRoles(); roles.size(); } - + } - - private void createData() { + + private void createData() { MRole r0 = new MRole("r0"); MRole r1 = new MRole("r1"); @@ -38,5 +37,5 @@ public class TestManyToManyLazyLoading extends BaseTestCase { Ebean.save(u0); } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestObjectGraphNodeStatsCollection.java b/src/test/java/com/avaje/tests/query/other/TestObjectGraphNodeStatsCollection.java index 9decc1dff..5539a1a8c 100644 --- a/src/test/java/com/avaje/tests/query/other/TestObjectGraphNodeStatsCollection.java +++ b/src/test/java/com/avaje/tests/query/other/TestObjectGraphNodeStatsCollection.java @@ -1,10 +1,5 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -16,20 +11,24 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestObjectGraphNodeStatsCollection extends BaseTestCase { @Test public void test() { - + ResetBasicData.reset(); - + EbeanServer server = Ebean.getServer(null); - + MetaInfoManager infoManager = server.getMetaInfoManager(); - + server.find(Order.class).findCount(); - + infoManager.collectNodeStatistics(true); infoManager.collectQueryPlanStatistics(true); @@ -45,7 +44,7 @@ public class TestObjectGraphNodeStatsCollection extends BaseTestCase { for (MetaQueryPlanStatistic planStatistic : planStatistics) { planStatistic.getSql(); } - + } private void runFindCustomerQuery(EbeanServer server) { @@ -54,22 +53,22 @@ public class TestObjectGraphNodeStatsCollection extends BaseTestCase { .select("name") .fetch("contacts") .findList(); - + Assert.assertTrue(!customers.isEmpty()); - + List custs = server.find(Customer.class).select("name").findList(); for (Customer customer : custs) { customer.getShippingAddress(); } } - + private void runFindOrderQuery(EbeanServer server) { List orders = server.find(Order.class) .where().gt("id", 0) .order().asc("orderDate") .setMaxRows(40) .findList(); - + for (Order order : orders) { Customer customer = order.getCustomer(); Address billingAddress = customer.getBillingAddress(); @@ -85,19 +84,19 @@ public class TestObjectGraphNodeStatsCollection extends BaseTestCase { orderDetail.getUnitPrice(); orderDetail.getProduct().getName(); } - + } - + } - + @Test public void testFindByIds() { - + ResetBasicData.reset(); - + List ids = Ebean.find(Order.class).findIds(); Assert.assertTrue(!ids.isEmpty()); - + } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestOneToManyAsMap.java b/src/test/java/com/avaje/tests/query/other/TestOneToManyAsMap.java index 4fa20a0d5..5e4a17da8 100644 --- a/src/test/java/com/avaje/tests/query/other/TestOneToManyAsMap.java +++ b/src/test/java/com/avaje/tests/query/other/TestOneToManyAsMap.java @@ -1,15 +1,14 @@ package com.avaje.tests.query.other; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.tests.model.map.MpRole; import com.avaje.tests.model.map.MpUser; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Map; public class TestOneToManyAsMap extends BaseTestCase { @@ -35,12 +34,12 @@ public class TestOneToManyAsMap extends BaseTestCase { Map listMap = u3.getRoles(); Assert.assertEquals(1, listMap.size()); - + MpRole mpRole = listMap.get("one"); Assert.assertNotNull(mpRole); Assert.assertEquals(Long.valueOf(47L), mpRole.getOrganizationId()); Assert.assertEquals("one", mpRole.getCode()); - + } } diff --git a/src/test/java/com/avaje/tests/query/other/TestQueryConversationRowCount.java b/src/test/java/com/avaje/tests/query/other/TestQueryConversationRowCount.java index e93fa3617..a686bef08 100644 --- a/src/test/java/com/avaje/tests/query/other/TestQueryConversationRowCount.java +++ b/src/test/java/com/avaje/tests/query/other/TestQueryConversationRowCount.java @@ -1,64 +1,63 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.converstation.Conversation; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryConversationRowCount extends BaseTestCase { @Test public void test() { - + //"find conversation where club = :clubId and ( ( isPublic = :false and participants.user.id = :userId ) or isPublic = :true ) order by createdAt desc "; //"find conversation where groupId = :groupId and ( ( open = :false and participants.user.id = :userId ) or open = :true ) order by whenCreated desc "; - + Long groupId = 1L; Long userId = 1L; - + Query query = Ebean.find(Conversation.class) .where().eq("group.id", groupId) .disjunction() - .conjunction() - .eq("open", false).eq("participants.user.id", userId) - .endJunction() - .eq("open", true) + .conjunction() + .eq("open", false).eq("participants.user.id", userId) + .endJunction() + .eq("open", true) .endJunction() .orderBy("whenCreated desc"); - + query.findList(); String generatedSql = sqlOf(query, 1); - - // select distinct t0.id c0, t0.title c1, t0.open c2, t0.version c3, t0.when_created c4, t0.when_updated c5, t0.group_id c6, t0.when_created - // from c_conversation t0 + + // select distinct t0.id c0, t0.title c1, t0.open c2, t0.version c3, t0.when_created c4, t0.when_updated c5, t0.group_id c6, t0.when_created + // from c_conversation t0 // left join c_participation u1 on u1.conversation_id = t0.id - // where t0.group_id = ? and ((t0.open = ? and u1.user_id = ? ) or t0.open = ? ) - // order by t0.when_created desc; + // where t0.group_id = ? and ((t0.open = ? and u1.user_id = ? ) or t0.open = ? ) + // order by t0.when_created desc; Assert.assertTrue(generatedSql.contains("select distinct t0.id, t0.title, t0.isopen")); Assert.assertTrue(generatedSql.contains("left join c_participation u1 on u1.conversation_id = t0.id")); Assert.assertTrue(generatedSql.contains("where t0.group_id = ? and ((t0.isopen = ? and u1.user_id = ? ) or t0.isopen = ? )")); - + LoggedSqlCollector.start(); query.findCount(); - // select count(*) from ( - // select distinct t0.id c0 - // from c_conversation t0 + // select count(*) from ( + // select distinct t0.id c0 + // from c_conversation t0 // left join c_participation u1 on u1.conversation_id = t0.id - // where t0.group_id = ? and ((t0.open = ? and u1.user_id = ? ) or t0.open = ? ) + // where t0.group_id = ? and ((t0.open = ? and u1.user_id = ? ) or t0.open = ? ) // ); --bind(1,true,1,true) - + List loggedSql = LoggedSqlCollector.stop(); Assert.assertEquals(1, loggedSql.size()); - + String countSql = trimSql(loggedSql.get(0), 0); Assert.assertTrue(countSql.contains("select count(*) from ( select distinct t0.id from c_conversation t0 left join c_participation u1 on u1.conversation_id = t0.id where t0.group_id = ? and ((t0.isopen = ? and u1.user_id = ? ) or t0.isopen = ? )")); } diff --git a/src/test/java/com/avaje/tests/query/other/TestQueryDistinct.java b/src/test/java/com/avaje/tests/query/other/TestQueryDistinct.java index 1e02c5a28..d9b9ceddc 100644 --- a/src/test/java/com/avaje/tests/query/other/TestQueryDistinct.java +++ b/src/test/java/com/avaje/tests/query/other/TestQueryDistinct.java @@ -20,24 +20,24 @@ public class TestQueryDistinct extends BaseTestCase { @Test public void test() { - + ResetBasicData.reset(); - + Query query = Ebean.find(Customer.class) .setDistinct(true) .select("name"); - + List customers = query.findList(); - + String generatedSql = sqlOf(query); assertThat(generatedSql).contains("select distinct t0.name from o_customer t0"); - + for (Customer customer : customers) { - - EntityBeanIntercept ebi = ((EntityBean)customer)._ebean_getIntercept(); + + EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept(); assertTrue(ebi.isDisableLazyLoad()); assertNull(ebi.getPersistenceContext()); - + // lazy loading disabled assertNull(customer.getId()); assertNull(customer.getAnniversary()); @@ -50,34 +50,34 @@ public class TestQueryDistinct extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .where().setDistinct(true) - .select("name"); + .where().setDistinct(true) + .select("name"); query.findList(); String generatedSql = sqlOf(query); assertThat(generatedSql).contains("select distinct t0.name from o_customer t0"); } - + @Test public void testDistinctStatus() { - + ResetBasicData.reset(); - + Query query = Ebean.find(Customer.class) .setDistinct(true) .select("status") .where().isNotNull("status").query(); - + List customers = query.findList(); - + String generatedSql = sqlOf(query); assertThat(generatedSql).contains("select distinct t0.status from o_customer t0"); - + for (Customer customer : customers) { - + assertNotNull(customer.getStatus()); - + // lazy loading disabled assertNull(customer.getId()); assertNull(customer.getAnniversary()); @@ -101,5 +101,5 @@ public class TestQueryDistinct extends BaseTestCase { assertThat(generatedSql).contains("select distinct t0.name from o_customer t0 limit 10"); } } - + } diff --git a/src/test/java/com/avaje/tests/query/other/TestQueryRawExpressionMany.java b/src/test/java/com/avaje/tests/query/other/TestQueryRawExpressionMany.java index e55e5606e..4ac173387 100644 --- a/src/test/java/com/avaje/tests/query/other/TestQueryRawExpressionMany.java +++ b/src/test/java/com/avaje/tests/query/other/TestQueryRawExpressionMany.java @@ -22,8 +22,8 @@ public class TestQueryRawExpressionMany extends BaseTestCase { Integer quantity = 1; Query query = Ebean.find(Order.class) - .where().raw("details.orderQty = ?", quantity) - .query(); + .where().raw("details.orderQty = ?", quantity) + .query(); LoggedSqlCollector.start(); diff --git a/src/test/java/com/avaje/tests/query/other/TestQueryRowCountWithMany.java b/src/test/java/com/avaje/tests/query/other/TestQueryRowCountWithMany.java index 5885d196a..6546411ee 100644 --- a/src/test/java/com/avaje/tests/query/other/TestQueryRowCountWithMany.java +++ b/src/test/java/com/avaje/tests/query/other/TestQueryRowCountWithMany.java @@ -1,16 +1,15 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestQueryRowCountWithMany extends BaseTestCase { @@ -24,21 +23,21 @@ public class TestQueryRowCountWithMany extends BaseTestCase { Long productId = 1L; Query query = Ebean.find(Order.class) - .fetch("details") - .where().eq("details.product.id", productId) - .orderBy("cretime asc"); + .fetch("details") + .where().eq("details.product.id", productId) + .orderBy("cretime asc"); List list = query.findList(); - // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t2.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, - // t1.id c8, t1.order_qty c9, t1.ship_qty c10, t1.unit_price c11, t1.cretime c12, t1.updtime c13, t1.order_id c14, t1.product_id c15, t0.cretime, t0.id, t1.id, t1.order_qty, t1.cretime - // from o_order t0 - // join o_customer t2 on t2.id = t0.kcustomer_id + // select distinct t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t2.name c4, t0.cretime c5, t0.updtime c6, t0.kcustomer_id c7, + // t1.id c8, t1.order_qty c9, t1.ship_qty c10, t1.unit_price c11, t1.cretime c12, t1.updtime c13, t1.order_id c14, t1.product_id c15, t0.cretime, t0.id, t1.id, t1.order_qty, t1.cretime + // from o_order t0 + // join o_customer t2 on t2.id = t0.kcustomer_id // left join o_order_detail t1 on t1.order_id = t0.id - // join o_order_detail u1 on u1.order_id = t0.id - // where t1.id > 0 and u1.product_id = ? + // join o_order_detail u1 on u1.order_id = t0.id + // where t1.id > 0 and u1.product_id = ? // order by t0.cretime, t0.id, t1.id asc, t1.order_qty asc, t1.cretime desc; --bind(1) - + String generatedSql = sqlOf(query, 1); Assert.assertTrue(generatedSql.contains("select distinct t0.id, t0.status,")); // need the distinct Assert.assertTrue(generatedSql.contains("left join o_order_detail t1 on t1.order_id = t0.id")); //fetch join @@ -46,7 +45,7 @@ public class TestQueryRowCountWithMany extends BaseTestCase { Assert.assertTrue(generatedSql.contains(" u1.product_id = ?")); // u1 as predicate alias Assert.assertTrue(generatedSql.contains(" order by t0.cretime")); - + int rowCount = query.findCount(); // select count(*) from o_order t0 @@ -63,12 +62,11 @@ public class TestQueryRowCountWithMany extends BaseTestCase { Assert.assertEquals(list.size(), rowCount); Assert.assertEquals(2, sqlLogged.size()); Assert.assertTrue(trimSql(sqlLogged.get(1), 1).contains( - "select count(*) from ( select distinct t0.id from o_order t0 join o_order_detail u1 on u1.order_id = t0.id where u1.product_id = ? )")); + "select count(*) from ( select distinct t0.id from o_order t0 join o_order_detail u1 on u1.order_id = t0.id where u1.product_id = ? )")); } - @Test public void testWithFirstRowsMaxRows() { @@ -77,11 +75,11 @@ public class TestQueryRowCountWithMany extends BaseTestCase { Long productId = 1L; Query query = Ebean.find(Order.class) - .fetch("details") - .where().eq("details.product.id", productId) - .setFirstRow(2) - .setMaxRows(20) - .orderBy("cretime asc"); + .fetch("details") + .where().eq("details.product.id", productId) + .setFirstRow(2) + .setMaxRows(20) + .orderBy("cretime asc"); LoggedSqlCollector.start(); query.findCount(); diff --git a/src/test/java/com/avaje/tests/query/other/TestQuerySingleAttribute.java b/src/test/java/com/avaje/tests/query/other/TestQuerySingleAttribute.java index f6103f1d4..dff521e02 100644 --- a/src/test/java/com/avaje/tests/query/other/TestQuerySingleAttribute.java +++ b/src/test/java/com/avaje/tests/query/other/TestQuerySingleAttribute.java @@ -21,13 +21,13 @@ public class TestQuerySingleAttribute extends BaseTestCase { ResetBasicData.reset(); List names = - Ebean.find(Customer.class) - .setDistinct(true) - .select("name") - .where().eq("status", Customer.Status.NEW) - .orderBy().asc("name") - .setMaxRows(100) - .findSingleAttributeList(); + Ebean.find(Customer.class) + .setDistinct(true) + .select("name") + .where().eq("status", Customer.Status.NEW) + .orderBy().asc("name") + .setMaxRows(100) + .findSingleAttributeList(); assertThat(names).isNotNull(); } @@ -38,12 +38,12 @@ public class TestQuerySingleAttribute extends BaseTestCase { ResetBasicData.reset(); List dates = - Ebean.find(Customer.class) - .setDistinct(true) - .select("anniversary") - .where().isNotNull("anniversary") - .orderBy().asc("anniversary") - .findSingleAttributeList(); + Ebean.find(Customer.class) + .setDistinct(true) + .select("anniversary") + .where().isNotNull("anniversary") + .orderBy().asc("anniversary") + .findSingleAttributeList(); assertThat(dates).isNotNull(); } @@ -52,12 +52,12 @@ public class TestQuerySingleAttribute extends BaseTestCase { public void withOrderBy() { Query query = - Ebean.find(Customer.class) - .setDistinct(true) - .select("name") - .where().eq("status", Customer.Status.NEW) - .orderBy().asc("name") - .setMaxRows(100); + Ebean.find(Customer.class) + .setDistinct(true) + .select("name") + .where().eq("status", Customer.Status.NEW) + .orderBy().asc("name") + .setMaxRows(100); query.findSingleAttributeList(); assertThat(sqlOf(query)).contains("select distinct t0.name from o_customer t0 where t0.status = ? order by t0.name "); @@ -82,10 +82,10 @@ public class TestQuerySingleAttribute extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .setDistinct(true) - .select("name") - .where().eq("status", Customer.Status.NEW) - .query(); + .setDistinct(true) + .select("name") + .where().eq("status", Customer.Status.NEW) + .query(); List names = query.findSingleAttributeList(); @@ -99,11 +99,11 @@ public class TestQuerySingleAttribute extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .setDistinct(true) - .select("name") - .where().eq("status", Customer.Status.NEW) - .istartsWith("billingAddress.city", "auck") - .query(); + .setDistinct(true) + .select("name") + .where().eq("status", Customer.Status.NEW) + .istartsWith("billingAddress.city", "auck") + .query(); List names = query.findSingleAttributeList(); diff --git a/src/test/java/com/avaje/tests/query/other/TestSelfParent.java b/src/test/java/com/avaje/tests/query/other/TestSelfParent.java index 7e8e35306..633919629 100644 --- a/src/test/java/com/avaje/tests/query/other/TestSelfParent.java +++ b/src/test/java/com/avaje/tests/query/other/TestSelfParent.java @@ -1,13 +1,12 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.selfref.SelfParent; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestSelfParent extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/other/TestSubQueryBinding.java b/src/test/java/com/avaje/tests/query/other/TestSubQueryBinding.java index 9537a4361..91106d2a5 100644 --- a/src/test/java/com/avaje/tests/query/other/TestSubQueryBinding.java +++ b/src/test/java/com/avaje/tests/query/other/TestSubQueryBinding.java @@ -1,13 +1,12 @@ package com.avaje.tests.query.other; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Expression; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Customer; +import org.junit.Test; public class TestSubQueryBinding extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/query/other/TestWhereAnnotation.java b/src/test/java/com/avaje/tests/query/other/TestWhereAnnotation.java index 7d5410321..e9d9fa721 100644 --- a/src/test/java/com/avaje/tests/query/other/TestWhereAnnotation.java +++ b/src/test/java/com/avaje/tests/query/other/TestWhereAnnotation.java @@ -1,54 +1,53 @@ package com.avaje.tests.query.other; -import java.util.List; - -import org.avaje.ebeantest.LoggedSqlCollector; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.avaje.ebeantest.LoggedSqlCollector; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestWhereAnnotation extends BaseTestCase { @Test - public void fetchEager_inFirstQuery(){ - + public void fetchEager_inFirstQuery() { + ResetBasicData.reset(); - + LoggedSqlCollector.start(); - + Ebean.find(Customer.class) .fetch("orders") .findList(); - + List loggedSql = LoggedSqlCollector.stop(); - + Assert.assertEquals(1, loggedSql.size()); - + String sql = loggedSql.get(0); Assert.assertTrue(sql.contains("t1.order_date is not null")); } @Test - public void fetchLazy_inLazyLoadQuery(){ - + public void fetchLazy_inLazyLoadQuery() { + ResetBasicData.reset(); - + LoggedSqlCollector.start(); - + List customers = Ebean.find(Customer.class).findList(); - + List orders = customers.get(0).getOrders(); orders.size(); - + List loggedSql = LoggedSqlCollector.stop(); - + Assert.assertEquals(2, loggedSql.size()); - + String sql = loggedSql.get(1); Assert.assertTrue(sql.contains("t0.order_date is not null")); } diff --git a/src/test/java/com/avaje/tests/query/other/TestWhereLikeWithSlash.java b/src/test/java/com/avaje/tests/query/other/TestWhereLikeWithSlash.java index 285053af8..4090bf56d 100644 --- a/src/test/java/com/avaje/tests/query/other/TestWhereLikeWithSlash.java +++ b/src/test/java/com/avaje/tests/query/other/TestWhereLikeWithSlash.java @@ -6,16 +6,14 @@ import com.avaje.ebean.Query; import com.avaje.tests.model.basic.EBasic; import org.junit.Test; -import java.util.List; - -public class TestWhereLikeWithSlash extends BaseTestCase { +public class TestWhereLikeWithSlash extends BaseTestCase { @Test public void test() { - + EBasic basic = new EBasic(); basic.setName("slash\\monkey"); - + Ebean.save(basic); Query query = Ebean.find(EBasic.class).where().like("name", "slash\\mon%").query(); @@ -25,5 +23,5 @@ public class TestWhereLikeWithSlash extends BaseTestCase { // Still good on Postgres which was the original issue //Assert.assertEquals(1, list.size()); } - + } diff --git a/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java b/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java index a0ba745c8..2428bf0dd 100644 --- a/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java +++ b/src/test/java/com/avaje/tests/query/softdelete/TestSoftDeletePagingList.java @@ -28,9 +28,9 @@ public class TestSoftDeletePagingList extends BaseTestCase { LoggedSqlCollector.start(); PagedList pagedList = Ebean.find(Cover.class) - .where().startsWith("s3Url", "SoftDelPaged-") - .setMaxRows(10) - .findPagedList(); + .where().startsWith("s3Url", "SoftDelPaged-") + .setMaxRows(10) + .findPagedList(); int totalRowCount = pagedList.getTotalCount(); List resultList = pagedList.getList(); diff --git a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java index 83c0db136..09d234d62 100644 --- a/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java +++ b/src/test/java/com/avaje/tests/query/sqlquery/SqlQueryTests.java @@ -2,8 +2,6 @@ package com.avaje.tests.query.sqlquery; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; -import com.avaje.ebean.QueryEachConsumer; -import com.avaje.ebean.QueryEachWhileConsumer; import com.avaje.ebean.SqlQuery; import com.avaje.ebean.SqlRow; import com.avaje.tests.model.basic.Order; diff --git a/src/test/java/com/avaje/tests/query/sqlquery/TestNativeILikeExpression.java b/src/test/java/com/avaje/tests/query/sqlquery/TestNativeILikeExpression.java index ff07ddf86..e9a35e621 100644 --- a/src/test/java/com/avaje/tests/query/sqlquery/TestNativeILikeExpression.java +++ b/src/test/java/com/avaje/tests/query/sqlquery/TestNativeILikeExpression.java @@ -22,8 +22,8 @@ public class TestNativeILikeExpression extends BaseTestCase { ResetBasicData.reset(); Query query = Ebean.find(Customer.class) - .where().ilike("name", "rob") - .query(); + .where().ilike("name", "rob") + .query(); List list = query.findList(); diff --git a/src/test/java/com/avaje/tests/rawsql/TestInsertSqlLogging.java b/src/test/java/com/avaje/tests/rawsql/TestInsertSqlLogging.java index c5cf75e31..d2f4b39ad 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestInsertSqlLogging.java +++ b/src/test/java/com/avaje/tests/rawsql/TestInsertSqlLogging.java @@ -1,11 +1,10 @@ package com.avaje.tests.rawsql; -import com.avaje.tests.idkeys.db.AuditLog; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlUpdate; +import com.avaje.tests.idkeys.db.AuditLog; +import org.junit.Test; public class TestInsertSqlLogging extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/rawsql/TestOrderReportTotal.java b/src/test/java/com/avaje/tests/rawsql/TestOrderReportTotal.java index d114541df..04bf37a23 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestOrderReportTotal.java +++ b/src/test/java/com/avaje/tests/rawsql/TestOrderReportTotal.java @@ -40,9 +40,9 @@ public class TestOrderReportTotal extends BaseTestCase { private RawSql getRawSql() { String sql = - "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + - "from o_order_detail \n" + - "group by order_id"; + "select order_id, count(*) as totalItems, sum(order_qty*unit_price) as totalAmount \n" + + "from o_order_detail \n" + + "group by order_id"; return RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id").create(); } @@ -53,10 +53,10 @@ public class TestOrderReportTotal extends BaseTestCase { ResetBasicData.reset(); int detailsCount = Ebean.find(OrderDetail.class) - .where() - .gt("order.id", 2) - .istartsWith("order.customer.name","rob") - .findCount(); + .where() + .gt("order.id", 2) + .istartsWith("order.customer.name", "rob") + .findCount(); assertThat(detailsCount).isGreaterThan(0); } diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlAsKeyword.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlAsKeyword.java index 0222d82d2..652283f59 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlAsKeyword.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlAsKeyword.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -12,71 +7,75 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlAsKeyword extends BaseTestCase { - + @Test public void test() { // Make this false to run this test ... as the pipe string concatenation syntax is DB specific boolean skipTestAsDBSpecficSQL = true; - + if (skipTestAsDBSpecficSQL) { - + return; } - - ResetBasicData.reset(); - - - // try valid query where spaces in the formula ... - RawSql rawSql = - RawSqlBuilder - .parse("select r.id, r.name || 'hello' as name from o_customer r ") - .create(); - - Query query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.where().ilike("name", "r%"); - - List list = query.findList(); - Assert.assertNotNull(list); - - - // try valid query with no spaces - rawSql = - RawSqlBuilder - .parse("select r.id, r.name||'hello' as name from o_customer r ") - .create(); - - query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.where().ilike("name", "r%"); - - list = query.findList(); - Assert.assertNotNull(list); - - rawSql = - RawSqlBuilder - .parse("select r.id, r.name||'hello' name from o_customer r ") - .create(); - query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.where().ilike("name", "r%"); - - list = query.findList(); - Assert.assertNotNull(list); - - // this will barf - expecting the AS keyword now - rawSql = - RawSqlBuilder - .parse("select r.id, r.name || 'hello' name from o_customer r ") - .create(); - query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.where().ilike("name", "r%"); - - list = query.findList(); - Assert.assertNotNull(list); + + ResetBasicData.reset(); + + + // try valid query where spaces in the formula ... + RawSql rawSql = + RawSqlBuilder + .parse("select r.id, r.name || 'hello' as name from o_customer r ") + .create(); + + Query query = Ebean.find(Customer.class); + query.setRawSql(rawSql); + query.where().ilike("name", "r%"); + + List list = query.findList(); + Assert.assertNotNull(list); + + + // try valid query with no spaces + rawSql = + RawSqlBuilder + .parse("select r.id, r.name||'hello' as name from o_customer r ") + .create(); + + query = Ebean.find(Customer.class); + query.setRawSql(rawSql); + query.where().ilike("name", "r%"); + + list = query.findList(); + Assert.assertNotNull(list); + + rawSql = + RawSqlBuilder + .parse("select r.id, r.name||'hello' name from o_customer r ") + .create(); + query = Ebean.find(Customer.class); + query.setRawSql(rawSql); + query.where().ilike("name", "r%"); + + list = query.findList(); + Assert.assertNotNull(list); + + // this will barf - expecting the AS keyword now + rawSql = + RawSqlBuilder + .parse("select r.id, r.name || 'hello' name from o_customer r ") + .create(); + query = Ebean.find(Customer.class); + query.setRawSql(rawSql); + query.where().ilike("name", "r%"); + + list = query.findList(); + Assert.assertNotNull(list); } } diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlCustomerAggregate.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlCustomerAggregate.java index 9aa2ea8cd..98074dfa9 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlCustomerAggregate.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlCustomerAggregate.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -12,6 +7,10 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.CustomerAggregate; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlCustomerAggregate extends BaseTestCase { @@ -21,9 +20,9 @@ public class TestRawSqlCustomerAggregate extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder - .parse( - "select c.customer_id, count(*) as totalContacts from contact c group by c.customer_id") - .columnMapping("c.customer_id", "customer.id").create(); + .parse( + "select c.customer_id, count(*) as totalContacts from contact c group by c.customer_id") + .columnMapping("c.customer_id", "customer.id").create(); Query query = Ebean.find(CustomerAggregate.class); query.setRawSql(rawSql); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java index 1a1e7639f..561f91294 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlMasterDetail.java @@ -15,9 +15,7 @@ import java.util.List; import java.util.Random; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.*; public class TestRawSqlMasterDetail extends BaseTestCase { @@ -26,30 +24,30 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); - String rs = "select t0.id, t0.status, t1.id, t1.name, "+ - " t2.id, t2.order_qty, t3.id, t3.name " + - "from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id " + - "join o_order_detail t2 on t2.order_id = t0.id " + - "join o_product t3 on t3.id = t2.product_id " + - "where t0.id <= :maxOrderId and t3.id = :productId "+ - "order by t0.id, t2.id asc"; + String rs = "select t0.id, t0.status, t1.id, t1.name, " + + " t2.id, t2.order_qty, t3.id, t3.name " + + "from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id " + + "join o_order_detail t2 on t2.order_id = t0.id " + + "join o_product t3 on t3.id = t2.product_id " + + "where t0.id <= :maxOrderId and t3.id = :productId " + + "order by t0.id, t2.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .columnMapping("t0.id", "id") - .columnMapping("t0.status", "status") - .columnMapping("t1.id", "customer.id") - .columnMapping("t1.name", "customer.name") - .columnMapping("t2.id", "details.id") - .columnMapping("t2.order_qty", "details.orderQty") - .columnMapping("t3.id", "details.product.id") - .columnMapping("t3.name", "details.product.name") - .create(); + .columnMapping("t0.id", "id") + .columnMapping("t0.status", "status") + .columnMapping("t1.id", "customer.id") + .columnMapping("t1.name", "customer.name") + .columnMapping("t2.id", "details.id") + .columnMapping("t2.order_qty", "details.orderQty") + .columnMapping("t3.id", "details.product.id") + .columnMapping("t3.name", "details.product.name") + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .setParameter("maxOrderId", 2) - .setParameter("productId", 1) - .findList(); + .setRawSql(rawSql) + .setParameter("maxOrderId", 2) + .setParameter("productId", 1) + .findList(); printOrders(ordersFromRaw, "using RawSql"); @@ -63,15 +61,15 @@ public class TestRawSqlMasterDetail extends BaseTestCase { // billing_address_id fk column is automatically // mapped to the logical path: billingAddress.id - String rs = "select c.id, c.name, c.billing_address_id, c.updtime "+ - "from o_customer c " + - "order by c.id"; + String rs = "select c.id, c.name, c.billing_address_id, c.updtime " + + "from o_customer c " + + "order by c.id"; RawSql rawSql = RawSqlBuilder.parse(rs).create(); List customers = Ebean.find(Customer.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); assertThat(customers).isNotEmpty(); } @@ -82,18 +80,18 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); - String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime "+ - "from o_customer c " + - " left join o_address ba on ba.id = c.billing_address_id "+ - "order by c.id"; + String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime " + + "from o_customer c " + + " left join o_address ba on ba.id = c.billing_address_id " + + "order by c.id"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("ba", "billingAddress") - .create(); + .tableAliasMapping("ba", "billingAddress") + .create(); List customers = Ebean.find(Customer.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); assertThat(customers).isNotEmpty(); } @@ -103,20 +101,20 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); - String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime, sa.id, sa.line_1, sa.city "+ - "from o_customer c " + - " left join o_address ba on ba.id = c.billing_address_id "+ - " left join o_address sa on sa.id = c.shipping_address_id "+ - "order by c.id"; + String rs = "select c.id, c.name, c.billing_address_id, ba.line_1, ba.city, c.updtime, sa.id, sa.line_1, sa.city " + + "from o_customer c " + + " left join o_address ba on ba.id = c.billing_address_id " + + " left join o_address sa on sa.id = c.shipping_address_id " + + "order by c.id"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("ba", "billingAddress") - .tableAliasMapping("sa", "shippingAddress") - .create(); + .tableAliasMapping("ba", "billingAddress") + .tableAliasMapping("sa", "shippingAddress") + .create(); List customers = Ebean.find(Customer.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); assertThat(customers).isNotEmpty(); } @@ -126,26 +124,26 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); - String rs = "select o.id, o.status, c.id, c.name, "+ - " d.id, d.order_qty, p.id, p.name " + - "from o_order o join o_customer c on c.id = o.kcustomer_id " + - "join o_order_detail d on d.order_id = o.id " + - "join o_product p on p.id = d.product_id " + - "where o.id <= :maxOrderId and p.id = :productId "+ - "order by o.id, d.id asc"; + String rs = "select o.id, o.status, c.id, c.name, " + + " d.id, d.order_qty, p.id, p.name " + + "from o_order o join o_customer c on c.id = o.kcustomer_id " + + "join o_order_detail d on d.order_id = o.id " + + "join o_product p on p.id = d.product_id " + + "where o.id <= :maxOrderId and p.id = :productId " + + "order by o.id, d.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("c", "customer") - .tableAliasMapping("d", "details") - .tableAliasMapping("p", "details.product") - .create(); + .tableAliasMapping("c", "customer") + .tableAliasMapping("d", "details") + .tableAliasMapping("p", "details.product") + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .setParameter("maxOrderId", 2) - .setParameter("productId", 1) - .findList(); + .setRawSql(rawSql) + .setParameter("maxOrderId", 2) + .setParameter("productId", 1) + .findList(); printOrders(ordersFromRaw, "using RawSql with tableAlias mapping"); @@ -154,7 +152,7 @@ public class TestRawSqlMasterDetail extends BaseTestCase { @Test public void testWithNoIdPropertyWithInsert() { - String name = "RawSql-NoIdTest"+new Random().nextInt(); + String name = "RawSql-NoIdTest" + new Random().nextInt(); EBasic basic = new EBasic(); basic.setName(name); basic.setStatus(EBasic.Status.ACTIVE); @@ -166,9 +164,9 @@ public class TestRawSqlMasterDetail extends BaseTestCase { RawSql rawSql = RawSqlBuilder.parse(rs).create(); List list = Ebean.find(EBasic.class) - .setRawSql(rawSql) - .where().eq("name", name) - .findList(); + .setRawSql(rawSql) + .where().eq("name", name) + .findList(); assertEquals(1, list.size()); EBasic basic1 = list.get(0); @@ -185,11 +183,11 @@ public class TestRawSqlMasterDetail extends BaseTestCase { String rs = "select o.status, o.order_date from o_order o "; RawSql rawSql = RawSqlBuilder.parse(rs) - .create(); + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); assertNotNull(ordersFromRaw); assertFalse(ordersFromRaw.isEmpty()); @@ -201,14 +199,14 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); String rs = "select o.id, o.status " + - "from o_order o order by o.id asc"; + "from o_order o order by o.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .create(); + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); for (Order order : ordersFromRaw) { assertThat(order.getId()).isNotNull(); @@ -223,15 +221,15 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); String rs = "select o.id, o.status " + - "from o_order o order by o.id asc"; + "from o_order o order by o.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("o", null) - .create(); + .tableAliasMapping("o", null) + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); for (Order order : ordersFromRaw) { assertThat(order.getId()).isNotNull(); @@ -244,23 +242,23 @@ public class TestRawSqlMasterDetail extends BaseTestCase { ResetBasicData.reset(); - String rs = "select o.id, o.status, c.id, c.name, "+ - " d.id, d.order_qty, p.id, p.name " + - "from o_order o join o_customer c on c.id = o.kcustomer_id " + - "join o_order_detail d on d.order_id = o.id " + - "join o_product p on p.id = d.product_id " + - "order by o.id, d.id asc"; + String rs = "select o.id, o.status, c.id, c.name, " + + " d.id, d.order_qty, p.id, p.name " + + "from o_order o join o_customer c on c.id = o.kcustomer_id " + + "join o_order_detail d on d.order_id = o.id " + + "join o_product p on p.id = d.product_id " + + "order by o.id, d.id asc"; RawSql rawSql = RawSqlBuilder.parse(rs) - .tableAliasMapping("c", "customer") - .tableAliasMapping("d", "details") - .tableAliasMapping("p", "details.product") - .create(); + .tableAliasMapping("c", "customer") + .tableAliasMapping("d", "details") + .tableAliasMapping("p", "details.product") + .create(); List ordersFromRaw = Ebean.find(Order.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); printOrders(ordersFromRaw, "using RawSql with tableAlias mapping"); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlNamedParams.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlNamedParams.java index 423301bc1..d0add8794 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlNamedParams.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlNamedParams.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -12,6 +7,10 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlNamedParams extends BaseTestCase { @@ -21,8 +20,8 @@ public class TestRawSqlNamedParams extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder - .parse("select r.id, r.name from o_customer r where r.id > :id and r.name like :name") - .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); + .parse("select r.id, r.name from o_customer r where r.id > :id and r.name like :name") + .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQuery.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQuery.java index 2edb3f395..158d76c74 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQuery.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQuery.java @@ -1,12 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; -import java.util.concurrent.ExecutionException; - -import com.avaje.tests.model.basic.Order; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -16,7 +9,13 @@ import com.avaje.ebean.Query; import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; +import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; +import java.util.concurrent.ExecutionException; import static org.assertj.core.api.Assertions.assertThat; @@ -47,8 +46,8 @@ public class TestRawSqlOrmQuery extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder.parse("select r.id, r.name from o_customer r ") - .columnMapping("r.id", "id") - .columnMapping("r.name", "name").create(); + .columnMapping("r.id", "id") + .columnMapping("r.name", "name").create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); @@ -60,21 +59,21 @@ public class TestRawSqlOrmQuery extends BaseTestCase { List list = query.findList(); Assert.assertNotNull(list); } - + @Test public void testFirstRowsMaxRows() throws InterruptedException, ExecutionException { if (isMsSqlServer()) return; ResetBasicData.reset(); - - RawSql rawSql = - RawSqlBuilder - .parse("select r.id, r.name from o_customer r ") - .columnMapping("r.id", "id") - .columnMapping("r.name", "name") - .create(); - + + RawSql rawSql = + RawSqlBuilder + .parse("select r.id, r.name from o_customer r ") + .columnMapping("r.id", "id") + .columnMapping("r.name", "name") + .create(); + Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); @@ -83,40 +82,40 @@ public class TestRawSqlOrmQuery extends BaseTestCase { query.setFirstRow(1); query.setMaxRows(2); List list = query.findList(); - + int rowCount = query.findCount(); FutureRowCount futureRowCount = query.findFutureCount(); Assert.assertEquals(initialRowCount, rowCount); Assert.assertEquals(initialRowCount, futureRowCount.get().intValue()); - + // check that lazy loading still executes for (Customer customer : list) { customer.getCretime(); } - + } - + @Test public void testPaging() { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder.parse("select r.id, r.name from o_customer r ") - .columnMapping("r.id", "id") - .columnMapping("r.name", "name") - .create(); + .columnMapping("r.id", "id") + .columnMapping("r.name", "name") + .create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); - + int initialRowCount = query.findCount(); - + PagedList page = query.setMaxRows(2).findPagedList(); List list = page.getList(); int rowCount = page.getTotalCount(); - + Assert.assertEquals(2, list.size()); Assert.assertEquals(initialRowCount, rowCount); @@ -133,10 +132,10 @@ public class TestRawSqlOrmQuery extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder.parse("select o.id, o.order_date, o.ship_date from o_order o order by o.ship_date desc") - .columnMapping("o.id", "id") - .columnMapping("o.order_date", "orderDate") - .columnMapping("o.ship_date", "shipDate") - .create(); + .columnMapping("o.id", "id") + .columnMapping("o.order_date", "orderDate") + .columnMapping("o.ship_date", "shipDate") + .create(); Query query = Ebean.find(Order.class); query.setRawSql(rawSql); @@ -153,10 +152,10 @@ public class TestRawSqlOrmQuery extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder.parse("select o.id, o.order_date, o.ship_date from o_order o order by o.ship_date desc nulls last") - .columnMapping("o.id", "id") - .columnMapping("o.order_date", "orderDate") - .columnMapping("o.ship_date", "shipDate") - .create(); + .columnMapping("o.id", "id") + .columnMapping("o.order_date", "orderDate") + .columnMapping("o.ship_date", "shipDate") + .create(); Query query = Ebean.find(Order.class); query.setRawSql(rawSql); @@ -174,10 +173,10 @@ public class TestRawSqlOrmQuery extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder.parse("select o.id, o.order_date, o.ship_date from o_order o order by o.ship_date desc") - .columnMapping("o.id", "id") - .columnMapping("o.order_date", "orderDate") - .columnMapping("o.ship_date", "shipDate") - .create(); + .columnMapping("o.id", "id") + .columnMapping("o.order_date", "orderDate") + .columnMapping("o.ship_date", "shipDate") + .create(); Query query = Ebean.find(Order.class); query.setRawSql(rawSql); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQueryDistinct.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQueryDistinct.java index 33d1fc300..6c580f529 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQueryDistinct.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmQueryDistinct.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -13,6 +8,10 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlOrmQueryDistinct extends BaseTestCase { @@ -22,14 +21,14 @@ public class TestRawSqlOrmQueryDistinct extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql0 = RawSqlBuilder.parse(" select distinct r.id, r.name from o_customer r ") - .create(); + .create(); Query query0 = Ebean.find(Customer.class); query0.setRawSql(rawSql0); query0.where().ilike("name", "r%"); RawSql rawSql = RawSqlBuilder.parse(" select distinct r.id, r.name from o_customer r ") - .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); + .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper.java index bb7b7e7bf..21da0059f 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; @@ -12,9 +7,12 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.OrderAggregate; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlOrmWrapper extends BaseTestCase { @@ -24,21 +22,21 @@ public class TestRawSqlOrmWrapper extends BaseTestCase { ResetBasicData.reset(); String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount" - + " from o_order o" - + " join o_customer c on c.id = o.kcustomer_id " - + " join o_order_detail d on d.order_id = o.id " - + " group by order_id, o.status, c.id, c.name "; + + " from o_order o" + + " join o_customer c on c.id = o.kcustomer_id " + + " join o_order_detail d on d.order_id = o.id " + + " group by order_id, o.status, c.id, c.name "; RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id") - .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id") - .columnMapping("c.name", "order.customer.name") - // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") - .create(); + .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id") + .columnMapping("c.name", "order.customer.name") + // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") + .create(); Query query = Ebean.find(OrderAggregate.class); query.setRawSql(rawSql) - // .fetch("order.details", new FetchConfig().query()) - .where().gt("order.id", 0).having().gt("totalAmount", 20); + // .fetch("order.details", new FetchConfig().query()) + .where().gt("order.id", 0).having().gt("totalAmount", 20); List list = query.findList(); Assert.assertNotNull(list); @@ -46,8 +44,8 @@ public class TestRawSqlOrmWrapper extends BaseTestCase { output(list); List list2 = Ebean.find(OrderAggregate.class).setRawSql(rawSql) - // .fetch("order.details", new FetchConfig().query()) - .where().gt("order.id", 2).having().gt("totalAmount", 10).findList(); + // .fetch("order.details", new FetchConfig().query()) + .where().gt("order.id", 2).having().gt("totalAmount", 10).findList(); output(list2); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper2.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper2.java index 183a0dba1..845421677 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper2.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper2.java @@ -1,10 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -14,6 +9,10 @@ import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.OrderAggregate; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestRawSqlOrmWrapper2 extends BaseTestCase { @@ -23,18 +22,18 @@ public class TestRawSqlOrmWrapper2 extends BaseTestCase { ResetBasicData.reset(); String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount " - + " from o_order_detail d group by order_id "; + + " from o_order_detail d group by order_id "; RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id") - .columnMappingIgnore("'ignoreMe'") - // don't need this when using column alias - // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") - .create(); + .columnMappingIgnore("'ignoreMe'") + // don't need this when using column alias + // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") + .create(); Query query = Ebean.find(OrderAggregate.class); query.setRawSql(rawSql).fetch("order", "status,orderDate", new FetchConfig().query()) - .fetch("order.customer", "name").where().gt("order.id", 0).having().gt("totalAmount", 20) - .order().desc("totalAmount").setMaxRows(10); + .fetch("order.customer", "name").where().gt("order.id", 0).having().gt("totalAmount", 20) + .order().desc("totalAmount").setMaxRows(10); List list = query.findList(); Assert.assertNotNull(list); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper3.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper3.java index f69e8aacb..89b42312d 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper3.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlOrmWrapper3.java @@ -1,9 +1,5 @@ package com.avaje.tests.rawsql; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -11,9 +7,11 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; -import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.OrderAggregate; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.util.List; public class TestRawSqlOrmWrapper3 extends BaseTestCase { @@ -23,24 +21,24 @@ public class TestRawSqlOrmWrapper3 extends BaseTestCase { ResetBasicData.reset(); String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount" - + " from o_order o" - + " join o_customer c on c.id = o.kcustomer_id " - + " join o_order_detail d on d.order_id = o.id " - + " group by order_id, o.status, c.id, c.name "; + + " from o_order o" + + " join o_customer c on c.id = o.kcustomer_id " + + " join o_order_detail d on d.order_id = o.id " + + " group by order_id, o.status, c.id, c.name "; RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id") - .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id") - .columnMapping("c.name", "order.customer.name") - // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") - .create(); + .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id") + .columnMapping("c.name", "order.customer.name") + // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount") + .create(); List list2 = Ebean.find(OrderAggregate.class).setRawSql(rawSql) - .fetch("order", new FetchConfig().query()) - .fetch("order.details", new FetchConfig().query()) - .where().gt("order.id", 2) - .having().gt("totalAmount", 10) - .filterMany("order.details").gt("unitPrice", 2d) - .findList(); + .fetch("order", new FetchConfig().query()) + .fetch("order.details", new FetchConfig().query()) + .where().gt("order.id", 2) + .having().gt("totalAmount", 10) + .filterMany("order.details").gt("unitPrice", 2d) + .findList(); output(list2); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlPositionedParams.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlPositionedParams.java index 6ec2b6c75..aa4269f62 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlPositionedParams.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlPositionedParams.java @@ -21,8 +21,8 @@ public class TestRawSqlPositionedParams extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder - .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") - .create(); + .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") + .create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); @@ -41,9 +41,9 @@ public class TestRawSqlPositionedParams extends BaseTestCase { ResetBasicData.reset(); RawSql rawSql = RawSqlBuilder - .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") - .columnMapping("r.id", "id") - .columnMapping("r.name", "name").create(); + .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?") + .columnMapping("r.id", "id") + .columnMapping("r.name", "name").create(); Query query = Ebean.find(Customer.class); query.setRawSql(rawSql); diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlUnparsedQuery.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlUnparsedQuery.java index c2843b320..c16a74401 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlUnparsedQuery.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlUnparsedQuery.java @@ -1,6 +1,10 @@ package com.avaje.tests.rawsql; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.Query; +import com.avaje.ebean.RawSql; +import com.avaje.ebean.RawSqlBuilder; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; import org.junit.Assert; @@ -10,28 +14,28 @@ import java.util.List; public class TestRawSqlUnparsedQuery extends BaseTestCase { - @Test - public void testDoubleUnparsedQuery() { + @Test + public void testDoubleUnparsedQuery() { - // Checks for RawSql caching issue https://github.com/ebean-orm/avaje-ebeanorm/issues/259 - ResetBasicData.reset(); + // Checks for RawSql caching issue https://github.com/ebean-orm/avaje-ebeanorm/issues/259 + ResetBasicData.reset(); - test(); - test(); - } + test(); + test(); + } - private static void test() { - RawSql rawSql = RawSqlBuilder - .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b") - .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); + private static void test() { + RawSql rawSql = RawSqlBuilder + .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b") + .columnMapping("r.id", "id").columnMapping("r.name", "name").create(); - Query query = Ebean.find(Customer.class); - query.setRawSql(rawSql); - query.setParameter("a", 1); - query.setParameter("b", "R%"); + Query query = Ebean.find(Customer.class); + query.setRawSql(rawSql); + query.setParameter("a", 1); + query.setParameter("b", "R%"); - List list = query.findList(); - Assert.assertNotNull(list); - } + List list = query.findList(); + Assert.assertNotNull(list); + } } diff --git a/src/test/java/com/avaje/tests/rawsql/TestRawSqlWithResultSet.java b/src/test/java/com/avaje/tests/rawsql/TestRawSqlWithResultSet.java index 32bef08ef..122501d8d 100644 --- a/src/test/java/com/avaje/tests/rawsql/TestRawSqlWithResultSet.java +++ b/src/test/java/com/avaje/tests/rawsql/TestRawSqlWithResultSet.java @@ -1,13 +1,5 @@ package com.avaje.tests.rawsql; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.FetchConfig; @@ -15,30 +7,37 @@ import com.avaje.ebean.RawSql; import com.avaje.ebean.Transaction; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; public class TestRawSqlWithResultSet extends BaseTestCase { @Test public void test() throws SQLException { - + ResetBasicData.reset(); - + // Transaction supplies our jdbc Connection Transaction txn = Ebean.beginTransaction(); - + PreparedStatement pstmt = null; - + try { pstmt = txn.getConnection().prepareStatement("select id, name, billing_address_id from o_customer"); - + // ResultSet will be closed by Ebean ResultSet resultSet = pstmt.executeQuery(); - + RawSql rawSql = new RawSql(resultSet, "id", "name", "billingAddress.id"); - + List list = Ebean.find(Customer.class) .setRawSql(rawSql) - // also test a secondary query join + // also test a secondary query join .fetch("billingAddress", new FetchConfig().query()) .findList(); @@ -47,14 +46,14 @@ public class TestRawSqlWithResultSet extends BaseTestCase { customer.getName(); customer.getBillingAddress(); } - + } finally { close(pstmt); txn.end(); } - + } - + private static void close(Statement stmt) { if (stmt != null) { @@ -65,5 +64,5 @@ public class TestRawSqlWithResultSet extends BaseTestCase { } } } - + } diff --git a/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java b/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java index 6a867ac26..d7747f24d 100644 --- a/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java +++ b/src/test/java/com/avaje/tests/rawsql/inherit/ParentRawSqlTest.java @@ -16,9 +16,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ParentRawSqlTest extends BaseTestCase { @@ -43,12 +41,12 @@ public class ParentRawSqlTest extends BaseTestCase { Ebean.save(c); RawSql rawSql = RawSqlBuilder - .parse("select type, id, val from rawinherit_parent where val > 1") - .create(); + .parse("select type, id, val from rawinherit_parent where val > 1") + .create(); List partial = Ebean.find(Parent.class) - .setRawSql(rawSql) - .findList(); + .setRawSql(rawSql) + .findList(); assertNotNull(partial.get(0).getData()); assertEquals(partial.get(0).getData().get(0).getVal().intValue(), 0); @@ -95,13 +93,13 @@ public class ParentRawSqlTest extends BaseTestCase { // For bug 416 we need the parent.more to trigger it RawSql rawSql = RawSqlBuilder - .unparsed("select u.id, u.name, p.type as p_type, p.id as p_id, p.more as p_more from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") - .columnMapping("id", "id") - .columnMapping("name", "name") - .columnMapping("p_type", "parent.type") - .columnMapping("p_id", "parent.id") - .columnMapping("p_more", "parent.more") - .create(); + .unparsed("select u.id, u.name, p.type as p_type, p.id as p_id, p.more as p_more from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") + .columnMapping("id", "id") + .columnMapping("name", "name") + .columnMapping("p_type", "parent.type") + .columnMapping("p_id", "parent.id") + .columnMapping("p_more", "parent.more") + .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql).findList(); @@ -113,16 +111,16 @@ public class ParentRawSqlTest extends BaseTestCase { private void joinToInheritanceHierarchy_with_queryJoin() { RawSql rawSql = RawSqlBuilder - .unparsed("select u.id, u.name, p.type as p_type, p.id as p_id from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") - .columnMapping("id", "id") - .columnMapping("name", "name") - .columnMapping("p_type", "parent.type") - .columnMapping("p_id", "parent.id") - .create(); + .unparsed("select u.id, u.name, p.type as p_type, p.id as p_id from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") + .columnMapping("id", "id") + .columnMapping("name", "name") + .columnMapping("p_type", "parent.type") + .columnMapping("p_id", "parent.id") + .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) - .findList(); + .fetch("parent", new FetchConfig().query()) + .findList(); assertNotNull(uncles.get(0)); Parent parent = uncles.get(0).getParent(); @@ -132,16 +130,16 @@ public class ParentRawSqlTest extends BaseTestCase { private void joinToInheritanceHierarchy_withIgnore() { RawSql rawSql = RawSqlBuilder - .unparsed("select u.id, u.name, p.type as ptype, p.id as pid from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") - .columnMapping("id", "id") - .columnMapping("name", "name") - .columnMappingIgnore("ptype") - .columnMapping("pid", "parent.id") - .create(); + .unparsed("select u.id, u.name, p.type as ptype, p.id as pid from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") + .columnMapping("id", "id") + .columnMapping("name", "name") + .columnMappingIgnore("ptype") + .columnMapping("pid", "parent.id") + .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) - .findList(); + .fetch("parent", new FetchConfig().query()) + .findList(); assertNotNull(uncles.get(0)); Parent parent = uncles.get(0).getParent(); @@ -151,12 +149,12 @@ public class ParentRawSqlTest extends BaseTestCase { private void joinToInheritanceHierarchy_withAliasMapping() { RawSql rawSql = RawSqlBuilder - .parse("select u.id, u.name, p.type, p.id from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") - .tableAliasMapping("p", "parent") - .create(); + .parse("select u.id, u.name, p.type, p.id from rawinherit_uncle u join rawinherit_parent p on p.id = u.parent_id") + .tableAliasMapping("p", "parent") + .create(); List uncles = Ebean.find(EUncle.class).setRawSql(rawSql) - .findList(); + .findList(); assertNotNull(uncles.get(0)); Parent parent = uncles.get(0).getParent(); @@ -169,14 +167,14 @@ public class ParentRawSqlTest extends BaseTestCase { private void useColumnMappingWithDiscriminator() { RawSql rawSql = RawSqlBuilder - .unparsed("select type, id from rawinherit_parent where val > 1") - .columnMapping("type", "parent.type") // can map the discriminator column 'type' - .columnMapping("id", "parent.id") - .create(); + .unparsed("select type, id from rawinherit_parent where val > 1") + .columnMapping("type", "parent.type") // can map the discriminator column 'type' + .columnMapping("id", "parent.id") + .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) - .findList(); + .fetch("parent", new FetchConfig().query()) + .findList(); List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { @@ -193,14 +191,14 @@ public class ParentRawSqlTest extends BaseTestCase { private void useColumnMappingIgnore() { RawSql rawSql = RawSqlBuilder - .unparsed("select type, id from rawinherit_parent where val > 1") - .columnMappingIgnore("type") // can ignore the discriminator 'type' - .columnMapping("id", "parent.id") - .create(); + .unparsed("select type, id from rawinherit_parent where val > 1") + .columnMappingIgnore("type") // can ignore the discriminator 'type' + .columnMapping("id", "parent.id") + .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) - .findList(); + .fetch("parent", new FetchConfig().query()) + .findList(); List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { @@ -217,16 +215,16 @@ public class ParentRawSqlTest extends BaseTestCase { private void useExtraColumnMappingIgnore() { RawSql rawSql = RawSqlBuilder - .unparsed("select 'a', type, id, 'b' from rawinherit_parent where val > 1") - .columnMappingIgnore("a") // extra ignore before - .columnMappingIgnore("type") - .columnMapping("id", "parent.id") - .columnMappingIgnore("b") // extra ignore after - .create(); + .unparsed("select 'a', type, id, 'b' from rawinherit_parent where val > 1") + .columnMappingIgnore("a") // extra ignore before + .columnMappingIgnore("type") + .columnMapping("id", "parent.id") + .columnMappingIgnore("b") // extra ignore after + .create(); List aggregates = Ebean.find(ParentAggregate.class).setRawSql(rawSql) - .fetch("parent", new FetchConfig().query()) - .findList(); + .fetch("parent", new FetchConfig().query()) + .findList(); List partial = new ArrayList<>(); for (ParentAggregate aggregate : aggregates) { diff --git a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java index 59657d078..df741e4b4 100644 --- a/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java +++ b/src/test/java/com/avaje/tests/readaudit/TestReadAudit.java @@ -3,7 +3,6 @@ package com.avaje.tests.readaudit; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.EbeanServerFactory; import com.avaje.ebean.FutureList; -import com.avaje.ebean.QueryEachConsumer; import com.avaje.ebean.cache.ServerCache; import com.avaje.ebean.cache.ServerCacheStatistics; import com.avaje.ebean.config.ServerConfig; @@ -142,8 +141,8 @@ public class TestReadAudit extends BaseTestCase { resetCounters(); List list = server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findList(); + .where().startsWith("shortDescription", "readAudit") + .findList(); assertThat(list).hasSize(2); assertThat(readAuditPrepare.count).isEqualTo(1); @@ -153,8 +152,8 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findList(); + .where().startsWith("shortDescription", "readAudit") + .findList(); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -169,9 +168,9 @@ public class TestReadAudit extends BaseTestCase { LoggedSqlCollector.start(); List list = server.find(EBasicChangeLog.class) - .setUseQueryCache(true) - .where().startsWith("shortDescription", "readAudit") - .findList(); + .setUseQueryCache(true) + .where().startsWith("shortDescription", "readAudit") + .findList(); System.out.println("test_findList_useL2Cache> first query"); @@ -183,19 +182,19 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); List list1 = server.find(EBasicChangeLog.class) - .setUseQueryCache(true) - .where().startsWith("shortDescription", "readAudit") - .findList(); + .setUseQueryCache(true) + .where().startsWith("shortDescription", "readAudit") + .findList(); - System.out.println("test_findList_useL2Cache> second query "+list1.size()); + System.out.println("test_findList_useL2Cache> second query " + list1.size()); assertThat(list1).hasSize(2); List sql = LoggedSqlCollector.stop(); - System.out.println("test_findList_useL2Cache> sql: "+sql); + System.out.println("test_findList_useL2Cache> sql: " + sql); //assertThat(sql).hasSize(1); System.out.println("test_findList_useL2Cache> prepare:" + readAuditPrepare.count - + " plans:" + readAuditLogger.plans - + " many:" + readAuditLogger.many); + + " plans:" + readAuditLogger.plans + + " many:" + readAuditLogger.many); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -208,8 +207,8 @@ public class TestReadAudit extends BaseTestCase { resetCounters(); FutureList futureList = server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findFutureList(); + .where().startsWith("shortDescription", "readAudit") + .findFutureList(); List list = futureList.get(); assertThat(list).hasSize(2); @@ -220,8 +219,8 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findList(); + .where().startsWith("shortDescription", "readAudit") + .findList(); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -234,8 +233,8 @@ public class TestReadAudit extends BaseTestCase { resetCounters(); Set list = server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findSet(); + .where().startsWith("shortDescription", "readAudit") + .findSet(); assertThat(list).hasSize(2); assertThat(readAuditPrepare.count).isEqualTo(1); @@ -244,8 +243,8 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findSet(); + .where().startsWith("shortDescription", "readAudit") + .findSet(); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -257,9 +256,9 @@ public class TestReadAudit extends BaseTestCase { resetCounters(); - Map list = server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findMap(); + Map list = server.find(EBasicChangeLog.class) + .where().startsWith("shortDescription", "readAudit") + .findMap(); assertThat(list).hasSize(2); assertThat(readAuditPrepare.count).isEqualTo(1); @@ -268,8 +267,8 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findMap(); + .where().startsWith("shortDescription", "readAudit") + .findMap(); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -283,8 +282,8 @@ public class TestReadAudit extends BaseTestCase { final AtomicInteger count = new AtomicInteger(); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findEach(bean -> count.incrementAndGet()); + .where().startsWith("shortDescription", "readAudit") + .findEach(bean -> count.incrementAndGet()); assertThat(count.get()).isEqualTo(2); assertThat(readAuditPrepare.count).isEqualTo(1); @@ -293,8 +292,8 @@ public class TestReadAudit extends BaseTestCase { assertThat(readAuditLogger.many.get(0).getIds()).contains(id1, id2); server.find(EBasicChangeLog.class) - .where().startsWith("shortDescription", "readAudit") - .findEach(bean -> count.incrementAndGet()); + .where().startsWith("shortDescription", "readAudit") + .findEach(bean -> count.incrementAndGet()); assertThat(readAuditPrepare.count).isEqualTo(2); assertThat(readAuditLogger.plans).hasSize(1); @@ -334,6 +333,7 @@ public class TestReadAudit extends BaseTestCase { TDReadAuditPrepare(boolean dummy) { } + void resetCounters() { count = 0; } @@ -355,6 +355,7 @@ public class TestReadAudit extends BaseTestCase { TDReadAuditLogger(boolean dummy) { } + void resetCounters() { plans.clear(); beans.clear(); diff --git a/src/test/java/com/avaje/tests/refresh/TestRefreshWithMany.java b/src/test/java/com/avaje/tests/refresh/TestRefreshWithMany.java index 8a3bb834a..a177a6de9 100644 --- a/src/test/java/com/avaje/tests/refresh/TestRefreshWithMany.java +++ b/src/test/java/com/avaje/tests/refresh/TestRefreshWithMany.java @@ -26,13 +26,13 @@ public class TestRefreshWithMany extends BaseTestCase { assertEquals(3, customer.getContacts().size()); int rc = Ebean.createSqlUpdate("update o_customer set name = :name where id = :id") - .setParameter("name", "ref-modified") - .setParameter("id", customer.getId()) - .execute(); + .setParameter("name", "ref-modified") + .setParameter("id", customer.getId()) + .execute(); int rc2 = Ebean.createSqlUpdate("update contact set first_name = concat(first_name,'-mod') where customer_id = :id") - .setParameter("id", customer.getId()) - .execute(); + .setParameter("id", customer.getId()) + .execute(); assertEquals(1, rc); assertEquals(3, rc2); @@ -46,20 +46,20 @@ public class TestRefreshWithMany extends BaseTestCase { // now try again when the bean is fully loaded Customer customer1 = Ebean.find(Customer.class) - .fetch("contacts") - .setId(customer.getId()) - .findUnique(); + .fetch("contacts") + .setId(customer.getId()) + .findUnique(); int rcb1 = Ebean.createSqlUpdate("update o_customer set name = :name where id = :id") - .setParameter("name", "ref-modified-again") - .setParameter("id", customer.getId()) - .execute(); + .setParameter("name", "ref-modified-again") + .setParameter("id", customer.getId()) + .execute(); int rcb2 = Ebean.createSqlUpdate("update contact set first_name = :first, last_name='foo' where customer_id = :id") - .setParameter("id", customer.getId()) - .setParameter("first","-alt") - .execute(); + .setParameter("id", customer.getId()) + .setParameter("first", "-alt") + .execute(); List sqlRows = Ebean.createSqlQuery("select id, first_name, last_name from contact").findList(); for (SqlRow sqlRow : sqlRows) { diff --git a/src/test/java/com/avaje/tests/saveassociation/TestSaveAssociation.java b/src/test/java/com/avaje/tests/saveassociation/TestSaveAssociation.java index f04a0a36a..815718237 100644 --- a/src/test/java/com/avaje/tests/saveassociation/TestSaveAssociation.java +++ b/src/test/java/com/avaje/tests/saveassociation/TestSaveAssociation.java @@ -1,12 +1,11 @@ package com.avaje.tests.saveassociation; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TSDetail; import com.avaje.tests.model.basic.TSMaster; +import org.junit.Assert; +import org.junit.Test; public class TestSaveAssociation extends BaseTestCase { @@ -24,7 +23,7 @@ public class TestSaveAssociation extends BaseTestCase { Ebean.save(m0); TSMaster m0Check = Ebean.find(TSMaster.class).fetch("details").where().idEq(m0.getId()) - .findUnique(); + .findUnique(); Assert.assertEquals(2, m0Check.getDetails().size()); diff --git a/src/test/java/com/avaje/tests/saveassociation/TestSaveSamePK.java b/src/test/java/com/avaje/tests/saveassociation/TestSaveSamePK.java index fd1fdceac..31d18f69f 100644 --- a/src/test/java/com/avaje/tests/saveassociation/TestSaveSamePK.java +++ b/src/test/java/com/avaje/tests/saveassociation/TestSaveSamePK.java @@ -1,12 +1,11 @@ package com.avaje.tests.saveassociation; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.TSDetail; import com.avaje.tests.model.basic.TSMaster; +import org.junit.Assert; +import org.junit.Test; public class TestSaveSamePK extends BaseTestCase { @@ -27,11 +26,11 @@ public class TestSaveSamePK extends BaseTestCase { TSDetail tsDetail = new TSDetail("master1 detail1"); tsDetail.setId(10000); tsDetail.setMaster(m0); - + Ebean.save(tsDetail); TSDetail fetchedDetail = Ebean.find(TSDetail.class).setId(10000).fetch("master").findUnique(); - + Assert.assertNotNull(fetchedDetail); } } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/TestInheritQuery.java b/src/test/java/com/avaje/tests/singleTableInheritance/TestInheritQuery.java index 5afb69e61..d8e07ca86 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/TestInheritQuery.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/TestInheritQuery.java @@ -1,13 +1,17 @@ package com.avaje.tests.singleTableInheritance; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; -import com.avaje.tests.singleTableInheritance.model.*; +import com.avaje.tests.singleTableInheritance.model.PalletLocation; +import com.avaje.tests.singleTableInheritance.model.PalletLocationExternal; +import com.avaje.tests.singleTableInheritance.model.Warehouse; +import com.avaje.tests.singleTableInheritance.model.Zone; +import com.avaje.tests.singleTableInheritance.model.ZoneExternal; +import com.avaje.tests.singleTableInheritance.model.ZoneInternal; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestInheritQuery extends BaseTestCase { @@ -24,7 +28,7 @@ public class TestInheritQuery extends BaseTestCase { // This line should work too: List locations = Ebean.find(PalletLocation.class).where().eq("zone", zone) - .findList(); + .findList(); // List locations = // Ebean.find(PalletLocation.class).where().eq("zone.id", // zone.getId()).findList(); @@ -37,7 +41,7 @@ public class TestInheritQuery extends BaseTestCase { Assert.assertNotNull(rereadZone); Assert.assertTrue(rereadZone instanceof ZoneExternal); } - + @Test public void testDiscriminator_bug417() { @@ -48,120 +52,120 @@ public class TestInheritQuery extends BaseTestCase { Ebean.deleteAll(Ebean.find(ZoneInternal.class).findList()); Ebean.deleteAll(Ebean.find(ZoneInternal.class).findList()); - ZoneInternal zoneInt = new ZoneInternal(); - zoneInt.setAttribute("some zone 1"); - Ebean.save(zoneInt); - - ZoneExternal zoneExt = new ZoneExternal(); - zoneExt.setAttribute("some zone 2"); - Ebean.save(zoneExt); - - // queries of Zone and subclasses as root node of query - - // query abstract class on attribute (root of heirarchy) - List zones = Ebean.find(Zone.class).where().startsWith("attribute", "some zone").findList(); - // select t0.type c0, t0.ID c1, t0.attribute c2, t0.attribute c3 from zones t0 where t0.attribute like ? ; --bind(some zone%) - Assert.assertEquals(2, zones.size()); - Assert.assertTrue(zones.contains(zoneInt)); - Assert.assertTrue(zones.contains(zoneExt)); - - // query internal zones only - // discriminator is in WHERE clause where it belongs - List internalZones = Ebean.find(ZoneInternal.class).where().startsWith("attribute", "some zone").findList(); - // select t0.type c0, t0.ID c1, t0.attribute c2 from zones t0 where t0.type = 'INT' and t0.attribute like ? ; --bind(some zone%) - Assert.assertEquals(1, internalZones.size()); - Assert.assertTrue(internalZones.contains(zoneInt)); - Assert.assertFalse(internalZones.contains(zoneExt)); - Assert.assertTrue(internalZones.get(0) instanceof ZoneInternal); + ZoneInternal zoneInt = new ZoneInternal(); + zoneInt.setAttribute("some zone 1"); + Ebean.save(zoneInt); - // query external zones only - List externalZones = Ebean.find(ZoneExternal.class).where().startsWith("attribute", "some zone").findList(); - // select t0.type c0, t0.ID c1, t0.attribute c2 from zones t0 where t0.type = 'EXT' and t0.attribute like ? ; --bind(some zone%) - Assert.assertEquals(1, externalZones.size()); - Assert.assertTrue(externalZones.contains(zoneExt)); - Assert.assertFalse(externalZones.contains(zoneInt)); - Assert.assertTrue(externalZones.get(0) instanceof ZoneExternal); - - // parents with children of Zones and subclasses - - Warehouse wh = new Warehouse(); - wh.setOfficeZone(zoneInt); // many-to-one - wh.getShippingZones().add(zoneExt); // many-to-many - Ebean.save(wh); - - // JOIN clause, no discriminator - // parent with many-to-one, doesn't put in discriminator, why not, PK sufficient? - // eager join - Warehouse wh2 = Ebean.find(Warehouse.class, wh.getId()); - Assert.assertNotNull(wh2); - Assert.assertEquals(wh.getId(), wh2.getId()); - Assert.assertEquals(wh.getOfficeZone(), wh2.getOfficeZone()); - Assert.assertEquals(wh.getOfficeZone().getAttribute(), wh2.getOfficeZone().getAttribute()); - - // before the fix, next assertion runs this lazy query: - - // select t0.ID c0, t1.type c1, t1.ID c2 from warehouses t0 - // left join WarehousesShippingZones t1z_ on t1z_.warehouseId = t0.ID - // left join zones t1 on t1.ID = t1z_.shippingZoneId - // where t1.type = 'EXT' // this should be in the join clause - // and t0.ID = ? - // order by t0.ID; --bind(1) - - // this works here because we have at least one shipping zone - - Assert.assertEquals(1, wh2.getShippingZones().size()); - Assert.assertTrue(wh2.getShippingZones().contains(zoneExt)); - - // set optional concrete to null to set stage for failure - wh.setOfficeZone(null); - Ebean.save(wh); - - // no discriminator here - wh2 = Ebean.find(Warehouse.class) - .where().eq("id", wh.getId()) - .findUnique(); + ZoneExternal zoneExt = new ZoneExternal(); + zoneExt.setAttribute("some zone 2"); + Ebean.save(zoneExt); - Assert.assertNotNull(wh2); - // discriminator is used here, should be in join - // assuming this "manual" fetch is equivalent to autofetch (i.e., autofetch should work the same way) - // before Daryl's fix - // select t0.ID c0, t1.type c1, t1.ID c2, t1.attribute c3 from warehouses t0 left join zones t1 on t1.ID = t0.officeZoneId where t1.type = 'INT' and t0.ID = ? - // todo: after Daryl's fix, not sure if this is proper, no discriminator at all, isn't PK/FK sufficient? - // select t0.ID c0, t1.type c1, t1.ID c2, t1.attribute c3 from warehouses t0 left join zones t1 on t1.ID = t0.officeZoneId where t0.ID = ? ; --bind(1) - wh2 = Ebean.find(Warehouse.class) - .fetch("officeZone") - .where().eq("id", wh.getId()) - .findUnique(); - // key assertion #1 - fails due to left join with discriminator in WHERE - Assert.assertNotNull(wh2); - - // clear children to set the stage for left join failure - wh.getShippingZones().clear(); - Ebean.save(wh); - - wh2 = Ebean.find(Warehouse.class, wh.getId()); - Assert.assertNotNull(wh2); - Assert.assertEquals(wh.getId(), wh2.getId()); - Assert.assertEquals(0, wh.getShippingZones().size()); - - // query with lazy load of abstract children - wh = Ebean.find(Warehouse.class) - .where().eq("id", wh.getId()) - .findUnique(); - Assert.assertNotNull(wh); - Assert.assertEquals(wh.getId(), wh2.getId()); - Assert.assertEquals(0, wh.getShippingZones().size()); - - // query with fetch of abstract children - wh = Ebean.find(Warehouse.class) - .fetch("shippingZones") - .where().eq("id", wh.getId()) - .findUnique(); - // key assertion #2 - fails due to left join with discriminator in WHERE - Assert.assertNotNull(wh); - Assert.assertEquals(wh.getId(), wh2.getId()); - Assert.assertEquals(0, wh.getShippingZones().size()); - - - } -} \ No newline at end of file + // queries of Zone and subclasses as root node of query + + // query abstract class on attribute (root of heirarchy) + List zones = Ebean.find(Zone.class).where().startsWith("attribute", "some zone").findList(); + // select t0.type c0, t0.ID c1, t0.attribute c2, t0.attribute c3 from zones t0 where t0.attribute like ? ; --bind(some zone%) + Assert.assertEquals(2, zones.size()); + Assert.assertTrue(zones.contains(zoneInt)); + Assert.assertTrue(zones.contains(zoneExt)); + + // query internal zones only + // discriminator is in WHERE clause where it belongs + List internalZones = Ebean.find(ZoneInternal.class).where().startsWith("attribute", "some zone").findList(); + // select t0.type c0, t0.ID c1, t0.attribute c2 from zones t0 where t0.type = 'INT' and t0.attribute like ? ; --bind(some zone%) + Assert.assertEquals(1, internalZones.size()); + Assert.assertTrue(internalZones.contains(zoneInt)); + Assert.assertFalse(internalZones.contains(zoneExt)); + Assert.assertTrue(internalZones.get(0) instanceof ZoneInternal); + + // query external zones only + List externalZones = Ebean.find(ZoneExternal.class).where().startsWith("attribute", "some zone").findList(); + // select t0.type c0, t0.ID c1, t0.attribute c2 from zones t0 where t0.type = 'EXT' and t0.attribute like ? ; --bind(some zone%) + Assert.assertEquals(1, externalZones.size()); + Assert.assertTrue(externalZones.contains(zoneExt)); + Assert.assertFalse(externalZones.contains(zoneInt)); + Assert.assertTrue(externalZones.get(0) instanceof ZoneExternal); + + // parents with children of Zones and subclasses + + Warehouse wh = new Warehouse(); + wh.setOfficeZone(zoneInt); // many-to-one + wh.getShippingZones().add(zoneExt); // many-to-many + Ebean.save(wh); + + // JOIN clause, no discriminator + // parent with many-to-one, doesn't put in discriminator, why not, PK sufficient? + // eager join + Warehouse wh2 = Ebean.find(Warehouse.class, wh.getId()); + Assert.assertNotNull(wh2); + Assert.assertEquals(wh.getId(), wh2.getId()); + Assert.assertEquals(wh.getOfficeZone(), wh2.getOfficeZone()); + Assert.assertEquals(wh.getOfficeZone().getAttribute(), wh2.getOfficeZone().getAttribute()); + + // before the fix, next assertion runs this lazy query: + + // select t0.ID c0, t1.type c1, t1.ID c2 from warehouses t0 + // left join WarehousesShippingZones t1z_ on t1z_.warehouseId = t0.ID + // left join zones t1 on t1.ID = t1z_.shippingZoneId + // where t1.type = 'EXT' // this should be in the join clause + // and t0.ID = ? + // order by t0.ID; --bind(1) + + // this works here because we have at least one shipping zone + + Assert.assertEquals(1, wh2.getShippingZones().size()); + Assert.assertTrue(wh2.getShippingZones().contains(zoneExt)); + + // set optional concrete to null to set stage for failure + wh.setOfficeZone(null); + Ebean.save(wh); + + // no discriminator here + wh2 = Ebean.find(Warehouse.class) + .where().eq("id", wh.getId()) + .findUnique(); + + Assert.assertNotNull(wh2); + // discriminator is used here, should be in join + // assuming this "manual" fetch is equivalent to autofetch (i.e., autofetch should work the same way) + // before Daryl's fix + // select t0.ID c0, t1.type c1, t1.ID c2, t1.attribute c3 from warehouses t0 left join zones t1 on t1.ID = t0.officeZoneId where t1.type = 'INT' and t0.ID = ? + // todo: after Daryl's fix, not sure if this is proper, no discriminator at all, isn't PK/FK sufficient? + // select t0.ID c0, t1.type c1, t1.ID c2, t1.attribute c3 from warehouses t0 left join zones t1 on t1.ID = t0.officeZoneId where t0.ID = ? ; --bind(1) + wh2 = Ebean.find(Warehouse.class) + .fetch("officeZone") + .where().eq("id", wh.getId()) + .findUnique(); + // key assertion #1 - fails due to left join with discriminator in WHERE + Assert.assertNotNull(wh2); + + // clear children to set the stage for left join failure + wh.getShippingZones().clear(); + Ebean.save(wh); + + wh2 = Ebean.find(Warehouse.class, wh.getId()); + Assert.assertNotNull(wh2); + Assert.assertEquals(wh.getId(), wh2.getId()); + Assert.assertEquals(0, wh.getShippingZones().size()); + + // query with lazy load of abstract children + wh = Ebean.find(Warehouse.class) + .where().eq("id", wh.getId()) + .findUnique(); + Assert.assertNotNull(wh); + Assert.assertEquals(wh.getId(), wh2.getId()); + Assert.assertEquals(0, wh.getShippingZones().size()); + + // query with fetch of abstract children + wh = Ebean.find(Warehouse.class) + .fetch("shippingZones") + .where().eq("id", wh.getId()) + .findUnique(); + // key assertion #2 - fails due to left join with discriminator in WHERE + Assert.assertNotNull(wh); + Assert.assertEquals(wh.getId(), wh2.getId()); + Assert.assertEquals(0, wh.getShippingZones().size()); + + + } +} diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocation.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocation.java index bffeeaaf6..6b8f1efe1 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocation.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocation.java @@ -12,35 +12,30 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @Entity -@Inheritance(strategy= InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name="type", discriminatorType= DiscriminatorType.STRING) -public class PalletLocation -{ - @Id - @Column(name="id") - private Integer id; +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) +public class PalletLocation { + @Id + @Column(name = "id") + private Integer id; - @ManyToOne(fetch= FetchType.LAZY, optional=false) - @JoinColumn(name="ZONE_SID") - private Zone zone; + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "ZONE_SID") + private Zone zone; - public Integer getId() - { - return id; - } + public Integer getId() { + return id; + } - public void setId(Integer id) - { - this.id = id; - } + public void setId(Integer id) { + this.id = id; + } - public Zone getZone() - { - return zone; - } + public Zone getZone() { + return zone; + } - public void setZone(Zone zone) - { - this.zone = zone; - } + public void setZone(Zone zone) { + this.zone = zone; + } } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocationExternal.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocationExternal.java index 8f104aa44..e9bc37f50 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocationExternal.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/PalletLocationExternal.java @@ -5,17 +5,14 @@ import javax.persistence.Entity; @Entity @DiscriminatorValue("EXT") -public class PalletLocationExternal extends PalletLocation -{ - private String attribute; +public class PalletLocationExternal extends PalletLocation { + private String attribute; - public String getAttribute() - { - return attribute; - } + public String getAttribute() { + return attribute; + } - public void setAttribute(String attribute) - { - this.attribute = attribute; - } + public void setAttribute(String attribute) { + this.attribute = attribute; + } } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/Warehouse.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/Warehouse.java index 80aa46e03..18d8b0800 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/Warehouse.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/Warehouse.java @@ -1,49 +1,56 @@ package com.avaje.tests.singleTableInheritance.model; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; import java.util.Set; -import javax.persistence.*; - @Entity -@Table(name="warehouses") +@Table(name = "warehouses") public class Warehouse { - @Id - @Column(name="id") - private Integer id; - - @ManyToOne//(optional = false) //todo: should this be nullable with assertions made? - @JoinColumn(name = "officeZoneId") - private ZoneInternal officeZone; - - @ManyToMany(cascade = CascadeType.PERSIST) - @JoinTable(name = "warehousesshippingzones", - joinColumns = { @JoinColumn(name = "warehouseId", referencedColumnName = "ID") }, - inverseJoinColumns = { @JoinColumn(name = "shippingZoneId", referencedColumnName = "ID") } - ) - private Set shippingZones; + @Id + @Column(name = "id") + private Integer id; - public Integer getId() { - return id; - } + @ManyToOne//(optional = false) //todo: should this be nullable with assertions made? + @JoinColumn(name = "officeZoneId") + private ZoneInternal officeZone; - public void setId(Integer id) { - this.id = id; - } - - public ZoneInternal getOfficeZone() { - return officeZone; - } - - public void setOfficeZone(ZoneInternal officeZone) { - this.officeZone = officeZone; - } - - public Set getShippingZones() { - return shippingZones; - } + @ManyToMany(cascade = CascadeType.PERSIST) + @JoinTable(name = "warehousesshippingzones", + joinColumns = {@JoinColumn(name = "warehouseId", referencedColumnName = "ID")}, + inverseJoinColumns = {@JoinColumn(name = "shippingZoneId", referencedColumnName = "ID")} + ) + private Set shippingZones; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public ZoneInternal getOfficeZone() { + return officeZone; + } + + public void setOfficeZone(ZoneInternal officeZone) { + this.officeZone = officeZone; + } + + public Set getShippingZones() { + return shippingZones; + } + + public void setShippingZones(Set shippingZones) { + this.shippingZones = shippingZones; + } - public void setShippingZones(Set shippingZones) { - this.shippingZones = shippingZones; - } - } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/Zone.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/Zone.java index 88814d274..2032d958d 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/Zone.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/Zone.java @@ -10,36 +10,33 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; @Entity -@Inheritance(strategy=InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING) -@Table(name="zones") -public class Zone -{ - @Id - @Column(name="id") - private Integer id; +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) +@Table(name = "zones") +public class Zone { + @Id + @Column(name = "id") + private Integer id; - public Integer getId() - { - return id; - } + public Integer getId() { + return id; + } - public void setId(Integer id) - { - this.id = id; - } - - public int hashCode() { - if (getId() != null) return getId().hashCode(); - else return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Zone) { - return ((Zone) obj).getId().equals(getId()); - } else { - return false; - } - } + public void setId(Integer id) { + this.id = id; + } + + public int hashCode() { + if (getId() != null) return getId().hashCode(); + else return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Zone) { + return ((Zone) obj).getId().equals(getId()); + } else { + return false; + } + } } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneExternal.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneExternal.java index c3b24734e..1713dee77 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneExternal.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneExternal.java @@ -5,22 +5,19 @@ import javax.persistence.Entity; @Entity @DiscriminatorValue("EXT") -public class ZoneExternal extends Zone -{ - private String attribute; +public class ZoneExternal extends Zone { + private String attribute; - public String getAttribute() - { - return attribute; - } + public String getAttribute() { + return attribute; + } - public void setAttribute(String attribute) - { - this.attribute = attribute; - } - - @Override - public String toString() { - return "ZoneExternal " + getId() + " \"" + getAttribute() + "\""; - } + public void setAttribute(String attribute) { + this.attribute = attribute; + } + + @Override + public String toString() { + return "ZoneExternal " + getId() + " \"" + getAttribute() + "\""; + } } diff --git a/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneInternal.java b/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneInternal.java index 0ed1af183..bfb602f99 100644 --- a/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneInternal.java +++ b/src/test/java/com/avaje/tests/singleTableInheritance/model/ZoneInternal.java @@ -6,19 +6,19 @@ import javax.persistence.Entity; @Entity @DiscriminatorValue("INT") public class ZoneInternal extends Zone { - - private String attribute; - public String getAttribute() { - return attribute; - } + private String attribute; - public void setAttribute(String attribute) { - this.attribute = attribute; - } - - @Override - public String toString() { - return "ZoneInternal " + getId() + " \"" + getAttribute() + "\""; - } + public String getAttribute() { + return attribute; + } + + public void setAttribute(String attribute) { + this.attribute = attribute; + } + + @Override + public String toString() { + return "ZoneInternal " + getId() + " \"" + getAttribute() + "\""; + } } diff --git a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBasic.java b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBasic.java index 795d66307..8146b2ada 100644 --- a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBasic.java +++ b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBasic.java @@ -30,15 +30,15 @@ public class TestSoftDeleteBasic extends BaseTestCase { assertThat(sqlRow).isNotNull(); EBasicSoftDelete findNormal = Ebean.find(EBasicSoftDelete.class) - .setId(bean.getId()) - .findUnique(); + .setId(bean.getId()) + .findUnique(); assertThat(findNormal).isNull(); EBasicSoftDelete findInclude = Ebean.find(EBasicSoftDelete.class) - .setId(bean.getId()) - .setIncludeSoftDeletes() - .findUnique(); + .setId(bean.getId()) + .setIncludeSoftDeletes() + .findUnique(); assertThat(findInclude).isNotNull(); } @@ -53,11 +53,11 @@ public class TestSoftDeleteBasic extends BaseTestCase { Ebean.delete(bean); Query query = Ebean.find(EBasicSoftDelete.class) - .setIncludeSoftDeletes() - .where() - .eq("deleted", true) - .eq("name", "softDelFetch") - .query(); + .setIncludeSoftDeletes() + .where() + .eq("deleted", true) + .eq("name", "softDelFetch") + .query(); List list = query.findList(); assertThat(query.getGeneratedSql()).contains("deleted = ?"); @@ -108,9 +108,9 @@ public class TestSoftDeleteBasic extends BaseTestCase { // partially loaded bean without deleted state loaded EBasicSoftDelete partial = Ebean.find(EBasicSoftDelete.class) - .select("id") - .setId(bean.getId()) - .findUnique(); + .select("id") + .setId(bean.getId()) + .findUnique(); LoggedSqlCollector.start(); Ebean.delete(partial); @@ -172,10 +172,10 @@ public class TestSoftDeleteBasic extends BaseTestCase { LoggedSqlCollector.start(); Query query1 = - Ebean.find(EBasicSoftDelete.class) - .fetch("children") - .where().eq("id", bean.getId()) - .query(); + Ebean.find(EBasicSoftDelete.class) + .fetch("children") + .where().eq("id", bean.getId()) + .query(); List fetch1 = query1.findList(); String generatedSql = query1.getGeneratedSql(); @@ -194,9 +194,9 @@ public class TestSoftDeleteBasic extends BaseTestCase { // fetch includeSoftDeletes using lazy loading EBasicSoftDelete fetchAllWithLazy = - Ebean.find(EBasicSoftDelete.class) - .setId(bean.getId()) - .where() + Ebean.find(EBasicSoftDelete.class) + .setId(bean.getId()) + .where() .setIncludeSoftDeletes() .findUnique(); @@ -215,8 +215,8 @@ public class TestSoftDeleteBasic extends BaseTestCase { Ebean.deleteAll(bean.getChildren()); Query query = Ebean.find(EBasicSoftDelete.class) - .setId(bean.getId()) - .fetch("children"); + .setId(bean.getId()) + .fetch("children"); EBasicSoftDelete found = query.findUnique(); diff --git a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBook.java b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBook.java index 311679b01..60610d998 100644 --- a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBook.java +++ b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteBook.java @@ -16,7 +16,7 @@ public class TestSoftDeleteBook extends BaseTestCase { @Test public void test() { - // Create users + // Create users ESoftDelUser user1 = new ESoftDelUser("user1"); Ebean.save(user1); @@ -27,19 +27,19 @@ public class TestSoftDeleteBook extends BaseTestCase { Ebean.save(user3); // Create books - ESoftDelBook book1 = new ESoftDelBook("book1"); + ESoftDelBook book1 = new ESoftDelBook("book1"); book1.setLendBy(user1); book1.setLendBys(Arrays.asList(user2, user3)); Ebean.save(book1); - ESoftDelBook book2 = new ESoftDelBook("book2"); + ESoftDelBook book2 = new ESoftDelBook("book2"); book2.setLendBy(user2); book2.setLendBys(Arrays.asList(user1, user3)); Ebean.save(book2); // check if everything is stored correctly in DB book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").findUnique(); - book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findUnique(); + book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findUnique(); assertThat(book1.getLendBys().size()).isEqualTo(2); assertThat(book2.getLendBys().size()).isEqualTo(2); @@ -51,7 +51,7 @@ public class TestSoftDeleteBook extends BaseTestCase { // check if everything is still stored correctly in DB (softdeletes included) book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").setIncludeSoftDeletes().findUnique(); - book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").setIncludeSoftDeletes().findUnique(); + book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").setIncludeSoftDeletes().findUnique(); assertThat(book1.getLendBys().size()).isEqualTo(2); assertThat(book2.getLendBys().size()).isEqualTo(2); @@ -66,10 +66,10 @@ public class TestSoftDeleteBook extends BaseTestCase { assertThat(book1.getLendBys().size()).isEqualTo(2); // user2 & user3 assertThat(book2.getLendBys().size()).isEqualTo(1); // user1 (deleted) & user3 assertThat(book2.getLendBy().getUserName()).isEqualTo("user2"); - - // expected behaviour: + + // expected behaviour: // book1.getLendBy() == null - // current behaviour: + // current behaviour: // book1.getLendBy() is a "dead" object. nearly every operation on the // user object leads into an EntityNotFoundException @@ -98,8 +98,8 @@ public class TestSoftDeleteBook extends BaseTestCase { Ebean.delete(user2); Query query = Ebean.find(ESoftDelBook.class) - .setId(book1.getId()) - .fetch("lendBys"); + .setId(book1.getId()) + .fetch("lendBys"); ESoftDelBook found = query.findUnique(); diff --git a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteOptionalRelationship.java b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteOptionalRelationship.java index 916299bff..f90e063e1 100644 --- a/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteOptionalRelationship.java +++ b/src/test/java/com/avaje/tests/softdelete/TestSoftDeleteOptionalRelationship.java @@ -16,9 +16,9 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase { Ebean.save(mid1); ESoftDelMid bean = Ebean.find(ESoftDelMid.class) - .setId(mid1.getId()) - .fetch("top") - .findUnique(); + .setId(mid1.getId()) + .fetch("top") + .findUnique(); assertThat(bean).isNotNull(); assertThat(bean.getTop()).isNull(); diff --git a/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java b/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java index b700e3a93..e83bb9917 100644 --- a/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java +++ b/src/test/java/com/avaje/tests/sp/TestManyToManySaveTwice.java @@ -1,15 +1,14 @@ package com.avaje.tests.sp; -import java.util.LinkedList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.sp.model.car.Car; import com.avaje.tests.sp.model.car.Wheel; +import org.junit.Assert; +import org.junit.Test; + +import java.util.LinkedList; +import java.util.List; public class TestManyToManySaveTwice extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/sp/model/IdEntity.java b/src/test/java/com/avaje/tests/sp/model/IdEntity.java index d8ccfc9b6..563ecafa6 100644 --- a/src/test/java/com/avaje/tests/sp/model/IdEntity.java +++ b/src/test/java/com/avaje/tests/sp/model/IdEntity.java @@ -9,49 +9,50 @@ import javax.persistence.Version; @MappedSuperclass public abstract class IdEntity { - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - protected Long id; - - @Version - private int version; - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public Long getId() { - return id; - } + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + protected Long id; - public void setId(Long id) { - this.id = id; - } - - @Override - public int hashCode() { - return id == null ? 31 : 31 + 31 * id.hashCode(); - } - - @Override - public boolean equals(Object obj) { - - if (this == obj) - return true; - - if (obj == null || !this.getClass().isInstance(obj)) - return false; - - IdEntity o = (IdEntity)obj; - - return id != null && o.id != null && id.equals(o.id); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[" + id + "]"; - } + @Version + private int version; + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Override + public int hashCode() { + return id == null ? 31 : 31 + 31 * id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) + return true; + + if (obj == null || !this.getClass().isInstance(obj)) + return false; + + IdEntity o = (IdEntity) obj; + + return id != null && o.id != null && id.equals(o.id); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[" + id + "]"; + } } diff --git a/src/test/java/com/avaje/tests/sp/model/car/Car.java b/src/test/java/com/avaje/tests/sp/model/car/Car.java index 4851c2e58..15f488936 100644 --- a/src/test/java/com/avaje/tests/sp/model/car/Car.java +++ b/src/test/java/com/avaje/tests/sp/model/car/Car.java @@ -1,6 +1,6 @@ package com.avaje.tests.sp.model.car; -import java.util.List; +import com.avaje.tests.sp.model.IdEntity; import javax.persistence.CascadeType; import javax.persistence.Entity; @@ -8,24 +8,23 @@ import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; - -import com.avaje.tests.sp.model.IdEntity; +import java.util.List; @Entity -@Table(name="sp_car_car") +@Table(name = "sp_car_car") public class Car extends IdEntity { - private static final long serialVersionUID = 2579148859565507940L; - - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable(name = "sp_car_car_wheels", joinColumns = {@JoinColumn(name = "car")}, inverseJoinColumns = {@JoinColumn(name = "wheel")}) - private List wheels; - - public List getWheels() { - return wheels; - } - - public void setWheels(List wheels) { - this.wheels = wheels; - } + private static final long serialVersionUID = 2579148859565507940L; + + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable(name = "sp_car_car_wheels", joinColumns = {@JoinColumn(name = "car")}, inverseJoinColumns = {@JoinColumn(name = "wheel")}) + private List wheels; + + public List getWheels() { + return wheels; + } + + public void setWheels(List wheels) { + this.wheels = wheels; + } } diff --git a/src/test/java/com/avaje/tests/sp/model/car/Wheel.java b/src/test/java/com/avaje/tests/sp/model/car/Wheel.java index 997fb0103..c2ac2ba49 100644 --- a/src/test/java/com/avaje/tests/sp/model/car/Wheel.java +++ b/src/test/java/com/avaje/tests/sp/model/car/Wheel.java @@ -1,14 +1,14 @@ package com.avaje.tests.sp.model.car; +import com.avaje.tests.sp.model.IdEntity; + import javax.persistence.Entity; import javax.persistence.Table; -import com.avaje.tests.sp.model.IdEntity; - @Entity -@Table(name="sp_car_wheel") +@Table(name = "sp_car_wheel") public class Wheel extends IdEntity { - - private static final long serialVersionUID = 2399600193947163469L; + + private static final long serialVersionUID = 2399600193947163469L; } diff --git a/src/test/java/com/avaje/tests/text/csv/TestCsvReader.java b/src/test/java/com/avaje/tests/text/csv/TestCsvReader.java index b7bde0248..cdd619f06 100644 --- a/src/test/java/com/avaje/tests/text/csv/TestCsvReader.java +++ b/src/test/java/com/avaje/tests/text/csv/TestCsvReader.java @@ -1,17 +1,16 @@ package com.avaje.tests.text.csv; -import java.io.File; -import java.io.FileReader; -import java.net.URL; -import java.util.Locale; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.csv.CsvReader; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.io.File; +import java.io.FileReader; +import java.net.URL; +import java.util.Locale; public class TestCsvReader extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/csv/TestCsvReaderWithCallback.java b/src/test/java/com/avaje/tests/text/csv/TestCsvReaderWithCallback.java index a31ab0203..81068380a 100644 --- a/src/test/java/com/avaje/tests/text/csv/TestCsvReaderWithCallback.java +++ b/src/test/java/com/avaje/tests/text/csv/TestCsvReaderWithCallback.java @@ -1,12 +1,5 @@ package com.avaje.tests.text.csv; -import java.io.File; -import java.io.FileReader; -import java.net.URL; -import java.util.Locale; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -14,6 +7,12 @@ import com.avaje.ebean.text.csv.CsvReader; import com.avaje.ebean.text.csv.DefaultCsvCallback; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.io.File; +import java.io.FileReader; +import java.net.URL; +import java.util.Locale; public class TestCsvReaderWithCallback extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/csv/TestTimeStringParser.java b/src/test/java/com/avaje/tests/text/csv/TestTimeStringParser.java index 2cc0449ae..6e52a969e 100644 --- a/src/test/java/com/avaje/tests/text/csv/TestTimeStringParser.java +++ b/src/test/java/com/avaje/tests/text/csv/TestTimeStringParser.java @@ -1,12 +1,11 @@ package com.avaje.tests.text.csv; -import java.sql.Time; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.text.TimeStringParser; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Time; public class TestTimeStringParser extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonBeanDescriptorParse.java b/src/test/java/com/avaje/tests/text/json/TestJsonBeanDescriptorParse.java index 2db845ca0..2a55721e1 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonBeanDescriptorParse.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonBeanDescriptorParse.java @@ -1,48 +1,47 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.io.StringReader; -import java.util.Set; - -import com.avaje.ebeaninternal.server.text.json.ReadJson; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeaninternal.server.text.json.ReadJson; import com.avaje.tests.model.basic.Customer; import com.fasterxml.jackson.core.JsonParser; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.io.StringReader; +import java.util.Set; public class TestJsonBeanDescriptorParse extends BaseTestCase { @Test public void test() throws IOException { - - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); - + + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); + BeanDescriptor descriptor = server.getBeanDescriptor(Customer.class); - - + + StringReader reader = new StringReader("{\"id\":123,\"name\":\"Hello rob\"}"); JsonParser parser = server.json().createParser(reader); ReadJson readJson = new ReadJson(descriptor, parser, null, null); - + Customer customer = descriptor.jsonRead(readJson, null); - + Assert.assertEquals(Integer.valueOf(123), customer.getId()); Assert.assertEquals("Hello rob", customer.getName()); - + BeanState beanState = Ebean.getBeanState(customer); Set loadedProps = beanState.getLoadedProps(); - + Assert.assertEquals(2, loadedProps.size()); Assert.assertTrue(loadedProps.contains("id")); Assert.assertTrue(loadedProps.contains("name")); - + } - + } diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonInheritanceDiscriminator.java b/src/test/java/com/avaje/tests/text/json/TestJsonInheritanceDiscriminator.java index a0174a618..8aeb3ff60 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonInheritanceDiscriminator.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonInheritanceDiscriminator.java @@ -1,18 +1,17 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.sql.Date; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.Animal; import com.avaje.tests.model.basic.Cat; import com.avaje.tests.model.basic.Dog; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.sql.Date; +import java.util.List; public class TestJsonInheritanceDiscriminator extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonMap.java b/src/test/java/com/avaje/tests/text/json/TestJsonMap.java index ecf582b50..68cd8ecdb 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonMap.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonMap.java @@ -64,11 +64,11 @@ public class TestJsonMap extends BaseTestCase { ResetBasicData.reset(); PathProperties pathProperties = - PathProperties.parse("(id,status,name,shippingAddress(id,line1,city),billingAddress(*),contacts(*))"); + PathProperties.parse("(id,status,name,shippingAddress(id,line1,city),billingAddress(*),contacts(*))"); List customers = Ebean.find(Customer.class) - .apply(pathProperties) - .findList(); + .apply(pathProperties) + .findList(); Ebean.json().toJson(customers, pathProperties); diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java b/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java index 5ccf92d73..ad763caec 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonSimple.java @@ -1,5 +1,12 @@ package com.avaje.tests.text.json; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.text.json.EJson; +import com.avaje.ebean.text.json.JsonContext; +import org.junit.Assert; +import org.junit.Test; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -9,14 +16,6 @@ import java.io.Reader; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; - -import com.avaje.ebean.BaseTestCase; -import com.avaje.ebean.Ebean; -import com.avaje.ebean.text.json.EJson; -import com.avaje.ebean.text.json.JsonContext; - public class TestJsonSimple extends BaseTestCase { @SuppressWarnings("unchecked") @@ -39,10 +38,10 @@ public class TestJsonSimple extends BaseTestCase { Object el = EJson.parse(jsonText); - Map e2 = EJson.parseObject("{\"a\":12, \"name\":{\"first\":\"rob\", \"last\":\"byg\"}}"); + Map e2 = EJson.parseObject("{\"a\":12, \"name\":{\"first\":\"rob\", \"last\":\"byg\"}}"); Assert.assertEquals(12L, e2.get("a")); - Assert.assertEquals("rob", ((Map)e2.get("name")).get("first")); + Assert.assertEquals("rob", ((Map) e2.get("name")).get("first")); Map m = new LinkedHashMap<>(); m.put("hello", "rob"); @@ -56,9 +55,9 @@ public class TestJsonSimple extends BaseTestCase { Object jsonElement = EJson.parse(s); Assert.assertNotNull(jsonElement); - Map e3 = EJson.parseObject("{\"name\":\"\\u60a8\\u597d\"}"); + Map e3 = EJson.parseObject("{\"name\":\"\\u60a8\\u597d\"}"); - Assert.assertTrue(((String)e3.get("name")).length()==2); + Assert.assertTrue(((String) e3.get("name")).length() == 2); } diff --git a/src/test/java/com/avaje/tests/text/json/TestJsonSomeEnumWithToString.java b/src/test/java/com/avaje/tests/text/json/TestJsonSomeEnumWithToString.java index 8c9c1709f..6e4aa450d 100644 --- a/src/test/java/com/avaje/tests/text/json/TestJsonSomeEnumWithToString.java +++ b/src/test/java/com/avaje/tests/text/json/TestJsonSomeEnumWithToString.java @@ -1,15 +1,14 @@ package com.avaje.tests.text.json; -import java.io.IOException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.SomeEnum; import com.avaje.tests.model.basic.SomeEnumBean; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; public class TestJsonSomeEnumWithToString extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonBeanReadVisitor.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonBeanReadVisitor.java index 77c4e9489..fbe560d02 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonBeanReadVisitor.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonBeanReadVisitor.java @@ -1,17 +1,16 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.io.StringReader; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.io.StringReader; +import java.util.List; public class TestTextJsonBeanReadVisitor extends BaseTestCase { @@ -21,11 +20,11 @@ public class TestTextJsonBeanReadVisitor extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name, status, shippingAddress") - .fetch("billingAddress", "line1, city") - .fetch("billingAddress.country", "*") - .fetch("contacts", "firstName,email") - .order().desc("id").findList(); + .select("id, name, status, shippingAddress") + .fetch("billingAddress", "line1, city") + .fetch("billingAddress.country", "*") + .fetch("contacts", "firstName,email") + .order().desc("id").findList(); JsonContext json = Ebean.json(); diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonCompoundType.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonCompoundType.java index 67f008149..938d58337 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonCompoundType.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonCompoundType.java @@ -3,9 +3,11 @@ package com.avaje.tests.text.json; //import java.util.Currency; // //import org.junit.Assert; -import org.junit.Test; -// + import com.avaje.ebean.BaseTestCase; +import org.junit.Test; + +// //import com.avaje.ebean.Ebean; //import com.avaje.ebean.text.json.JsonContext; //import com.avaje.tests.model.ddd.DExhEntity; diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonInheritance.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonInheritance.java index fc567be68..402f05a73 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonInheritance.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonInheritance.java @@ -1,21 +1,20 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import com.avaje.tests.model.basic.CarAccessory; -import com.avaje.tests.model.basic.CarFuse; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.Car; +import com.avaje.tests.model.basic.CarAccessory; +import com.avaje.tests.model.basic.CarFuse; import com.avaje.tests.model.basic.Trip; import com.avaje.tests.model.basic.Truck; import com.avaje.tests.model.basic.Vehicle; import com.avaje.tests.model.basic.VehicleDriver; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonInheritance extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonInsertUpdate.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonInsertUpdate.java index c32dc132c..d8e9f8d95 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonInsertUpdate.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonInsertUpdate.java @@ -1,15 +1,14 @@ package com.avaje.tests.text.json; -import java.io.IOException; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebeaninternal.server.lib.util.StringHelper; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.io.IOException; public class TestTextJsonInsertUpdate extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonInvokeLazy.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonInvokeLazy.java index cb785a72d..95c4e329d 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonInvokeLazy.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonInvokeLazy.java @@ -1,16 +1,15 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebean.text.json.JsonWriteOptions; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonInvokeLazy extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonReadManyLazyLoad.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonReadManyLazyLoad.java index df7014606..8ce9fc560 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonReadManyLazyLoad.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonReadManyLazyLoad.java @@ -1,11 +1,5 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.PathProperties; @@ -13,6 +7,11 @@ import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebean.text.json.JsonWriteOptions; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonReadManyLazyLoad extends BaseTestCase { @@ -22,7 +21,7 @@ public class TestTextJsonReadManyLazyLoad extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).select("id, status, shippingAddress").order() - .desc("id").findList(); + .desc("id").findList(); JsonContext json = Ebean.json(); @@ -43,7 +42,7 @@ public class TestTextJsonReadManyLazyLoad extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).select("id, status, shippingAddress") - .fetch("contacts").order().desc("id").findList(); + .fetch("contacts").order().desc("id").findList(); JsonContext json = Ebean.json(); @@ -64,8 +63,8 @@ public class TestTextJsonReadManyLazyLoad extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).select("id, name, status, shippingAddress") - // .fetch("contacts") - .order().desc("id").findList(); + // .fetch("contacts") + .order().desc("id").findList(); JsonContext json = Ebean.json(); diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonReferenceBean.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonReferenceBean.java index fea42d6b6..aaae27598 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonReferenceBean.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonReferenceBean.java @@ -1,11 +1,5 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.BeanState; import com.avaje.ebean.Ebean; @@ -18,6 +12,11 @@ import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.Product; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonReferenceBean extends BaseTestCase { @@ -26,8 +25,8 @@ public class TestTextJsonReferenceBean extends BaseTestCase { ResetBasicData.reset(); - SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null); - + SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null); + JsonContext jsonContext = Ebean.json(); Product product = Ebean.getReference(Product.class, 1); @@ -43,12 +42,12 @@ public class TestTextJsonReferenceBean extends BaseTestCase { Product refProd = jsonContext.toBean(Product.class, jsonString); BeanDescriptor prodDesc = server.getBeanDescriptor(Product.class); - EntityBean eb = (EntityBean)refProd; + EntityBean eb = (EntityBean) refProd; prodDesc.isReference(eb._ebean_getIntercept()); - + BeanState beanState = Ebean.getBeanState(refProd); Assert.assertTrue(beanState.isNew()); - + String name = refProd.getName(); Assert.assertNull(name); @@ -60,10 +59,10 @@ public class TestTextJsonReferenceBean extends BaseTestCase { } List orders = Ebean.find(Order.class) - // .setUseCache(false) - .select("status, orderDate, shipDate, customer").fetch("details", "*") - // .fetch("details.product","id") - .order().asc("id").findList(); + // .setUseCache(false) + .select("status, orderDate, shipDate, customer").fetch("details", "*") + // .fetch("details.product","id") + .order().asc("id").findList(); Order order = orders.get(0); @@ -73,10 +72,10 @@ public class TestTextJsonReferenceBean extends BaseTestCase { Order o2 = jsonContext.toBean(Order.class, jsonOrder); Customer customer = o2.getCustomer(); - + BeanDescriptor custDesc = server.getBeanDescriptor(Customer.class); - Assert.assertTrue(custDesc.isReference(((EntityBean)customer)._ebean_getIntercept())); + Assert.assertTrue(custDesc.isReference(((EntityBean) customer)._ebean_getIntercept())); } diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonSimple.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonSimple.java index 47767bd08..ed935b760 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonSimple.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonSimple.java @@ -24,7 +24,8 @@ public class TestTextJsonSimple extends BaseTestCase { class CustJsonRead implements JsonReadBeanVisitor { - Customer bean; Map unmapped; + Customer bean; + Map unmapped; @Override public void visit(Customer bean, Map unmapped) { @@ -35,7 +36,8 @@ public class TestTextJsonSimple extends BaseTestCase { class ContactJsonRead implements JsonReadBeanVisitor { - Contact bean; Map unmapped; + Contact bean; + Map unmapped; @Override public void visit(Contact bean, Map unmapped) { @@ -46,7 +48,8 @@ public class TestTextJsonSimple extends BaseTestCase { class AddressJsonRead implements JsonReadBeanVisitor
{ - Address bean; Map unmapped; + Address bean; + Map unmapped; @Override public void visit(Address bean, Map unmapped) { @@ -61,10 +64,10 @@ public class TestTextJsonSimple extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name, status, shippingAddress") - .fetch("billingAddress", "line1, city").fetch("billingAddress.country", "*") - .fetch("contacts", "firstName,email") - .order().desc("id").findList(); + .select("id, name, status, shippingAddress") + .fetch("billingAddress", "line1, city").fetch("billingAddress.country", "*") + .fetch("contacts", "firstName,email") + .order().desc("id").findList(); EbeanServer server = Ebean.getServer(null); @@ -99,8 +102,8 @@ public class TestTextJsonSimple extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name") - .order().desc("id").findList(); + .select("id, name") + .order().desc("id").findList(); EbeanServer server = Ebean.getServer(null); @@ -122,8 +125,8 @@ public class TestTextJsonSimple extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class) - .select("id, name") - .order().desc("id").findList(); + .select("id, name") + .order().desc("id").findList(); EbeanServer server = Ebean.getServer(null); diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonSuperSimple.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonSuperSimple.java index f46ff2963..40b74e65f 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonSuperSimple.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonSuperSimple.java @@ -1,17 +1,16 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; import com.avaje.ebean.text.json.JsonContext; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonSuperSimple extends BaseTestCase { @@ -21,7 +20,7 @@ public class TestTextJsonSuperSimple extends BaseTestCase { ResetBasicData.reset(); List list = Ebean.find(Customer.class).select("id, name").order().desc("id") - .findList(); + .findList(); EbeanServer server = Ebean.getServer(null); diff --git a/src/test/java/com/avaje/tests/text/json/TestTextJsonUpdateCascade.java b/src/test/java/com/avaje/tests/text/json/TestTextJsonUpdateCascade.java index ffd599d4a..21c92a433 100644 --- a/src/test/java/com/avaje/tests/text/json/TestTextJsonUpdateCascade.java +++ b/src/test/java/com/avaje/tests/text/json/TestTextJsonUpdateCascade.java @@ -1,11 +1,5 @@ package com.avaje.tests.text.json; -import java.io.IOException; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -18,6 +12,11 @@ import com.avaje.tests.model.basic.Order.Status; import com.avaje.tests.model.basic.OrderDetail; import com.avaje.tests.model.basic.Product; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; public class TestTextJsonUpdateCascade extends BaseTestCase { @@ -87,8 +86,8 @@ public class TestTextJsonUpdateCascade extends BaseTestCase { jsonContext.toJson(u0); String s = "{\"userid\":" + u0.getUserid() - + ",\"userName\":\"userj1\", \"roles\":[{\"roleid\":" + r2.getRoleid() + "},{\"roleid\":" - + r3.getRoleid() + "}]} "; + + ",\"userName\":\"userj1\", \"roles\":[{\"roleid\":" + r2.getRoleid() + "},{\"roleid\":" + + r3.getRoleid() + "}]} "; MUser updMUser = jsonContext.toBean(MUser.class, s); diff --git a/src/test/java/com/avaje/tests/timezone/TimezoneTests.java b/src/test/java/com/avaje/tests/timezone/TimezoneTests.java index f70574345..4860b513f 100644 --- a/src/test/java/com/avaje/tests/timezone/TimezoneTests.java +++ b/src/test/java/com/avaje/tests/timezone/TimezoneTests.java @@ -50,11 +50,11 @@ public class TimezoneTests { PreparedStatement statement = connection.prepareStatement("select * from tztest"); ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { - System.out.println(" zone:"+resultSet.getString("zone")); - System.out.println(" ts:"+tsof(resultSet.getTimestamp("ts"))); - System.out.println(" tstz:"+tsof(resultSet.getTimestamp("tstz"))); - System.out.println(" ts1:"+tsof(resultSet.getTimestamp("ts1", cal()))); - System.out.println("tstz1:"+tsof(resultSet.getTimestamp("tstz1", cal()))); + System.out.println(" zone:" + resultSet.getString("zone")); + System.out.println(" ts:" + tsof(resultSet.getTimestamp("ts"))); + System.out.println(" tstz:" + tsof(resultSet.getTimestamp("tstz"))); + System.out.println(" ts1:" + tsof(resultSet.getTimestamp("ts1", cal()))); + System.out.println("tstz1:" + tsof(resultSet.getTimestamp("tstz1", cal()))); } System.out.println(""); resultSet.close(); @@ -63,7 +63,7 @@ public class TimezoneTests { } private String tsof(Timestamp timestamp) { - return ""+timestamp.getTime()+", "+timestamp.toString()+", "+timestamp.toInstant(); + return "" + timestamp.getTime() + ", " + timestamp.toString() + ", " + timestamp.toInstant(); } private void setZone(String zone) { diff --git a/src/test/java/com/avaje/tests/timezone/TzBean.java b/src/test/java/com/avaje/tests/timezone/TzBean.java index 258c8b2d5..86a3092ed 100644 --- a/src/test/java/com/avaje/tests/timezone/TzBean.java +++ b/src/test/java/com/avaje/tests/timezone/TzBean.java @@ -7,7 +7,7 @@ import javax.persistence.Table; import java.sql.Timestamp; @Entity -@Table(name="tz_bean") +@Table(name = "tz_bean") public class TzBean { @Id diff --git a/src/test/java/com/avaje/tests/timezone/TzBeanTests.java b/src/test/java/com/avaje/tests/timezone/TzBeanTests.java index d03a20fa1..b7e519e4d 100644 --- a/src/test/java/com/avaje/tests/timezone/TzBeanTests.java +++ b/src/test/java/com/avaje/tests/timezone/TzBeanTests.java @@ -10,7 +10,6 @@ import java.util.TimeZone; //import java.util.TimeZone; - // Postgres // manually create table // create table tz_bean (id serial, mode varchar(40), ts timestamp, tstz timestamp with time zone); @@ -79,16 +78,16 @@ public class TzBeanTests { System.setProperty("ebean.dataTimeZone", "UTC"); List list = Ebean.find(TzBean.class) - .findList(); + .findList(); for (TzBean bean : list) { - System.out.println(" mode:"+bean.getMode()); - System.out.println(" ts:"+tsof(bean.getTs())); - System.out.println(" tstz:"+tsof(bean.getTstz())); + System.out.println(" mode:" + bean.getMode()); + System.out.println(" ts:" + tsof(bean.getTs())); + System.out.println(" tstz:" + tsof(bean.getTstz())); } } private String tsof(Timestamp timestamp) { - return ""+timestamp.getTime()+", "+timestamp.toString()+", "+timestamp.toInstant(); + return "" + timestamp.getTime() + ", " + timestamp.toString() + ", " + timestamp.toInstant(); } } diff --git a/src/test/java/com/avaje/tests/transaction/TestBatchPersistCascade.java b/src/test/java/com/avaje/tests/transaction/TestBatchPersistCascade.java index db66fb72f..fd9dfb7ea 100644 --- a/src/test/java/com/avaje/tests/transaction/TestBatchPersistCascade.java +++ b/src/test/java/com/avaje/tests/transaction/TestBatchPersistCascade.java @@ -68,7 +68,7 @@ public class TestBatchPersistCascade extends BaseTestCase { txn.setBatchOnCascade(PersistBatch.ALL); for (int i = 0; i < 3; i++) { - UTMaster master = createMaster(i+500); + UTMaster master = createMaster(i + 500); logger.info("save ------------ {}", i); server.save(master); } @@ -77,11 +77,11 @@ public class TestBatchPersistCascade extends BaseTestCase { UTMaster lastMaster = null; for (UTMaster utMaster : list) { - utMaster.setName(utMaster.getName()+" + mod"); + utMaster.setName(utMaster.getName() + " + mod"); List details = utMaster.getDetails(); for (UTDetail detail : details) { - detail.setQty(detail.getQty()+7); - detail.setName(detail.getName()+" + foo"); + detail.setQty(detail.getQty() + 7); + detail.setName(detail.getName() + " + foo"); } server.save(utMaster); @@ -91,7 +91,7 @@ public class TestBatchPersistCascade extends BaseTestCase { logger.info("starting some inserts ------------ "); for (int i = 0; i < 3; i++) { - UTMaster master = createMaster(i+1000); + UTMaster master = createMaster(i + 1000); logger.info("save ------------ {}", i); server.save(master); if (i == 1) { @@ -112,7 +112,7 @@ public class TestBatchPersistCascade extends BaseTestCase { private UTDetail createUTDetail(String master, int count) { UTDetail detail = new UTDetail(); - detail.setName(master+"-"+count); + detail.setName(master + "-" + count); detail.setAmount(50d); detail.setQty(count); return detail; @@ -120,11 +120,11 @@ public class TestBatchPersistCascade extends BaseTestCase { private UTMaster createMaster(int count) { - String name = "master"+count; + String name = "master" + count; UTMaster m0 = new UTMaster(); m0.setName(name); - for (int i =0; i< 5; i++) { + for (int i = 0; i < 5; i++) { m0.addDetail(createUTDetail(name, i)); } return m0; diff --git a/src/test/java/com/avaje/tests/transaction/TestCreateTransactionWithIsolation.java b/src/test/java/com/avaje/tests/transaction/TestCreateTransactionWithIsolation.java index 575a0e0d9..4b372e6ee 100644 --- a/src/test/java/com/avaje/tests/transaction/TestCreateTransactionWithIsolation.java +++ b/src/test/java/com/avaje/tests/transaction/TestCreateTransactionWithIsolation.java @@ -1,6 +1,6 @@ package com.avaje.tests.transaction; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; import org.junit.Test; public class TestCreateTransactionWithIsolation extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/transaction/TestDeleteFromPersistenceContext.java b/src/test/java/com/avaje/tests/transaction/TestDeleteFromPersistenceContext.java index 79d26407b..6571f37ed 100644 --- a/src/test/java/com/avaje/tests/transaction/TestDeleteFromPersistenceContext.java +++ b/src/test/java/com/avaje/tests/transaction/TestDeleteFromPersistenceContext.java @@ -15,29 +15,29 @@ public class TestDeleteFromPersistenceContext extends BaseTestCase { @Test public void testDeleteBean() { - + ResetBasicData.reset(); - + EBasicVer bean = new EBasicVer("Please Delete Me"); Ebean.save(bean); - - SpiTransaction transaction = (SpiTransaction)Ebean.beginTransaction(); + + SpiTransaction transaction = (SpiTransaction) Ebean.beginTransaction(); try { - + EBasicVer bean2 = Ebean.find(EBasicVer.class, bean.getId()); assertNotSame(bean, bean2); - + EBasicVer bean3 = Ebean.find(EBasicVer.class, bean.getId()); - // same instance from PersistenceContext + // same instance from PersistenceContext assertSame(bean2, bean3); - + Object bean4 = transaction.getPersistenceContext().get(EBasicVer.class, bean.getId()); assertSame(bean2, bean4); - + Ebean.delete(bean2); Object bean5 = transaction.getPersistenceContext().get(EBasicVer.class, bean.getId()); - assertNull("Bean is deleted from PersistenceContext",bean5); + assertNull("Bean is deleted from PersistenceContext", bean5); Ebean.commitTransaction(); @@ -46,12 +46,12 @@ public class TestDeleteFromPersistenceContext extends BaseTestCase { } EBasicVer bean6 = Ebean.find(EBasicVer.class).where().eq("id", bean.getId()).findUnique(); - assertNull("Bean where id eq is not found "+bean6, bean6); + assertNull("Bean where id eq is not found " + bean6, bean6); awaitL2Cache(); EBasicVer bean7 = Ebean.find(EBasicVer.class, bean.getId()); - assertNull("Bean is not expected to be found? "+bean7, bean7); + assertNull("Bean is not expected to be found? " + bean7, bean7); } - + } diff --git a/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java b/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java index e83c9b328..ed8f1d652 100644 --- a/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java +++ b/src/test/java/com/avaje/tests/transaction/TestInsertManyAndRef.java @@ -1,14 +1,13 @@ package com.avaje.tests.transaction; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.BBookmark; import com.avaje.tests.model.basic.BBookmarkUser; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class TestInsertManyAndRef extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/transaction/TestNested.java b/src/test/java/com/avaje/tests/transaction/TestNested.java index 7d0519c77..74fb4e870 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNested.java +++ b/src/test/java/com/avaje/tests/transaction/TestNested.java @@ -1,11 +1,10 @@ package com.avaje.tests.transaction; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.TxRunnable; +import org.junit.Assert; +import org.junit.Test; public class TestNested extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequired.java b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequired.java index 163463ed5..685103f9e 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequired.java +++ b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequired.java @@ -1,6 +1,10 @@ package com.avaje.tests.transaction; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TxScope; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Product; diff --git a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiredWithFailure.java b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiredWithFailure.java index 1f52a9c03..af6d811c5 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiredWithFailure.java +++ b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiredWithFailure.java @@ -1,7 +1,14 @@ package com.avaje.tests.transaction; -import com.avaje.ebean.*; -import com.avaje.tests.model.basic.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TxScope; +import com.avaje.tests.model.basic.Country; +import com.avaje.tests.model.basic.Customer; +import com.avaje.tests.model.basic.EBasic; +import com.avaje.tests.model.basic.Product; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNew.java b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNew.java index 21d85d4b0..54ea5c366 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNew.java +++ b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNew.java @@ -1,6 +1,10 @@ package com.avaje.tests.transaction; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TxScope; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Product; diff --git a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNewWithFailure.java b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNewWithFailure.java index a99324c69..10cbba35b 100644 --- a/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNewWithFailure.java +++ b/src/test/java/com/avaje/tests/transaction/TestNestedBeginRequiresNewWithFailure.java @@ -1,6 +1,10 @@ package com.avaje.tests.transaction; -import com.avaje.ebean.*; +import com.avaje.ebean.BaseTestCase; +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.Transaction; +import com.avaje.ebean.TxScope; import com.avaje.tests.model.basic.Country; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Product; diff --git a/src/test/java/com/avaje/tests/transaction/TestPersistContextClear.java b/src/test/java/com/avaje/tests/transaction/TestPersistContextClear.java index b79c30348..f3b8c6db1 100644 --- a/src/test/java/com/avaje/tests/transaction/TestPersistContextClear.java +++ b/src/test/java/com/avaje/tests/transaction/TestPersistContextClear.java @@ -1,10 +1,5 @@ package com.avaje.tests.transaction; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -14,6 +9,10 @@ import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestPersistContextClear extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/transaction/TransactionNotTerminatedAfterRollback.java b/src/test/java/com/avaje/tests/transaction/TransactionNotTerminatedAfterRollback.java index aff082d25..6dec3f255 100644 --- a/src/test/java/com/avaje/tests/transaction/TransactionNotTerminatedAfterRollback.java +++ b/src/test/java/com/avaje/tests/transaction/TransactionNotTerminatedAfterRollback.java @@ -1,73 +1,79 @@ package com.avaje.tests.transaction; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.List; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.PersistenceException; -import javax.persistence.Table; - +import com.avaje.ebean.Ebean; +import com.avaje.ebean.annotation.Transactional; import org.avaje.agentloader.AgentLoader; import org.junit.BeforeClass; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.avaje.ebean.Ebean; -import com.avaje.ebean.annotation.Transactional; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PersistenceException; +import javax.persistence.Table; +import java.util.List; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * It shows the issue that the user record does NOT rolback when there is an exception thrown */ public class TransactionNotTerminatedAfterRollback { - private static final Logger LOG = LoggerFactory.getLogger(TransactionNotTerminatedAfterRollback.class); + private static final Logger LOG = LoggerFactory.getLogger(TransactionNotTerminatedAfterRollback.class); - @BeforeClass public static void preStart() { - LOG.debug("... preStart"); - // display the log message to see if the UserService is enhanced - AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", "debug=1"); - } + @BeforeClass + public static void preStart() { + LOG.debug("... preStart"); + // display the log message to see if the UserService is enhanced + AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", "debug=1"); + } - @Test public void test() { - try { - new UserService().create(new User(1L, "David")); - fail("Exception should be thrown"); - } catch (PersistenceException pe) { - LOG.error("e: " + pe); - } - List users = Ebean.find(User.class).findList(); - LOG.debug("users: {}", users); - assertTrue("users should be empty", users.isEmpty()); - } + @Test + public void test() { + try { + new UserService().create(new User(1L, "David")); + fail("Exception should be thrown"); + } catch (PersistenceException pe) { + LOG.error("e: " + pe); + } + List users = Ebean.find(User.class).findList(); + LOG.debug("users: {}", users); + assertTrue("users should be empty", users.isEmpty()); + } - @Transactional(rollbackFor = PersistenceException.class) public class UserService { - public void create(User i) { - Ebean.save(i); - Ebean.save(new User(1L, "Peter")); // make it throw exception and rollback - } - } + @Transactional(rollbackFor = PersistenceException.class) + public class UserService { + public void create(User i) { + Ebean.save(i); + Ebean.save(new User(1L, "Peter")); // make it throw exception and rollback + } + } - @Entity @Table(name="tx_user") public static class User { - @Id Long id; - String name; + @Entity + @Table(name = "tx_user") + public static class User { + @Id + Long id; + String name; - public User() {} + public User() { + } - public User(Long id, String name) { - this.id = id; - this.name = name; - } + public User(Long id, String name) { + this.id = id; + this.name = name; + } - @Override public String toString() { - StringBuilder s = new StringBuilder(); - s.append("{"); - s.append("id: ").append(id).append(", "); - s.append("name: ").append(name); - s.append("}"); - return s.toString(); - } - } + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append("{"); + s.append("id: ").append(id).append(", "); + s.append("name: ").append(name); + s.append("}"); + return s.toString(); + } + } } diff --git a/src/test/java/com/avaje/tests/types/TestFileType.java b/src/test/java/com/avaje/tests/types/TestFileType.java index c08dce4eb..657b7327c 100644 --- a/src/test/java/com/avaje/tests/types/TestFileType.java +++ b/src/test/java/com/avaje/tests/types/TestFileType.java @@ -26,9 +26,9 @@ public class TestFileType extends BaseTestCase { Ebean.save(bean0); SomeFileBean bean1 = Ebean.find(SomeFileBean.class) - .select("name, file") - .setId(bean0.getId()) - .findUnique(); + .select("name, file") + .setId(bean0.getId()) + .findUnique(); assertEquals("afile", bean1.getName()); assertNull(bean1.getContent()); @@ -37,16 +37,16 @@ public class TestFileType extends BaseTestCase { Ebean.save(bean1); SomeFileBean bean2 = Ebean.find(SomeFileBean.class) - .select("name, file") - .setId(bean0.getId()) - .findUnique(); + .select("name, file") + .setId(bean0.getId()) + .findUnique(); assertEquals("afile", bean2.getName()); assertNotNull(bean2.getContent()); Ebean.delete(bean1); } - @Test + @Test public void test_insertUpdateDelete() { assertTrue(file.exists()); @@ -59,9 +59,9 @@ public class TestFileType extends BaseTestCase { Ebean.save(bean0); SomeFileBean bean1 = Ebean.find(SomeFileBean.class) - .select("name, file") - .setId(bean0.getId()) - .findUnique(); + .select("name, file") + .setId(bean0.getId()) + .findUnique(); assertEquals("afile", bean1.getName()); assertNotNull(bean1.getContent()); @@ -74,9 +74,9 @@ public class TestFileType extends BaseTestCase { SomeFileBean bean2 = Ebean.find(SomeFileBean.class) - .select("name, file") - .setId(bean0.getId()) - .findUnique(); + .select("name, file") + .setId(bean0.getId()) + .findUnique(); assertEquals(file2.length(), bean2.getContent().length()); @@ -86,9 +86,9 @@ public class TestFileType extends BaseTestCase { Ebean.save(bean2); SomeFileBean bean3 = Ebean.find(SomeFileBean.class) - .select("name, file") - .setId(bean0.getId()) - .findUnique(); + .select("name, file") + .setId(bean0.getId()) + .findUnique(); assertNull(bean3.getContent()); diff --git a/src/test/java/com/avaje/tests/types/TestFileTypeFetching.java b/src/test/java/com/avaje/tests/types/TestFileTypeFetching.java index a1fab4217..250a4c536 100644 --- a/src/test/java/com/avaje/tests/types/TestFileTypeFetching.java +++ b/src/test/java/com/avaje/tests/types/TestFileTypeFetching.java @@ -28,8 +28,8 @@ public class TestFileTypeFetching extends BaseTestCase { Ebean.save(bean0); SomeFileBean bean1 = Ebean.find(SomeFileBean.class) - .setId(bean0.getId()) - .findUnique(); + .setId(bean0.getId()) + .findUnique(); BeanState beanState = Ebean.getBeanState(bean1); Set loadedProps = beanState.getLoadedProps(); @@ -48,9 +48,9 @@ public class TestFileTypeFetching extends BaseTestCase { Ebean.update(statelessUpdateBean); SomeFileBean bean2 = Ebean.find(SomeFileBean.class) - .select("file") - .setId(bean0.getId()) - .findUnique(); + .select("file") + .setId(bean0.getId()) + .findUnique(); assertEquals(file2.length(), bean2.getContent().length()); diff --git a/src/test/java/com/avaje/tests/types/TestHstore.java b/src/test/java/com/avaje/tests/types/TestHstore.java index 2bd8c9d44..684963efe 100644 --- a/src/test/java/com/avaje/tests/types/TestHstore.java +++ b/src/test/java/com/avaje/tests/types/TestHstore.java @@ -65,7 +65,7 @@ public class TestHstore extends BaseTestCase { EBasicHstore found = Ebean.find(EBasicHstore.class, bean.getId()); found.setName("modNamePlus"); - found.getMap().put("foo","9987"); + found.getMap().put("foo", "9987"); LoggedSqlCollector.start(); Ebean.save(found); diff --git a/src/test/java/com/avaje/tests/types/TestNewTypes.java b/src/test/java/com/avaje/tests/types/TestNewTypes.java index 5fc5edaa4..02ef14732 100644 --- a/src/test/java/com/avaje/tests/types/TestNewTypes.java +++ b/src/test/java/com/avaje/tests/types/TestNewTypes.java @@ -8,16 +8,24 @@ import org.junit.Test; import java.io.File; import java.io.IOException; import java.nio.file.Paths; -import java.time.*; +import java.time.DayOfWeek; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.Year; +import java.time.YearMonth; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestNewTypes extends BaseTestCase { - private static final String TEMP_PATH = new File("/tmp").getAbsolutePath(); + private static final String TEMP_PATH = new File("/tmp").getAbsolutePath(); + @Test public void testInsertUpdate() throws IOException, InterruptedException { SomeNewTypesBean bean = new SomeNewTypesBean(); diff --git a/src/test/java/com/avaje/tests/types/TestPeriodType.java b/src/test/java/com/avaje/tests/types/TestPeriodType.java index 4378f46f6..1b8c80043 100644 --- a/src/test/java/com/avaje/tests/types/TestPeriodType.java +++ b/src/test/java/com/avaje/tests/types/TestPeriodType.java @@ -39,29 +39,29 @@ public class TestPeriodType extends BaseTestCase { assertNull(bean3.getAnniversary()); List anniversaryList = Ebean.find(SomePeriodBean.class) - .where() - .eq("anniversary", MonthDay.of(4, 29)) - .eq("period_years", 3) - .eq("period_months", 4) - .findList(); + .where() + .eq("anniversary", MonthDay.of(4, 29)) + .eq("period_years", 3) + .eq("period_months", 4) + .findList(); assertEquals(1, anniversaryList.size()); // must use year 2000 for range predicates // ... using 2001 here so not finding anything anniversaryList = Ebean.find(SomePeriodBean.class) - .where() - .gt("anniversary", Date.valueOf(LocalDate.of(2001,4, 29))) - .findList(); + .where() + .gt("anniversary", Date.valueOf(LocalDate.of(2001, 4, 29))) + .findList(); assertEquals(0, anniversaryList.size()); // can use year 2000 for range predicates // ... and can use LocalDate to bind anniversaryList = Ebean.find(SomePeriodBean.class) - .where() - .gt("anniversary", LocalDate.of(2000,4, 22)) - .findList(); + .where() + .gt("anniversary", LocalDate.of(2000, 4, 22)) + .findList(); assertEquals(1, anniversaryList.size()); diff --git a/src/test/java/com/avaje/tests/unidirectional/TestUniDirectional.java b/src/test/java/com/avaje/tests/unidirectional/TestUniDirectional.java index 44f0cf9b5..f967aae1e 100644 --- a/src/test/java/com/avaje/tests/unidirectional/TestUniDirectional.java +++ b/src/test/java/com/avaje/tests/unidirectional/TestUniDirectional.java @@ -1,14 +1,13 @@ package com.avaje.tests.unidirectional; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.UTDetail; import com.avaje.tests.model.basic.UTMaster; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestUniDirectional extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/unitinternal/HelloMain.java b/src/test/java/com/avaje/tests/unitinternal/HelloMain.java index 659ade8a4..421ff81ae 100644 --- a/src/test/java/com/avaje/tests/unitinternal/HelloMain.java +++ b/src/test/java/com/avaje/tests/unitinternal/HelloMain.java @@ -1,16 +1,15 @@ package com.avaje.tests.unitinternal; -import java.io.File; - -import org.avaje.agentloader.AgentLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.EbeanServerFactory; -import org.avaje.datasource.DataSourceConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.tests.model.basic.TOne; +import org.avaje.agentloader.AgentLoader; +import org.avaje.datasource.DataSourceConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; public class HelloMain { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestBasics.java b/src/test/java/com/avaje/tests/unitinternal/TestBasics.java index 520ec21ff..8d6d5a0d0 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestBasics.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestBasics.java @@ -1,29 +1,28 @@ - package com.avaje.tests.unitinternal; import org.junit.Assert; import org.junit.Test; -public class TestBasics { +public class TestBasics { - private String parentPath(String path) { - - int pos = path.lastIndexOf('.'); - if (pos == -1){ - return null; - } else { - return path.substring(0, pos); - } - } - - @Test - public void testParentPath() { - - Assert.assertTrue((parentPath("banana") == null)); - Assert.assertTrue((parentPath("banana.apple").equals("banana"))); - Assert.assertTrue((parentPath("banana.apple.o").equals("banana.apple"))); - - } + private String parentPath(String path) { + + int pos = path.lastIndexOf('.'); + if (pos == -1) { + return null; + } else { + return path.substring(0, pos); + } + } + + @Test + public void testParentPath() { + + Assert.assertTrue((parentPath("banana") == null)); + Assert.assertTrue((parentPath("banana.apple").equals("banana"))); + Assert.assertTrue((parentPath("banana.apple.o").equals("banana.apple"))); + + } } diff --git a/src/test/java/com/avaje/tests/unitinternal/TestEqualsOnEnhanced.java b/src/test/java/com/avaje/tests/unitinternal/TestEqualsOnEnhanced.java index 83a6f0ea3..d88af051c 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestEqualsOnEnhanced.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestEqualsOnEnhanced.java @@ -1,12 +1,11 @@ package com.avaje.tests.unitinternal; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.bean.EntityBean; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; +import org.junit.Assert; +import org.junit.Test; public class TestEqualsOnEnhanced extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestLocaleParse.java b/src/test/java/com/avaje/tests/unitinternal/TestLocaleParse.java index 0f12dfa1c..33eed175e 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestLocaleParse.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestLocaleParse.java @@ -1,11 +1,10 @@ package com.avaje.tests.unitinternal; -import java.util.Locale; - +import com.avaje.ebeaninternal.server.type.ScalarTypeLocale; import org.junit.Assert; import org.junit.Test; -import com.avaje.ebeaninternal.server.type.ScalarTypeLocale; +import java.util.Locale; public class TestLocaleParse { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestNamingConvention.java b/src/test/java/com/avaje/tests/unitinternal/TestNamingConvention.java index ae5c8a196..2f251362a 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestNamingConvention.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestNamingConvention.java @@ -4,16 +4,16 @@ import junit.framework.TestCase; public class TestNamingConvention extends TestCase { - /** - * Test dummy method to allow rest to be commented out. - */ - public void testDummy() { - - } - - // Comment out for now so the entities do not get registered - // Run this manually as needed. - + /** + * Test dummy method to allow rest to be commented out. + */ + public void testDummy() { + + } + + // Comment out for now so the entities do not get registered + // Run this manually as needed. + // @Entity // @Table(name = "table1", schema = "annotationschema") // public class FooBar1 { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestNullCollectionSet.java b/src/test/java/com/avaje/tests/unitinternal/TestNullCollectionSet.java index 108060325..f428afc12 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestNullCollectionSet.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestNullCollectionSet.java @@ -1,15 +1,14 @@ package com.avaje.tests.unitinternal; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; import com.avaje.tests.model.basic.ENullCollection; import com.avaje.tests.model.basic.ENullCollectionDetail; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestNullCollectionSet extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java b/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java index 940b352e8..ff7507bf4 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestOrderByParse.java @@ -4,9 +4,7 @@ import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.OrderBy; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** * Test the OrderBy object and especially its parsing. diff --git a/src/test/java/com/avaje/tests/unitinternal/TestOriginIntEncoding.java b/src/test/java/com/avaje/tests/unitinternal/TestOriginIntEncoding.java index f5e753ab6..627285b93 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestOriginIntEncoding.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestOriginIntEncoding.java @@ -1,10 +1,9 @@ package com.avaje.tests.unitinternal; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.bean.CallStack; +import org.junit.Assert; +import org.junit.Test; public class TestOriginIntEncoding extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestTxTypeOnTransactional.java b/src/test/java/com/avaje/tests/unitinternal/TestTxTypeOnTransactional.java index 63a76739a..7fdd5400f 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestTxTypeOnTransactional.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestTxTypeOnTransactional.java @@ -1,18 +1,17 @@ package com.avaje.tests.unitinternal; -import javax.persistence.OptimisticLockException; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Transaction; import com.avaje.tests.model.basic.EBasicVer; import com.avaje.tests.model.basic.xtra.DummyDao; import com.avaje.tests.model.basic.xtra.OptimisticLockExceptionThrowingDao; +import org.junit.Assert; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.persistence.OptimisticLockException; public class TestTxTypeOnTransactional extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/unitinternal/TestVanillaCollectionSet.java b/src/test/java/com/avaje/tests/unitinternal/TestVanillaCollectionSet.java index b4aa4a90b..3b21938df 100644 --- a/src/test/java/com/avaje/tests/unitinternal/TestVanillaCollectionSet.java +++ b/src/test/java/com/avaje/tests/unitinternal/TestVanillaCollectionSet.java @@ -1,15 +1,14 @@ package com.avaje.tests.unitinternal; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.bean.BeanCollection; import com.avaje.tests.model.basic.EVanillaCollection; import com.avaje.tests.model.basic.EVanillaCollectionDetail; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestVanillaCollectionSet extends BaseTestCase { diff --git a/src/test/java/com/avaje/tests/update/TestEmbeddedRefreshUpdate.java b/src/test/java/com/avaje/tests/update/TestEmbeddedRefreshUpdate.java index 24e832ead..75f2ebe51 100644 --- a/src/test/java/com/avaje/tests/update/TestEmbeddedRefreshUpdate.java +++ b/src/test/java/com/avaje/tests/update/TestEmbeddedRefreshUpdate.java @@ -1,14 +1,13 @@ package com.avaje.tests.update; -import java.util.Date; - -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.embedded.EEmbDatePeriod; import com.avaje.tests.model.embedded.EEmbInner; import com.avaje.tests.model.embedded.EEmbOuter; +import org.junit.Test; + +import java.util.Date; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/avaje/tests/update/TestJsonStatelessUpdate.java b/src/test/java/com/avaje/tests/update/TestJsonStatelessUpdate.java index 9678eb7f0..a3e8779f7 100644 --- a/src/test/java/com/avaje/tests/update/TestJsonStatelessUpdate.java +++ b/src/test/java/com/avaje/tests/update/TestJsonStatelessUpdate.java @@ -1,22 +1,21 @@ package com.avaje.tests.update; -import java.io.IOException; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.text.json.JsonContext; import com.avaje.ebean.text.json.JsonWriteOptions; import com.avaje.tests.model.basic.UUOne; import com.avaje.tests.model.basic.UUTwo; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; public class TestJsonStatelessUpdate extends BaseTestCase { @Test public void test() throws IOException { - + UUOne one = new UUOne(); one.setName("oneName"); @@ -25,29 +24,29 @@ public class TestJsonStatelessUpdate extends BaseTestCase { UUTwo two = new UUTwo(); two.setMaster(one); two.setName("twoName"); - + Ebean.save(two); - + UUTwo twoX = Ebean.find(UUTwo.class, two.getId()); - + JsonContext jsonContext = Ebean.json(); - + JsonWriteOptions writeOptions = JsonWriteOptions.parsePath("(id,name,master(*))"); String jsonString = jsonContext.toJson(twoX, writeOptions); - + jsonString = jsonString.replace("twoName", "twoNameModified"); jsonString = jsonString.replace("oneName", "oneNameModified"); - - + + UUTwo two2 = jsonContext.toBean(UUTwo.class, jsonString); - + Assert.assertEquals(twoX.getId(), two2.getId()); Assert.assertEquals("twoNameModified", two2.getName()); Assert.assertEquals("oneNameModified", two2.getMaster().getName()); // The update below cascades to also save "master" and that fails // as it thinks it should INSERT master rather than UPDATE master - + Ebean.update(two2); awaitL2Cache(); @@ -57,7 +56,7 @@ public class TestJsonStatelessUpdate extends BaseTestCase { Assert.assertEquals("twoNameModified", twoConfirm.getName()); Assert.assertEquals("oneNameModified", twoConfirm.getMaster().getName()); - + } - + } diff --git a/src/test/java/com/avaje/tests/update/TestMarkAsDirty.java b/src/test/java/com/avaje/tests/update/TestMarkAsDirty.java index 789ec6e1d..55dcad9ff 100644 --- a/src/test/java/com/avaje/tests/update/TestMarkAsDirty.java +++ b/src/test/java/com/avaje/tests/update/TestMarkAsDirty.java @@ -1,27 +1,26 @@ package com.avaje.tests.update; -import java.sql.Timestamp; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EBasicVer; +import org.junit.Assert; +import org.junit.Test; + +import java.sql.Timestamp; public class TestMarkAsDirty extends BaseTestCase { @Test public void test() throws InterruptedException { - + EBasicVer bean = new EBasicVer("markAsDirty"); Ebean.save(bean); - + Timestamp lastUpdate = bean.getLastUpdate(); Assert.assertNotNull(lastUpdate); - + Thread.sleep(100); - + // ensure the update occurs and version property is updated/incremented Ebean.markAsDirty(bean); Ebean.save(bean); @@ -29,7 +28,7 @@ public class TestMarkAsDirty extends BaseTestCase { Timestamp lastUpdate2 = bean.getLastUpdate(); Assert.assertNotNull(lastUpdate2); Assert.assertNotEquals(lastUpdate, lastUpdate2); - + } - + } diff --git a/src/test/java/com/avaje/tests/update/TestPostgresTruncate.java b/src/test/java/com/avaje/tests/update/TestPostgresTruncate.java index 84803ebce..dfec7829f 100644 --- a/src/test/java/com/avaje/tests/update/TestPostgresTruncate.java +++ b/src/test/java/com/avaje/tests/update/TestPostgresTruncate.java @@ -1,10 +1,9 @@ package com.avaje.tests.update; +import com.avaje.ebean.BaseTestCase; import org.junit.Assert; import org.junit.Test; -import com.avaje.ebean.BaseTestCase; - public class TestPostgresTruncate extends BaseTestCase { @Test diff --git a/src/test/java/com/avaje/tests/update/TestSqlUpdateBindMultipleLists.java b/src/test/java/com/avaje/tests/update/TestSqlUpdateBindMultipleLists.java index 4590fbf1a..fae9d4382 100644 --- a/src/test/java/com/avaje/tests/update/TestSqlUpdateBindMultipleLists.java +++ b/src/test/java/com/avaje/tests/update/TestSqlUpdateBindMultipleLists.java @@ -57,7 +57,7 @@ public class TestSqlUpdateBindMultipleLists extends BaseTestCase { sqlUpdate.execute(); assertEquals("delete from o_customer where id in (?) and name in (?,?)", sqlUpdate.getGeneratedSql()); - sqlUpdate.setParameter("ids", asList(9992,4545)); + sqlUpdate.setParameter("ids", asList(9992, 4545)); sqlUpdate.setParameter("names", asList("ro3b")); sqlUpdate.execute(); assertEquals("delete from o_customer where id in (?,?) and name in (?)", sqlUpdate.getGeneratedSql()); diff --git a/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java b/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java index f8eff5f18..6e80edd5f 100644 --- a/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java +++ b/src/test/java/com/avaje/tests/update/TestSqlUpdateInTxn.java @@ -1,13 +1,11 @@ package com.avaje.tests.update; -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.SqlUpdate; -import com.avaje.ebean.TxRunnable; import com.avaje.tests.idkeys.db.AuditLog; +import org.junit.Assert; +import org.junit.Test; public class TestSqlUpdateInTxn extends BaseTestCase { @@ -20,36 +18,36 @@ public class TestSqlUpdateInTxn extends BaseTestCase { AuditLog log = new AuditLog(); log.setDescription("foo"); - + Ebean.save(log); - + AuditLog log2 = Ebean.find(AuditLog.class, log.getId()); Assert.assertEquals("foo", log2.getDescription()); - + final Long id = log2.getId(); final String updateDml = "update audit_log set description = :desc where id = :id"; final String updateModDml = "update audit_log set modified_description = :desc"; - + SqlUpdate sqlUpdate = Ebean.createSqlUpdate(updateDml); sqlUpdate.setParameter("desc", "foo2"); sqlUpdate.setParameter("id", id); sqlUpdate.execute(); - - SqlUpdate updateMod = Ebean.createSqlUpdate( updateModDml ) ; + + SqlUpdate updateMod = Ebean.createSqlUpdate(updateModDml); updateMod.setParameter("desc", "mod0"); updateMod.execute(); - + AuditLog log3 = Ebean.find(AuditLog.class, log.getId()); Assert.assertEquals("foo2", log3.getDescription()); Assert.assertEquals("mod0", log3.getModifiedDescription()); Ebean.execute(() -> { - SqlUpdate update = Ebean.createSqlUpdate( updateDml ) ; + SqlUpdate update = Ebean.createSqlUpdate(updateDml); update.setParameter("desc", "foo3"); update.setParameter("id", id); update.execute(); - SqlUpdate updateMod1 = Ebean.createSqlUpdate( updateModDml ) ; + SqlUpdate updateMod1 = Ebean.createSqlUpdate(updateModDml); updateMod1.setParameter("desc", "mod1"); updateMod1.execute(); }); @@ -58,15 +56,15 @@ public class TestSqlUpdateInTxn extends BaseTestCase { Assert.assertEquals("foo3", log4.getDescription()); Assert.assertEquals("mod1", log4.getModifiedDescription()); - + Ebean.beginTransaction(); - - SqlUpdate update = Ebean.createSqlUpdate( updateDml) ; + + SqlUpdate update = Ebean.createSqlUpdate(updateDml); update.setParameter("desc", "foo4"); update.setParameter("id", id); update.execute(); - updateMod = Ebean.createSqlUpdate( updateModDml ) ; + updateMod = Ebean.createSqlUpdate(updateModDml); updateMod.setParameter("desc", "mod2"); updateMod.execute(); @@ -77,5 +75,5 @@ public class TestSqlUpdateInTxn extends BaseTestCase { Assert.assertEquals("mod2", log5.getModifiedDescription()); } - + } diff --git a/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java b/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java index a5d832825..45e9d5e53 100644 --- a/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java +++ b/src/test/java/com/avaje/tests/update/TestStatelessUpdate.java @@ -1,15 +1,5 @@ package com.avaje.tests.update; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -17,6 +7,14 @@ import com.avaje.tests.model.basic.Contact; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.basic.EBasic.Status; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -156,7 +154,7 @@ public class TestStatelessUpdate extends BaseTestCase { Assert.assertNotNull(result.getContacts()); Assert.assertFalse("the contacts mustn't be deleted", result.getContacts().isEmpty()); } - + /** * When BeanCollection is inadvertantly initialised and empty then ignore it * Specifically a non-BeanCollection (like ArrayList) is not ignored in terms @@ -183,7 +181,7 @@ public class TestStatelessUpdate extends BaseTestCase { // with Ebean enhancement this loads the an empty contacts BeanList customerWithChange.getContacts(); - + // contacts has been initialised to empty BeanList Assert.assertTrue(containsContacts(customerWithChange)); server.update(customerWithChange); @@ -194,7 +192,7 @@ public class TestStatelessUpdate extends BaseTestCase { Assert.assertNotNull(result.getContacts()); Assert.assertFalse("the contacts mustn't be deleted", result.getContacts().isEmpty()); } - + @Test public void testStatelessUpdateDeleteChildrenForNonBeanCollection() { @@ -215,8 +213,8 @@ public class TestStatelessUpdate extends BaseTestCase { customerWithChange.setName("new name"); // with Ebean enhancement this loads the an empty contacts BeanList - customerWithChange.setContacts(Collections. emptyList()); - + customerWithChange.setContacts(Collections.emptyList()); + Assert.assertTrue(containsContacts(customerWithChange)); server.update(customerWithChange); @@ -226,11 +224,11 @@ public class TestStatelessUpdate extends BaseTestCase { Assert.assertNotNull(result.getContacts()); Assert.assertTrue("the contacts were deleted", result.getContacts().isEmpty()); } - + private boolean containsContacts(Customer cust) { return server.getBeanState(cust).getLoadedProps().contains("contacts"); } - + /** * when using stateless updates with recursive calls, * the version column shouldn't decide to use insert instead of update, @@ -258,7 +256,7 @@ public class TestStatelessUpdate extends BaseTestCase { Contact updateContact2 = new Contact(); updateContact2.setId(contact2.getId()); - + Customer updateCustomer = new Customer(); updateCustomer.setId(customer.getId()); updateCustomer.getContacts().add(updateContact1); @@ -270,7 +268,7 @@ public class TestStatelessUpdate extends BaseTestCase { // maybe check if update instead of insert has been executed, // currently "Unique index or primary key violation" PersistenceException is throwing } - + @Test public void testStatelessRecursiveUpdateWithChangesInDetailOnly() { // arrange @@ -286,7 +284,6 @@ public class TestStatelessUpdate extends BaseTestCase { customer.getContacts().add(contact2); server.save(customer); - // act @@ -294,11 +291,11 @@ public class TestStatelessUpdate extends BaseTestCase { updateContact1.setId(contact1.getId()); updateContact1.setLastName("contact1-changed"); - + Contact updateContact3 = new Contact(); //updateContact3.setId(contact3.getId()); updateContact3.setLastName("contact3-added"); - + Customer updateCustomer = new Customer(); updateCustomer.setId(customer.getId()); updateCustomer.getContacts().add(updateContact1); @@ -306,10 +303,10 @@ public class TestStatelessUpdate extends BaseTestCase { // not adding contact2 so it will get deleted //updateCustomer.getContacts().add(updateContact2); - + server.update(updateCustomer); - + // assert Customer assCustomer = server.find(Customer.class, customer.getId()); List assContacts = assCustomer.getContacts(); @@ -323,12 +320,12 @@ public class TestStatelessUpdate extends BaseTestCase { Assert.assertTrue(ids.contains(contact1.getId())); Assert.assertTrue(ids.contains(updateContact3.getId())); Assert.assertFalse(ids.contains(contact2.getId())); - + Assert.assertTrue(names.contains(updateContact1.getLastName())); Assert.assertTrue(names.contains(updateContact3.getLastName())); } - - + + @Test public void testStatelessRecursiveUpdateWithChangesInDetailOnlyAnd() { // arrange @@ -344,17 +341,17 @@ public class TestStatelessUpdate extends BaseTestCase { customer.getContacts().add(contact2); server.save(customer); - + // act Contact updateContact1 = new Contact(); updateContact1.setId(contact1.getId()); updateContact1.setLastName("contact1-changed"); - + Contact updateContact3 = new Contact(); updateContact3.setLastName("contact3-added"); - + Customer updateCustomer = new Customer(); updateCustomer.setId(customer.getId()); updateCustomer.getContacts().add(updateContact1); @@ -364,14 +361,14 @@ public class TestStatelessUpdate extends BaseTestCase { boolean deleteMissingChildren = false; server.update(updateCustomer, null, deleteMissingChildren); - + // assert Customer assCustomer = server.find(Customer.class, customer.getId()); List assContacts = assCustomer.getContacts(); - + // contact 2 was not deleted this time assertEquals(3, assContacts.size()); - + Set ids = new LinkedHashSet<>(); Set names = new LinkedHashSet<>(); for (Contact contact : assContacts) { @@ -381,7 +378,7 @@ public class TestStatelessUpdate extends BaseTestCase { Assert.assertTrue(ids.contains(contact1.getId())); Assert.assertTrue(ids.contains(updateContact3.getId())); Assert.assertTrue(ids.contains(contact2.getId())); - + Assert.assertTrue(names.contains(updateContact1.getLastName())); Assert.assertTrue(names.contains(contact2.getLastName())); Assert.assertTrue(names.contains(updateContact3.getLastName())); diff --git a/src/test/java/com/avaje/tests/update/TestUpdateAllLoadedProperties.java b/src/test/java/com/avaje/tests/update/TestUpdateAllLoadedProperties.java index a02782991..b892f6ebd 100644 --- a/src/test/java/com/avaje/tests/update/TestUpdateAllLoadedProperties.java +++ b/src/test/java/com/avaje/tests/update/TestUpdateAllLoadedProperties.java @@ -68,10 +68,10 @@ public class TestUpdateAllLoadedProperties extends BaseTestCase { ids.add(id2); List beans = Ebean.find(EBasicVer.class) - .select("name, other") - .where().idIn(ids) - .order().asc("id") - .findList(); + .select("name, other") + .where().idIn(ids) + .order().asc("id") + .findList(); assertEquals(2, beans.size()); diff --git a/src/test/java/com/avaje/tests/update/TestUpdatePartial.java b/src/test/java/com/avaje/tests/update/TestUpdatePartial.java index 6c6215627..f4a5e4283 100644 --- a/src/test/java/com/avaje/tests/update/TestUpdatePartial.java +++ b/src/test/java/com/avaje/tests/update/TestUpdatePartial.java @@ -23,11 +23,11 @@ public class TestUpdatePartial extends BaseTestCase { checkDbStatusValue(c.getId(), "A"); Customer c2 = Ebean.find(Customer.class) - .setUseCache(false) - .select("status, smallnote") - .setId(c.getId()) - .findUnique(); - + .setUseCache(false) + .select("status, smallnote") + .setId(c.getId()) + .findUnique(); + c2.setStatus(Customer.Status.INACTIVE); c2.setSmallnote("2nd note"); @@ -35,11 +35,11 @@ public class TestUpdatePartial extends BaseTestCase { checkDbStatusValue(c.getId(), "I"); Customer c3 = Ebean.find(Customer.class) - .setUseCache(false) - .select("status") - .setId(c.getId()) - .findUnique(); - + .setUseCache(false) + .select("status") + .setId(c.getId()) + .findUnique(); + c3.setStatus(Customer.Status.NEW); c3.setSmallnote("3rd note"); diff --git a/src/test/java/com/avaje/tests/update/TestUpdatePartialNoVer.java b/src/test/java/com/avaje/tests/update/TestUpdatePartialNoVer.java index c5da87de3..f72c6815e 100644 --- a/src/test/java/com/avaje/tests/update/TestUpdatePartialNoVer.java +++ b/src/test/java/com/avaje/tests/update/TestUpdatePartialNoVer.java @@ -1,11 +1,10 @@ package com.avaje.tests.update; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.tests.model.basic.EBasic; import com.avaje.tests.model.basic.EBasic.Status; +import org.junit.Test; public class TestUpdatePartialNoVer extends BaseTestCase { From 0322b37ae7902aafa2cc67f3b54183817966517b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 20:17:46 +1300 Subject: [PATCH 81/87] no effective change - format test code --- .../avaje/ebeantest/LoggedSqlCollector.java | 9 +++-- .../inheritmany/test/TestInheritWithMany.java | 36 +++++++++---------- .../avaje/test/model/rawsql/inherit/Data.java | 28 +++++++-------- .../model/rawsql/inherit/ParentAggregate.java | 4 +-- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java b/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java index c6b273502..6d32b6ff0 100644 --- a/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java +++ b/src/test/java/org/avaje/ebeantest/LoggedSqlCollector.java @@ -1,15 +1,14 @@ package org.avaje.ebeantest; -import java.util.ArrayList; -import java.util.List; - -import org.slf4j.LoggerFactory; - import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.UnsynchronizedAppenderBase; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; /** * Helper that can collect the SQL that is logged via SLF4J. diff --git a/src/test/java/org/avaje/test/model/inheritmany/test/TestInheritWithMany.java b/src/test/java/org/avaje/test/model/inheritmany/test/TestInheritWithMany.java index cd29de49b..f332cd5e7 100644 --- a/src/test/java/org/avaje/test/model/inheritmany/test/TestInheritWithMany.java +++ b/src/test/java/org/avaje/test/model/inheritmany/test/TestInheritWithMany.java @@ -1,10 +1,5 @@ package org.avaje.test.model.inheritmany.test; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.EbeanServer; @@ -15,6 +10,10 @@ import com.avaje.tests.model.inheritmany.IMRelated; import com.avaje.tests.model.inheritmany.IMRoot; import com.avaje.tests.model.inheritmany.IMRootOne; import com.avaje.tests.model.inheritmany.IMRootTwo; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; public class TestInheritWithMany extends BaseTestCase { @@ -25,49 +24,48 @@ public class TestInheritWithMany extends BaseTestCase { EbeanServer server = Ebean.getServer(null); Assert.assertNotNull(server); - - SpiEbeanServer spiServer = (SpiEbeanServer)server; + + SpiEbeanServer spiServer = (SpiEbeanServer) server; BeanDescriptor beanDescriptor = spiServer.getBeanDescriptor(IMRoot.class); InheritInfo inheritInfo = beanDescriptor.getInheritInfo(); Assert.assertNotNull(inheritInfo); - + IMRootOne one = new IMRootOne(); one.setName("One Name"); server.save(one); add(one, "aaa"); add(one, "bbb"); - - + IMRootTwo two = new IMRootTwo(); two.setTitle("Two Title"); server.save(two); add(two, "ccc"); add(two, "ddd"); - - + + List list = server.find(IMRoot.class).select("id").findList(); - + for (IMRoot imRoot : list) { // lazy load the related OneToMany which is related to a non-leaf List related = imRoot.getRelated(); for (IMRelated imRelated : related) { imRelated.getName(); - } + } } - + } - + private void add(IMRoot owner, String string) { - + IMRelated relate = new IMRelated(); relate.setName(string); relate.setOwner(owner); - + EbeanServer server = Ebean.getServer(null); server.save(relate); } - + } diff --git a/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java b/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java index 0858128b7..dcde322bf 100644 --- a/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java +++ b/src/test/java/org/avaje/test/model/rawsql/inherit/Data.java @@ -11,24 +11,24 @@ import java.util.List; @Table(name = "rawinherit_data") public class Data { - @Id - private Long id; + @Id + private Long id; - private Integer val; + private Integer val; - @ManyToMany(mappedBy = "data") - public List parents = new ArrayList<>(); + @ManyToMany(mappedBy = "data") + public List parents = new ArrayList<>(); - public Data(int number) { - this.val = number; - } + public Data(int number) { + this.val = number; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public Integer getVal() { - return val; - } + public Integer getVal() { + return val; + } } diff --git a/src/test/java/org/avaje/test/model/rawsql/inherit/ParentAggregate.java b/src/test/java/org/avaje/test/model/rawsql/inherit/ParentAggregate.java index bfaeb097c..fcc813ae5 100644 --- a/src/test/java/org/avaje/test/model/rawsql/inherit/ParentAggregate.java +++ b/src/test/java/org/avaje/test/model/rawsql/inherit/ParentAggregate.java @@ -9,7 +9,7 @@ import javax.persistence.OneToOne; @Sql public class ParentAggregate { - @OneToOne - public Parent parent; + @OneToOne + public Parent parent; } From b0dae02c4282e8f3dd684383ced73789c0d02086 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Thu, 17 Nov 2016 22:59:50 +1300 Subject: [PATCH 82/87] #881 - Split DocPropertyType.STRING into KEYWORD and TEXT ... for ElasticSearch 5.x support --- .../ebeaninternal/server/deploy/BeanProperty.java | 15 +++++---------- .../server/type/ScalarTypeArrayList.java | 2 +- .../server/type/ScalarTypeArrayListH2.java | 2 +- .../server/type/ScalarTypeBaseVarchar.java | 2 +- .../server/type/ScalarTypeDuration.java | 2 +- .../server/type/ScalarTypeJodaLocalTime.java | 2 +- .../server/type/ScalarTypeLocalTime.java | 2 +- .../server/type/ScalarTypeMonthDay.java | 2 +- .../server/type/ScalarTypeString.java | 2 +- .../ebeaninternal/server/type/ScalarTypeTime.java | 2 +- .../docstore/api/mapping/DocMappingBuilder.java | 2 +- .../docstore/api/mapping/DocPropertyOptions.java | 8 ++++++++ .../docstore/api/mapping/DocPropertyType.java | 9 +++++++-- 13 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java index ac1619718..332533a25 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanProperty.java @@ -1388,20 +1388,15 @@ public class BeanProperty implements ElPropertyValue, Property { if (mapping.includesProperty(prefix, name)) { DocPropertyType type = scalarType.getDocType(); - DocPropertyOptions options = docOptions.copy(); - if (DocPropertyType.UUID == type || DocPropertyType.ENUM == type || isStringId(type)) { - options.setCode(true); + if (isKeywordType(type, docOptions)) { + type = DocPropertyType.KEYWORD; } - - mapping.add(new DocPropertyMapping(name, type, options)); + mapping.add(new DocPropertyMapping(name, type, docOptions)); } } - /** - * Return true if this is a String Id property and should be treated as a code by the document store. - */ - private boolean isStringId(DocPropertyType type) { - return DocPropertyType.STRING == type && (id || discriminator); + private boolean isKeywordType(DocPropertyType type, DocPropertyOptions docOptions) { + return type == DocPropertyType.TEXT && (docOptions.isCode() || id || discriminator); } public void merge(EntityBean bean, EntityBean existing) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java index 4aa61b15a..ff6a51a53 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java @@ -25,7 +25,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { private static ScalarTypeArrayList LONG = new ScalarTypeArrayList("bigint", DocPropertyType.LONG, ArrayElementConverter.LONG); private static ScalarTypeArrayList INTEGER = new ScalarTypeArrayList("integer", DocPropertyType.INTEGER, ArrayElementConverter.INTEGER); private static ScalarTypeArrayList DOUBLE = new ScalarTypeArrayList("float", DocPropertyType.DOUBLE, ArrayElementConverter.DOUBLE); - private static ScalarTypeArrayList STRING = new ScalarTypeArrayList("varchar", DocPropertyType.STRING, ArrayElementConverter.STRING); + private static ScalarTypeArrayList STRING = new ScalarTypeArrayList("varchar", DocPropertyType.TEXT, ArrayElementConverter.STRING); static PlatformArrayTypeFactory factory() { return new Factory(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java index b9b4175d8..3c620a369 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayListH2.java @@ -16,7 +16,7 @@ class ScalarTypeArrayListH2 extends ScalarTypeArrayList { private static ScalarTypeArrayListH2 LONG = new ScalarTypeArrayListH2("bigint", DocPropertyType.LONG, ArrayElementConverter.LONG); private static ScalarTypeArrayListH2 INTEGER = new ScalarTypeArrayListH2("integer", DocPropertyType.INTEGER, ArrayElementConverter.INTEGER); private static ScalarTypeArrayListH2 DOUBLE = new ScalarTypeArrayListH2("double", DocPropertyType.DOUBLE, ArrayElementConverter.DOUBLE); - private static ScalarTypeArrayListH2 STRING = new ScalarTypeArrayListH2("varchar", DocPropertyType.STRING, ArrayElementConverter.STRING); + private static ScalarTypeArrayListH2 STRING = new ScalarTypeArrayListH2("varchar", DocPropertyType.TEXT, ArrayElementConverter.STRING); static PlatformArrayTypeFactory factory() { return new ScalarTypeArrayListH2.Factory(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java index bc6c6817a..fabc01fe2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBaseVarchar.java @@ -129,7 +129,7 @@ public abstract class ScalarTypeBaseVarchar extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.TEXT; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java index 6f0dc11a4..478515765 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDuration.java @@ -112,7 +112,7 @@ public class ScalarTypeDuration extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java index 02dc9bae8..fd33c984b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalTime.java @@ -119,6 +119,6 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java index 1e3d0da6f..c9fc34d57 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalTime.java @@ -105,7 +105,7 @@ public class ScalarTypeLocalTime extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java index 983439a12..d8943b03e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeMonthDay.java @@ -129,7 +129,7 @@ public class ScalarTypeMonthDay extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.KEYWORD; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java index 0c3b31103..1c8638404 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeString.java @@ -96,6 +96,6 @@ public class ScalarTypeString extends ScalarTypeBase { @Override public DocPropertyType getDocType() { - return DocPropertyType.STRING; + return DocPropertyType.TEXT; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java index 09e046062..f310e918d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeTime.java @@ -98,7 +98,7 @@ public class ScalarTypeTime extends ScalarTypeBase