Don't turn off not-null on existing columns.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.1.x@711959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2008-11-06 20:16:14 +00:00
parent 4ff176e797
commit dd171ca54b
1 changed files with 6 additions and 3 deletions

View File

@ -584,7 +584,8 @@ public abstract class MappingInfo
// find existing column
Column col = table.getColumn(colName);
if (col == null && !adapt)
boolean existingCol = col != null;
if (!existingCol && !adapt)
throw new MetaDataException(_loc.get(prefix + "-bad-col-name",
context, colName, table));
@ -687,7 +688,9 @@ public abstract class MappingInfo
// not know it, so set it even if not adapting
if (defStr != null)
col.setDefaultString(defStr);
if (notNull != null)
// don't turn off nullability for existing columns unless this col
// is shared with other mappings
if (notNull != null && (!existingCol || notNull.booleanValue()))
col.setNotNull(notNull.booleanValue());
// add other details if adapting
@ -1650,7 +1653,7 @@ public abstract class MappingInfo
if (col.getDefaultString() != null)
copy.setDefaultString(col.getDefaultString());
if (col.isNotNull() && !col.isPrimaryKey()
&& (!isPrimitive(col.getJavaType()) || isForeignKey(col)))
&& (!isPrimitive(col.getJavaType()) || isForeignKey(col)))
copy.setNotNull(true);
// set type name if not default