@@ -40,21 +40,25 @@ else if ( value instanceof Collection collection ) {
40
40
if ( on .isEmpty () || table .getName ().equalsIgnoreCase ( on ) ) {
41
41
table .setComment ( text );
42
42
}
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
+ }
48
50
}
51
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
49
52
}
50
- //TODO: list index / map key columns
51
53
}
52
54
else {
53
55
for ( Column column : value .getColumns () ) {
54
56
if ( on .isEmpty () || column .getName ().equalsIgnoreCase ( on ) ) {
55
57
column .setComment ( text );
58
+ return ;
56
59
}
57
60
}
61
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
58
62
}
59
63
}
60
64
@@ -67,12 +71,16 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
67
71
if ( on .isEmpty () || primary .getName ().equalsIgnoreCase ( on ) ) {
68
72
primary .setComment ( text );
69
73
}
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
+ }
75
82
}
83
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
76
84
}
77
85
}
78
86
0 commit comments