#2318 - Refactor internals - trim whitespace in deploy package

This commit is contained in:
rbygrave committed 2021-08-20 17:51:01 +12:00
1 parent 6f7efe6922
commit bf2d75e55e
19 files changed
+3 -246

No files matched your search

@@ -70,131 +70,86 @@ public class DeployBeanDescriptor<T> {
private static final String I_SCALAOBJECT = "scala.ScalaObject";
private final DatabaseConfig config;
private final BeanDescriptorManager manager;
/**
* Map of BeanProperty Linked so as to preserve order.
*/
private LinkedHashMap<String, DeployBeanProperty> propMap = new LinkedHashMap<>();
private Map<String, SpiRawSql> namedRawSql;
private Map<String, String> namedQuery;
private EntityType entityType;
private DeployBeanPropertyAssocOne<?> unidirectional;
private DeployBeanProperty orderColumn;
private Class<?> idClass;
private DeployBeanPropertyAssocOne<?> idClassProperty;
private DeployIdentityMode identityMode = DeployIdentityMode.auto();
private PlatformIdGenerator idGenerator;
/**
* Set true when explicit auto generated Id.
*/
private boolean idGeneratedValue;
/**
* Used with Identity columns but no getGeneratedKeys support.
*/
private String selectLastInsertedId;
private String selectLastInsertedIdDraft;
/**
* The concurrency mode for beans of this type.
*/
private ConcurrencyMode concurrencyMode;
private List<IndexDefinition> indexDefinitions;
private String storageEngine;
/**
* The base database table.
*/
private String baseTable;
private String baseTableAsOf;
private String baseTableVersionsBetween;
private String draftTable;
private String[] dependentTables;
private boolean historySupport;
private boolean readAuditing;
private boolean draftable;
private boolean draftableElement;
private TableName baseTableFull;
private String[] properties;
/**
* The EntityBean type used to create new EntityBeans.
*/
private final Class<T> beanType;
private final List<BeanPersistController> persistControllers = new ArrayList<>();
private final List<BeanPersistListener> persistListeners = new ArrayList<>();
private final List<BeanQueryAdapter> queryAdapters = new ArrayList<>();
private final List<BeanPostLoad> postLoaders = new ArrayList<>();
private final List<BeanPostConstructListener> postConstructListeners = new ArrayList<>();
private CacheOptions cacheOptions = CacheOptions.NO_CACHING;
/**
* If set overrides the find implementation. Server side only.
*/
private BeanFindController beanFinder;
/**
* Inheritance information. Server side only.
*/
private InheritInfo inheritInfo;
private String name;
private ChangeLogFilter changeLogFilter;
private String dbComment;
private PartitionMeta partitionMeta;
/**
* One of NONE, INDEX or EMBEDDED.
*/
private boolean docStoreMapped;
private DocStore docStore;
private PathProperties docStorePathProperties;
private String docStoreQueueId;
private String docStoreIndexName;
private String docStoreIndexType;
private DocStoreMode docStorePersist;
private DocStoreMode docStoreInsert;
private DocStoreMode docStoreUpdate;
private DocStoreMode docStoreDelete;
private DeployBeanProperty idProperty;
private TableJoin primaryKeyJoin;
private Object jacksonAnnotatedClass;
/**
@@ -55,170 +55,119 @@ public class DeployBeanProperty {
* Flag to mark this at part of the unique id.
*/
private boolean id;
boolean importedPrimaryKey;
/**
* Flag to mark the property as embedded. This could be on
* BeanPropertyAssocOne rather than here. Put it here for checking Id type
* (embedded or not).
*/
private boolean embedded;
/**
* Flag indicating if this the version property.
*/
private boolean versionColumn;
private boolean fetchEager = true;
/**
* Set if this property is nullable.
*/
private boolean nullable = true;
private boolean unique;
private boolean discriminator;
/**
* The length or precision of the DB column.
*/
private int dbLength;
private int dbScale;
private String dbColumnDefn;
private boolean isTransient;
private boolean localEncrypted;
private boolean jsonSerialize = true;
private boolean jsonDeserialize = true;
private MutationDetection mutationDetection;
private boolean dbEncrypted;
private DbEncryptFunction dbEncryptFunction;
private int dbEncryptedType;
private String dbBind = "?";
/**
* Is this property include in database resultSet.
*/
private boolean dbRead;
/**
* Include this in DB insert.
*/
private boolean dbInsertable;
/**
* Include this in a DB update.
*/
private boolean dbUpdateable;
private DeployTableJoin secondaryTableJoin;
private String secondaryTableJoinPrefix;
/**
* Set to true if this property is based on a secondary table.
*/
private String secondaryTable;
/**
* The type that owns this property.
*/
private Class<?> owningType;
/**
* True if the property is a Clob, Blob LongVarchar or LongVarbinary.
*/
private boolean lob;
private boolean naturalKey;
/**
* The logical bean property name.
*/
private String name;
/**
* The reflected field.
*/
private Field field;
/**
* The bean type.
*/
private final Class<?> propertyType;
private final Type genericType;
/**
* Set for Non-JDBC types to provide logical to db type conversion.
*/
private ScalarType<?> scalarType;
/**
* The database column. This can include quoted identifiers.
*/
private String dbColumn;
private String aggregationPrefix;
private String aggregation;
private String aggregationParsed;
private String sqlFormulaSelect;
private String sqlFormulaJoin;
/**
* The jdbc data type this maps to.
*/
private int dbType;
private final DeployDocPropertyOptions docMapping = new DeployDocPropertyOptions();
private int propertyIndex;
private BeanPropertyGetter getter;
private BeanPropertySetter setter;
/**
* Generator for insert or update timestamp etc.
*/
private GeneratedProperty generatedProperty;
final DeployBeanDescriptor<?> desc;
private boolean undirectionalShadow;
private boolean elementProperty;
private int sortOrder;
private boolean excludedFromHistory;
private boolean tenantId;
private boolean draft;
private boolean draftOnly;
private boolean draftDirty;
private boolean draftReset;
private boolean softDelete;
private boolean unmappedJson;
private String dbComment;
private String dbColumnDefault;
private List<DbMigrationInfo> dbMigrationInfos;
private Set<Annotation> metaAnnotations;
public DeployBeanProperty(DeployBeanDescriptor<?> desc, Class<?> propertyType, ScalarType<?> scalarType, ScalarTypeConverter<?, ?> typeConverter) {
@@ -13,38 +13,29 @@ public abstract class DeployBeanPropertyAssoc<T> extends DeployBeanProperty {
* The type of the joined bean.
*/
Class<T> targetType;
/**
* Persist settings.
*/
final BeanCascadeInfo cascadeInfo = new BeanCascadeInfo();
/**
* The join table information.
*/
private BeanTable beanTable;
/**
* Join between the beans.
*/
final DeployTableJoin tableJoin = new DeployTableJoin();
/**
* Literal added to where clause of lazy loading query.
*/
private String extraWhere;
/**
* From the deployment mappedBy attribute.
*/
private String mappedBy;
private String docStoreDoc;
private int fetchPreference = 1000;
private PropertyForeignKey foreignKey;
boolean orphanRemoval;
/**
@@ -17,41 +17,29 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
* The type of the many, set, list or map.
*/
private final ManyType manyType;
ModifyListenMode modifyListenMode = ModifyListenMode.NONE;
/**
* Flag to indicate manyToMany relationship.
*/
private boolean manyToMany;
private boolean o2mJoinTable;
private boolean elementCollection;
/**
* Flag to indicate this is a unidirectional relationship.
*/
private boolean unidirectional;
/**
* Join for manyToMany intersection table.
*/
private DeployTableJoin intersectionJoin;
/**
* For ManyToMany this is the Inverse join used to build reference queries.
*/
private DeployTableJoin inverseJoin;
private String fetchOrderBy;
private String mapKey;
private String intersectionDraftTable;
private DeployOrderColumn orderColumn;
/**
* Effectively the dynamically created target descriptor (that doesn't have a mapped type/class per say).
*/
@@ -10,15 +10,10 @@ import javax.persistence.CascadeType;
public final class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
private boolean oneToOne;
private boolean oneToOneExported;
private boolean primaryKeyJoin;
private boolean primaryKeyExport;
private DeployBeanEmbedded deployEmbedded;
private String columnPrefix;
/**
@@ -16,12 +16,10 @@ import io.ebeaninternal.server.deploy.BeanPropertyAssocOne;
public final class DeployBeanTable {
private final Class<?> beanType;
/**
* The base table.
*/
private String baseTable;
private DeployBeanProperty idProperty;
/**
@@ -21,19 +21,15 @@ public final class DeployTableJoin {
* The joined table.
*/
private String table;
/**
* The type of join. LEFT JOIN etc.
*/
private SqlJoinType type = SqlJoinType.INNER;
/**
* The list of join column pairs. Used to generate the on clause.
*/
private ArrayList<DeployTableJoinColumn> columns = new ArrayList<>(4);
private InheritInfo inheritInfo;
private String extraWhere;
/**
@@ -14,24 +14,19 @@ public final class DeployTableJoinColumn {
* The local database column name.
*/
private String localDbColumn;
/**
* SQL formula used for local column
*/
private String localSqlFormula;
/**
* The foreign database column name.
*/
private String foreignDbColumn;
/**
* SQL formula used for foreign column
*/
private String foreignSqlFormula;
private boolean insertable;
private boolean updateable;
/**
@@ -69,7 +69,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
}
private void read(DeployBeanPropertyAssocMany<?> prop) {
OneToMany oneToMany = get(prop, OneToMany.class);
if (oneToMany != null) {
readToOne(oneToMany, prop);
@@ -105,27 +104,22 @@ final class AnnotationAssocManys extends AnnotationAssoc {
if (get(prop, HistoryExclude.class) != null) {
prop.setExcludedFromHistory();
}
OrderBy orderBy = get(prop, OrderBy.class);
if (orderBy != null) {
prop.setFetchOrderBy(orderBy.value());
}
MapKey mapKey = get(prop, MapKey.class);
if (mapKey != null) {
prop.setMapKey(mapKey.name());
}
Where where = prop.getMetaAnnotationWhere(platform);
if (where != null) {
prop.setExtraWhere(processFormula(where.clause()));
}
FetchPreference fetchPreference = get(prop, FetchPreference.class);
if (fetchPreference != null) {
prop.setFetchPreference(fetchPreference.value());
}
// check for manually defined joins
BeanTable beanTable = prop.getBeanTable();
@@ -147,31 +141,24 @@ final class AnnotationAssocManys extends AnnotationAssoc {
} else if (prop.isManyToMany()) {
checkSelfManyToMany(prop);
}
if (prop.getMappedBy() != null) {
// the join is derived by reversing the join information
// from the mapped by property.
// Refer BeanDescriptorManager.readEntityRelationships()
return;
}
if (prop.isManyToMany()) {
manyToManyDefaultJoins(prop);
return;
}
if (!prop.getTableJoin().hasJoinColumns() && beanTable != null) {
// use naming convention to define join (based on the bean name for this side of relationship)
// A unidirectional OneToMany or OneToMany with no mappedBy property
NamingConvention nc = factory.getNamingConvention();
String fkeyPrefix = null;
if (nc.isUseForeignKeyPrefix()) {
fkeyPrefix = nc.getColumnFromProperty(descriptor.getBeanType(), descriptor.getName());
}
// Use the owning bean table to define the join
BeanTable owningBeanTable = factory.getBeanTable(descriptor.getBeanType());
owningBeanTable.createJoinColumn(fkeyPrefix, prop.getTableJoin(), false, prop.getSqlFormulaSelect());
@@ -186,7 +173,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
@SuppressWarnings("unchecked")
private void readElementCollection(DeployBeanPropertyAssocMany<?> prop, ElementCollection elementCollection) {
prop.setElementCollection();
if (!elementCollection.targetClass().equals(void.class)) {
prop.setTargetType(elementCollection.targetClass());
@@ -199,7 +185,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
}
CollectionTable collectionTable = get(prop, CollectionTable.class);
String fullTableName = getFullTableName(collectionTable);
if (fullTableName == null) {
fullTableName = descriptor.getBaseTable()+"_"+ CamelCaseHelper.toUnderscoreFromCamel(prop.getName());
@@ -288,7 +273,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
}
private void setElementProperty(DeployBeanProperty elementProp, String name, String dbColumn, int sortOrder) {
if (dbColumn == null) {
dbColumn = "value";
}
@@ -310,7 +294,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
* </p>
*/
private void readJoinTable(JoinTable joinTable, DeployBeanPropertyAssocMany<?> prop) {
String intTableName = getFullTableName(joinTable);
if (intTableName.isEmpty()) {
BeanTable localTable = factory.getBeanTable(descriptor.getBeanType());
@@ -369,9 +352,7 @@ final class AnnotationAssocManys extends AnnotationAssoc {
* </p>
*/
private void manyToManyDefaultJoins(DeployBeanPropertyAssocMany<?> prop) {
String intTableName = null;
DeployTableJoin intJoin = prop.getIntersectionJoin();
if (intJoin == null) {
intJoin = new DeployTableJoin();
@@ -396,8 +377,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
}
DeployTableJoin destJoin = prop.getTableJoin();
if (intJoin.hasJoinColumns() && destJoin.hasJoinColumns()) {
// already defined the foreign key columns etc
return;
@@ -448,7 +427,6 @@ final class AnnotationAssocManys extends AnnotationAssoc {
}
private String getM2MJoinTableName(BeanTable lhsTable, BeanTable rhsTable) {
TableName lhs = new TableName(lhsTable.getBaseTable());
TableName rhs = new TableName(rhsTable.getBaseTable());
TableName joinTable = namingConvention.getM2MJoinTableName(lhs, rhs);
@@ -231,11 +231,9 @@ final class AnnotationAssocOnes extends AnnotationAssoc {
if (!primaryKeyJoin.referencedColumnName().isEmpty()) {
log.info("Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{}] on {}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
}
BeanTable baseBeanTable = factory.getBeanTable(info.getDescriptor().getBeanType());
String localPrimaryKey = baseBeanTable.getIdColumn();
String foreignColumn = getBeanTable(prop).getIdColumn();
prop.getTableJoin().addJoinColumn(new DeployTableJoinColumn(localPrimaryKey, foreignColumn, false, false));
}
@@ -41,9 +41,7 @@ final class AnnotationClass extends AnnotationParser {
private static final Logger logger = LoggerFactory.getLogger(AnnotationClass.class);
private final String asOfViewSuffix;
private final String versionsBetweenSuffix;
private final boolean disableL2Cache;
/**
@@ -88,7 +86,6 @@ final class AnnotationClass extends AnnotationParser {
* Set the table name if it has not already been set.
*/
private void setTableName() {
if (descriptor.isBaseTableType()) {
Class<?> beanType = descriptor.getBeanType();
InheritInfo inheritInfo = descriptor.getInheritInfo();
@@ -109,7 +106,6 @@ final class AnnotationClass extends AnnotationParser {
descriptor.setEntityType(EntityType.DOC);
descriptor.setName(cls.getSimpleName());
}
Entity entity = typeGet(cls, Entity.class);
if (entity != null) {
descriptor.setEntityType(EntityType.ORM);
@@ -119,12 +115,10 @@ final class AnnotationClass extends AnnotationParser {
descriptor.setName(entity.name());
}
}
Identity identity = typeGet(cls, Identity.class);
if (identity != null) {
descriptor.setIdentityMode(identity);
}
IdClass idClass = typeGet(cls, IdClass.class);
if (idClass != null) {
descriptor.setIdClass(idClass.value());
@@ -135,7 +129,6 @@ final class AnnotationClass extends AnnotationParser {
descriptor.setEntityType(EntityType.EMBEDDED);
descriptor.setName("Embeddable:" + cls.getSimpleName());
}
for (Index index : annotationClassIndexes(cls)) {
descriptor.addIndex(new IndexDefinition(convertColumnNames(index.columnNames()), index.name(),
index.unique(), index.platforms(), index.concurrent(), index.definition()));
@@ -145,7 +138,6 @@ final class AnnotationClass extends AnnotationParser {
if (uc != null) {
descriptor.addIndex(new IndexDefinition(convertColumnNames(uc.columnNames())));
}
View view = typeGet(cls, View.class);
if (view != null) {
descriptor.setView(view.name(), view.dependentTables());
@@ -157,42 +149,34 @@ final class AnnotationClass extends AnnotationParser {
descriptor.addIndex(new IndexDefinition(convertColumnNames(c.columnNames())));
}
}
StorageEngine storage = typeGet(cls, StorageEngine.class);
if (storage != null) {
descriptor.setStorageEngine(storage.value());
}
DbPartition partition = typeGet(cls, DbPartition.class);
if (partition != null) {
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
}
Draftable draftable = typeGet(cls, Draftable.class);
if (draftable != null) {
descriptor.setDraftable();
}
DraftableElement draftableElement = typeGet(cls, DraftableElement.class);
if (draftableElement != null) {
descriptor.setDraftableElement();
}
ReadAudit readAudit = typeGet(cls, ReadAudit.class);
if (readAudit != null) {
descriptor.setReadAuditing();
}
History history = typeGet(cls, History.class);
if (history != null) {
descriptor.setHistorySupport();
}
DbComment comment = typeGet(cls, DbComment.class);
if (comment != null) {
descriptor.setDbComment(comment.value());
}
if (!disableL2Cache) {
Cache cache = typeGet(cls, Cache.class);
if (cache != null) {
@@ -204,7 +188,6 @@ final class AnnotationClass extends AnnotationParser {
}
}
}
for (NamedQuery namedQuery : annotationClassNamedQuery(cls)) {
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
}
@@ -20,11 +20,8 @@ import java.util.UUID;
public abstract class AnnotationParser extends AnnotationBase {
final DeployBeanInfo<?> info;
final DeployBeanDescriptor<?> descriptor;
final Class<?> beanType;
final ReadAnnotationConfig readConfig;
AnnotationParser(DeployBeanInfo<?> info, ReadAnnotationConfig readConfig) {
@@ -83,7 +80,6 @@ public abstract class AnnotationParser extends AnnotationBase {
* Read an AttributeOverrides if they exist for this embedded bean.
*/
void readEmbeddedAttributeOverrides(DeployBeanPropertyAssocOne<?> prop) {
Set<AttributeOverride> attrOverrides = annotationAttributeOverrides(prop);
if (!attrOverrides.isEmpty()) {
Map<String, Column> propMap = new HashMap<>(attrOverrides.size());
@@ -12,9 +12,7 @@ import io.ebeaninternal.server.rawsql.SpiRawSql;
public final class DeployBeanInfo<T> {
private final DeployUtil util;
private final DeployBeanDescriptor<T> descriptor;
private DeployBeanPropertyAssoc<?> embeddedId;
/**
@@ -40,7 +40,6 @@ public final class DeployCreateProperties {
private static final Logger logger = LoggerFactory.getLogger(DeployCreateProperties.class);
private final DetermineManyType determineManyType;
private final TypeManager typeManager;
public DeployCreateProperties(TypeManager typeManager) {
@@ -82,15 +81,12 @@ public final class DeployCreateProperties {
* columns.
*/
private void createProperties(DeployBeanDescriptor<?> desc, Class<?> beanType, int level) {
if (beanType.equals(Model.class)) {
// ignore all fields on model (_$dbName)
return;
}
try {
Field[] fields = beanType.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
if (!ignoreField(field)) {
@@ -112,16 +108,13 @@ public final class DeployCreateProperties {
}
Class<?> superClass = beanType.getSuperclass();
if (!superClass.equals(Object.class)) {
// recursively add any properties in the inheritance hierarchy
// up to the Object.class level...
createProperties(desc, superClass, level + 1);
}
} catch (PersistenceException ex) {
throw ex;
} catch (Exception ex) {
throw new PersistenceException(ex);
}
@@ -129,7 +122,6 @@ public final class DeployCreateProperties {
@SuppressWarnings({"unchecked"})
private DeployBeanProperty createManyType(DeployBeanDescriptor<?> desc, Class<?> targetType, ManyType manyType) {
try {
ScalarType<?> scalarType = typeManager.getScalarType(targetType);
if (scalarType != null) {
@@ -143,12 +135,10 @@ public final class DeployCreateProperties {
@SuppressWarnings({"unchecked"})
private DeployBeanProperty createProp(DeployBeanDescriptor<?> desc, Field field) {
Class<?> propertyType = field.getType();
if (isSpecialScalarType(field)) {
return new DeployBeanProperty(desc, propertyType, field.getGenericType());
}
// check for Collection type (list, set or map)
ManyType manyType = determineManyType.getManyType(propertyType);
if (manyType != null) {
@@ -163,16 +153,13 @@ public final class DeployCreateProperties {
}
return createManyType(desc, targetType, manyType);
}
if (propertyType.isEnum() || propertyType.isPrimitive()) {
return new DeployBeanProperty(desc, propertyType, null, null);
}
ScalarType<?> scalarType = typeManager.getScalarType(propertyType);
if (scalarType != null) {
return new DeployBeanProperty(desc, propertyType, scalarType, null);
}
if (isTransientField(field)) {
// return with no ScalarType (still support JSON features)
return new DeployBeanProperty(desc, propertyType, null, null);
@@ -219,11 +206,9 @@ public final class DeployCreateProperties {
* ParameterizedType.
*/
private Class<?> determineTargetType(Field field) {
Type genType = field.getGenericType();
if (genType instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) genType;
Type[] typeArgs = ptype.getActualTypeArguments();
if (typeArgs.length == 1) {
// expecting set or list
@@ -20,7 +20,6 @@ public final class DeployInherit {
private final Map<Class<?>, DeployInheritInfo> deployMap = new LinkedHashMap<>();
private final Map<Class<?>, InheritInfo> finalMap = new LinkedHashMap<>();
private final BootupClasses bootupClasses;
/**
@@ -37,26 +36,21 @@ public final class DeployInherit {
}
private void initialise() {
List<Class<?>> entityList = bootupClasses.getEntities();
findInheritClasses(entityList);
findInheritClasses(bootupClasses.getEntities());
buildDeployTree();
buildFinalTree();
}
private void findInheritClasses(List<Class<?>> entityList) {
// go through each class and initialise the info object...
for (Class<?> cls : entityList) {
if (isInheritanceClass(cls)) {
DeployInheritInfo info = createInfo(cls);
deployMap.put(cls, info);
deployMap.put(cls, createInfo(cls));
}
}
}
private void buildDeployTree() {
for (DeployInheritInfo info : deployMap.values()) {
if (!info.isRoot()) {
DeployInheritInfo parent = getInfo(info.getParent());
@@ -66,7 +60,6 @@ public final class DeployInherit {
}
private void buildFinalTree() {
for (DeployInheritInfo deploy : deployMap.values()) {
if (deploy.isRoot()) {
// build tree top down...
@@ -76,17 +69,14 @@ public final class DeployInherit {
}
private void createFinalInfo(InheritInfo root, InheritInfo parent, DeployInheritInfo deploy) {
InheritInfo node = new InheritInfo(root, parent, deploy);
if (parent != null) {
parent.addChild(node);
}
finalMap.put(node.getType(), node);
if (root == null) {
root = node;
}
// buildFinalChildren(root, child, deploy);
for (DeployInheritInfo childDeploy : deploy.children()) {
createFinalInfo(root, node, childDeploy);
@@ -101,9 +91,7 @@ public final class DeployInherit {
}
private DeployInheritInfo createInfo(Class<?> cls) {
DeployInheritInfo info = new DeployInheritInfo(cls);
Class<?> parent = findParent(cls);
if (parent != null) {
info.setParent(parent);
@@ -121,7 +109,6 @@ public final class DeployInherit {
info.setColumnLength(da.length());
info.setColumnDefn(da.columnDefinition());
}
if (!info.isAbstract()) {
DiscriminatorValue dv = AnnotationUtil.get(cls, DiscriminatorValue.class); // do not search recursive
if (dv != null) {
@@ -21,16 +21,12 @@ public final class DeployInheritInfo {
private String discriminatorStringValue;
private Object discriminatorObjectValue;
private int columnType;
private String columnName;
private int columnLength;
private String columnDefn;
private final Class<?> type;
private Class<?> parent;
private final ArrayList<DeployInheritInfo> children = new ArrayList<>();
/**
@@ -207,7 +203,6 @@ public final class DeployInheritInfo {
}
public String getWhere() {
List<Object> discList = new ArrayList<>();
appendDiscriminator(discList);
return buildWhereLiteral(discList);
@@ -42,17 +42,11 @@ public final class DeployUtil {
private static final int DEFAULT_JSON_VARCHAR_LENGTH = 3000;
private final NamingConvention namingConvention;
private final TypeManager typeManager;
private final DatabasePlatform dbPlatform;
private final EncryptDeployManager encryptDeployManager;
private final EncryptKeyManager encryptKeyManager;
private final Encryptor bytesEncryptor;
private final boolean useValidationNotNull;
public DeployUtil(TypeManager typeMgr, DatabaseConfig config) {
@@ -101,7 +95,6 @@ public final class DeployUtil {
@SuppressWarnings("unchecked")
void setEnumScalarType(Enumerated enumerated, DeployBeanProperty prop) {
Class<?> enumType = prop.getPropertyType();
if (!enumType.isEnum()) {
throw new IllegalArgumentException("Class [" + enumType + "] is Not a Enum?");
@@ -112,7 +105,6 @@ public final class DeployUtil {
ScalarType<?> scalarType = typeManager.createEnumScalarType(enumClass, type);
prop.setScalarType(scalarType);
prop.setDbType(scalarType.getJdbcType());
} catch (IllegalStateException e) {
throw new PersistenceException("Error mapping property " + prop.getFullBeanName() + " - " + e.getMessage());
}
@@ -126,13 +118,11 @@ public final class DeployUtil {
* </p>
*/
public void setScalarType(DeployBeanProperty property) {
if (property.getScalarType() != null) {
// already has a ScalarType assigned.
// this will be an Enum type...
return;
}
ScalarType<?> scalarType = getScalarType(property);
if (scalarType != null) {
// set the jdbc type this maps to
@@ -143,7 +133,6 @@ public final class DeployUtil {
}
private ScalarType<?> getScalarType(DeployBeanProperty property) {
// Note that Temporal types already have dbType
// set via annotations
Class<?> propType = property.getPropertyType();
@@ -166,7 +155,6 @@ public final class DeployUtil {
* Map to Postgres HSTORE type (with fallback to JSON storage in VARCHAR).
*/
void setDbMap(DeployBeanProperty prop, DbMap dbMap) {
ScalarType<?> scalarType = typeManager.getDbMapScalarType();
int dbType = scalarType.getJdbcType();
prop.setDbType(dbType);
@@ -183,7 +171,6 @@ public final class DeployUtil {
* Set the DbArray type (effectively Postgres only).
*/
void setDbArray(DeployBeanProperty prop, DbArray dbArray) {
Class<?> type = prop.getPropertyType();
ScalarType<?> scalarType = typeManager.getArrayScalarType(type, dbArray, prop.getGenericType(), prop.isNullable());
if (scalarType == null) {
@@ -233,7 +220,6 @@ public final class DeployUtil {
* Return the JDBC type for the JSON storage type.
*/
private int getDbJsonStorage(DbJsonType dbJsonType) {
switch (dbJsonType) {
case JSONB:
return DbPlatformType.JSONB;
@@ -252,9 +238,7 @@ public final class DeployUtil {
* This property is marked as a Lob object.
*/
void setLobType(DeployBeanProperty prop) {
ScalarType<?> scalarType = prop.getScalarType();
if (scalarType instanceof ScalarTypeWrapper) {
int lobType = scalarType.getJdbcType() == Types.VARCHAR ? dbCLOBType : dbBLOBType;
prop.setDbType(lobType);
@@ -43,19 +43,14 @@ public final class ReadAnnotations {
* </p>
*/
public void readAssociations(DeployBeanInfo<?> info, BeanDescriptorManager factory) {
try {
new AnnotationAssocOnes(info, readConfig, factory).parse();
new AnnotationAssocManys(info, readConfig, factory).parse();
// read the Sql annotations last because they may be
// dependent on field level annotations
new AnnotationSql(info, readConfig).parse();
new AnnotationClass(info, readConfig).parseAttributeOverride();
info.getDescriptor().postAnnotations();
} catch (RuntimeException e) {
throw new RuntimeException("Error reading annotations for " + info, e);
}
@@ -25,19 +25,15 @@ public class VisitProperties {
if (idProp != null) {
visit(propertyVisitor, idProp);
}
BeanPropertyAssocOne<?> unidirectional = desc.getUnidirectional();
if (unidirectional != null) {
visit(propertyVisitor, unidirectional);
}
BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient();
for (BeanProperty p : propertiesNonTransient) {
for (BeanProperty p : desc.propertiesNonTransient()) {
if (p.isDDLColumn()) {
visit(propertyVisitor, p);
}
}
visitInheritanceProperties(desc, propertyVisitor);
propertyVisitor.visitEnd();
}
@@ -46,7 +42,6 @@ public class VisitProperties {
* Visit the property.
*/
protected void visit(BeanPropertyVisitor pv, BeanProperty p) {
if (p instanceof BeanPropertyAssocMany<?>) {
// oneToMany or manyToMany
pv.visitMany((BeanPropertyAssocMany<?>) p);
@@ -60,16 +55,13 @@ public class VisitProperties {
for (BeanProperty embProp : embProps) {
pv.visitEmbeddedScalar(embProp, assocOne);
}
} else if (assocOne.isOneToOneExported()) {
// associated one exported
pv.visitOneExported(assocOne);
} else {
// associated one imported
pv.visitOneImported(assocOne);
}
} else {
// simple scalar type
pv.visitScalar(p, true);
@@ -81,7 +73,6 @@ public class VisitProperties {
* Visit all the other inheritance properties that are not on the root.
*/
protected void visitInheritanceProperties(BeanDescriptor<?> descriptor, BeanPropertyVisitor pv) {
InheritInfo inheritInfo = descriptor.getInheritInfo();
if (inheritInfo != null && inheritInfo.isRoot()) {
// add all properties on the children objects