From ce82b844dd23a9c166177a73b8561dc1a2a026f5 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Mon, 26 Apr 2010 02:03:34 +0000 Subject: [PATCH] HHH-4773 @CollectionId does not force the id column to not-null git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19291 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../src/main/java/org/hibernate/cfg/Ejb3Column.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java b/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java index 6524b2d8bb..c4fbdeea23 100644 --- a/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java +++ b/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java @@ -439,9 +439,11 @@ public class Ejb3Column { column.setPropertyName( BinderHelper.getRelativePath( propertyHolder, inferredData.getPropertyName() ) ); - column.setNullable( - col.nullable() - ); //TODO force to not null if available? This is a (bad) user choice. + //although in theory, null is an acceptable value in a Map key + //we need force this column to be not null, as it intended to be the primary key. + if ( nullability != Nullability.FORCED_NULL ) { + column.setNullable( false ); + } column.setUnique( col.unique() ); column.setInsertable( col.insertable() ); column.setUpdatable( col.updatable() );