private void readColumn(Column columnAnn, DeployBeanProperty prop) { if (!isEmpty(columnAnn.name())) { String dbColumn = databasePlatform.convertQuotedIdentifiers(columnAnn.name()); prop.setDbColumn(dbColumn); } prop.setDbInsertable(columnAnn.insertable()); prop.setDbUpdateable(columnAnn.updatable()); prop.setNullable(columnAnn.nullable()); prop.setUnique(columnAnn.unique()); if (columnAnn.precision() > 0) { prop.setDbLength(columnAnn.precision()); } else if (columnAnn.length() != 255) { // set default 255 on DbTypeMap prop.setDbLength(columnAnn.length()); } prop.setDbScale(columnAnn.scale()); prop.setDbColumnDefn(columnAnn.columnDefinition()); String baseTable = descriptor.getBaseTable(); String tableName = columnAnn.table(); if (tableName.equals("") || tableName.equalsIgnoreCase(baseTable)) { // its a base table property... } else { // its on a secondary table... prop.setSecondaryTable(tableName); // DeployTableJoin tableJoin = info.getTableJoin(tableName); // tableJoin.addProperty(prop); } }
private void searchForRevisionInfoCfgInProperties( XClass clazz, ReflectionManager reflectionManager, MutableBoolean revisionNumberFound, MutableBoolean revisionTimestampFound, MutableBoolean modifiedEntityNamesFound, String accessType) { for (XProperty property : clazz.getDeclaredProperties(accessType)) { RevisionNumber revisionNumber = property.getAnnotation(RevisionNumber.class); RevisionTimestamp revisionTimestamp = property.getAnnotation(RevisionTimestamp.class); ModifiedEntityNames modifiedEntityNames = property.getAnnotation(ModifiedEntityNames.class); if (revisionNumber != null) { if (revisionNumberFound.isSet()) { throw new MappingException("Only one property may be annotated with @RevisionNumber!"); } XClass revisionNumberClass = property.getType(); if (reflectionManager.equals(revisionNumberClass, Integer.class) || reflectionManager.equals(revisionNumberClass, Integer.TYPE)) { revisionInfoIdData = new PropertyData(property.getName(), property.getName(), accessType, null); revisionNumberFound.set(); } else if (reflectionManager.equals(revisionNumberClass, Long.class) || reflectionManager.equals(revisionNumberClass, Long.TYPE)) { revisionInfoIdData = new PropertyData(property.getName(), property.getName(), accessType, null); revisionNumberFound.set(); // The default is integer revisionPropType = "long"; } else { throw new MappingException( "The field annotated with @RevisionNumber must be of type " + "int, Integer, long or Long"); } // Getting the @Column definition of the revision number property, to later use that info to // generate the same mapping for the relation from an audit table's revision number to the // revision entity revision number. Column revisionPropColumn = property.getAnnotation(Column.class); if (revisionPropColumn != null) { revisionPropSqlType = revisionPropColumn.columnDefinition(); } } if (revisionTimestamp != null) { if (revisionTimestampFound.isSet()) { throw new MappingException("Only one property may be annotated with @RevisionTimestamp!"); } XClass revisionTimestampClass = property.getType(); if (reflectionManager.equals(revisionTimestampClass, Long.class) || reflectionManager.equals(revisionTimestampClass, Long.TYPE) || reflectionManager.equals(revisionTimestampClass, Date.class) || reflectionManager.equals(revisionTimestampClass, java.sql.Date.class)) { revisionInfoTimestampData = new PropertyData(property.getName(), property.getName(), accessType, null); revisionTimestampFound.set(); } else { throw new MappingException( "The field annotated with @RevisionTimestamp must be of type " + "long, Long, java.util.Date or java.sql.Date"); } } if (modifiedEntityNames != null) { if (modifiedEntityNamesFound.isSet()) { throw new MappingException( "Only one property may be annotated with @ModifiedEntityNames!"); } XClass modifiedEntityNamesClass = property.getType(); if (reflectionManager.equals(modifiedEntityNamesClass, Set.class) && reflectionManager.equals(property.getElementClass(), String.class)) { modifiedEntityNamesData = new PropertyData(property.getName(), property.getName(), accessType, null); modifiedEntityNamesFound.set(); } else { throw new MappingException( "The field annotated with @ModifiedEntityNames must be of Set<String> type."); } } } }