#2124 - ENH: Add name() attribute to @DbArray, @DbJson, @DbJsonB, @DbMap

This commit is contained in:
rob bygrave
2020-12-07 22:46:04 +13:00
parent d68f477e8e
commit 7389a8b344
6 changed files with 15 additions and 9 deletions
@@ -311,19 +311,23 @@ public class AnnotationFields extends AnnotationParser {
DbMap dbMap = get(prop, DbMap.class);
if (dbMap != null) {
util.setDbMap(prop, dbMap);
setColumnName(prop, dbMap.name());
}
DbJson dbJson = get(prop, DbJson.class);
if (dbJson != null) {
util.setDbJsonType(prop, dbJson);
setColumnName(prop, dbJson.name());
} else {
DbJsonB dbJsonB = get(prop, DbJsonB.class);
if (dbJsonB != null) {
util.setDbJsonBType(prop, dbJsonB);
setColumnName(prop, dbJsonB.name());
}
}
DbArray dbArray = get(prop, DbArray.class);
if (dbArray != null) {
util.setDbArray(prop, dbArray);
setColumnName(prop, dbArray.name());
}
}
@@ -99,11 +99,7 @@ public abstract class AnnotationParser extends AnnotationBase {
}
void readColumn(Column columnAnn, DeployBeanProperty prop) {
if (!isEmpty(columnAnn.name())) {
prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(columnAnn.name()));
}
setColumnName(prop, columnAnn.name());
prop.setDbInsertable(columnAnn.insertable());
prop.setDbUpdateable(columnAnn.updatable());
prop.setNullable(columnAnn.nullable());
@@ -125,6 +121,12 @@ public abstract class AnnotationParser extends AnnotationBase {
}
}
protected void setColumnName(DeployBeanProperty prop, String name) {
if (!isEmpty(name)) {
prop.setDbColumn(databasePlatform.convertQuotedIdentifiers(name));
}
}
/**
* Return true if the validation groups are {@link Default} (respectively empty)
* can be applied to DDL generation.