I can think of no reason why this was ever allowed to be null.

This commit is contained in:
Par Winzell
2011-02-10 17:21:06 +00:00
parent b8fec6cab5
commit 5c52a84916
@@ -342,7 +342,7 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
*/ */
public boolean hasPrimaryKey () public boolean hasPrimaryKey ()
{ {
return (_pkColumns != null); return !_pkColumns.isEmpty();
} }
/** /**
@@ -695,7 +695,7 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
// create the table // create the table
String[] primaryKeyColumns = null; String[] primaryKeyColumns = null;
if (_pkColumns != null) { if (hasPrimaryKey()) {
primaryKeyColumns = new String[_pkColumns.size()]; primaryKeyColumns = new String[_pkColumns.size()];
for (int ii = 0; ii < primaryKeyColumns.length; ii ++) { for (int ii = 0; ii < primaryKeyColumns.length; ii ++) {
primaryKeyColumns[ii] = _pkColumns.get(ii).getColumnName(); primaryKeyColumns[ii] = _pkColumns.get(ii).getColumnName();
@@ -1030,7 +1030,7 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
protected void checkHasNonCompositePrimaryKey () protected void checkHasNonCompositePrimaryKey ()
{ {
if (_pkColumns == null || _pkColumns.size() != 1) { if (_pkColumns.size() != 1) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
getClass().getName() + " does not define a single column primary key"); getClass().getName() + " does not define a single column primary key");
} }
@@ -1125,7 +1125,7 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
/** The field marshallers for our persistent object's primary key columns or null if it did not /** The field marshallers for our persistent object's primary key columns or null if it did not
* define a primary key. */ * define a primary key. */
protected List<FieldMarshaller<?>> _pkColumns; protected List<FieldMarshaller<?>> _pkColumns = Lists.newArrayList();
/** The persisent fields of our object, in definition order. */ /** The persisent fields of our object, in definition order. */
protected ColumnExp<?>[] _allFields; protected ColumnExp<?>[] _allFields;