@@ -40,22 +40,25 @@ else if ( value instanceof Collection collection ) {
4040 if ( on .isEmpty () || table .getName ().equalsIgnoreCase ( on ) ) {
4141 table .setComment ( text );
4242 }
43- // but if 'on' is explicit, it can go on a column
44- Value element = collection .getElement ();
45- for ( Column column : element .getColumns () ) {
46- if ( column .getName ().equalsIgnoreCase ( on ) ) {
47- column .setComment ( text );
43+ else {
44+ // but if 'on' is explicit, it can go on a column
45+ for ( Column column : table .getColumns () ) {
46+ if ( column .getName ().equalsIgnoreCase ( on ) ) {
47+ column .setComment ( text );
48+ return ;
49+ }
4850 }
4951 }
50- //TODO: list index / map key columns
5152 }
5253 else {
5354 for ( Column column : value .getColumns () ) {
5455 if ( on .isEmpty () || column .getName ().equalsIgnoreCase ( on ) ) {
5556 column .setComment ( text );
57+ return ;
5658 }
5759 }
5860 }
61+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
5962 }
6063
6164 @ Override
@@ -67,12 +70,16 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
6770 if ( on .isEmpty () || primary .getName ().equalsIgnoreCase ( on ) ) {
6871 primary .setComment ( text );
6972 }
70- // but if 'on' is explicit, it can go on a secondary table
71- for ( Join join : entity .getJoins () ) {
72- Table secondary = join .getTable ();
73- if ( secondary .getName ().equalsIgnoreCase ( on ) ) {
74- secondary .setComment ( text );
73+ else {
74+ // but if 'on' is explicit, it can go on a secondary table
75+ for ( Join join : entity .getJoins () ) {
76+ Table secondary = join .getTable ();
77+ if ( secondary .getName ().equalsIgnoreCase ( on ) ) {
78+ secondary .setComment ( text );
79+ return ;
80+ }
7581 }
82+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
7683 }
7784 }
7885
0 commit comments