mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
solution v1
(cherry picked from commit 3d83c6bd0e2bcca6fc04f73ce08983266b9df636)
This commit is contained in:
+22
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.DbConstraintNaming;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
@@ -24,6 +25,7 @@ import io.ebeaninternal.dbmigration.model.MTable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Controls the DDL generation for a specific database platform.
|
||||
@@ -317,12 +319,32 @@ public class PlatformDdl {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
type = extract(type);
|
||||
|
||||
if (type.contains("[]")) {
|
||||
return convertArrayType(type);
|
||||
}
|
||||
return typeConverter.convert(type);
|
||||
}
|
||||
|
||||
// if columnType is different for different platforms, use pattern
|
||||
// @Column(columnDefinition = PLATFORM1;DEFINITION1;PLATFORM2;DEFINITON2;DEFINITON-DEFAULT)
|
||||
// e.g. @Column(columnDefinition = "db2;blob(64M);sqlserver,h2;varchar(227);varchar(127)")
|
||||
private String extract(String type) {
|
||||
String[] tmp = type.split(";");
|
||||
assert tmp.length % 2 == 1;
|
||||
for (int i = 0; i < tmp.length - 2; i+=2) {
|
||||
String[] platforms = tmp[i].split(",");
|
||||
for (String plat : platforms) {
|
||||
if (platform.isPlatform(Platform.valueOf(plat.toUpperCase(Locale.ENGLISH)))) {
|
||||
return tmp[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp[tmp.length-1]; // else
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the logical array type to a db platform specific type to support the array data.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
@@ -39,7 +40,8 @@ public class EBasic {
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
// @Size(max=127)
|
||||
@Column(columnDefinition = "db2;blob(64M);sqlserver,h2;varchar(227);varchar(127)")
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
|
||||
Reference in New Issue
Block a user