#909 - @Lob with @Size ... produces incorrect DDL for Postgres

This commit is contained in:
Rob Bygrave
2016-12-03 08:42:46 +13:00
parent cc989af1c6
commit 2dbd543127
3 changed files with 13 additions and 10 deletions
@@ -40,7 +40,7 @@ public class PostgresPlatform extends DatabasePlatform {
this.openQuote = "\"";
this.closeQuote = "\"";
DbPlatformType dbTypeText = new DbPlatformType("text");
DbPlatformType dbTypeText = new DbPlatformType("text", false);
DbPlatformType dbBytea = new DbPlatformType("bytea", false);
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
@@ -156,12 +156,11 @@ public class AnnotationFields extends AnnotationParser {
// determine the JDBC type using Lob/Temporal
// otherwise based on the property Class
Lob lob = get(prop, Lob.class);
Temporal temporal = get(prop, Temporal.class);
if (temporal != null) {
readTemporal(temporal, prop);
} else if (lob != null) {
} else if (get(prop, Lob.class) != null) {
util.setLobType(prop);
}
@@ -275,15 +274,17 @@ public class AnnotationFields extends AnnotationParser {
prop.setNullable(false);
}
// take the max size of all @Size annotations
int maxSize = -1;
for (Size size : getAll(prop, Size.class)) {
if (size.max() < Integer.MAX_VALUE) {
maxSize = Math.max(maxSize, size.max());
if (!prop.isLob()) {
// take the max size of all @Size annotations
int maxSize = -1;
for (Size size : getAll(prop, Size.class)) {
if (size.max() < Integer.MAX_VALUE) {
maxSize = Math.max(maxSize, size.max());
}
}
}
if (maxSize != -1) {
if (maxSize != -1) {
prop.setDbLength(maxSize);
}
}
}