Author: awhite
Date: Thu Nov 6 12:16:14 2008
New Revision: 711959
URL: http://svn.apache.org/viewvc?rev=711959&view=rev
Log:
Don't turn off not-null on existing columns.
Modified:
openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
Modified:
openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?rev=711959&r1=711958&r2=711959&view=diff
==============================================================================
---
openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
(original)
+++
openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
Thu Nov 6 12:16:14 2008
@@ -584,7 +584,8 @@
// 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 @@
// 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 @@
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