@@ -43,21 +43,25 @@ else if ( value instanceof Collection ) {
43
43
if ( on .isEmpty () || table .getName ().equalsIgnoreCase ( on ) ) {
44
44
table .setComment ( text );
45
45
}
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
+ }
51
53
}
54
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
52
55
}
53
- //TODO: list index / map key columns
54
56
}
55
57
else {
56
58
for ( Column column : value .getColumns () ) {
57
59
if ( on .isEmpty () || column .getName ().equalsIgnoreCase ( on ) ) {
58
60
column .setComment ( text );
61
+ return ;
59
62
}
60
63
}
64
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
61
65
}
62
66
}
63
67
@@ -70,12 +74,16 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
70
74
if ( on .isEmpty () || primary .getName ().equalsIgnoreCase ( on ) ) {
71
75
primary .setComment ( text );
72
76
}
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
+ }
78
85
}
86
+ throw new AnnotationException ( "No matching column for '@Comment(on=\" " + on + "\" )'" );
79
87
}
80
88
}
81
89
0 commit comments