mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - format and imports only
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -2543,7 +2543,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
}
|
||||
|
||||
public void setUnmappedJson(EntityBean bean, Map<String, Object> unmappedProperties) {
|
||||
if( unmappedJson != null) {
|
||||
if (unmappedJson != null) {
|
||||
unmappedJson.setValueIntercept(bean, unmappedProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
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<T> {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class BeanMapHelp<T> implements BeanCollectionHelp<T> {
|
||||
@Override
|
||||
public BeanCollection<T> createEmpty(EntityBean ownerBean) {
|
||||
|
||||
BeanMap<?,T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
|
||||
BeanMap<?, T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
|
||||
if (many != null) {
|
||||
beanMap.setModifyListening(many.getModifyListenMode());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,8 +389,8 @@ public abstract class BeanPropertyAssoc<T> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,11 +206,11 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
public void publishMany(EntityBean draft, EntityBean live) {
|
||||
|
||||
// collections will not be null due to enhancement
|
||||
BeanCollection<T> draftVal = (BeanCollection<T>)getValueIntercept(draft);
|
||||
BeanCollection<T> liveVal = (BeanCollection<T>)getValueIntercept(live);
|
||||
BeanCollection<T> draftVal = (BeanCollection<T>) getValueIntercept(draft);
|
||||
BeanCollection<T> liveVal = (BeanCollection<T>) getValueIntercept(live);
|
||||
|
||||
// Organise the existing live beans into map keyed by id
|
||||
Map<Object, T> liveBeansAsMap = liveBeansAsMap(liveVal);
|
||||
@@ -1037,15 +1037,15 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Object,T> liveBeansAsMap(BeanCollection<?> liveVal) {
|
||||
private Map<Object, T> liveBeansAsMap(BeanCollection<?> liveVal) {
|
||||
|
||||
liveVal.size();
|
||||
Collection<?> liveBeans = liveVal.getActualDetails();
|
||||
Map<Object,T> liveMap = new LinkedHashMap<>();
|
||||
Map<Object, T> 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
} else {
|
||||
// we are only interested in the Id value
|
||||
newBean = (EntityBean)newEmb;
|
||||
oldBean = (EntityBean)oldEmb;
|
||||
newBean = (EntityBean) newEmb;
|
||||
oldBean = (EntityBean) oldEmb;
|
||||
|
||||
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
|
||||
BeanProperty idProperty = targetDescriptor.getIdProperty();
|
||||
@@ -427,7 +427,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
@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<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
|
||||
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<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
|
||||
private void setEmbeddedOwner(EntityBean bean, Object value) {
|
||||
((EntityBean)value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex);
|
||||
((EntityBean) value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,177 +10,177 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Chains multiple BeanPersistController's together.
|
||||
*
|
||||
* <p>
|
||||
* 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<BeanPersistController> list;
|
||||
private final List<BeanPersistController> 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<BeanPersistController> addList(BeanPersistController c1, BeanPersistController c2) {
|
||||
ArrayList<BeanPersistController> 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<BeanPersistController> addList(BeanPersistController c1, BeanPersistController c2) {
|
||||
ArrayList<BeanPersistController> addList = new ArrayList<>(2);
|
||||
addList.add(c1);
|
||||
addList.add(c2);
|
||||
return addList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct given the list of BeanPersistController's.
|
||||
*/
|
||||
public ChainedBeanPersistController(List<BeanPersistController> 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<BeanPersistController> 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<BeanPersistController> 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<BeanPersistController> 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<BeanPersistController> 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<BeanPersistController> 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<BeanPersistController> {
|
||||
/**
|
||||
* Helper to order the BeanPersistController's in a chain.
|
||||
*/
|
||||
private static class Sorter implements Comparator<BeanPersistController> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int compare(BeanPersistController o1, BeanPersistController o2) {
|
||||
|
||||
int i1 = o1.getExecutionOrder() ;
|
||||
int i2 = o2.getExecutionOrder() ;
|
||||
return (i1<i2 ? -1 : (i1==i2 ? 0 : 1));
|
||||
}
|
||||
int i1 = o1.getExecutionOrder();
|
||||
int i2 = o2.getExecutionOrder();
|
||||
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.event.BeanPersistListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.ebean.event.BeanPersistListener;
|
||||
|
||||
/**
|
||||
* Handles multiple BeanPersistListener's for a given entity type.
|
||||
*/
|
||||
public class ChainedBeanPersistListener implements BeanPersistListener {
|
||||
|
||||
private final List<BeanPersistListener> list;
|
||||
private final List<BeanPersistListener> 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<BeanPersistListener> addList(BeanPersistListener c1, BeanPersistListener c2) {
|
||||
ArrayList<BeanPersistListener> 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<BeanPersistListener> addList(BeanPersistListener c1, BeanPersistListener c2) {
|
||||
ArrayList<BeanPersistListener> addList = new ArrayList<>(2);
|
||||
addList.add(c1);
|
||||
addList.add(c2);
|
||||
return addList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct given the list of BeanPersistListener's.
|
||||
*/
|
||||
public ChainedBeanPersistListener(List<BeanPersistListener> list) {
|
||||
this.list = list;
|
||||
this.chain = list.toArray(new BeanPersistListener[list.size()]);
|
||||
}
|
||||
/**
|
||||
* Construct given the list of BeanPersistListener's.
|
||||
*/
|
||||
public ChainedBeanPersistListener(List<BeanPersistListener> 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<BeanPersistListener> 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<BeanPersistListener> 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<BeanPersistListener> 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<BeanPersistListener> 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<String> updatedProperties) {
|
||||
for (BeanPersistListener aChain : chain) {
|
||||
aChain.updated(bean, updatedProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,47 +10,47 @@ import java.util.List;
|
||||
*/
|
||||
public class ChainedBeanPostLoad implements BeanPostLoad {
|
||||
|
||||
private final List<BeanPostLoad> list;
|
||||
private final List<BeanPostLoad> list;
|
||||
|
||||
private final BeanPostLoad[] chain;
|
||||
private final BeanPostLoad[] chain;
|
||||
|
||||
/**
|
||||
* Construct given the list of BeanPostLoad's.
|
||||
*/
|
||||
public ChainedBeanPostLoad(List<BeanPostLoad> list) {
|
||||
this.list = list;
|
||||
this.chain = list.toArray(new BeanPostLoad[list.size()]);
|
||||
}
|
||||
/**
|
||||
* Construct given the list of BeanPostLoad's.
|
||||
*/
|
||||
public ChainedBeanPostLoad(List<BeanPostLoad> 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<BeanPostLoad> 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<BeanPostLoad> 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<BeanPostLoad> 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<BeanPostLoad> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BeanQueryAdapter> list;
|
||||
private final List<BeanQueryAdapter> list;
|
||||
|
||||
private final BeanQueryAdapter[] chain;
|
||||
private final BeanQueryAdapter[] chain;
|
||||
|
||||
/**
|
||||
* Construct given the list of BeanQueryAdapter's.
|
||||
*/
|
||||
public ChainedBeanQueryAdapter(List<BeanQueryAdapter> 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<BeanQueryAdapter> 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<BeanQueryAdapter> 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<BeanQueryAdapter> 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<BeanQueryAdapter> 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<BeanQueryAdapter> 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<BeanQueryAdapter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Helper to order the BeanQueryAdapter's in a chain.
|
||||
*/
|
||||
private static class Sorter implements Comparator<BeanQueryAdapter> {
|
||||
|
||||
@Override
|
||||
public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) {
|
||||
|
||||
int i1 = o1.getExecutionOrder() ;
|
||||
int i2 = o2.getExecutionOrder() ;
|
||||
return (i1<i2 ? -1 : (i1==i2 ? 0 : 1));
|
||||
}
|
||||
int i1 = o1.getExecutionOrder();
|
||||
int i2 = o2.getExecutionOrder();
|
||||
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
@@ -9,6 +7,8 @@ import io.ebean.bean.PersistenceContext;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.server.type.DataReader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Context provided when a BeanProperty reads from a ResultSet.
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ public class DeployDocPropertyOptions {
|
||||
mapping = new DocPropertyOptions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the DocProperty deployment options.
|
||||
*/
|
||||
|
||||
@@ -7,164 +7,164 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class DeployParser {
|
||||
|
||||
/**
|
||||
* used to identify sql literal.
|
||||
*/
|
||||
protected static final char SINGLE_QUOTE = '\'';
|
||||
/**
|
||||
* used to identify sql literal.
|
||||
*/
|
||||
protected static final char SINGLE_QUOTE = '\'';
|
||||
|
||||
/**
|
||||
* used to identify query named parameters.
|
||||
*/
|
||||
protected static final char COLON = ':';
|
||||
/**
|
||||
* used to identify query named parameters.
|
||||
*/
|
||||
protected static final char COLON = ':';
|
||||
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char UNDERSCORE = '_';
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char UNDERSCORE = '_';
|
||||
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char PERIOD = '.';
|
||||
/**
|
||||
* Used to determine when a column name terminates.
|
||||
*/
|
||||
protected static final char PERIOD = '.';
|
||||
|
||||
protected boolean encrypted;
|
||||
protected boolean encrypted;
|
||||
|
||||
protected String source;
|
||||
protected String source;
|
||||
|
||||
protected StringBuilder sb;
|
||||
protected StringBuilder sb;
|
||||
|
||||
protected int sourceLength;
|
||||
protected int sourceLength;
|
||||
|
||||
protected int pos;
|
||||
protected int pos;
|
||||
|
||||
protected String word;
|
||||
protected String word;
|
||||
|
||||
protected char wordTerminator;
|
||||
protected char wordTerminator;
|
||||
|
||||
protected abstract String convertWord();
|
||||
protected abstract String convertWord();
|
||||
|
||||
public abstract String getDeployWord(String expression);
|
||||
public abstract String getDeployWord(String expression);
|
||||
|
||||
|
||||
/**
|
||||
* Return the join includes.
|
||||
*/
|
||||
public abstract Set<String> getIncludes();
|
||||
/**
|
||||
* Return the join includes.
|
||||
*/
|
||||
public abstract Set<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
* <p>
|
||||
@@ -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<String> includes = new HashSet<>();
|
||||
private final Set<String> includes = new HashSet<>();
|
||||
|
||||
public DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
|
||||
this.beanDescriptor = beanDescriptor;
|
||||
}
|
||||
public DeployPropertyParser(BeanDescriptor<?> beanDescriptor) {
|
||||
this.beanDescriptor = beanDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getIncludes() {
|
||||
return includes;
|
||||
}
|
||||
@Override
|
||||
public Set<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> getIncludes() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Return null as not used for updates.
|
||||
*/
|
||||
@Override
|
||||
public Set<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -8,71 +8,72 @@ import java.lang.reflect.Type;
|
||||
*/
|
||||
public class ParamTypeUtil {
|
||||
|
||||
/**
|
||||
* Find and return the parameter type given a generic interface or class.
|
||||
* <p>
|
||||
* This assumes there is only one generic parameter.
|
||||
* </p>
|
||||
* <p>
|
||||
* Returns null if no match was found.
|
||||
* </p>
|
||||
* @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.
|
||||
* <p>
|
||||
* This assumes there is only one generic parameter.
|
||||
* </p>
|
||||
* <p>
|
||||
* Returns null if no match was found.
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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<BeanPersistListener> list;
|
||||
private final List<BeanPersistListener> 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 <T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||
/**
|
||||
* Return the BeanPersistController for a given entity type.
|
||||
*/
|
||||
public <T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||
|
||||
for (BeanPersistListener listener : list) {
|
||||
if (listener.isRegisterFor(deployDesc.getBeanType())) {
|
||||
@@ -37,6 +37,6 @@ public class PersistListenerManager {
|
||||
deployDesc.addPersistListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TableJoinColumn {
|
||||
@Override
|
||||
public String toString() {
|
||||
return (localSqlFormula == null ? localDbColumn : localSqlFormula) + " = "
|
||||
+ (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula);
|
||||
+ (foreignSqlFormula == null ? foreignDbColumn : foreignSqlFormula);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class GeneratedPropertyFactory {
|
||||
|
||||
private final ClassLoadConfig classLoadConfig;
|
||||
|
||||
private final Map<String,PlatformIdGenerator> idGeneratorMap = new HashMap<>();
|
||||
private final Map<String, PlatformIdGenerator> idGeneratorMap = new HashMap<>();
|
||||
|
||||
public GeneratedPropertyFactory(ServerConfig serverConfig, List<IdGenerator> idGenerators) {
|
||||
|
||||
|
||||
@@ -246,8 +246,8 @@ public final class IdBinderEmbedded implements IdBinder {
|
||||
@Override
|
||||
public Object getIdForJson(EntityBean bean) {
|
||||
|
||||
EntityBean ebValue = (EntityBean)embIdProperty.getValue(bean);
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
EntityBean ebValue = (EntityBean) embIdProperty.getValue(bean);
|
||||
Map<String, Object> 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<String,Object> map = (Map<String, Object>)value;
|
||||
Map<String, Object> map = (Map<String, Object>) value;
|
||||
|
||||
EntityBean idValue = idDesc.createEntityBean();
|
||||
for (BeanProperty prop : props) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Helpers for Id property conversion</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Helpers for Id property conversion</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Helpers for Id property conversion
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
@@ -629,7 +629,7 @@ public class DeployBeanDescriptor<T> {
|
||||
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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -8,140 +8,140 @@ import io.ebeaninternal.server.deploy.BeanTable;
|
||||
*/
|
||||
public abstract class DeployBeanPropertyAssoc<T> extends DeployBeanProperty {
|
||||
|
||||
/**
|
||||
* The type of the joined bean.
|
||||
*/
|
||||
protected Class<T> targetType;
|
||||
/**
|
||||
* The type of the joined bean.
|
||||
*/
|
||||
protected Class<T> 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<T> targetType) {
|
||||
super(desc, targetType, null, null);
|
||||
this.targetType = targetType;
|
||||
}
|
||||
/**
|
||||
* Construct the property.
|
||||
*/
|
||||
DeployBeanPropertyAssoc(DeployBeanDescriptor<?> desc, Class<T> 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.
|
||||
* <p>
|
||||
* This is the class of the associated bean, or beans contained in a list,
|
||||
* set or map.
|
||||
* </p>
|
||||
*/
|
||||
public Class<T> getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
/**
|
||||
* Return the type of the target.
|
||||
* <p>
|
||||
* This is the class of the associated bean, or beans contained in a list,
|
||||
* set or map.
|
||||
* </p>
|
||||
*/
|
||||
public Class<T> 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.
|
||||
* <p>
|
||||
* This has the table name which is used to determine the relationship for
|
||||
* this association.
|
||||
* </p>
|
||||
*/
|
||||
public BeanTable getBeanTable() {
|
||||
return beanTable;
|
||||
}
|
||||
/**
|
||||
* Return the BeanTable for this association.
|
||||
* <p>
|
||||
* This has the table name which is used to determine the relationship for
|
||||
* this association.
|
||||
* </p>
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
* This is the name of the property in the 'detail' bean that maps back to
|
||||
* this 'master' bean.
|
||||
* </p>
|
||||
*/
|
||||
public String getMappedBy() {
|
||||
return mappedBy;
|
||||
}
|
||||
/**
|
||||
* Return the mappedBy deployment attribute.
|
||||
* <p>
|
||||
* This is the name of the property in the 'detail' bean that maps back to
|
||||
* this 'master' bean.
|
||||
* </p>
|
||||
*/
|
||||
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;
|
||||
|
||||
+150
-150
@@ -14,184 +14,184 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
|
||||
*/
|
||||
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<T> targetType, ManyType manyType) {
|
||||
super(desc, targetType);
|
||||
this.manyType = manyType;
|
||||
}
|
||||
* Create this property.
|
||||
*/
|
||||
public DeployBeanPropertyAssocMany(DeployBeanDescriptor<?> desc, Class<T> targetType, ManyType manyType) {
|
||||
super(desc, targetType);
|
||||
this.manyType = manyType;
|
||||
}
|
||||
|
||||
/**
|
||||
* When generics is not used for manyType you can specify via annotations.
|
||||
* <p>
|
||||
* Really only expect this for Scala due to a Scala compiler bug at the moment.
|
||||
* Otherwise I'd probably not bother support this.
|
||||
* </p>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setTargetType(Class<?> cls){
|
||||
this.targetType = (Class<T>)cls;
|
||||
}
|
||||
/**
|
||||
* When generics is not used for manyType you can specify via annotations.
|
||||
* <p>
|
||||
* Really only expect this for Scala due to a Scala compiler bug at the moment.
|
||||
* Otherwise I'd probably not bother support this.
|
||||
* </p>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setTargetType(Class<?> cls) {
|
||||
this.targetType = (Class<T>) 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<T> extends DeployBeanPropertyAssoc<T> {
|
||||
* ManyToMany between 2 @Draftable entities to also need draft intersection table.
|
||||
*/
|
||||
public void setIntersectionDraftTable() {
|
||||
this.intersectionDraftTable = intersectionJoin.getTable()+"_draft";
|
||||
this.intersectionDraftTable = intersectionJoin.getTable() + "_draft";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<DeployBeanProperty> idProperties;
|
||||
private List<DeployBeanProperty> 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<DeployBeanProperty> 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<DeployBeanProperty> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
* <p>
|
||||
* Assume that we want the foreign key to be insertable and updateable.
|
||||
* </p>
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
* Assume that we want the foreign key to be insertable and updateable.
|
||||
* </p>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<title>Temporary objects used to collect deployment information</title>
|
||||
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<title>Temporary objects used to collect deployment information</title>
|
||||
</head>
|
||||
<body BGCOLOR="#ffffff">
|
||||
Temporary objects used to collect deployment information
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<title>Bean description</title>
|
||||
<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<title>Bean description</title>
|
||||
</head>
|
||||
<body BGCOLOR="#ffffff">
|
||||
Bean description
|
||||
|
||||
<p>
|
||||
Describes beans with their properties and configuration.
|
||||
Describes beans with their properties and configuration.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -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 <code>value()</code> method for a possible containerAnnotation.
|
||||
* Method is retuned only, if its signature is <code>array of containingType</code>.
|
||||
*/
|
||||
private static <A extends Annotation> Method getRepeatableValueMethod(
|
||||
Annotation containerAnnotation, Class<A> containingType) {
|
||||
private static <A extends Annotation> Method getRepeatableValueMethod(
|
||||
Annotation containerAnnotation, Class<A> containingType) {
|
||||
|
||||
Method method = valueMethods.get(containerAnnotation);
|
||||
if (method == null) {
|
||||
|
||||
@@ -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<Index> 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<NamedQuery> namedQueries = AnnotationBase.findAnnotations(cls,NamedQuery.class);
|
||||
Set<NamedQuery> namedQueries = AnnotationBase.findAnnotations(cls, NamedQuery.class);
|
||||
for (NamedQuery namedQuery : namedQueries) {
|
||||
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
|
||||
}
|
||||
|
||||
@@ -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<Index> indices = getAll(prop, Index.class);
|
||||
for (Index index: indices) {
|
||||
Set<Index> 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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,81 +13,81 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class DeployBeanInfo<T> {
|
||||
|
||||
/**
|
||||
* Holds TableJoins for secondary table properties.
|
||||
*/
|
||||
private final HashMap<String,DeployTableJoin> tableJoinMap = new HashMap<>();
|
||||
/**
|
||||
* Holds TableJoins for secondary table properties.
|
||||
*/
|
||||
private final HashMap<String, DeployTableJoin> tableJoinMap = new HashMap<>();
|
||||
|
||||
private final DeployUtil util;
|
||||
private final DeployUtil util;
|
||||
|
||||
private final DeployBeanDescriptor<T> descriptor;
|
||||
private final DeployBeanDescriptor<T> descriptor;
|
||||
|
||||
/**
|
||||
* Create with a DeployUtil and BeanDescriptor.
|
||||
*/
|
||||
public DeployBeanInfo(DeployUtil util, DeployBeanDescriptor<T> descriptor) {
|
||||
this.util = util;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
/**
|
||||
* Create with a DeployUtil and BeanDescriptor.
|
||||
*/
|
||||
public DeployBeanInfo(DeployUtil util, DeployBeanDescriptor<T> 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<T> getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
/**
|
||||
* Return the BeanDescriptor currently being processed.
|
||||
*/
|
||||
public DeployBeanDescriptor<T> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>)enumType;
|
||||
Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) 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
|
||||
|
||||
@@ -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<String> keywords = new HashSet<>();
|
||||
static {
|
||||
private static final HashSet<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DeployBeanProperty> props = desc.propertiesBase();
|
||||
for (DeployBeanProperty prop : props) {
|
||||
if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) {
|
||||
// non-transient...
|
||||
prop.setTransient();
|
||||
}
|
||||
List<DeployBeanProperty> props = desc.propertiesBase();
|
||||
for (DeployBeanProperty prop : props) {
|
||||
if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) {
|
||||
// non-transient...
|
||||
prop.setTransient();
|
||||
}
|
||||
|
||||
List<DeployBeanPropertyAssocOne<?>> ones = desc.propertiesAssocOne();
|
||||
for (DeployBeanPropertyAssocOne<?> prop : ones) {
|
||||
if (prop.getBeanTable() == null) {
|
||||
if (!prop.isEmbedded()) {
|
||||
prop.setTransient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DeployBeanPropertyAssocMany<?>> manys = desc.propertiesAssocMany();
|
||||
for (DeployBeanPropertyAssocMany<?> prop : manys) {
|
||||
if (prop.getBeanTable() == null) {
|
||||
prop.setTransient();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<DeployBeanPropertyAssocOne<?>> ones = desc.propertiesAssocOne();
|
||||
for (DeployBeanPropertyAssocOne<?> prop : ones) {
|
||||
if (prop.getBeanTable() == null) {
|
||||
if (!prop.isEmbedded()) {
|
||||
prop.setTransient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DeployBeanPropertyAssocMany<?>> manys = desc.propertiesAssocMany();
|
||||
for (DeployBeanPropertyAssocMany<?> prop : manys) {
|
||||
if (prop.getBeanTable() == null) {
|
||||
prop.setTransient();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<!ELEMENT ebean (table | iudextender | findextender | datasource | primarykeys | property)* >
|
||||
<!ELEMENT table EMPTY >
|
||||
<!ATTLIST table name CDATA #REQUIRED>
|
||||
<!ATTLIST table name CDATA #REQUIRED>
|
||||
<!ELEMENT iudextender EMPTY >
|
||||
<!ATTLIST iudextender classname CDATA #REQUIRED>
|
||||
<!ATTLIST iudextender classname CDATA #REQUIRED>
|
||||
<!ELEMENT findextender EMPTY >
|
||||
<!ATTLIST findextender classname CDATA #REQUIRED>
|
||||
<!ATTLIST findextender classname CDATA #REQUIRED>
|
||||
<!ELEMENT datasource EMPTY >
|
||||
<!ATTLIST datasource name CDATA #REQUIRED>
|
||||
<!ATTLIST datasource name CDATA #REQUIRED>
|
||||
<!ELEMENT primarykeys EMPTY >
|
||||
<!ATTLIST primarykeys keys CDATA #REQUIRED>
|
||||
<!ATTLIST primarykeys keys CDATA #REQUIRED>
|
||||
<!ELEMENT property EMPTY >
|
||||
<!ATTLIST property name CDATA #REQUIRED
|
||||
datatype CDATA #REQUIRED
|
||||
deploydatatype CDATA #IMPLIED
|
||||
deployname CDATA #IMPLIED >
|
||||
<!ATTLIST property name CDATA #REQUIRED
|
||||
datatype CDATA #REQUIRED
|
||||
deploydatatype CDATA #IMPLIED
|
||||
deployname CDATA #IMPLIED >
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Deployment information parsing</TITLE>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
|
||||
<TITLE>Deployment information parsing</TITLE>
|
||||
</HEAD>
|
||||
<Body BGCOLOR="#ffffff">
|
||||
Deployment information parsing
|
||||
|
||||
|
||||
</Body>
|
||||
</HTML>
|
||||
</HTML>
|
||||
|
||||
Reference in New Issue
Block a user