diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java index 5fdd97d290..bcc9cd2448 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java @@ -35,7 +35,7 @@ public void addColumn(Column column) { log.debugf( "Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), - getTable().getNameIdentifier().getCanonicalName() + getTableNameForLogging( column ) ); } } @@ -44,7 +44,12 @@ public void addColumn(Column column) { protected String getTableNameForLogging(Column column) { if ( getTable() != null ) { - return getTable().getNameIdentifier().getCanonicalName(); + if ( getTable().getNameIdentifier() != null ) { + return getTable().getNameIdentifier().getCanonicalName(); + } + else { + return ""; + } } else if ( column.getValue() != null && column.getValue().getTable() != null ) { return column.getValue().getTable().getNameIdentifier().getCanonicalName();