@@ -40,21 +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 }
51+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
4952 }
50- //TODO: list index / map key columns
5153 }
5254 else {
5355 for ( Column column : value .getColumns () ) {
5456 if ( on .isEmpty () || column .getName ().equalsIgnoreCase ( on ) ) {
5557 column .setComment ( text );
58+ return ;
5659 }
5760 }
61+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
5862 }
5963 }
6064
@@ -67,12 +71,16 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
6771 if ( on .isEmpty () || primary .getName ().equalsIgnoreCase ( on ) ) {
6872 primary .setComment ( text );
6973 }
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 );
74+ else {
75+ // but if 'on' is explicit, it can go on a secondary table
76+ for ( Join join : entity .getJoins () ) {
77+ Table secondary = join .getTable ();
78+ if ( secondary .getName ().equalsIgnoreCase ( on ) ) {
79+ secondary .setComment ( text );
80+ return ;
81+ }
7582 }
83+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
7684 }
7785 }
7886
0 commit comments