diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanCollectionUtil.java b/src/main/java/io/ebeaninternal/server/deploy/BeanCollectionUtil.java index e8e2b1c0c..40171b0da 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanCollectionUtil.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanCollectionUtil.java @@ -1,11 +1,10 @@ package io.ebeaninternal.server.deploy; -import java.util.Collection; -import java.util.Map; +import io.ebean.bean.BeanCollection; import javax.persistence.PersistenceException; - -import io.ebean.bean.BeanCollection; +import java.util.Collection; +import java.util.Map; /** * Utility methods for BeanCollections. diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index e65a559da..a29ffcfa7 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -2543,7 +2543,7 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType { } public void setUnmappedJson(EntityBean bean, Map unmappedProperties) { - if( unmappedJson != null) { + if (unmappedJson != null) { unmappedJson.setValueIntercept(bean, unmappedProperties); } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java index 841b8d901..6731c9ade 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java @@ -116,7 +116,7 @@ final class BeanDescriptorCacheHelp { if (isBeanCaching() || isQueryCaching() || cacheNotifyOnAll || cacheNotifyOnDelete) { String notifyMode = cacheNotifyOnAll ? "All" : (cacheNotifyOnDelete ? "Delete" : "None"); logger.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ", - desc.getFullName(), isBeanCaching(), isQueryCaching(), notifyMode); + desc.getFullName(), isBeanCaching(), isQueryCaching(), notifyMode); } } } @@ -139,7 +139,7 @@ final class BeanDescriptorCacheHelp { */ boolean isCacheNotify(PersistRequest.Type type) { return cacheNotifyOnAll - || cacheNotifyOnDelete && (type == PersistRequest.Type.DELETE || type == PersistRequest.Type.DELETE_PERMANENT); + || cacheNotifyOnDelete && (type == PersistRequest.Type.DELETE || type == PersistRequest.Type.DELETE_PERMANENT); } /** diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java index 6de001332..944d980d2 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorJsonHelp.java @@ -1,13 +1,13 @@ package io.ebeaninternal.server.deploy; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import io.ebean.bean.EntityBean; import io.ebean.text.json.EJson; import io.ebeaninternal.server.text.json.ReadJson; import io.ebeaninternal.server.text.json.WriteJson; import io.ebeaninternal.server.text.json.WriteJson.WriteBean; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import java.io.IOException; import java.util.LinkedHashMap; diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index bd25ccda7..91eb1f879 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -804,7 +804,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap { DeployBeanPropertyAssocOne assocOne = descriptor.findJoinToTable(tableName); if (assocOne == null) { String msg = "Error with property " + prop.getFullBeanName() + ". Could not find a Relationship to table " + tableName - + ". Perhaps you could use a @JoinColumn instead."; + + ". Perhaps you could use a @JoinColumn instead."; throw new RuntimeException(msg); } DeployTableJoin tableJoin = assocOne.getTableJoin(); @@ -1467,8 +1467,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap { Field[] fields = beanClass.getDeclaredFields(); for (Field field : fields) { if (!Modifier.isStatic(field.getModifiers()) - && !Modifier.isTransient(field.getModifiers()) - && !field.isAnnotationPresent(Transient.class)) { + && !Modifier.isTransient(field.getModifiers()) + && !field.isAnnotationPresent(Transient.class)) { return false; } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanEmbeddedMetaFactory.java b/src/main/java/io/ebeaninternal/server/deploy/BeanEmbeddedMetaFactory.java index 0a8e274f1..cbe297901 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanEmbeddedMetaFactory.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanEmbeddedMetaFactory.java @@ -1,10 +1,9 @@ package io.ebeaninternal.server.deploy; -import java.util.Map; +import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; import javax.persistence.PersistenceException; - -import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; +import java.util.Map; /** * Creates BeanProperties for Embedded beans that have deployment information @@ -23,7 +22,7 @@ public class BeanEmbeddedMetaFactory { BeanDescriptor targetDesc = owner.getBeanDescriptor(prop.getTargetType()); if (targetDesc == null) { String msg = "Could not find BeanDescriptor for " + prop.getTargetType() - + ". Perhaps the EmbeddedId class is not registered?"; + + ". Perhaps the EmbeddedId class is not registered?"; throw new PersistenceException(msg); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index fabe7587a..73da1e1a3 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -1,9 +1,12 @@ package io.ebeaninternal.server.deploy; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; +import io.ebean.annotation.PostSoftDelete; +import io.ebean.annotation.PreSoftDelete; +import io.ebean.event.BeanPersistAdapter; +import io.ebean.event.BeanPersistRequest; +import io.ebean.event.BeanPostConstructListener; +import io.ebean.event.BeanPostLoad; +import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import javax.annotation.PostConstruct; import javax.persistence.PersistenceException; @@ -14,14 +17,10 @@ import javax.persistence.PostUpdate; import javax.persistence.PrePersist; import javax.persistence.PreRemove; import javax.persistence.PreUpdate; - -import io.ebean.annotation.PostSoftDelete; -import io.ebean.annotation.PreSoftDelete; -import io.ebean.event.BeanPersistAdapter; -import io.ebean.event.BeanPersistRequest; -import io.ebean.event.BeanPostConstructListener; -import io.ebean.event.BeanPostLoad; -import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; /** * Helper that looks for methods annotated with lifecycle events and registers an adapter for them. diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanListHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanListHelp.java index eef71b386..0cf435615 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanListHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanListHelp.java @@ -1,9 +1,5 @@ package io.ebeaninternal.server.deploy; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import io.ebean.EbeanServer; import io.ebean.Query; import io.ebean.Transaction; @@ -14,6 +10,10 @@ import io.ebean.bean.EntityBean; import io.ebean.common.BeanList; import io.ebeaninternal.server.text.json.WriteJson; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + /** * Helper object for dealing with Lists. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanMapHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanMapHelp.java index fbf668781..202f0a464 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanMapHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanMapHelp.java @@ -100,7 +100,7 @@ public final class BeanMapHelp implements BeanCollectionHelp { @Override 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/io/ebeaninternal/server/deploy/BeanProperty.java b/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java index 23dfa610e..34676b8b2 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.deploy; +import com.fasterxml.jackson.core.JsonToken; import io.ebean.ValuePair; import io.ebean.bean.EntityBean; import io.ebean.bean.PersistenceContext; @@ -35,7 +36,6 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyMapping; import io.ebeanservice.docstore.api.mapping.DocPropertyOptions; import io.ebeanservice.docstore.api.mapping.DocPropertyType; import io.ebeanservice.docstore.api.support.DocStructure; -import com.fasterxml.jackson.core.JsonToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -567,7 +567,7 @@ public class BeanProperty implements ElPropertyValue, Property { if (aggregation != null) { ctx.appendRawColumn(aggregation); - } else if (formula) { + } else if (formula) { ctx.appendFormulaSelect(sqlFormulaSelect); } else if (!isTransient && !ignoreDraftOnlyProperty(ctx.isDraftQuery())) { @@ -1143,7 +1143,7 @@ public class BeanProperty implements ElPropertyValue, Property { if (platformTypes || !(scalarType instanceof ScalarTypeLogicalType)) { return dbType; } - return ((ScalarTypeLogicalType)scalarType).getLogicalType(); + return ((ScalarTypeLogicalType) scalarType).getLogicalType(); } /** @@ -1387,7 +1387,7 @@ public class BeanProperty implements ElPropertyValue, Property { // change in behavior for #318 objValue = null; String msg = "Error trying to use Jackson ObjectMapper to read transient property " - + getFullBeanName() + " - consider marking this property with @JsonIgnore"; + + getFullBeanName() + " - consider marking this property with @JsonIgnore"; logger.error(msg, e); } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java index 710bddfe4..e23d883d2 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssoc.java @@ -389,8 +389,8 @@ public abstract class BeanPropertyAssoc extends BeanProperty { } String msg = "Error with the Join on [" + getFullBeanName() - + "]. Could not find the local match for [" + matchColumn + "] "//in table["+searchTable+"]?" - + " Perhaps an error in a @JoinColumn"; + + "]. Could not find the local match for [" + matchColumn + "] "//in table["+searchTable+"]?" + + " Perhaps an error in a @JoinColumn"; throw new PersistenceException(msg); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java index ad9c989f8..4630b4082 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocMany.java @@ -206,11 +206,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { Object existingCollection = getVal(existing); if (existingCollection instanceof BeanCollection) { - BeanCollection toBC = (BeanCollection)existingCollection; + BeanCollection toBC = (BeanCollection) existingCollection; if (!toBC.isPopulated()) { Object fromCollection = getVal(bean); if (fromCollection instanceof BeanCollection) { - BeanCollection fromBC = (BeanCollection)fromCollection; + BeanCollection fromBC = (BeanCollection) fromCollection; if (fromBC.isPopulated()) { toBC.loadFrom(fromBC); } @@ -244,11 +244,11 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { } if (insertedParent) { // check 'vanilla' collection types - if (val instanceof Collection){ + if (val instanceof Collection) { return ((Collection) val).isEmpty(); } - if (val instanceof Map) { - return ((Map) val).isEmpty(); + if (val instanceof Map) { + return ((Map) val).isEmpty(); } } return false; @@ -263,7 +263,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { Object value = getValue(bean); if (value instanceof BeanCollection) { // reset the collection back to empty - ((BeanCollection)value).reset(bean, name); + ((BeanCollection) value).reset(bean, name); } else { createReference(bean); } @@ -312,9 +312,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { EbeanServer server = getBeanDescriptor().getEbeanServer(); Query q = server.find(getPropertyType()) - .where() - .raw(rawWhere, bindValues.toArray()) - .query(); + .where() + .raw(rawWhere, bindValues.toArray()) + .query(); if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) { Expression idIn = q.getExpressionFactory().idIn(excludeDetailIds); @@ -384,9 +384,9 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { EbeanServer server = getBeanDescriptor().getEbeanServer(); Query q = server.find(getPropertyType()) - .where() - .raw(expr, bindValues.toArray()) - .query(); + .where() + .raw(expr, bindValues.toArray()) + .query(); if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) { Expression idIn = q.getExpressionFactory().idIn(excludeDetailIds); @@ -499,7 +499,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { SpiQuery query = request.getQueryRequest().getQuery(); if (manyToMany) { - sb.append(query.isAsDraft() ? intersectionDraftTable : intersectionPublishTable); + sb.append(query.isAsDraft() ? intersectionDraftTable : intersectionPublishTable); } else { sb.append(targetDescriptor.getBaseTable(query.getTemporalMode())); } @@ -829,8 +829,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { } String msg = "Error with the Join on [" + getFullBeanName() - + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" - + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; + + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" + + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; throw new PersistenceException(msg); } @@ -981,7 +981,7 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { if (isTransient && targetDescriptor == null) { ctx.writeValueUsingObjectMapper(name, value); } else { - Collection collection = (Collection)value; + Collection collection = (Collection) value; if (!collection.isEmpty() || ctx.isIncludeEmpty()) { ctx.toJson(name, collection); } @@ -1000,8 +1000,8 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { public void publishMany(EntityBean draft, EntityBean live) { // collections will not be null due to enhancement - BeanCollection draftVal = (BeanCollection)getValueIntercept(draft); - BeanCollection liveVal = (BeanCollection)getValueIntercept(live); + BeanCollection draftVal = (BeanCollection) getValueIntercept(draft); + BeanCollection liveVal = (BeanCollection) getValueIntercept(live); // Organise the existing live beans into map keyed by id Map liveBeansAsMap = liveBeansAsMap(liveVal); @@ -1037,15 +1037,15 @@ public class BeanPropertyAssocMany extends BeanPropertyAssoc { } @SuppressWarnings("unchecked") - private Map liveBeansAsMap(BeanCollection liveVal) { + private Map liveBeansAsMap(BeanCollection liveVal) { liveVal.size(); Collection liveBeans = liveVal.getActualDetails(); - Map liveMap = new LinkedHashMap<>(); + Map liveMap = new LinkedHashMap<>(); for (Object liveBean : liveBeans) { Object id = targetDescriptor.getId((EntityBean) liveBean); - liveMap.put(id, (T)liveBean); + liveMap.put(id, (T) liveBean); } return liveMap; } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonHelp.java index 5e5f45f71..aa115c54b 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonHelp.java @@ -1,12 +1,12 @@ package io.ebeaninternal.server.deploy; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import io.ebean.bean.BeanCollection; import io.ebean.bean.BeanCollectionAdd; import io.ebean.bean.EntityBean; import io.ebeaninternal.server.text.json.ReadJson; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import java.io.IOException; @@ -82,7 +82,7 @@ public class BeanPropertyAssocManyJsonHelp { private void jsonReadTransientUsingObjectMapper(ReadJson readJson, EntityBean parentBean) throws IOException { if (jsonTransient == null) { - throw new IllegalStateException("Jackson ObjectMapper is required to read this Transient property "+many.getFullBeanName()); + throw new IllegalStateException("Jackson ObjectMapper is required to read this Transient property " + many.getFullBeanName()); } jsonTransient.jsonReadUsingObjectMapper(many, readJson, parentBean); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonTransient.java b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonTransient.java index 50de7e849..e00215e6c 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonTransient.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManyJsonTransient.java @@ -1,12 +1,12 @@ package io.ebeaninternal.server.deploy; -import io.ebean.bean.EntityBean; -import io.ebeaninternal.server.text.json.ReadJson; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.CollectionType; import com.fasterxml.jackson.databind.type.MapType; import com.fasterxml.jackson.databind.type.TypeFactory; +import io.ebean.bean.EntityBean; +import io.ebeaninternal.server.text.json.ReadJson; import java.io.IOException; import java.util.LinkedHashMap; diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocOne.java b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocOne.java index 178a0a434..93f0e6c39 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocOne.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocOne.java @@ -107,7 +107,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { String foreignIdColumn = targetDescriptor.getIdProperty().getDbColumn(); if (!foreignJoinColumn.equalsIgnoreCase(foreignIdColumn)) { throw new PersistenceException("Mapping limitation - @JoinColumn on " + getFullBeanName() + " needs to map to a primary key as per Issue #529 " - + " - joining to " + foreignJoinColumn + " and not " + foreignIdColumn); + + " - joining to " + foreignJoinColumn + " and not " + foreignIdColumn); } } @@ -244,9 +244,9 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { EbeanServer server = getBeanDescriptor().getEbeanServer(); Query q = server.find(getPropertyType()) - .where() - .raw(rawWhere, bindValues.toArray()) - .query(); + .where() + .raw(rawWhere, bindValues.toArray()) + .query(); return server.findIds(q, t); } @@ -265,7 +265,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { EbeanServer server = getBeanDescriptor().getEbeanServer(); Query q = (Query) server.find(getPropertyType()) - .where().raw(expr, bindValues.toArray()); + .where().raw(expr, bindValues.toArray()); return server.findIds(q, t); } @@ -381,8 +381,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { } else { // we are only interested in the Id value - newBean = (EntityBean)newEmb; - oldBean = (EntityBean)oldEmb; + newBean = (EntityBean) newEmb; + oldBean = (EntityBean) oldEmb; BeanDescriptor targetDescriptor = getTargetDescriptor(); BeanProperty idProperty = targetDescriptor.getIdProperty(); @@ -427,7 +427,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { setValue(bean, targetDescriptor.cacheEmbeddedBeanLoad((CachedBeanData) cacheData, context)); } else { if (cacheData instanceof String) { - cacheData = targetDescriptor.getIdProperty().scalarType.parse((String)cacheData); + cacheData = targetDescriptor.getIdProperty().scalarType.parse((String) cacheData); } // cacheData is the id value, maybe already in persistence context Object assocBean = targetDescriptor.contextGet(context, cacheData); @@ -492,10 +492,10 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { @Override public Object pathGetNested(Object bean) { - Object value = getValueIntercept((EntityBean)bean); + Object value = getValueIntercept((EntityBean) bean); if (value == null) { value = targetDescriptor.createEntityBean(); - setValueIntercept((EntityBean)bean, value); + setValueIntercept((EntityBean) bean, value); } return value; } @@ -576,8 +576,8 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { } String msg = "Error with the Join on [" + getFullBeanName() - + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" - + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; + + "]. Could not find the matching foreign key for [" + matchColumn + "] in table[" + searchTable + "]?" + + " Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?"; throw new PersistenceException(msg); } @@ -634,7 +634,7 @@ public class BeanPropertyAssocOne extends BeanPropertyAssoc { } private void setEmbeddedOwner(EntityBean bean, Object value) { - ((EntityBean)value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex); + ((EntityBean) value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex); } @Override diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanSetHelp.java b/src/main/java/io/ebeaninternal/server/deploy/BeanSetHelp.java index 48702967a..8f93d4984 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanSetHelp.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanSetHelp.java @@ -1,9 +1,5 @@ package io.ebeaninternal.server.deploy; -import java.io.IOException; -import java.util.LinkedHashSet; -import java.util.Set; - import io.ebean.EbeanServer; import io.ebean.Query; import io.ebean.Transaction; @@ -14,6 +10,10 @@ import io.ebean.bean.EntityBean; import io.ebean.common.BeanSet; import io.ebeaninternal.server.text.json.WriteJson; +import java.io.IOException; +import java.util.LinkedHashSet; +import java.util.Set; + /** * Helper specifically for dealing with Sets. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/BeanTable.java b/src/main/java/io/ebeaninternal/server/deploy/BeanTable.java index 32feaf137..a091aa979 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/BeanTable.java +++ b/src/main/java/io/ebeaninternal/server/deploy/BeanTable.java @@ -19,80 +19,80 @@ import org.slf4j.LoggerFactory; */ public class BeanTable { - private static final Logger logger = LoggerFactory.getLogger(BeanTable.class); + private static final Logger logger = LoggerFactory.getLogger(BeanTable.class); - private final BeanDescriptorMap owner; + private final BeanDescriptorMap owner; - private final Class beanType; + private final Class beanType; - /** - * The base table. - */ - private final String baseTable; + /** + * The base table. + */ + private final String baseTable; - private final BeanProperty[] idProperties; + private final BeanProperty[] idProperties; - /** - * Create the BeanTable. - */ - public BeanTable(DeployBeanTable mutable, BeanDescriptorMap owner) { - this.owner = owner; - this.beanType = mutable.getBeanType(); - this.baseTable = InternString.intern(mutable.getBaseTable()); - this.idProperties = mutable.createIdProperties(owner); + /** + * Create the BeanTable. + */ + public BeanTable(DeployBeanTable mutable, BeanDescriptorMap owner) { + this.owner = owner; + this.beanType = mutable.getBeanType(); + this.baseTable = InternString.intern(mutable.getBaseTable()); + this.idProperties = mutable.createIdProperties(owner); + } + + @Override + public String toString() { + return baseTable; + } + + /** + * Return the base table for this BeanTable. + * This is used to determine the join information + * for associations. + */ + 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. + */ + public BeanProperty[] getIdProperties() { + return idProperties; + } + + /** + * Return the class for this beanTable. + */ + public Class getBeanType() { + return beanType; + } + + public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse, String sqlFormulaSelect) { + + boolean complexKey = false; + BeanProperty[] props = idProperties; + + if (idProperties.length == 1) { + if (idProperties[0] instanceof BeanPropertyAssocOne) { + BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne) idProperties[0]; + props = assocOne.getProperties(); + complexKey = true; + } } - @Override - public String toString(){ - return baseTable; - } - - /** - * Return the base table for this BeanTable. - * This is used to determine the join information - * for associations. - */ - 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. - */ - public BeanProperty[] getIdProperties() { - return idProperties; - } - - /** - * Return the class for this beanTable. - */ - public Class getBeanType() { - return beanType; - } - - public void createJoinColumn(String foreignKeyPrefix, DeployTableJoin join, boolean reverse, String sqlFormulaSelect) { - - boolean complexKey = false; - BeanProperty[] props = idProperties; - - if (idProperties.length == 1){ - if (idProperties[0] instanceof BeanPropertyAssocOne) { - BeanPropertyAssocOne assocOne = (BeanPropertyAssocOne)idProperties[0]; - props = assocOne.getProperties(); - complexKey = true; - } - } - for (BeanProperty prop : props) { String lc = prop.getDbColumn(); @@ -119,6 +119,6 @@ public class BeanTable { join.addJoinColumn(joinCol); } - } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPersistController.java b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPersistController.java index 2fc4a332f..e1c299cd3 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPersistController.java +++ b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPersistController.java @@ -10,177 +10,177 @@ import java.util.List; /** * Chains multiple BeanPersistController's together. - * + *

* Used when multiple BeanPersistController register for the same bean type. */ public class ChainedBeanPersistController implements BeanPersistController { - private static final Sorter SORTER = new Sorter(); + private static final Sorter SORTER = new Sorter(); - private final List list; + private final List list; - private final BeanPersistController[] chain; + private final BeanPersistController[] chain; - /** - * Construct adding 2 BeanPersistController's. - */ - public ChainedBeanPersistController(BeanPersistController c1, BeanPersistController c2) { - this(addList(c1, c2)); - } + /** + * 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. - */ - private static List addList(BeanPersistController c1, BeanPersistController c2) { - ArrayList addList = new ArrayList<>(2); - addList.add(c1); - addList.add(c2); - return addList; - } + /** + * Helper method used to create a list from 2 BeanPersistController's. + */ + private static List addList(BeanPersistController c1, BeanPersistController c2) { + ArrayList addList = new ArrayList<>(2); + addList.add(c1); + addList.add(c2); + return addList; + } - /** - * Construct given the list of BeanPersistController's. - */ - public ChainedBeanPersistController(List list) { - this.list = list; - BeanPersistController[] c = list.toArray(new BeanPersistController[list.size()]); - Arrays.sort(c, SORTER); - this.chain = c; - } + /** + * Construct given the list of BeanPersistController's. + */ + public ChainedBeanPersistController(List list) { + this.list = list; + BeanPersistController[] c = list.toArray(new BeanPersistController[list.size()]); + Arrays.sort(c, SORTER); + this.chain = c; + } /** * Return the size of the chain. */ - protected int size() { - return chain.length; - } + protected int size() { + return chain.length; + } - /** - * Register a new BeanPersistController and return the resulting chain. - */ - public ChainedBeanPersistController register(BeanPersistController c) { - if (list.contains(c)){ - return this; - } else { - ArrayList newList = new ArrayList<>(); - newList.addAll(list); - newList.add(c); + /** + * Register a new BeanPersistController and return the resulting chain. + */ + public ChainedBeanPersistController register(BeanPersistController c) { + if (list.contains(c)) { + return this; + } else { + ArrayList newList = new ArrayList<>(); + newList.addAll(list); + newList.add(c); - return new ChainedBeanPersistController(newList); - } - } + return new ChainedBeanPersistController(newList); + } + } - /** - * De-register a BeanPersistController and return the resulting chain. - */ - public ChainedBeanPersistController deregister(BeanPersistController c) { - if (!list.contains(c)){ - return this; - } else { - ArrayList newList = new ArrayList<>(); - newList.addAll(list); - newList.remove(c); + /** + * De-register a BeanPersistController and return the resulting chain. + */ + public ChainedBeanPersistController deregister(BeanPersistController c) { + if (!list.contains(c)) { + return this; + } else { + ArrayList newList = new ArrayList<>(); + newList.addAll(list); + newList.remove(c); - return new ChainedBeanPersistController(newList); - } - } + return new ChainedBeanPersistController(newList); + } + } - /** - * Always returns 0 (not used for this object). - */ + /** + * Always returns 0 (not used for this object). + */ @Override - public int getExecutionOrder() { - return 0; - } + public int getExecutionOrder() { + return 0; + } - /** - * Always returns false (not used for this object). - */ + /** + * Always returns false (not used for this object). + */ @Override - public boolean isRegisterFor(Class cls) { - return false; - } + public boolean isRegisterFor(Class cls) { + return false; + } @Override - public void postDelete(BeanPersistRequest request) { + public void postDelete(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { aChain.postDelete(request); } - } + } @Override - public void postInsert(BeanPersistRequest request) { + public void postInsert(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { aChain.postInsert(request); } - } + } @Override - public void postUpdate(BeanPersistRequest request) { + public void postUpdate(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { aChain.postUpdate(request); } - } + } - @Override - public void postSoftDelete(BeanPersistRequest request) { + @Override + public void postSoftDelete(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { aChain.postSoftDelete(request); } - } + } @Override - public boolean preDelete(BeanPersistRequest request) { + public boolean preDelete(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { if (!aChain.preDelete(request)) { return false; } } - return true; - } + return true; + } - @Override - public boolean preSoftDelete(BeanPersistRequest request) { + @Override + public boolean preSoftDelete(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { if (!aChain.preSoftDelete(request)) { return false; } } - return true; - } + return true; + } @Override - public boolean preInsert(BeanPersistRequest request) { + public boolean preInsert(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { if (!aChain.preInsert(request)) { return false; } } - return true; - } + return true; + } @Override - public boolean preUpdate(BeanPersistRequest request) { + public boolean preUpdate(BeanPersistRequest request) { for (BeanPersistController aChain : chain) { if (!aChain.preUpdate(request)) { return false; } } - return true; - } + return true; + } - /** - * Helper to order the BeanPersistController's in a chain. - */ - private static class Sorter implements Comparator { + /** + * Helper to order the BeanPersistController's in a chain. + */ + private static class Sorter implements Comparator { - @Override + @Override public int compare(BeanPersistController o1, BeanPersistController o2) { - int i1 = o1.getExecutionOrder() ; - int i2 = o2.getExecutionOrder() ; - return (i1 list; + private final List list; - private final BeanPersistListener[] chain; + private final BeanPersistListener[] chain; - /** - * Construct adding 2 BeanPersistListener's. - */ - ChainedBeanPersistListener(BeanPersistListener c1, BeanPersistListener c2) { - this(addList(c1, c2)); - } + /** + * Construct adding 2 BeanPersistListener's. + */ + ChainedBeanPersistListener(BeanPersistListener c1, BeanPersistListener c2) { + this(addList(c1, c2)); + } - /** - * Return the size of the chain. - */ - protected int size() { - return chain.length; - } + /** + * Return the size of the chain. + */ + protected int size() { + return chain.length; + } @Override public boolean isRegisterFor(Class cls) { @@ -36,78 +36,78 @@ 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); - addList.add(c1); - addList.add(c2); - return addList; - } + * Helper method used to create a list from 2 BeanPersistListener. + */ + private static List addList(BeanPersistListener c1, BeanPersistListener c2) { + ArrayList addList = new ArrayList<>(2); + addList.add(c1); + addList.add(c2); + return addList; + } - /** - * Construct given the list of BeanPersistListener's. - */ - public ChainedBeanPersistListener(List list) { - this.list = list; - this.chain = list.toArray(new BeanPersistListener[list.size()]); - } + /** + * Construct given the list of BeanPersistListener's. + */ + public ChainedBeanPersistListener(List list) { + this.list = list; + this.chain = list.toArray(new BeanPersistListener[list.size()]); + } - /** - * Register a new BeanPersistListener and return the resulting chain. - */ - public ChainedBeanPersistListener register(BeanPersistListener c) { - if (list.contains(c)){ - return this; - } else { - List newList = new ArrayList<>(); - newList.addAll(list); - newList.add(c); + /** + * Register a new BeanPersistListener and return the resulting chain. + */ + public ChainedBeanPersistListener register(BeanPersistListener c) { + if (list.contains(c)) { + return this; + } else { + List newList = new ArrayList<>(); + newList.addAll(list); + newList.add(c); - return new ChainedBeanPersistListener(newList); - } - } + return new ChainedBeanPersistListener(newList); + } + } - /** - * De-register a BeanPersistListener and return the resulting chain. - */ - public ChainedBeanPersistListener deregister(BeanPersistListener c) { - if (!list.contains(c)){ - return this; - } else { - ArrayList newList = new ArrayList<>(); - newList.addAll(list); - newList.remove(c); + /** + * De-register a BeanPersistListener and return the resulting chain. + */ + public ChainedBeanPersistListener deregister(BeanPersistListener c) { + if (!list.contains(c)) { + return this; + } else { + ArrayList newList = new ArrayList<>(); + newList.addAll(list); + newList.remove(c); - return new ChainedBeanPersistListener(newList); - } - } + return new ChainedBeanPersistListener(newList); + } + } - @Override + @Override public void deleted(Object bean) { for (BeanPersistListener aChain : chain) { aChain.deleted(bean); } - } + } - @Override + @Override public void softDeleted(Object bean) { for (BeanPersistListener aChain : chain) { aChain.softDeleted(bean); } - } + } - @Override + @Override public void inserted(Object bean) { for (BeanPersistListener aChain : chain) { aChain.inserted(bean); } - } + } - @Override + @Override public void updated(Object bean, Set updatedProperties) { for (BeanPersistListener aChain : chain) { aChain.updated(bean, updatedProperties); } - } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPostLoad.java b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPostLoad.java index 2ac9c92de..dbaa9c633 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPostLoad.java +++ b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanPostLoad.java @@ -10,47 +10,47 @@ import java.util.List; */ public class ChainedBeanPostLoad implements BeanPostLoad { - private final List list; + private final List list; - private final BeanPostLoad[] chain; + private final BeanPostLoad[] chain; - /** - * Construct given the list of BeanPostLoad's. - */ - public ChainedBeanPostLoad(List list) { - this.list = list; - this.chain = list.toArray(new BeanPostLoad[list.size()]); - } + /** + * Construct given the list of BeanPostLoad's. + */ + public ChainedBeanPostLoad(List list) { + this.list = list; + this.chain = list.toArray(new BeanPostLoad[list.size()]); + } - /** - * Register a new BeanPostLoad and return the resulting chain. - */ - public ChainedBeanPostLoad register(BeanPostLoad c) { - if (list.contains(c)){ - return this; - } else { - List newList = new ArrayList<>(); - newList.addAll(list); - newList.add(c); + /** + * Register a new BeanPostLoad and return the resulting chain. + */ + public ChainedBeanPostLoad register(BeanPostLoad c) { + if (list.contains(c)) { + return this; + } else { + List newList = new ArrayList<>(); + newList.addAll(list); + newList.add(c); - return new ChainedBeanPostLoad(newList); - } - } + return new ChainedBeanPostLoad(newList); + } + } - /** - * De-register a BeanPostLoad and return the resulting chain. - */ - public ChainedBeanPostLoad deregister(BeanPostLoad c) { - if (!list.contains(c)){ - return this; - } else { - ArrayList newList = new ArrayList<>(); - newList.addAll(list); - newList.remove(c); + /** + * De-register a BeanPostLoad and return the resulting chain. + */ + public ChainedBeanPostLoad deregister(BeanPostLoad c) { + if (!list.contains(c)) { + return this; + } else { + ArrayList newList = new ArrayList<>(); + newList.addAll(list); + newList.remove(c); - return new ChainedBeanPostLoad(newList); - } - } + return new ChainedBeanPostLoad(newList); + } + } /** * Return the size of the chain. @@ -69,9 +69,9 @@ public class ChainedBeanPostLoad implements BeanPostLoad { * Fire postLoad on all registered BeanPostLoad implementations. */ @Override - public void postLoad(Object bean) { + public void postLoad(Object bean) { for (BeanPostLoad aChain : chain) { aChain.postLoad(bean); } - } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java index 87b64c0c8..de1270b42 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java +++ b/src/main/java/io/ebeaninternal/server/deploy/ChainedBeanQueryAdapter.java @@ -1,100 +1,101 @@ package io.ebeaninternal.server.deploy; +import io.ebean.event.BeanQueryAdapter; +import io.ebean.event.BeanQueryRequest; + import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; -import io.ebean.event.BeanQueryAdapter; -import io.ebean.event.BeanQueryRequest; - /** * Handles multiple BeanQueryAdapter for a given entity type. */ public class ChainedBeanQueryAdapter implements BeanQueryAdapter { - private static final Sorter SORTER = new Sorter(); + private static final Sorter SORTER = new Sorter(); - private final List list; + private final List list; - private final BeanQueryAdapter[] chain; + private final BeanQueryAdapter[] chain; - /** - * Construct given the list of BeanQueryAdapter's. - */ - public ChainedBeanQueryAdapter(List list) { - this.list = list; - BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[list.size()]); - Arrays.sort(c, SORTER); - this.chain = c; - } + /** + * Construct given the list of BeanQueryAdapter's. + */ + public ChainedBeanQueryAdapter(List list) { + this.list = list; + BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[list.size()]); + Arrays.sort(c, SORTER); + this.chain = c; + } - /** - * Register a new BeanQueryAdapter and return the resulting chain. - */ - public ChainedBeanQueryAdapter register(BeanQueryAdapter c) { - if (list.contains(c)){ - return this; - } else { - List newList = new ArrayList<>(); - newList.addAll(list); - newList.add(c); + /** + * Register a new BeanQueryAdapter and return the resulting chain. + */ + public ChainedBeanQueryAdapter register(BeanQueryAdapter c) { + if (list.contains(c)) { + return this; + } else { + List newList = new ArrayList<>(); + newList.addAll(list); + newList.add(c); - return new ChainedBeanQueryAdapter(newList); - } - } + return new ChainedBeanQueryAdapter(newList); + } + } - /** - * De-register a BeanQueryAdapter and return the resulting chain. - */ - public ChainedBeanQueryAdapter deregister(BeanQueryAdapter c) { - if (!list.contains(c)){ - return this; - } else { - ArrayList newList = new ArrayList<>(); - newList.addAll(list); - newList.remove(c); + /** + * De-register a BeanQueryAdapter and return the resulting chain. + */ + public ChainedBeanQueryAdapter deregister(BeanQueryAdapter c) { + if (!list.contains(c)) { + return this; + } else { + ArrayList newList = new ArrayList<>(); + newList.addAll(list); + newList.remove(c); - return new ChainedBeanQueryAdapter(newList); - } - } + return new ChainedBeanQueryAdapter(newList); + } + } - /** - * Return 0 as not used by this Chained adapter. - */ - @Override + /** + * Return 0 as not used by this Chained adapter. + */ + @Override public int getExecutionOrder() { - return 0; - } + return 0; + } - /** - * Return false as only individual adapters are registered. - */ - @Override + /** + * Return false as only individual adapters are registered. + */ + @Override public boolean isRegisterFor(Class cls) { - return false; - } + return false; + } - @Override + @Override public void preQuery(BeanQueryRequest request) { for (BeanQueryAdapter aChain : chain) { aChain.preQuery(request); } - } - /** - * Helper to order the BeanQueryAdapter's in a chain. - */ - private static class Sorter implements Comparator { + } - @Override + /** + * Helper to order the BeanQueryAdapter's in a chain. + */ + private static class Sorter implements Comparator { + + @Override public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) { - int i1 = o1.getExecutionOrder() ; - int i2 = o2.getExecutionOrder() ; - return (i1 getIncludes(); + /** + * Return the join includes. + */ + public abstract Set getIncludes(); - public void setEncrypted(boolean encrypted) { - this.encrypted = encrypted; - } + public void setEncrypted(boolean encrypted) { + this.encrypted = encrypted; + } - public String parse(String source) { + public String parse(String source) { - if (source == null) { - return null; - } + if (source == null) { + return null; + } - pos = -1; - this.source = source; - this.sourceLength = source.length(); - this.sb = new StringBuilder(source.length() + 20); + pos = -1; + this.source = source; + this.sourceLength = source.length(); + this.sb = new StringBuilder(source.length() + 20); - while (nextWord()) { - String deployWord = convertWord(); - sb.append(deployWord); - if (pos < sourceLength) { - sb.append(wordTerminator); - if (wordTerminator == SINGLE_QUOTE) { - readLiteral(); - } - } - } + while (nextWord()) { + String deployWord = convertWord(); + sb.append(deployWord); + if (pos < sourceLength) { + sb.append(wordTerminator); + if (wordTerminator == SINGLE_QUOTE) { + readLiteral(); + } + } + } - return sb.toString(); - } + return sb.toString(); + } - private boolean nextWord() { + private boolean nextWord() { - if (!findWordStart()) { - return false; - } + if (!findWordStart()) { + return false; + } - StringBuilder wordBuffer = new StringBuilder(); - wordBuffer.append(source.charAt(pos)); - while (++pos < sourceLength) { - char ch = source.charAt(pos); - if (isWordPart(ch)) { - wordBuffer.append(ch); - } else { - wordTerminator = ch; - break; - } - } + StringBuilder wordBuffer = new StringBuilder(); + wordBuffer.append(source.charAt(pos)); + while (++pos < sourceLength) { + char ch = source.charAt(pos); + if (isWordPart(ch)) { + wordBuffer.append(ch); + } else { + wordTerminator = ch; + break; + } + } - word = wordBuffer.toString(); + word = wordBuffer.toString(); - return true; - } + return true; + } - private boolean findWordStart() { - while (++pos < sourceLength) { - char ch = source.charAt(pos); - if (ch == SINGLE_QUOTE) { - // read a literal value and just - // append to string builder - sb.append(ch); - readLiteral(); - } else if (ch == COLON) { - // read a named parameter - // just append to string builder - sb.append(ch); - readNamedParameter(); - } else if (isWordStart(ch)) { - // its the start of a word that could - // be translated - return true; - } else { - sb.append(ch); - } - } - return false; - } + private boolean findWordStart() { + while (++pos < sourceLength) { + char ch = source.charAt(pos); + if (ch == SINGLE_QUOTE) { + // read a literal value and just + // append to string builder + sb.append(ch); + readLiteral(); + } else if (ch == COLON) { + // read a named parameter + // just append to string builder + sb.append(ch); + readNamedParameter(); + } else if (isWordStart(ch)) { + // its the start of a word that could + // be translated + return true; + } else { + sb.append(ch); + } + } + return false; + } - /** - * Read the rest of a literal value. These do not get translated so are just - * read and appended to the string builder. - */ - private void readLiteral() { - while (++pos < sourceLength) { - char ch = source.charAt(pos); - sb.append(ch); - if (ch == SINGLE_QUOTE) { - break; - } - } - } + /** + * Read the rest of a literal value. These do not get translated so are just + * read and appended to the string builder. + */ + private void readLiteral() { + while (++pos < sourceLength) { + char ch = source.charAt(pos); + sb.append(ch); + if (ch == SINGLE_QUOTE) { + break; + } + } + } - /** - * Read a named parameter. These are not translated. They will be replaced - * by positioned parameters later. - */ - private void readNamedParameter() { - while (++pos < sourceLength) { - char ch = source.charAt(pos); - sb.append(ch); - if (Character.isWhitespace(ch)) { - break; - } else if (ch == ',') { - break; - } - } - } + /** + * Read a named parameter. These are not translated. They will be replaced + * by positioned parameters later. + */ + private void readNamedParameter() { + while (++pos < sourceLength) { + char ch = source.charAt(pos); + sb.append(ch); + if (Character.isWhitespace(ch)) { + break; + } else if (ch == ',') { + break; + } + } + } - /** - * return true if the char is a letter, digit or underscore. - */ - private boolean isWordPart(char ch) { + /** + * return true if the char is a letter, digit or underscore. + */ + private boolean isWordPart(char ch) { return Character.isLetterOrDigit(ch) || ch == UNDERSCORE || ch == PERIOD; } - private boolean isWordStart(char ch) { + private boolean isWordStart(char ch) { return Character.isLetter(ch); - } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/DeployPropertyParser.java b/src/main/java/io/ebeaninternal/server/deploy/DeployPropertyParser.java index 48060652f..a698b9f9e 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/DeployPropertyParser.java +++ b/src/main/java/io/ebeaninternal/server/deploy/DeployPropertyParser.java @@ -1,10 +1,10 @@ package io.ebeaninternal.server.deploy; +import io.ebeaninternal.server.el.ElPropertyDeploy; + import java.util.HashSet; import java.util.Set; -import io.ebeaninternal.server.el.ElPropertyDeploy; - /** * Converts logical property names to database columns with table alias. *

@@ -15,39 +15,39 @@ import io.ebeaninternal.server.el.ElPropertyDeploy; public final class DeployPropertyParser extends DeployParser { - private final BeanDescriptor beanDescriptor; + private final BeanDescriptor beanDescriptor; - private final Set includes = new HashSet<>(); + private final Set includes = new HashSet<>(); - public DeployPropertyParser(BeanDescriptor beanDescriptor) { - this.beanDescriptor = beanDescriptor; - } + public DeployPropertyParser(BeanDescriptor beanDescriptor) { + this.beanDescriptor = beanDescriptor; + } - @Override - public Set getIncludes() { - return includes; - } + @Override + public Set getIncludes() { + return includes; + } - @Override - public String getDeployWord(String expression) { - ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression); - if (elProp == null){ - return null; - } else { - addIncludes(elProp.getElPrefix()); - return elProp.getElPlaceholder(encrypted); - } + @Override + public String getDeployWord(String expression) { + ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression); + if (elProp == null) { + return null; + } else { + addIncludes(elProp.getElPrefix()); + return elProp.getElPlaceholder(encrypted); } + } - @Override - public String convertWord() { - String r = getDeployWord(word); - return r == null ? word : r; - } + @Override + public String convertWord() { + String r = getDeployWord(word); + return r == null ? word : r; + } - private void addIncludes(String prefix) { - if (prefix != null){ - includes.add(prefix); - } - } + private void addIncludes(String prefix) { + if (prefix != null) { + includes.add(prefix); + } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/DeployUpdateParser.java b/src/main/java/io/ebeaninternal/server/deploy/DeployUpdateParser.java index e81578cd6..73e66d699 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/DeployUpdateParser.java +++ b/src/main/java/io/ebeaninternal/server/deploy/DeployUpdateParser.java @@ -1,92 +1,92 @@ package io.ebeaninternal.server.deploy; -import java.util.Set; - import io.ebeaninternal.server.el.ElPropertyDeploy; +import java.util.Set; + /** * For updates converts logical property names to database columns and bean type to base table. */ public final class DeployUpdateParser extends DeployParser { - private final BeanDescriptor beanDescriptor; + private final BeanDescriptor beanDescriptor; - public DeployUpdateParser(BeanDescriptor beanDescriptor) { - this.beanDescriptor = beanDescriptor; - } + public DeployUpdateParser(BeanDescriptor beanDescriptor) { + this.beanDescriptor = beanDescriptor; + } - /** - * Return null as not used for updates. - */ - @Override - public Set getIncludes() { - return null; - } + /** + * Return null as not used for updates. + */ + @Override + public Set getIncludes() { + return null; + } - @Override + @Override public String convertWord() { - String dbWord = getDeployWord(word); + String dbWord = getDeployWord(word); - if (dbWord != null) { - return dbWord; - } - // maybe tableAlias.propertyName - return convertSubword(0, word, null); - } + if (dbWord != null) { + return dbWord; + } + // maybe tableAlias.propertyName + return convertSubword(0, word, null); + } - private String convertSubword(int start, String currentWord, StringBuilder localBuffer) { + private String convertSubword(int start, String currentWord, StringBuilder localBuffer) { - int dotPos = currentWord.indexOf('.', start); - if (start == 0 && dotPos == -1){ - return currentWord; - } - if (start == 0){ - localBuffer = new StringBuilder(); - } - if (dotPos == -1){ - // no match... - localBuffer.append(currentWord.substring(start)); - return localBuffer.toString(); - } + int dotPos = currentWord.indexOf('.', start); + if (start == 0 && dotPos == -1) { + return currentWord; + } + if (start == 0) { + localBuffer = new StringBuilder(); + } + if (dotPos == -1) { + // no match... + localBuffer.append(currentWord.substring(start)); + return localBuffer.toString(); + } - // append up to the dot - localBuffer.append(currentWord.substring(start, dotPos+1)); + // append up to the dot + localBuffer.append(currentWord.substring(start, dotPos + 1)); - if (dotPos == currentWord.length()-1){ - // ends with a "." ??? - return localBuffer.toString(); - } + if (dotPos == currentWord.length() - 1) { + // ends with a "." ??? + return localBuffer.toString(); + } - // get the remainder after the dot - start = dotPos+1; - String remainder = currentWord.substring(start, currentWord.length()); + // get the remainder after the dot + start = dotPos + 1; + String remainder = currentWord.substring(start, currentWord.length()); - //String dbWord = deployMap.get(remainder.toLowerCase()); - String dbWord = getDeployWord(remainder); - if (dbWord != null){ - // we have found a match for the remainder - localBuffer.append(dbWord); - return localBuffer.toString(); - } else { - // - return convertSubword(start, currentWord, localBuffer); - } - } + //String dbWord = deployMap.get(remainder.toLowerCase()); + String dbWord = getDeployWord(remainder); + if (dbWord != null) { + // we have found a match for the remainder + localBuffer.append(dbWord); + return localBuffer.toString(); + } else { + // + return convertSubword(start, currentWord, localBuffer); + } + } - @Override + @Override public String getDeployWord(String expression) { - if (expression.equalsIgnoreCase(beanDescriptor.getName())){ - return beanDescriptor.getBaseTable(); - } + if (expression.equalsIgnoreCase(beanDescriptor.getName())) { + return beanDescriptor.getBaseTable(); + } - ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression); - if (elProp != null){ - return elProp.getDbColumn(); - } else { - return null; - } - } + ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression); + if (elProp != null) { + return elProp.getDbColumn(); + } else { + return null; + } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/DetermineAggPath.java b/src/main/java/io/ebeaninternal/server/deploy/DetermineAggPath.java index 3d4e3683e..b57d9973b 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/DetermineAggPath.java +++ b/src/main/java/io/ebeaninternal/server/deploy/DetermineAggPath.java @@ -29,16 +29,16 @@ class DetermineAggPath { // so find the first open bracket int start = aggregation.indexOf('('); if (start == -1) { - throw new IllegalArgumentException("Aggregation formula ["+aggregation+"] is expected to have a '(' ?"); + throw new IllegalArgumentException("Aggregation formula [" + aggregation + "] is expected to have a '(' ?"); } - for (int i = start + 1; i< aggregation.length(); i++) { + for (int i = start + 1; i < aggregation.length(); i++) { char ch = aggregation.charAt(i); if (!isNamePart(ch)) { return aggregation.substring(start + 1, i); } } - throw new IllegalArgumentException("Could not find path in aggregation formula ["+aggregation+"]"); + throw new IllegalArgumentException("Could not find path in aggregation formula [" + aggregation + "]"); } private static boolean isNamePart(char ch) { @@ -86,11 +86,11 @@ class DetermineAggPath { return path(pos); } else if (details instanceof DeployBeanPropertyAssocOne) { - DeployBeanPropertyAssocOne one = (DeployBeanPropertyAssocOne)details; + DeployBeanPropertyAssocOne one = (DeployBeanPropertyAssocOne) details; DeployBeanDescriptor targetDesc = one.getTargetDeploy(); return getManyPath(pos + 1, targetDesc); } - throw new IllegalArgumentException("Can not find path to many in aggregation formula ["+aggregation+"]"); + throw new IllegalArgumentException("Can not find path to many in aggregation formula [" + aggregation + "]"); } } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/InheritInfo.java b/src/main/java/io/ebeaninternal/server/deploy/InheritInfo.java index 098b0f402..90095bdaf 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/InheritInfo.java +++ b/src/main/java/io/ebeaninternal/server/deploy/InheritInfo.java @@ -1,18 +1,17 @@ package io.ebeaninternal.server.deploy; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Set; - -import javax.persistence.PersistenceException; - import io.ebean.bean.EntityBean; import io.ebeaninternal.server.core.InternString; import io.ebeaninternal.server.deploy.id.IdBinder; import io.ebeaninternal.server.deploy.parse.DeployInheritInfo; import io.ebeaninternal.server.query.SqlTreeProperties; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Set; + /** * Represents a node in the Inheritance tree. Holds information regarding Super Subclass support. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/InheritInfoVisitor.java b/src/main/java/io/ebeaninternal/server/deploy/InheritInfoVisitor.java index a2b91ee7a..b23b4119b 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/InheritInfoVisitor.java +++ b/src/main/java/io/ebeaninternal/server/deploy/InheritInfoVisitor.java @@ -5,9 +5,9 @@ package io.ebeaninternal.server.deploy; */ public interface InheritInfoVisitor { - /** - * visit the InheritInfo for this node. - */ - void visit(InheritInfo inheritInfo); + /** + * visit the InheritInfo for this node. + */ + void visit(InheritInfo inheritInfo); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/IntersectionRow.java b/src/main/java/io/ebeaninternal/server/deploy/IntersectionRow.java index 756ff0106..fb756a0e2 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/IntersectionRow.java +++ b/src/main/java/io/ebeaninternal/server/deploy/IntersectionRow.java @@ -1,16 +1,16 @@ package io.ebeaninternal.server.deploy; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import io.ebean.EbeanServer; import io.ebean.SqlUpdate; import io.ebeaninternal.api.BindParams; import io.ebeaninternal.server.core.DefaultSqlUpdate; -import io.ebeaninternal.server.expression.IdInExpression; import io.ebeaninternal.server.expression.DefaultExpressionRequest; +import io.ebeaninternal.server.expression.IdInExpression; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; public class IntersectionRow { diff --git a/src/main/java/io/ebeaninternal/server/deploy/ParamTypeUtil.java b/src/main/java/io/ebeaninternal/server/deploy/ParamTypeUtil.java index 55c5549a5..63a443dba 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/ParamTypeUtil.java +++ b/src/main/java/io/ebeaninternal/server/deploy/ParamTypeUtil.java @@ -8,71 +8,72 @@ import java.lang.reflect.Type; */ public class ParamTypeUtil { - /** - * Find and return the parameter type given a generic interface or class. - *

- * This assumes there is only one generic parameter. - *

- *

- * Returns null if no match was found. - *

- * @param cls the class to search for the parameter type - * @param matchType the type which has the generic parameter - */ - public static Class findParamType(Class cls, Class matchType) { + /** + * Find and return the parameter type given a generic interface or class. + *

+ * This assumes there is only one generic parameter. + *

+ *

+ * Returns null if no match was found. + *

+ * + * @param cls the class to search for the parameter type + * @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); - } - } + // 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); + } + } - if (paramType instanceof Class){ - // only interested in classes - return (Class)paramType; - } else { - return null; - } - } + if (paramType instanceof Class) { + // only interested in classes + return (Class) paramType; + } else { + 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. - */ - private static Type matchParamType(Type type, Class matchType) { - if (type instanceof ParameterizedType){ - ParameterizedType pt = (ParameterizedType)type; - Type rawType = pt.getRawType(); - boolean isAssignable = matchType.isAssignableFrom((Class) rawType); - if (isAssignable) { - // assume there is only one parameter type - Type[] typeArguments = pt.getActualTypeArguments(); - if (typeArguments.length != 1){ - String m = "Expecting only 1 generic paramater but got "+typeArguments.length+" for "+type; - throw new RuntimeException(m); - } - return typeArguments[0]; - } - } - 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. + */ + private static Type matchParamType(Type type, Class matchType) { + if (type instanceof ParameterizedType) { + ParameterizedType pt = (ParameterizedType) type; + Type rawType = pt.getRawType(); + boolean isAssignable = matchType.isAssignableFrom((Class) rawType); + if (isAssignable) { + // assume there is only one parameter type + Type[] typeArguments = pt.getActualTypeArguments(); + if (typeArguments.length != 1) { + String m = "Expecting only 1 generic paramater but got " + typeArguments.length + " for " + type; + throw new RuntimeException(m); + } + return typeArguments[0]; + } + } + return null; + } - /** - * Search the interfaces this class implements. - */ - private static Type matchByInterfaces(Class cls, Class matchType) { + /** + * Search the interfaces this class implements. + */ + private static Type matchByInterfaces(Class cls, Class matchType) { - Type[] gis = cls.getGenericInterfaces(); + Type[] gis = cls.getGenericInterfaces(); for (Type gi : gis) { Type match = matchParamType(gi, matchType); if (match != null) { return match; } } - return null; - } + return null; + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/PersistControllerManager.java b/src/main/java/io/ebeaninternal/server/deploy/PersistControllerManager.java index 9b2210e2b..791c56ad9 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/PersistControllerManager.java +++ b/src/main/java/io/ebeaninternal/server/deploy/PersistControllerManager.java @@ -1,13 +1,13 @@ package io.ebeaninternal.server.deploy; -import java.util.List; - import io.ebean.event.BeanPersistController; import io.ebeaninternal.server.core.bootup.BootupClasses; import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; + /** * Default implementation for creating BeanControllers. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/PersistListenerManager.java b/src/main/java/io/ebeaninternal/server/deploy/PersistListenerManager.java index 484da5cd8..c83d3ffdc 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/PersistListenerManager.java +++ b/src/main/java/io/ebeaninternal/server/deploy/PersistListenerManager.java @@ -14,22 +14,22 @@ import java.util.List; */ public class PersistListenerManager { - private static final Logger logger = LoggerFactory.getLogger(PersistListenerManager.class); + private static final Logger logger = LoggerFactory.getLogger(PersistListenerManager.class); - private final List list; + private final List list; - public PersistListenerManager(BootupClasses bootupClasses) { - list = bootupClasses.getBeanPersistListeners(); - } + public PersistListenerManager(BootupClasses bootupClasses) { + list = bootupClasses.getBeanPersistListeners(); + } - public int getRegisterCount() { - return list.size(); - } + public int getRegisterCount() { + return list.size(); + } - /** - * Return the BeanPersistController for a given entity type. - */ - public void addPersistListeners(DeployBeanDescriptor deployDesc) { + /** + * Return the BeanPersistController for a given entity type. + */ + public void addPersistListeners(DeployBeanDescriptor deployDesc) { for (BeanPersistListener listener : list) { if (listener.isRegisterFor(deployDesc.getBeanType())) { @@ -37,6 +37,6 @@ public class PersistListenerManager { deployDesc.addPersistListener(listener); } } - } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/TableJoin.java b/src/main/java/io/ebeaninternal/server/deploy/TableJoin.java index ca671c114..1390db6e1 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/TableJoin.java +++ b/src/main/java/io/ebeaninternal/server/deploy/TableJoin.java @@ -88,7 +88,6 @@ public final class TableJoin { } - /** * Return a hash value for adding to a query plan. */ @@ -138,12 +137,12 @@ public final class TableJoin { public SqlJoinType addJoin(SqlJoinType joinType, String a1, String a2, DbSqlContext ctx) { - String inheritance = inheritInfo != null ? inheritInfo.getWhere() : null; + String inheritance = inheritInfo != null ? inheritInfo.getWhere() : null; - String joinLiteral = joinType.getLiteral(type); - ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); + String joinLiteral = joinType.getLiteral(type); + ctx.addJoin(joinLiteral, table, columns(), a1, a2, inheritance); - return joinType.autoToOuter(type); + return joinType.autoToOuter(type); } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/TableJoinColumn.java b/src/main/java/io/ebeaninternal/server/deploy/TableJoinColumn.java index fed73ce8a..f8921b49e 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/TableJoinColumn.java +++ b/src/main/java/io/ebeaninternal/server/deploy/TableJoinColumn.java @@ -77,7 +77,7 @@ public class TableJoinColumn { @Override public String toString() { return (localSqlFormula == null ? localDbColumn : localSqlFormula) + " = " - + (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula); + + (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula); } /** diff --git a/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java b/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java index 0d2ab4be5..922fdcdc8 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java +++ b/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java @@ -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/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index bc37212be..e64a05be7 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -246,8 +246,8 @@ public final class IdBinderEmbedded implements IdBinder { @Override public Object getIdForJson(EntityBean bean) { - EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean); - Map map = new LinkedHashMap<>(); + EntityBean ebValue = (EntityBean) embIdProperty.getValue(bean); + Map map = new LinkedHashMap<>(); for (BeanProperty prop : props) { map.put(prop.getName(), prop.getValue(ebValue)); } @@ -261,7 +261,7 @@ public final class IdBinderEmbedded implements IdBinder { @SuppressWarnings("unchecked") public Object convertIdFromJson(Object value) { - Map map = (Map)value; + Map map = (Map) value; EntityBean idValue = idDesc.createEntityBean(); for (BeanProperty prop : props) { diff --git a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedId.java b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedId.java index ed79717a3..422b0c41f 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedId.java +++ b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedId.java @@ -1,7 +1,5 @@ package io.ebeaninternal.server.deploy.id; -import java.sql.SQLException; - import io.ebean.SqlUpdate; import io.ebean.bean.EntityBean; import io.ebeaninternal.server.deploy.BeanProperty; @@ -10,6 +8,8 @@ import io.ebeaninternal.server.deploy.IntersectionRow; import io.ebeaninternal.server.persist.dml.GenerateDmlRequest; import io.ebeaninternal.server.persist.dmlbind.BindableRequest; +import java.sql.SQLException; + /** * Represents a imported property. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java index e5016608d..1a37c7f52 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java +++ b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdEmbedded.java @@ -1,9 +1,5 @@ package io.ebeaninternal.server.deploy.id; -import java.sql.SQLException; - -import javax.persistence.PersistenceException; - import io.ebean.SqlUpdate; import io.ebean.bean.EntityBean; import io.ebeaninternal.server.deploy.BeanFkeyProperty; @@ -15,6 +11,9 @@ import io.ebeaninternal.server.deploy.IntersectionRow; import io.ebeaninternal.server.persist.dml.GenerateDmlRequest; import io.ebeaninternal.server.persist.dmlbind.BindableRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; + /** * Imported Embedded id. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdSimple.java b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdSimple.java index 6051d8b99..803ff4b56 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdSimple.java +++ b/src/main/java/io/ebeaninternal/server/deploy/id/ImportedIdSimple.java @@ -1,12 +1,5 @@ package io.ebeaninternal.server.deploy.id; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import javax.persistence.PersistenceException; - import io.ebean.SqlUpdate; import io.ebean.bean.EntityBean; import io.ebeaninternal.server.core.InternString; @@ -18,6 +11,12 @@ import io.ebeaninternal.server.deploy.IntersectionRow; import io.ebeaninternal.server.persist.dml.GenerateDmlRequest; import io.ebeaninternal.server.persist.dmlbind.BindableRequest; +import javax.persistence.PersistenceException; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + /** * Single scalar imported id. */ diff --git a/src/main/java/io/ebeaninternal/server/deploy/id/package.html b/src/main/java/io/ebeaninternal/server/deploy/id/package.html index fe4d3a6f3..87663e196 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/id/package.html +++ b/src/main/java/io/ebeaninternal/server/deploy/id/package.html @@ -1,10 +1,10 @@ - - Helpers for Id property conversion + + Helpers for Id property conversion Helpers for Id property conversion - \ No newline at end of file + diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index 88f7f3ae7..f0146c98c 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -629,7 +629,7 @@ public class DeployBeanDescriptor { this.baseTable = baseTableFull == null ? null : baseTableFull.getQualifiedName(); this.baseTableAsOf = baseTable + asOfSuffix; this.baseTableVersionsBetween = baseTable + versionsBetweenSuffix; - this.draftTable = (draftable) ? baseTable+"_draft" : baseTable; + this.draftTable = (draftable) ? baseTable + "_draft" : baseTable; } public void sortProperties() { diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java index 979831ab5..a57172989 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java @@ -258,11 +258,11 @@ public class DeployBeanProperty { private boolean isAuditProperty() { return (AnnotationBase.findAnnotation(field, WhenCreated.class) != null - || AnnotationBase.findAnnotation(field, WhenModified.class) != null - || AnnotationBase.findAnnotation(field, WhoModified.class) != null - || AnnotationBase.findAnnotation(field, WhoCreated.class) != null - || AnnotationBase.findAnnotation(field, UpdatedTimestamp.class) != null - || AnnotationBase.findAnnotation(field, CreatedTimestamp.class) != null); + || AnnotationBase.findAnnotation(field, WhenModified.class) != null + || AnnotationBase.findAnnotation(field, WhoModified.class) != null + || AnnotationBase.findAnnotation(field, WhoCreated.class) != null + || AnnotationBase.findAnnotation(field, UpdatedTimestamp.class) != null + || AnnotationBase.findAnnotation(field, CreatedTimestamp.class) != null); } public String getFullBeanName() { diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java index 38055e1cb..6467e8333 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssoc.java @@ -8,140 +8,140 @@ import io.ebeaninternal.server.deploy.BeanTable; */ public abstract class DeployBeanPropertyAssoc extends DeployBeanProperty { - /** - * The type of the joined bean. - */ - protected Class targetType; + /** + * The type of the joined bean. + */ + protected Class targetType; - /** - * Persist settings. - */ + /** + * Persist settings. + */ private final BeanCascadeInfo cascadeInfo = new BeanCascadeInfo(); - /** - * The join table information. - */ + /** + * The join table information. + */ private BeanTable beanTable; - /** - * Join between the beans. - */ + /** + * Join between the beans. + */ protected final DeployTableJoin tableJoin = new DeployTableJoin(); - /** - * Literal added to where clause of lazy loading query. - */ + /** + * Literal added to where clause of lazy loading query. + */ private String extraWhere; - /** - * From the deployment mappedBy attribute. - */ + /** + * From the deployment mappedBy attribute. + */ private String mappedBy; - private String docStoreDoc; + private String docStoreDoc; - /** - * Construct the property. - */ - DeployBeanPropertyAssoc(DeployBeanDescriptor desc, Class targetType) { - super(desc, targetType, null, null); - this.targetType = targetType; - } + /** + * Construct the property. + */ + DeployBeanPropertyAssoc(DeployBeanDescriptor desc, Class targetType) { + super(desc, targetType, null, null); + this.targetType = targetType; + } /** * Return the target DeployBeanDescriptor for this associated bean property. */ - public DeployBeanDescriptor getTargetDeploy() { - return desc.getDeploy(targetType).getDescriptor(); - } + public DeployBeanDescriptor getTargetDeploy() { + return desc.getDeploy(targetType).getDescriptor(); + } - /** - * Return the type of the target. - *

- * This is the class of the associated bean, or beans contained in a list, - * set or map. - *

- */ - public Class getTargetType() { - return targetType; - } + /** + * Return the type of the target. + *

+ * This is the class of the associated bean, or beans contained in a list, + * set or map. + *

+ */ + public Class getTargetType() { + return targetType; + } - /** - * Return a literal expression that is added to the query that lazy loads - * the collection. - */ - public String getExtraWhere() { - return extraWhere; - } + /** + * Return a literal expression that is added to the query that lazy loads + * the collection. + */ + public String getExtraWhere() { + return extraWhere; + } - /** - * Set a literal expression to add to the query that lazy loads the - * collection. - */ - public void setExtraWhere(String extraWhere) { - this.extraWhere = extraWhere; - } + /** + * Set a literal expression to add to the query that lazy loads the + * collection. + */ + public void setExtraWhere(String extraWhere) { + this.extraWhere = extraWhere; + } - /** - * return the join to use for the bean. - */ - public DeployTableJoin getTableJoin() { - return tableJoin; - } + /** + * return the join to use for the bean. + */ + public DeployTableJoin getTableJoin() { + return tableJoin; + } - /** - * Return the BeanTable for this association. - *

- * This has the table name which is used to determine the relationship for - * this association. - *

- */ - public BeanTable getBeanTable() { - return beanTable; - } + /** + * Return the BeanTable for this association. + *

+ * This has the table name which is used to determine the relationship for + * this association. + *

+ */ + public BeanTable getBeanTable() { + return beanTable; + } - /** - * Set the bean table. - */ - public void setBeanTable(BeanTable beanTable) { - this.beanTable = beanTable; - getTableJoin().setTable(beanTable.getBaseTable()); - } + /** + * Set the bean table. + */ + public void setBeanTable(BeanTable beanTable) { + this.beanTable = beanTable; + getTableJoin().setTable(beanTable.getBaseTable()); + } - /** - * Get the persist info. - */ - public BeanCascadeInfo getCascadeInfo() { - return cascadeInfo; - } + /** + * Get the persist info. + */ + public BeanCascadeInfo getCascadeInfo() { + return cascadeInfo; + } - /** - * Return the mappedBy deployment attribute. - *

- * This is the name of the property in the 'detail' bean that maps back to - * this 'master' bean. - *

- */ - public String getMappedBy() { - return mappedBy; - } + /** + * Return the mappedBy deployment attribute. + *

+ * This is the name of the property in the 'detail' bean that maps back to + * this 'master' bean. + *

+ */ + public String getMappedBy() { + return mappedBy; + } - /** - * Set mappedBy deployment attribute. - */ - public void setMappedBy(String mappedBy) { - if (!"".equals(mappedBy)) { - this.mappedBy = mappedBy; - } - } + /** + * Set mappedBy deployment attribute. + */ + public void setMappedBy(String mappedBy) { + if (!"".equals(mappedBy)) { + this.mappedBy = mappedBy; + } + } - /** - * Set DocStoreEmbedded deployment information. - */ - public void setDocStoreEmbedded(String embeddedDoc) { - this.docStoreDoc = embeddedDoc; - } + /** + * Set DocStoreEmbedded deployment information. + */ + public void setDocStoreEmbedded(String embeddedDoc) { + this.docStoreDoc = embeddedDoc; + } public String getDocStoreDoc() { return docStoreDoc; diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java index 6bab6698d..06a6c9915 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java @@ -14,184 +14,184 @@ public class DeployBeanPropertyAssocMany extends DeployBeanPropertyAssoc { */ final ManyType manyType; - ModifyListenMode modifyListenMode = ModifyListenMode.NONE; + ModifyListenMode modifyListenMode = ModifyListenMode.NONE; - /** - * Flag to indicate manyToMany relationship. - */ - boolean manyToMany; + /** + * Flag to indicate manyToMany relationship. + */ + boolean manyToMany; - /** - * Flag to indicate this is a unidirectional relationship. - */ - boolean unidirectional; + /** + * Flag to indicate this is a unidirectional relationship. + */ + boolean unidirectional; - /** - * Join for manyToMany intersection table. - */ - DeployTableJoin intersectionJoin; + /** + * Join for manyToMany intersection table. + */ + DeployTableJoin intersectionJoin; - /** - * For ManyToMany this is the Inverse join used to build reference queries. - */ - DeployTableJoin inverseJoin; + /** + * For ManyToMany this is the Inverse join used to build reference queries. + */ + DeployTableJoin inverseJoin; - String fetchOrderBy; + String fetchOrderBy; - String mapKey; + String mapKey; String intersectionDraftTable; /** - * Create this property. - */ - public DeployBeanPropertyAssocMany(DeployBeanDescriptor desc, Class targetType, ManyType manyType) { - super(desc, targetType); - this.manyType = manyType; - } + * Create this property. + */ + public DeployBeanPropertyAssocMany(DeployBeanDescriptor desc, Class targetType, ManyType manyType) { + super(desc, targetType); + this.manyType = manyType; + } - /** - * When generics is not used for manyType you can specify via annotations. - *

- * Really only expect this for Scala due to a Scala compiler bug at the moment. - * Otherwise I'd probably not bother support this. - *

- */ - @SuppressWarnings("unchecked") - public void setTargetType(Class cls){ - this.targetType = (Class)cls; - } + /** + * When generics is not used for manyType you can specify via annotations. + *

+ * Really only expect this for Scala due to a Scala compiler bug at the moment. + * Otherwise I'd probably not bother support this. + *

+ */ + @SuppressWarnings("unchecked") + public void setTargetType(Class cls) { + this.targetType = (Class) cls; + } - /** - * Return the many type. - */ - public ManyType getManyType() { - return manyType; - } + /** + * Return the many type. + */ + public ManyType getManyType() { + return manyType; + } - /** - * Return true if this is many to many. - */ - public boolean isManyToMany() { - return manyToMany; - } + /** + * Return true if this is many to many. + */ + public boolean isManyToMany() { + return manyToMany; + } - /** - * Set to true if this is a many to many. - */ - public void setManyToMany() { - this.manyToMany = true; - } + /** + * Set to true if this is a many to many. + */ + public void setManyToMany() { + this.manyToMany = true; + } - /** - * Return the mode for listening to changes to the List Set or Map. - */ - public ModifyListenMode getModifyListenMode() { - return modifyListenMode; - } + /** + * Return the mode for listening to changes to the List Set or Map. + */ + public ModifyListenMode getModifyListenMode() { + return modifyListenMode; + } - /** - * Set the mode for listening to changes to the List Set or Map. - */ - public void setModifyListenMode(ModifyListenMode modifyListenMode) { - this.modifyListenMode = modifyListenMode; - } + /** + * Set the mode for listening to changes to the List Set or Map. + */ + public void setModifyListenMode(ModifyListenMode modifyListenMode) { + this.modifyListenMode = modifyListenMode; + } - /** - * Return true if this is a unidirectional relationship. - */ - public boolean isUnidirectional() { - return unidirectional; - } + /** + * Return true if this is a unidirectional relationship. + */ + public boolean isUnidirectional() { + return unidirectional; + } - /** - * Set to true if this is a unidirectional relationship. - */ - public void setUnidirectional() { - this.unidirectional = true; - } + /** + * Set to true if this is a unidirectional relationship. + */ + public void setUnidirectional() { + this.unidirectional = true; + } - /** - * Create the immutable version of the intersection join. - */ - public TableJoin createIntersectionTableJoin() { - if (intersectionJoin != null){ - return new TableJoin(intersectionJoin); - } else { - return null; - } - } + /** + * Create the immutable version of the intersection join. + */ + public TableJoin createIntersectionTableJoin() { + if (intersectionJoin != null) { + return new TableJoin(intersectionJoin); + } else { + return null; + } + } - /** - * Create the immutable version of the inverse join. - */ - public TableJoin createInverseTableJoin() { - if (inverseJoin != null){ - return new TableJoin(inverseJoin); - } else { - return null; - } - } + /** + * Create the immutable version of the inverse join. + */ + public TableJoin createInverseTableJoin() { + if (inverseJoin != null) { + return new TableJoin(inverseJoin); + } else { + return null; + } + } - /** - * ManyToMany only, join from local table to intersection table. - */ - public DeployTableJoin getIntersectionJoin() { - return intersectionJoin; - } + /** + * ManyToMany only, join from local table to intersection table. + */ + public DeployTableJoin getIntersectionJoin() { + return intersectionJoin; + } - public DeployTableJoin getInverseJoin() { - return inverseJoin; - } + public DeployTableJoin getInverseJoin() { + return inverseJoin; + } - /** - * ManyToMany only, join from local table to intersection table. - */ - public void setIntersectionJoin(DeployTableJoin intersectionJoin) { - this.intersectionJoin = intersectionJoin; - } + /** + * ManyToMany only, join from local table to intersection table. + */ + public void setIntersectionJoin(DeployTableJoin intersectionJoin) { + this.intersectionJoin = intersectionJoin; + } - /** - * ManyToMany only, join from foreign table to intersection table. - */ - public void setInverseJoin(DeployTableJoin inverseJoin) { - this.inverseJoin = inverseJoin; - } + /** + * ManyToMany only, join from foreign table to intersection table. + */ + public void setInverseJoin(DeployTableJoin inverseJoin) { + this.inverseJoin = inverseJoin; + } - /** - * Return the order by clause used to order the fetching of the data for - * this list, set or map. - */ - public String getFetchOrderBy() { - return fetchOrderBy; - } + /** + * Return the order by clause used to order the fetching of the data for + * this list, set or map. + */ + public String getFetchOrderBy() { + return fetchOrderBy; + } - /** - * Return the default mapKey when returning a Map. - */ - public String getMapKey() { - return mapKey; - } + /** + * Return the default mapKey when returning a Map. + */ + public String getMapKey() { + return mapKey; + } - /** - * Set the default mapKey to use when returning a Map. - */ - public void setMapKey(String mapKey) { - if (mapKey != null && !mapKey.isEmpty()) { - this.mapKey = mapKey; - } - } + /** + * Set the default mapKey to use when returning a Map. + */ + public void setMapKey(String mapKey) { + if (mapKey != null && !mapKey.isEmpty()) { + this.mapKey = mapKey; + } + } - /** - * Set the order by clause used to order the fetching or the data for this - * list, set or map. - */ - public void setFetchOrderBy(String orderBy) { - if (orderBy != null && !orderBy.isEmpty()) { - fetchOrderBy = orderBy; - } - } + /** + * Set the order by clause used to order the fetching or the data for this + * list, set or map. + */ + public void setFetchOrderBy(String orderBy) { + if (orderBy != null && !orderBy.isEmpty()) { + fetchOrderBy = orderBy; + } + } /** * Return a draft table for intersection between 2 @Draftable entities. @@ -204,6 +204,6 @@ public class DeployBeanPropertyAssocMany extends DeployBeanPropertyAssoc { * ManyToMany between 2 @Draftable entities to also need draft intersection table. */ public void setIntersectionDraftTable() { - this.intersectionDraftTable = intersectionJoin.getTable()+"_draft"; + this.intersectionDraftTable = intersectionJoin.getTable() + "_draft"; } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java index 2a2936757..6623475f7 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanPropertyLists.java @@ -64,7 +64,7 @@ public class DeployBeanPropertyLists { private final BeanPropertyAssocOne unidirectional; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) public DeployBeanPropertyLists(BeanDescriptorMap owner, BeanDescriptor desc, DeployBeanDescriptor deploy) { this.desc = desc; @@ -189,7 +189,7 @@ public class DeployBeanPropertyLists { } if (prop instanceof BeanPropertyAssocMany) { - manys.add((BeanPropertyAssocMany)prop); + manys.add((BeanPropertyAssocMany) prop); } else { nonManys.add(prop); @@ -241,8 +241,8 @@ public class DeployBeanPropertyLists { public BeanProperty getId() { if (ids.size() > 1) { - String msg = "Issue with bean "+desc+". Ebean does not support multiple @Id properties. You need to convert to using an @EmbeddedId." - +" Please email the ebean google group if you need further clarification."; + String msg = "Issue with bean " + desc + ". Ebean does not support multiple @Id properties. You need to convert to using an @EmbeddedId." + + " Please email the ebean google group if you need further clarification."; throw new IllegalStateException(msg); } if (ids.isEmpty()) { @@ -333,7 +333,7 @@ public class DeployBeanPropertyLists { public BeanProperty getSoftDeleteProperty() { - for (BeanProperty prop: nonManys) { + for (BeanProperty prop : nonManys) { if (prop.isSoftDelete()) { return prop; } @@ -414,7 +414,7 @@ public class DeployBeanPropertyLists { return (BeanPropertyAssocMany[]) list.toArray(new BeanPropertyAssocMany[list.size()]); } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) private BeanProperty createBeanProperty(BeanDescriptorMap owner, DeployBeanProperty deployProp) { if (deployProp instanceof DeployBeanPropertyAssocOne) { diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanTable.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanTable.java index c2eb4ad9c..d37b4a6e8 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanTable.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanTable.java @@ -1,11 +1,11 @@ package io.ebeaninternal.server.deploy.meta; -import java.util.List; - import io.ebeaninternal.server.deploy.BeanDescriptorMap; import io.ebeaninternal.server.deploy.BeanProperty; import io.ebeaninternal.server.deploy.BeanPropertyAssocOne; +import java.util.List; + /** * Used for associated beans in place of a BeanDescriptor. This is done to avoid @@ -18,73 +18,73 @@ import io.ebeaninternal.server.deploy.BeanPropertyAssocOne; */ public class DeployBeanTable { - private final Class beanType; + private final Class beanType; - /** - * The base table. - */ - private String baseTable; + /** + * The base table. + */ + private String baseTable; - private List idProperties; + private List idProperties; - /** - * Create the BeanTable. - */ - public DeployBeanTable(Class beanType) { - this.beanType = beanType; + /** + * Create the BeanTable. + */ + public DeployBeanTable(Class beanType) { + this.beanType = beanType; + } + + /** + * Return the base table for this BeanTable. + * This is used to determine the join information + * for associations. + */ + public String getBaseTable() { + return baseTable; + } + + /** + * Set the base table for this BeanTable. + */ + public void setBaseTable(String baseTable) { + this.baseTable = baseTable; + } + + /** + * Return the id properties. + */ + public BeanProperty[] createIdProperties(BeanDescriptorMap owner) { + BeanProperty[] props = new BeanProperty[idProperties.size()]; + for (int i = 0; i < idProperties.size(); i++) { + props[i] = createProperty(owner, idProperties.get(i)); + } + return props; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private BeanProperty createProperty(BeanDescriptorMap owner, DeployBeanProperty prop) { + + if (prop instanceof DeployBeanPropertyAssocOne) { + return new BeanPropertyAssocOne(owner, (DeployBeanPropertyAssocOne) prop); + + } else { + return new BeanProperty(prop); } - /** - * Return the base table for this BeanTable. - * This is used to determine the join information - * for associations. - */ - public String getBaseTable() { - return baseTable; - } + } - /** - * Set the base table for this BeanTable. - */ - public void setBaseTable(String baseTable) { - this.baseTable = baseTable; - } + /** + * Set the Id properties. + */ + public void setIdProperties(List idProperties) { + this.idProperties = idProperties; + } - /** - * Return the id properties. - */ - public BeanProperty[] createIdProperties(BeanDescriptorMap owner) { - BeanProperty[] props = new BeanProperty[idProperties.size()]; - for (int i = 0; i < idProperties.size(); i++) { - props[i] = createProperty(owner, idProperties.get(i)); - } - return props; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private BeanProperty createProperty(BeanDescriptorMap owner, DeployBeanProperty prop){ - - if (prop instanceof DeployBeanPropertyAssocOne){ - return new BeanPropertyAssocOne(owner, (DeployBeanPropertyAssocOne)prop); - - } else { - return new BeanProperty(prop); - } - - } - - /** - * Set the Id properties. - */ - public void setIdProperties(List idProperties) { - this.idProperties = idProperties; - } - - /** - * Return the class for this beanTable. - */ - public Class getBeanType() { - return beanType; - } + /** + * Return the class for this beanTable. + */ + public Class getBeanType() { + return beanType; + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java index 7d4804f3f..2df36a716 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/DeployTableJoinColumn.java @@ -1,31 +1,31 @@ package io.ebeaninternal.server.deploy.meta; -import javax.persistence.JoinColumn; - import io.ebeaninternal.server.deploy.BeanProperty; import io.ebeaninternal.server.deploy.BeanTable; +import javax.persistence.JoinColumn; + /** * A join pair of local and foreign properties. */ public class DeployTableJoinColumn { - /** - * The local database column name. - */ - String localDbColumn; + /** + * The local database column name. + */ + String localDbColumn; - /** - * SQL formula used for local column - */ + /** + * SQL formula used for local column + */ String localSqlFormula; - /** - * The foreign database column name. - */ - String foreignDbColumn; + /** + * The foreign database column name. + */ + String foreignDbColumn; - /** + /** * SQL formula used for foreign column */ String foreignSqlFormula; @@ -35,152 +35,151 @@ public class DeployTableJoinColumn { boolean updateable; - - /** - * Construct when automatically determining the join. - *

- * Assume that we want the foreign key to be insertable and updateable. - *

- */ - public DeployTableJoinColumn(String localDbColumn, String foreignDbColumn) { - this(localDbColumn, foreignDbColumn, true, true); - } - - /** - * Construct with explicit insertable and updateable flags. - */ - public DeployTableJoinColumn(String localDbColumn, String foreignDbColumn, boolean insertable, boolean updateable) { - this.localDbColumn = nullEmptyString(localDbColumn); - this.foreignDbColumn = nullEmptyString(foreignDbColumn); - 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; - } + /** + * Construct when automatically determining the join. + *

+ * Assume that we want the foreign key to be insertable and updateable. + *

+ */ + public DeployTableJoinColumn(String localDbColumn, String foreignDbColumn) { + this(localDbColumn, foreignDbColumn, true, true); } - public String getLocalSqlFormula() { + /** + * Construct with explicit insertable and updateable flags. + */ + public DeployTableJoinColumn(String localDbColumn, String foreignDbColumn, boolean insertable, boolean updateable) { + this.localDbColumn = nullEmptyString(localDbColumn); + this.foreignDbColumn = nullEmptyString(foreignDbColumn); + 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 void setForeignSqlFormula(String foreignSqlFormula) { + if (foreignSqlFormula != null) { + this.foreignSqlFormula = foreignSqlFormula; + this.foreignDbColumn = null; + this.insertable = false; + this.updateable = false; + } } - public String getForeignSqlFormula() { + public String getForeignSqlFormula() { return foreignSqlFormula; } - public DeployTableJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) { - this(jc.referencedColumnName(), jc.name(), jc.insertable(), jc.updatable()); - setReferencedColumn(beanTable); - if (!order){ - reverse(); - } + public DeployTableJoinColumn(boolean order, JoinColumn jc, BeanTable beanTable) { + this(jc.referencedColumnName(), jc.name(), jc.insertable(), jc.updatable()); + setReferencedColumn(beanTable); + if (!order) { + reverse(); } + } - private void setReferencedColumn(BeanTable beanTable){ - if (localDbColumn == null){ - BeanProperty[] idProperties = beanTable.getIdProperties(); - if (idProperties.length == 1){ - localDbColumn = idProperties[0].getDbColumn(); - } - } + private void setReferencedColumn(BeanTable beanTable) { + if (localDbColumn == null) { + BeanProperty[] idProperties = beanTable.getIdProperties(); + if (idProperties.length == 1) { + localDbColumn = idProperties[0].getDbColumn(); + } } + } - /** - * Reverse the direction of the join. - */ - public DeployTableJoinColumn reverse() { - String temp = localDbColumn; - localDbColumn = foreignDbColumn; - foreignDbColumn = temp; + /** + * Reverse the direction of the join. + */ + public DeployTableJoinColumn reverse() { + String temp = localDbColumn; + localDbColumn = foreignDbColumn; + foreignDbColumn = temp; - temp = localSqlFormula; - localSqlFormula = foreignSqlFormula; - foreignSqlFormula = temp; - return this; + temp = localSqlFormula; + localSqlFormula = foreignSqlFormula; + foreignSqlFormula = temp; + return this; + } + + /** + * Helper method to null out empty strings. + */ + private String nullEmptyString(String s) { + if ("".equals(s)) { + return null; } - - /** - * Helper method to null out empty strings. - */ - private String nullEmptyString(String s){ - if ("".equals(s)){ - return null; - } - return s; - } + return s; + } - public DeployTableJoinColumn copy(boolean reverse) { - // 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){ - ret = new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); - ret.setLocalSqlFormula(foreignSqlFormula); - ret.setForeignSqlFormula(localSqlFormula); + public DeployTableJoinColumn copy(boolean reverse) { + // 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) { + ret = new DeployTableJoinColumn(foreignDbColumn, localDbColumn, insertable, updateable); + ret.setLocalSqlFormula(foreignSqlFormula); + ret.setForeignSqlFormula(localSqlFormula); - } else { - ret = new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); + } else { + ret = new DeployTableJoinColumn(localDbColumn, foreignDbColumn, insertable, updateable); ret.setLocalSqlFormula(localSqlFormula); ret.setForeignSqlFormula(foreignSqlFormula); - } - return ret; - } + } + return ret; + } - @Override + @Override public String toString() { - return localDbColumn + " = " + foreignDbColumn; - } + return localDbColumn + " = " + foreignDbColumn; + } - /** - * Return true if this column should be insertable. - */ - public boolean isInsertable() { - return insertable; - } - - /** - * Return true if this column should be updateable. - */ - public boolean isUpdateable() { - return updateable; - } - - /** - * Return the foreign database column name. - */ - public String getForeignDbColumn() { - return foreignDbColumn; - } - - /** - * Return the local database column name. - */ - public String getLocalDbColumn() { - return localDbColumn; - } - - /** - * Set the local database column name. + /** + * Return true if this column should be insertable. */ - public void setLocalDbColumn(String localDbColumn) { - this.localDbColumn = localDbColumn; - } + public boolean isInsertable() { + return insertable; + } + + /** + * Return true if this column should be updateable. + */ + public boolean isUpdateable() { + return updateable; + } + + /** + * Return the foreign database column name. + */ + public String getForeignDbColumn() { + return foreignDbColumn; + } + + /** + * Return the local database column name. + */ + public String getLocalDbColumn() { + return localDbColumn; + } + + /** + * Set the local database column name. + */ + public void setLocalDbColumn(String localDbColumn) { + this.localDbColumn = localDbColumn; + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/meta/package.html b/src/main/java/io/ebeaninternal/server/deploy/meta/package.html index 847f20537..732ba91fc 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/meta/package.html +++ b/src/main/java/io/ebeaninternal/server/deploy/meta/package.html @@ -1,10 +1,10 @@ - - Temporary objects used to collect deployment information + + Temporary objects used to collect deployment information Temporary objects used to collect deployment information - \ No newline at end of file + diff --git a/src/main/java/io/ebeaninternal/server/deploy/package.html b/src/main/java/io/ebeaninternal/server/deploy/package.html index 4905b8192..1b962aa2b 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/package.html +++ b/src/main/java/io/ebeaninternal/server/deploy/package.html @@ -1,14 +1,14 @@ - - Bean description + + Bean description Bean description

-Describes beans with their properties and configuration. + Describes beans with their properties and configuration.

- \ No newline at end of file + diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationBase.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationBase.java index 67a5d491e..ce53db9f9 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationBase.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationBase.java @@ -1,9 +1,9 @@ package io.ebeaninternal.server.deploy.parse; +import io.ebean.Platform; import io.ebean.annotation.Formula; import io.ebean.annotation.Where; import io.ebean.config.NamingConvention; -import io.ebean.Platform; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; @@ -272,8 +272,8 @@ public abstract class AnnotationBase { * Returns the value() method for a possible containerAnnotation. * Method is retuned only, if its signature is array of containingType. */ - private static Method getRepeatableValueMethod( - Annotation containerAnnotation, Class containingType) { + private static Method getRepeatableValueMethod( + Annotation containerAnnotation, Class containingType) { Method method = valueMethods.get(containerAnnotation); if (method == null) { diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java index 344d3d435..f63fd81a4 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java @@ -18,8 +18,6 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Set; - import javax.persistence.AttributeOverride; import javax.persistence.Column; import javax.persistence.Embeddable; @@ -27,6 +25,7 @@ import javax.persistence.Entity; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.UniqueConstraint; +import java.util.Set; /** * Read the class level deployment annotations. @@ -68,7 +67,7 @@ public class AnnotationClass extends AnnotationParser { public void parseAttributeOverride() { Class cls = descriptor.getBeanType(); - AttributeOverride override = AnnotationBase.findAnnotation(cls,AttributeOverride.class); + AttributeOverride override = AnnotationBase.findAnnotation(cls, AttributeOverride.class); if (override != null) { String propertyName = override.name(); Column column = override.column(); @@ -110,14 +109,14 @@ public class AnnotationClass extends AnnotationParser { private void read(Class cls) { // maybe doc store only so check for this before @Entity - DocStore docStore = AnnotationBase.findAnnotation(cls,DocStore.class); + DocStore docStore = AnnotationBase.findAnnotation(cls, DocStore.class); if (docStore != null) { descriptor.readDocStore(docStore); descriptor.setEntityType(EntityType.DOC); descriptor.setName(cls.getSimpleName()); } - Entity entity = AnnotationBase.findAnnotation(cls,Entity.class); + Entity entity = AnnotationBase.findAnnotation(cls, Entity.class); if (entity != null) { descriptor.setEntityType(EntityType.ORM); if (entity.name().isEmpty()) { @@ -127,27 +126,27 @@ public class AnnotationClass extends AnnotationParser { } } - Embeddable embeddable = AnnotationBase.findAnnotation(cls,Embeddable.class); + Embeddable embeddable = AnnotationBase.findAnnotation(cls, Embeddable.class); if (embeddable != null) { descriptor.setEntityType(EntityType.EMBEDDED); descriptor.setName("Embeddable:" + cls.getSimpleName()); } Set indices = AnnotationBase.findAnnotations(cls, Index.class); - for (Index index: indices) { + for (Index index : indices) { descriptor.addIndex(new IndexDefinition(index.columnNames(), index.name(), index.unique())); } - UniqueConstraint uc = AnnotationBase.findAnnotation(cls,UniqueConstraint.class); + UniqueConstraint uc = AnnotationBase.findAnnotation(cls, UniqueConstraint.class); if (uc != null) { descriptor.addIndex(new IndexDefinition(uc.columnNames())); } - View view = AnnotationBase.findAnnotation(cls,View.class); + View view = AnnotationBase.findAnnotation(cls, View.class); if (view != null) { descriptor.setView(view.name(), view.dependentTables()); } - Table table = AnnotationBase.findAnnotation(cls,Table.class); + Table table = AnnotationBase.findAnnotation(cls, Table.class); if (table != null) { UniqueConstraint[] uniqueConstraints = table.uniqueConstraints(); for (UniqueConstraint c : uniqueConstraints) { @@ -155,42 +154,42 @@ public class AnnotationClass extends AnnotationParser { } } - Draftable draftable = AnnotationBase.findAnnotation(cls,Draftable.class); + Draftable draftable = AnnotationBase.findAnnotation(cls, Draftable.class); if (draftable != null) { descriptor.setDraftable(); } - DraftableElement draftableElement = AnnotationBase.findAnnotation(cls,DraftableElement.class); + DraftableElement draftableElement = AnnotationBase.findAnnotation(cls, DraftableElement.class); if (draftableElement != null) { descriptor.setDraftableElement(); } - ReadAudit readAudit = AnnotationBase.findAnnotation(cls,ReadAudit.class); + ReadAudit readAudit = AnnotationBase.findAnnotation(cls, ReadAudit.class); if (readAudit != null) { descriptor.setReadAuditing(); } - History history = AnnotationBase.findAnnotation(cls,History.class); + History history = AnnotationBase.findAnnotation(cls, History.class); if (history != null) { descriptor.setHistorySupport(); } - DbComment comment = AnnotationBase.findAnnotation(cls,DbComment.class); + DbComment comment = AnnotationBase.findAnnotation(cls, DbComment.class); if (comment != null) { descriptor.setDbComment(comment.value()); } - UpdateMode updateMode = AnnotationBase.findAnnotation(cls,UpdateMode.class); + UpdateMode updateMode = AnnotationBase.findAnnotation(cls, UpdateMode.class); if (updateMode != null) { descriptor.setUpdateChangesOnly(updateMode.updateChangesOnly()); } - Cache cache = AnnotationBase.findAnnotation(cls,Cache.class); + Cache cache = AnnotationBase.findAnnotation(cls, Cache.class); if (cache != null && !disableL2Cache) { descriptor.setCache(cache); } - Set namedQueries = AnnotationBase.findAnnotations(cls,NamedQuery.class); + Set namedQueries = AnnotationBase.findAnnotations(cls, NamedQuery.class); for (NamedQuery namedQuery : namedQueries) { descriptor.addNamedQuery(namedQuery.name(), namedQuery.query()); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index 0cb9c969a..19dd45426 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -20,6 +20,15 @@ import io.ebean.annotation.Expose; import io.ebean.annotation.Formula; import io.ebean.annotation.HistoryExclude; import io.ebean.annotation.Index; +import io.ebean.annotation.JsonIgnore; +import io.ebean.annotation.SoftDelete; +import io.ebean.annotation.TenantId; +import io.ebean.annotation.UnmappedJson; +import io.ebean.annotation.UpdatedTimestamp; +import io.ebean.annotation.WhenCreated; +import io.ebean.annotation.WhenModified; +import io.ebean.annotation.WhoCreated; +import io.ebean.annotation.WhoModified; import io.ebean.config.EncryptDeploy; import io.ebean.config.EncryptDeploy.Mode; import io.ebean.config.dbplatform.DbEncrypt; @@ -36,15 +45,6 @@ import io.ebeaninternal.server.type.ScalarType; import io.ebeaninternal.server.type.ScalarTypeBytesBase; import io.ebeaninternal.server.type.ScalarTypeBytesEncrypted; import io.ebeaninternal.server.type.ScalarTypeEncryptedWrapper; -import io.ebean.annotation.JsonIgnore; -import io.ebean.annotation.SoftDelete; -import io.ebean.annotation.TenantId; -import io.ebean.annotation.UnmappedJson; -import io.ebean.annotation.UpdatedTimestamp; -import io.ebean.annotation.WhenCreated; -import io.ebean.annotation.WhenModified; -import io.ebean.annotation.WhoCreated; -import io.ebean.annotation.WhoModified; import javax.persistence.Basic; import javax.persistence.Column; @@ -108,7 +108,7 @@ public class AnnotationFields extends AnnotationParser { for (DeployBeanProperty prop : descriptor.propertiesAll()) { if (prop instanceof DeployBeanPropertyAssoc) { - readAssocOne((DeployBeanPropertyAssoc)prop); + readAssocOne((DeployBeanPropertyAssoc) prop); } else { readField(prop); } @@ -362,8 +362,8 @@ public class AnnotationFields extends AnnotationParser { } } - Set indices = getAll(prop, Index.class); - for (Index index: indices) { + Set indices = getAll(prop, Index.class); + for (Index index : indices) { addIndex(prop, index); } } @@ -371,10 +371,10 @@ public class AnnotationFields extends AnnotationParser { private void addIndex(DeployBeanProperty prop, Index index) { String[] columnNames; if (index.columnNames() == null || index.columnNames().length == 0) { - columnNames = new String[] {prop.getDbColumn()}; + columnNames = new String[]{prop.getDbColumn()}; } else { columnNames = new String[index.columnNames().length]; - int i=0; + int i = 0; int found = 0; for (String colName : index.columnNames()) { if (colName.equals("${fa}") || colName.equals(prop.getDbColumn())) { @@ -422,8 +422,8 @@ public class AnnotationFields extends AnnotationParser { private boolean hasRelationshipItem(DeployBeanProperty prop) { return get(prop, OneToMany.class) != null || - get(prop, ManyToOne.class) != null || - get(prop, OneToOne.class) != null; + get(prop, ManyToOne.class) != null || + get(prop, OneToOne.class) != null; } private void setEncryption(DeployBeanProperty prop, boolean dbEncString, int dbLen) { @@ -530,7 +530,7 @@ public class AnnotationFields extends AnnotationParser { // use a custom IdGenerator PlatformIdGenerator idGenerator = generatedPropFactory.getIdGenerator(genName); if (idGenerator == null) { - throw new IllegalStateException("No custom IdGenerator registered with name "+genName); + throw new IllegalStateException("No custom IdGenerator registered with name " + genName); } descriptor.setCustomIdGenerator(idGenerator); } else if (prop.getPropertyType().equals(UUID.class)) { diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java index 90d8253d6..89cc225f5 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java @@ -1,19 +1,18 @@ package io.ebeaninternal.server.deploy.parse; -import java.util.HashMap; -import java.util.Set; - -import javax.persistence.AttributeOverride; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.validation.groups.Default; - import io.ebean.annotation.EbeanDDL; import io.ebeaninternal.server.deploy.BeanCascadeInfo; import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; +import javax.persistence.AttributeOverride; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.validation.groups.Default; +import java.util.HashMap; +import java.util.Set; + /** * Base class for reading deployment annotations. */ @@ -100,7 +99,7 @@ public abstract class AnnotationParser extends AnnotationBase { */ protected boolean isEbeanValidationGroups(Class[] groups) { if (groups.length == 0 - || groups.length == 1 && javax.validation.groups.Default.class.isAssignableFrom(groups[0])) { + || groups.length == 1 && javax.validation.groups.Default.class.isAssignableFrom(groups[0])) { return true; } else { for (Class group : groups) { diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java index 773321511..ab3dbb758 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java @@ -15,7 +15,7 @@ public class AnnotationSql extends AnnotationParser { @Override public void parse() { Class cls = descriptor.getBeanType(); - Sql sql = AnnotationBase.findAnnotation(cls,Sql.class); + Sql sql = AnnotationBase.findAnnotation(cls, Sql.class); if (sql != null) { descriptor.setEntityType(BeanDescriptor.EntityType.SQL); } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployBeanInfo.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployBeanInfo.java index a1ca4515b..ebffb6f3c 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployBeanInfo.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployBeanInfo.java @@ -13,81 +13,81 @@ import java.util.HashMap; */ public class DeployBeanInfo { - /** - * Holds TableJoins for secondary table properties. - */ - private final HashMap tableJoinMap = new HashMap<>(); + /** + * Holds TableJoins for secondary table properties. + */ + private final HashMap tableJoinMap = new HashMap<>(); - private final DeployUtil util; + private final DeployUtil util; - private final DeployBeanDescriptor descriptor; + private final DeployBeanDescriptor descriptor; - /** - * Create with a DeployUtil and BeanDescriptor. - */ - public DeployBeanInfo(DeployUtil util, DeployBeanDescriptor descriptor) { - this.util = util; - this.descriptor = descriptor; - } + /** + * Create with a DeployUtil and BeanDescriptor. + */ + public DeployBeanInfo(DeployUtil util, DeployBeanDescriptor descriptor) { + this.util = util; + this.descriptor = descriptor; + } - @Override - public String toString() { - return String.valueOf(descriptor); - } + @Override + public String toString() { + return String.valueOf(descriptor); + } - /** - * Return the BeanDescriptor currently being processed. - */ - public DeployBeanDescriptor getDescriptor() { - return descriptor; - } + /** + * Return the BeanDescriptor currently being processed. + */ + public DeployBeanDescriptor getDescriptor() { + return descriptor; + } - /** - * Return the DeployUtil we are using. - */ - public DeployUtil getUtil() { - return util; - } + /** + * Return the DeployUtil we are using. + */ + public DeployUtil getUtil() { + return util; + } - /** - * Appropriate TableJoin for a property mapped to a secondary table. - */ - public DeployTableJoin getTableJoin(String tableName) { + /** + * Appropriate TableJoin for a property mapped to a secondary table. + */ + public DeployTableJoin getTableJoin(String tableName) { - String key = tableName.toLowerCase(); + String key = tableName.toLowerCase(); - DeployTableJoin tableJoin = tableJoinMap.get(key); - if (tableJoin == null) { - tableJoin = new DeployTableJoin(); - tableJoin.setTable(tableName); - tableJoin.setType(SqlJoinType.INNER); - descriptor.addTableJoin(tableJoin); + DeployTableJoin tableJoin = tableJoinMap.get(key); + if (tableJoin == null) { + tableJoin = new DeployTableJoin(); + tableJoin.setTable(tableName); + tableJoin.setType(SqlJoinType.INNER); + descriptor.addTableJoin(tableJoin); - tableJoinMap.put(key, tableJoin); - } - return tableJoin; - } + tableJoinMap.put(key, tableJoin); + } + return tableJoin; + } - /** - * Set a the join alias for a assoc one property. - */ - public void setBeanJoinType(DeployBeanPropertyAssocOne beanProp, boolean outerJoin) { + /** + * Set a the join alias for a assoc one property. + */ + public void setBeanJoinType(DeployBeanPropertyAssocOne beanProp, boolean outerJoin) { - DeployTableJoin tableJoin = beanProp.getTableJoin(); - tableJoin.setType(outerJoin ? SqlJoinType.OUTER : SqlJoinType.INNER); - } + DeployTableJoin tableJoin = beanProp.getTableJoin(); + tableJoin.setType(outerJoin ? SqlJoinType.OUTER : SqlJoinType.INNER); + } /** * Add named RawSql from ebean.xml. */ - public void addRawSql(String name, RawSql rawSql) { - descriptor.addRawSql(name, rawSql); - } + public void addRawSql(String name, RawSql rawSql) { + descriptor.addRawSql(name, rawSql); + } - /** - * Add the named query. + /** + * Add the named query. */ - public void addNamedQuery(String name, String query) { - descriptor.addNamedQuery(name, query); - } + public void addNamedQuery(String name, String query) { + descriptor.addNamedQuery(name, query); + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index 401d302d5..c91864434 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -159,7 +159,7 @@ public class DeployCreateProperties { String name = field.getName(); if ((Boolean.class.equals(field.getType()) || boolean.class.equals(field.getType())) - && name.startsWith("is") && name.length() > 2) { + && name.startsWith("is") && name.length() > 2) { // it is a boolean type field starting with "is" char c = name.charAt(2); diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java index 06c21d7f8..a89bed0d4 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java @@ -111,11 +111,11 @@ public class DeployInherit { info.setParent(parent); } - Inheritance ia = AnnotationBase.findAnnotation(cls,Inheritance.class); + Inheritance ia = AnnotationBase.findAnnotation(cls, Inheritance.class); if (ia != null) { ia.strategy(); } - DiscriminatorColumn da = AnnotationBase.findAnnotation(cls,DiscriminatorColumn.class); + DiscriminatorColumn da = AnnotationBase.findAnnotation(cls, DiscriminatorColumn.class); if (da != null) { // lowercase the discriminator column for RawSql and JSON info.setDiscriminatorColumn(da.name().toLowerCase()); @@ -128,7 +128,7 @@ public class DeployInherit { info.setDiscriminatorLength(da.length()); } - DiscriminatorValue dv = AnnotationBase.findAnnotation(cls,DiscriminatorValue.class); + DiscriminatorValue dv = AnnotationBase.findAnnotation(cls, DiscriminatorValue.class); if (dv != null) { info.setDiscriminatorValue(dv.value()); } @@ -149,7 +149,7 @@ public class DeployInherit { if (cls.equals(Object.class)) { return false; } - Annotation a = AnnotationBase.findAnnotation(cls,Inheritance.class); + Annotation a = AnnotationBase.findAnnotation(cls, Inheritance.class); if (a != null) { return true; } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java index 8f3ac03df..8470ee17d 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -1,10 +1,5 @@ package io.ebeaninternal.server.deploy.parse; -import java.sql.Types; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.PersistenceException; - import io.ebean.annotation.DbArray; import io.ebean.annotation.DbHstore; import io.ebean.annotation.DbJson; @@ -29,6 +24,11 @@ import io.ebeaninternal.server.type.TypeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.PersistenceException; +import java.sql.Types; + /** * Utility object to help processing deployment information. */ @@ -122,7 +122,7 @@ public class DeployUtil { } if (scalarType == null) { // look for @DbEnumValue or @EnumValue annotations etc - Class> enumClass = (Class>)enumType; + Class> enumClass = (Class>) enumType; scalarType = typeManager.createEnumScalarType(enumClass); if (scalarType == null) { // use JPA normal Enum type (without mapping) @@ -143,8 +143,8 @@ public class DeployUtil { */ private boolean enumOverrideDefaultMapping(Enumerated enumerated, ScalarType scalarType) { return enumerated != null && scalarType != null - && enumerated.value() == EnumType.STRING - && scalarType.getJdbcType() != Types.VARCHAR; + && enumerated.value() == EnumType.STRING + && scalarType.getJdbcType() != Types.VARCHAR; } private ScalarType createEnumScalarTypePerSpec(Class enumType, EnumType type) { @@ -239,13 +239,13 @@ public class DeployUtil { Class type = prop.getPropertyType(); ScalarType scalarType = typeManager.getArrayScalarType(type, dbArray, prop.getGenericType()); if (scalarType == null) { - throw new RuntimeException("No ScalarType for @DbArray type for [" + prop.getFullBeanName()+ "]"); + throw new RuntimeException("No ScalarType for @DbArray type for [" + prop.getFullBeanName() + "]"); } int dbType = scalarType.getJdbcType(); prop.setDbType(dbType); prop.setScalarType(scalarType); if (scalarType instanceof ScalarTypeArrayList) { - prop.setDbColumnDefn(((ScalarTypeArrayList)scalarType).getDbColumnDefn()); + prop.setDbColumnDefn(((ScalarTypeArrayList) scalarType).getDbColumnDefn()); } if (dbType == Types.VARCHAR) { // determine the db column size diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/SqlReservedWords.java b/src/main/java/io/ebeaninternal/server/deploy/parse/SqlReservedWords.java index b48e2162f..88fb822fc 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/SqlReservedWords.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/SqlReservedWords.java @@ -10,69 +10,70 @@ import java.util.HashSet; */ public class SqlReservedWords { - 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" - +",BOTH,BY,CALL,CALLED,CASCADE,CASCADED,CASE,CAST,CATALOG,CHAR" - +",CHARACTER,CHECK,CLOB,CLOSE,COALESCE,COLLATE" - +",COLLATION,COLUMN,COMMIT,CONDITION,CONNECT,CONNECTION,CONSTRAINT" - +",CONSTRAINTS,CONSTRUCTOR,CONTAINS,CONTINUE,CONVERT" - +",COUNT,CREATE,CROSS,CURRENT_DATE" - +",CURRENT_PATH,CURRENT_ROLE,CURRENT_TIME,CURRENT_TIMESTAMP" - +",CURRENT_USER,CURSOR,DATE" - +",DAY,DEC,DECIMAL,DECLARE,DEFAULT,DELETE" - +",DESC" - +",DISTINCT,DO,DOUBLE,DROP,ELSE,ELSEIF,END,EQUALS" - +",EXEC,EXIT,EXISTS,EXTRACT" - +",FLOAT,FROM,FOR,FREE" - +",GET,GLOBAL,GO,GOTO,GRANT,GROUP,HAVING,HOUR" - +",IF,IN,INNER,INOUT,INSERT" - +",INT,INTEGER,INTO,IS,JOIN" - +",LAST,LIKE,LIMIT" - +",MAX,MIN" - +",NCHAR,NCLOB,NOT" - +",NULL,NULLIF,NUMERIC," - +",OR,ORDER,OUTER" - +",REAL,REF,REFERENCES" - +",RETURN,RETURNS" - +",SELECT,SSL" - +",SMALLINT," - +",SYSTEM,SYSTEM_USER,TABLE" - +",TO" - +",TRIGGER,UNION,UNIQUE" - +",UPDATE,USER,VARCHAR,VIEW,WHEN" - +",WHERE,WITH"; + 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" + + ",BOTH,BY,CALL,CALLED,CASCADE,CASCADED,CASE,CAST,CATALOG,CHAR" + + ",CHARACTER,CHECK,CLOB,CLOSE,COALESCE,COLLATE" + + ",COLLATION,COLUMN,COMMIT,CONDITION,CONNECT,CONNECTION,CONSTRAINT" + + ",CONSTRAINTS,CONSTRUCTOR,CONTAINS,CONTINUE,CONVERT" + + ",COUNT,CREATE,CROSS,CURRENT_DATE" + + ",CURRENT_PATH,CURRENT_ROLE,CURRENT_TIME,CURRENT_TIMESTAMP" + + ",CURRENT_USER,CURSOR,DATE" + + ",DAY,DEC,DECIMAL,DECLARE,DEFAULT,DELETE" + + ",DESC" + + ",DISTINCT,DO,DOUBLE,DROP,ELSE,ELSEIF,END,EQUALS" + + ",EXEC,EXIT,EXISTS,EXTRACT" + + ",FLOAT,FROM,FOR,FREE" + + ",GET,GLOBAL,GO,GOTO,GRANT,GROUP,HAVING,HOUR" + + ",IF,IN,INNER,INOUT,INSERT" + + ",INT,INTEGER,INTO,IS,JOIN" + + ",LAST,LIKE,LIMIT" + + ",MAX,MIN" + + ",NCHAR,NCLOB,NOT" + + ",NULL,NULLIF,NUMERIC," + + ",OR,ORDER,OUTER" + + ",REAL,REF,REFERENCES" + + ",RETURN,RETURNS" + + ",SELECT,SSL" + + ",SMALLINT," + + ",SYSTEM,SYSTEM_USER,TABLE" + + ",TO" + + ",TRIGGER,UNION,UNIQUE" + + ",UPDATE,USER,VARCHAR,VIEW,WHEN" + + ",WHERE,WITH"; - private static final HashSet keywords = new HashSet<>(); - static { + private static final HashSet keywords = new HashSet<>(); - String[] initialKeywords = baseKeyWords.split(","); + static { + + String[] initialKeywords = baseKeyWords.split(","); for (String initialKeyword : initialKeywords) { keywords.add(initialKeyword.trim()); } - } + } - /** - * Return true if the tableAlias is a keyword. - */ - public static synchronized boolean isKeyword(String keyword){ - String s = keyword.trim().toUpperCase(); - return keywords.contains(s); - } + /** + * Return true if the tableAlias is a keyword. + */ + public static synchronized boolean isKeyword(String keyword) { + String s = keyword.trim().toUpperCase(); + return keywords.contains(s); + } - /** - * Add a sql keyword to the known set. - */ - public static synchronized void addKeyword(String keyword){ - if (keyword != null){ - keyword = keyword.trim().toUpperCase(); - if (!keyword.isEmpty()){ - keywords.add(keyword); - } - } - } + /** + * Add a sql keyword to the known set. + */ + public static synchronized void addKeyword(String keyword) { + if (keyword != null) { + keyword = keyword.trim().toUpperCase(); + if (!keyword.isEmpty()) { + keywords.add(keyword); + } + } + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/TransientProperties.java b/src/main/java/io/ebeaninternal/server/deploy/parse/TransientProperties.java index 83ed97321..4be75b3b3 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/TransientProperties.java +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/TransientProperties.java @@ -1,48 +1,48 @@ package io.ebeaninternal.server.deploy.parse; -import java.util.List; - import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocMany; import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne; +import java.util.List; + /** * Mark transient properties. */ public class TransientProperties { - public TransientProperties() { - } + public TransientProperties() { + } - /** - * Mark any additional properties as transient. - */ - public void process(DeployBeanDescriptor desc) { + /** + * Mark any additional properties as transient. + */ + public void process(DeployBeanDescriptor desc) { - List props = desc.propertiesBase(); - for (DeployBeanProperty prop : props) { - if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { - // non-transient... - prop.setTransient(); - } + List props = desc.propertiesBase(); + for (DeployBeanProperty prop : props) { + if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) { + // non-transient... + prop.setTransient(); } - - List> ones = desc.propertiesAssocOne(); - for (DeployBeanPropertyAssocOne prop : ones) { - if (prop.getBeanTable() == null) { - if (!prop.isEmbedded()) { - prop.setTransient(); - } - } - } - - List> manys = desc.propertiesAssocMany(); - for (DeployBeanPropertyAssocMany prop : manys) { - if (prop.getBeanTable() == null) { - prop.setTransient(); - } - } - } + + List> ones = desc.propertiesAssocOne(); + for (DeployBeanPropertyAssocOne prop : ones) { + if (prop.getBeanTable() == null) { + if (!prop.isEmbedded()) { + prop.setTransient(); + } + } + } + + List> manys = desc.propertiesAssocMany(); + for (DeployBeanPropertyAssocMany prop : manys) { + if (prop.getBeanTable() == null) { + prop.setTransient(); + } + } + + } } diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/ebeandeploy.dtd b/src/main/java/io/ebeaninternal/server/deploy/parse/ebeandeploy.dtd index 37a869e4e..b40794fa9 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/ebeandeploy.dtd +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/ebeandeploy.dtd @@ -1,16 +1,16 @@ - + - + - + - + - + - + diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/package.html b/src/main/java/io/ebeaninternal/server/deploy/parse/package.html index b4c4bceec..1a5860bc0 100644 --- a/src/main/java/io/ebeaninternal/server/deploy/parse/package.html +++ b/src/main/java/io/ebeaninternal/server/deploy/parse/package.html @@ -1,11 +1,11 @@ - - Deployment information parsing + + Deployment information parsing Deployment information parsing - \ No newline at end of file +