[hibernate-commits] Hibernate SVN: r11044 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Jan 15 22:25:48 EST 2007


Author: epbernard
Date: 2007-01-15 22:25:47 -0500 (Mon, 15 Jan 2007)
New Revision: 11044

Modified:
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
Log:
ANN-532 better exception handling of @UniqueConstraint

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2007-01-16 03:22:16 UTC (rev 11043)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java	2007-01-16 03:25:47 UTC (rev 11044)
@@ -483,11 +483,19 @@
 		int size = columnNames.length;
 		Column[] columns = new Column[size];
 		Set<Column> unbound = new HashSet<Column>();
+		Set<Column> unboundNoLogical = new HashSet<Column>();
 		ExtendedMappings mappings = createExtendedMappings();
 		for ( int index = 0; index < size ; index++ ) {
-			columns[index] = new Column( mappings.getPhysicalColumnName( columnNames[index], table ) );
-			unbound.add( columns[index] );
-			//column equals and hashcode is based on column name
+			String columnName;
+			try {
+				columnName = mappings.getPhysicalColumnName( columnNames[index], table );
+				columns[index] = new Column( columnName );
+				unbound.add( columns[index] );
+				//column equals and hashcode is based on column name
+			}
+			catch( MappingException e ) {
+				unboundNoLogical.add( new Column( columnNames[index] ) );
+			}
 		}
 		for ( Column column : columns ) {
 			if ( table.containsColumn( column ) ) {
@@ -496,7 +504,7 @@
 				unbound.remove( column );
 			}
 		}
-		if ( unbound.size() > 0 ) {
+		if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
 			StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
 			for ( String columnName : columnNames ) {
 				sb.append( columnName ).append( ", " );
@@ -506,6 +514,9 @@
 			for ( Column column : unbound ) {
 				sb.append( column.getName() ).append( ", " );
 			}
+			for ( Column column : unboundNoLogical ) {
+				sb.append( column.getName() ).append( ", " );
+			}
 			sb.setLength( sb.length() - 2 );
 			sb.append( " not found" );
 			throw new AnnotationException( sb.toString() );




More information about the hibernate-commits mailing list