mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#999 - @DiscriminatorColumn columnDefinition is ignored for DDL generation
This commit is contained in:
@@ -53,10 +53,12 @@ public class ModelBuildBeanVisitor implements BeanVisitor {
|
||||
if (inheritInfo != null && inheritInfo.isRoot()) {
|
||||
// add the discriminator column
|
||||
String discColumn = inheritInfo.getDiscriminatorColumn();
|
||||
DbPlatformType dbType = ctx.getDbTypeMap().get(inheritInfo.getDiscriminatorType());
|
||||
String discDbType = dbType.renderType(inheritInfo.getDiscriminatorLength(), 0);
|
||||
|
||||
table.addColumn(new MColumn(discColumn, discDbType, true));
|
||||
String columnDefn = inheritInfo.getColumnDefn();
|
||||
if (columnDefn == null || columnDefn.isEmpty()) {
|
||||
DbPlatformType dbType = ctx.getDbTypeMap().get(inheritInfo.getDiscriminatorType());
|
||||
columnDefn = dbType.renderType(inheritInfo.getDiscriminatorLength(), 0);
|
||||
}
|
||||
table.addColumn(new MColumn(discColumn, columnDefn, true));
|
||||
}
|
||||
|
||||
return new ModelBuildPropertyVisitor(ctx, table, descriptor);
|
||||
|
||||
@@ -26,6 +26,8 @@ public class InheritInfo {
|
||||
|
||||
private final int discriminatorLength;
|
||||
|
||||
private final String columnDefn;
|
||||
|
||||
private final String where;
|
||||
|
||||
private final Class<?> type;
|
||||
@@ -58,6 +60,7 @@ public class InheritInfo {
|
||||
|
||||
this.discriminatorType = deploy.getDiscriminatorType(parent);
|
||||
this.discriminatorLength = deploy.getDiscriminatorLength(parent);
|
||||
this.columnDefn = deploy.getColumnDefn();
|
||||
this.where = InternString.intern(deploy.getWhere());
|
||||
|
||||
if (r == null) {
|
||||
@@ -164,14 +167,14 @@ public class InheritInfo {
|
||||
public BeanProperty[] localProperties() {
|
||||
return descriptor.propertiesLocal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the children.
|
||||
*/
|
||||
public ArrayList<InheritInfo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the bean property additionally looking in the sub types.
|
||||
*/
|
||||
@@ -342,6 +345,13 @@ public class InheritInfo {
|
||||
return discriminatorLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the explicit column definition.
|
||||
*/
|
||||
public String getColumnDefn() {
|
||||
return columnDefn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the discriminator value for this node.
|
||||
*/
|
||||
|
||||
@@ -126,6 +126,7 @@ public class DeployInherit {
|
||||
info.setDiscriminatorType(Types.VARCHAR);
|
||||
}
|
||||
info.setDiscriminatorLength(da.length());
|
||||
info.setColumnDefn(da.columnDefinition());
|
||||
}
|
||||
|
||||
DiscriminatorValue dv = AnnotationBase.findAnnotation(cls, DiscriminatorValue.class);
|
||||
|
||||
@@ -26,6 +26,8 @@ public class DeployInheritInfo {
|
||||
|
||||
private String discriminatorColumn;
|
||||
|
||||
private String columnDefn;
|
||||
|
||||
private String discriminatorWhere;
|
||||
|
||||
private final Class<?> type;
|
||||
@@ -157,6 +159,20 @@ public class DeployInheritInfo {
|
||||
this.discriminatorType = discriminatorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set explicit column definition (ddl).
|
||||
*/
|
||||
public void setColumnDefn(String columnDefn) {
|
||||
this.columnDefn = columnDefn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the explicit column definition.
|
||||
*/
|
||||
public String getColumnDefn() {
|
||||
return columnDefn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of the discriminator column.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user