@@ -43,21 +43,25 @@ else if ( value instanceof Collection ) {
4343 if ( on .isEmpty () || table .getName ().equalsIgnoreCase ( on ) ) {
4444 table .setComment ( text );
4545 }
46- // but if 'on' is explicit, it can go on a column
47- Value element = collection .getElement ();
48- for ( Column column : element .getColumns () ) {
49- if ( column .getName ().equalsIgnoreCase ( on ) ) {
50- column .setComment ( text );
46+ else {
47+ // but if 'on' is explicit, it can go on a column
48+ for ( Column column : table .getColumns () ) {
49+ if ( column .getName ().equalsIgnoreCase ( on ) ) {
50+ column .setComment ( text );
51+ return ;
52+ }
5153 }
54+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
5255 }
53- //TODO: list index / map key columns
5456 }
5557 else {
5658 for ( Column column : value .getColumns () ) {
5759 if ( on .isEmpty () || column .getName ().equalsIgnoreCase ( on ) ) {
5860 column .setComment ( text );
61+ return ;
5962 }
6063 }
64+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
6165 }
6266 }
6367
@@ -70,12 +74,16 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
7074 if ( on .isEmpty () || primary .getName ().equalsIgnoreCase ( on ) ) {
7175 primary .setComment ( text );
7276 }
73- // but if 'on' is explicit, it can go on a secondary table
74- for ( Join join : entity .getJoins () ) {
75- Table secondary = join .getTable ();
76- if ( secondary .getName ().equalsIgnoreCase ( on ) ) {
77- secondary .setComment ( text );
77+ else {
78+ // but if 'on' is explicit, it can go on a secondary table
79+ for ( Join join : entity .getJoins () ) {
80+ Table secondary = join .getTable ();
81+ if ( secondary .getName ().equalsIgnoreCase ( on ) ) {
82+ secondary .setComment ( text );
83+ return ;
84+ }
7885 }
86+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
7987 }
8088 }
8189
0 commit comments