@@ -357,7 +357,7 @@ private static NotFoundAction notFoundAction(
357357 if ( notFound != null ) {
358358 if ( manyToManyAnn == null ) {
359359 throw new AnnotationException ( "Collection '" + getPath ( propertyHolder , inferredData )
360- + "' annotated '@NotFound' is not a '@ManyToMany' association" );
360+ + "' annotated '@NotFound' is not a '@ManyToMany' association" );
361361 }
362362 return notFound .action ();
363363 }
@@ -405,8 +405,8 @@ private static void checkAnnotations(
405405 if ( ( oneToMany != null || manyToMany != null || elementCollection != null )
406406 && isToManyAssociationWithinEmbeddableCollection ( propertyHolder ) ) {
407407 throw new AnnotationException ( "Property '" + getPath ( propertyHolder , inferredData ) +
408- "' belongs to an '@Embeddable' class that is contained in an '@ElementCollection' and may not be a "
409- + annotationName ( oneToMany , manyToMany , elementCollection ) );
408+ "' belongs to an '@Embeddable' class that is contained in an '@ElementCollection' and may not be a "
409+ + annotationName ( oneToMany , manyToMany , elementCollection ) );
410410 }
411411
412412 if ( oneToMany != null && property .hasDirectAnnotationUsage ( SoftDelete .class ) ) {
@@ -420,20 +420,20 @@ && isToManyAssociationWithinEmbeddableCollection( propertyHolder ) ) {
420420 && manyToMany != null
421421 && isNotBlank ( manyToMany .mappedBy () ) ) {
422422 throw new AnnotationException ( "Collection '" + getPath ( propertyHolder , inferredData ) +
423- "' is the unowned side of a bidirectional '@ManyToMany' and may not have an '@OrderColumn'" );
423+ "' is the unowned side of a bidirectional '@ManyToMany' and may not have an '@OrderColumn'" );
424424 }
425425
426426 if ( manyToMany != null || elementCollection != null ) {
427427 if ( property .hasDirectAnnotationUsage ( JoinColumn .class )
428428 || property .hasDirectAnnotationUsage ( JoinColumns .class ) ) {
429429 throw new AnnotationException ( "Property '" + getPath ( propertyHolder , inferredData )
430- + "' is a " + annotationName (
430+ + "' is a " + annotationName (
431431 oneToMany ,
432432 manyToMany ,
433433 elementCollection
434434 )
435- + " and is directly annotated '@JoinColumn'"
436- + " (specify '@JoinColumn' inside '@JoinTable' or '@CollectionTable')" );
435+ + " and is directly annotated '@JoinColumn'"
436+ + " (specify '@JoinColumn' inside '@JoinTable' or '@CollectionTable')" );
437437 }
438438 }
439439 }
@@ -476,13 +476,13 @@ private static String handleTargetEntity(
476476 //TODO enhance exception with @ManyToAny and @CollectionOfElements
477477 if ( oneToManyAnn != null && manyToManyAnn != null ) {
478478 throw new AnnotationException ( "Property '" + getPath ( propertyHolder , inferredData )
479- + "' is annotated both '@OneToMany' and '@ManyToMany'" );
479+ + "' is annotated both '@OneToMany' and '@ManyToMany'" );
480480 }
481481 final String mappedBy ;
482482 if ( oneToManyAnn != null ) {
483483 if ( joinColumns .isSecondary () ) {
484484 throw new AnnotationException ( "Collection '" + getPath ( propertyHolder , inferredData )
485- + "' has foreign key in secondary table" );
485+ + "' has foreign key in secondary table" );
486486 }
487487 collectionBinder .setFkJoinColumns ( joinColumns );
488488 mappedBy = nullIfEmpty ( oneToManyAnn .mappedBy () );
@@ -497,7 +497,7 @@ private static String handleTargetEntity(
497497 else if ( elementCollectionAnn != null ) {
498498 if ( joinColumns .isSecondary () ) {
499499 throw new AnnotationException ( "Collection '" + getPath ( propertyHolder , inferredData )
500- + "' has foreign key in secondary table" );
500+ + "' has foreign key in secondary table" );
501501 }
502502 collectionBinder .setFkJoinColumns ( joinColumns );
503503 mappedBy = null ;
@@ -657,14 +657,9 @@ private static void bindJoinedTableAssociation(
657657 buildingContext
658658 );
659659
660- // If @CollectionTableOverride is present, use its collectionTable annotation
661- final CollectionTable effectiveCollectionTable = collectionTableOverride != null
662- ? collectionTableOverride .collectionTable ()
663- : collectionTable ;
664-
665660 final JoinColumn [] annJoins ;
666661 final JoinColumn [] annInverseJoins ;
667- if ( assocTable != null || effectiveCollectionTable != null ) {
662+ if ( assocTable != null || collectionTable != null ) {
668663 final String catalog ;
669664 final String schema ;
670665 final String tableName ;
@@ -675,15 +670,18 @@ private static void bindJoinedTableAssociation(
675670 final String options ;
676671
677672 //JPA 2 has priority
678- if ( effectiveCollectionTable != null ) {
679- catalog = effectiveCollectionTable .catalog ();
680- schema = effectiveCollectionTable .schema ();
681- tableName = effectiveCollectionTable .name ();
682- uniqueConstraints = effectiveCollectionTable .uniqueConstraints ();
683- joins = effectiveCollectionTable .joinColumns ();
673+ if ( collectionTable != null ) {
674+ catalog = collectionTable .catalog ();
675+ schema = collectionTable .schema ();
676+ // Use overridden table name if @CollectionTableOverride is present
677+ tableName = collectionTableOverride != null
678+ ? collectionTableOverride .table ()
679+ : collectionTable .name ();
680+ uniqueConstraints = collectionTable .uniqueConstraints ();
681+ joins = collectionTable .joinColumns ();
684682 inverseJoins = null ;
685- jpaIndexes = effectiveCollectionTable .indexes ();
686- options = effectiveCollectionTable .options ();
683+ jpaIndexes = collectionTable .indexes ();
684+ options = collectionTable .options ();
687685 }
688686 else {
689687 catalog = assocTable .catalog ();
@@ -930,20 +928,20 @@ private static CollectionClassification determineCollectionClassification(
930928
931929 if ( property .hasAnnotationUsage ( OrderColumn .class , modelsContext ) ) {
932930 throw new AnnotationException ( "Attribute '"
933- + qualify (
931+ + qualify (
934932 property .getDeclaringType ().getName (),
935933 property .getName ()
936934 )
937- + "' is annotated '@Bag' and may not also be annotated '@OrderColumn'" );
935+ + "' is annotated '@Bag' and may not also be annotated '@OrderColumn'" );
938936 }
939937
940938 if ( property .hasAnnotationUsage ( ListIndexBase .class , modelsContext ) ) {
941939 throw new AnnotationException ( "Attribute '"
942- + qualify (
940+ + qualify (
943941 property .getDeclaringType ().getName (),
944942 property .getName ()
945943 )
946- + "' is annotated '@Bag' and may not also be annotated '@ListIndexBase'" );
944+ + "' is annotated '@Bag' and may not also be annotated '@ListIndexBase'" );
947945 }
948946
949947 final var collectionJavaType = property .getType ().determineRawClass ().toJavaClass ();
@@ -1080,7 +1078,7 @@ private void setElementType(TypeDetails collectionElementType) {
10801078
10811079 private void setTargetEntity (Class <?> targetEntity ) {
10821080 setTargetEntity ( modelsContext ().getClassDetailsRegistry ()
1083- .resolveClassDetails ( targetEntity .getName () ) );
1081+ .resolveClassDetails ( targetEntity .getName () ) );
10841082 }
10851083
10861084 private void setTargetEntity (ClassDetails targetEntity ) {
@@ -1153,7 +1151,7 @@ private boolean isMutable() {
11531151 private void checkMapKeyColumn () {
11541152 if ( property .hasDirectAnnotationUsage ( MapKeyColumn .class ) && hasMapKeyProperty ) {
11551153 throw new AnnotationException ( "Collection '" + qualify ( propertyHolder .getPath (), propertyName )
1156- + "' is annotated both '@MapKey' and '@MapKeyColumn'" );
1154+ + "' is annotated both '@MapKey' and '@MapKeyColumn'" );
11571155 }
11581156 }
11591157
@@ -1190,49 +1188,49 @@ private void detectMappedByProblem(boolean isMappedBy) {
11901188 if ( property .hasDirectAnnotationUsage ( JoinColumn .class )
11911189 || property .hasDirectAnnotationUsage ( JoinColumns .class ) ) {
11921190 throw new AnnotationException ( "Association '"
1193- + qualify ( propertyHolder .getPath (), propertyName )
1194- + "' is 'mappedBy' another entity and may not specify the '@JoinColumn'" );
1191+ + qualify ( propertyHolder .getPath (), propertyName )
1192+ + "' is 'mappedBy' another entity and may not specify the '@JoinColumn'" );
11951193 }
11961194 if ( propertyHolder .getJoinTable ( property ) != null ) {
11971195 throw new AnnotationException ( "Association '"
1198- + qualify ( propertyHolder .getPath (), propertyName )
1199- + "' is 'mappedBy' another entity and may not specify the '@JoinTable'" );
1196+ + qualify ( propertyHolder .getPath (), propertyName )
1197+ + "' is 'mappedBy' another entity and may not specify the '@JoinTable'" );
12001198 }
12011199 if ( oneToMany ) {
12021200 if ( property .hasDirectAnnotationUsage ( MapKeyColumn .class ) ) {
12031201 BOOT_LOGGER .warn ( "Association '"
1204- + qualify ( propertyHolder .getPath (), propertyName )
1205- + "' is 'mappedBy' another entity and should not specify a '@MapKeyColumn'"
1206- + " (use '@MapKey' instead)" );
1202+ + qualify ( propertyHolder .getPath (), propertyName )
1203+ + "' is 'mappedBy' another entity and should not specify a '@MapKeyColumn'"
1204+ + " (use '@MapKey' instead)" );
12071205 }
12081206 if ( property .hasDirectAnnotationUsage ( OrderColumn .class ) ) {
12091207 BOOT_LOGGER .warn ( "Association '"
1210- + qualify ( propertyHolder .getPath (), propertyName )
1211- + "' is 'mappedBy' another entity and should not specify an '@OrderColumn'"
1212- + " (use '@OrderBy' instead)" );
1208+ + qualify ( propertyHolder .getPath (), propertyName )
1209+ + "' is 'mappedBy' another entity and should not specify an '@OrderColumn'"
1210+ + " (use '@OrderBy' instead)" );
12131211 }
12141212 }
12151213 else {
12161214 if ( property .hasDirectAnnotationUsage ( MapKeyColumn .class ) ) {
12171215 throw new AnnotationException ( "Association '"
1218- + qualify ( propertyHolder .getPath (), propertyName )
1219- + "' is 'mappedBy' another entity and may not specify a '@MapKeyColumn'"
1220- + " (use '@MapKey' instead)" );
1216+ + qualify ( propertyHolder .getPath (), propertyName )
1217+ + "' is 'mappedBy' another entity and may not specify a '@MapKeyColumn'"
1218+ + " (use '@MapKey' instead)" );
12211219 }
12221220 if ( property .hasDirectAnnotationUsage ( OrderColumn .class ) ) {
12231221 throw new AnnotationException ( "Association '"
1224- + qualify ( propertyHolder .getPath (), propertyName )
1225- + "' is 'mappedBy' another entity and may not specify an '@OrderColumn'"
1226- + " (use '@OrderBy' instead)" );
1222+ + qualify ( propertyHolder .getPath (), propertyName )
1223+ + "' is 'mappedBy' another entity and may not specify an '@OrderColumn'"
1224+ + " (use '@OrderBy' instead)" );
12271225 }
12281226 }
12291227 }
12301228 else if ( oneToMany
12311229 && property .hasDirectAnnotationUsage ( OnDelete .class )
12321230 && !hasExplicitJoinColumn () ) {
12331231 throw new AnnotationException ( "Unidirectional '@OneToMany' association '"
1234- + qualify ( propertyHolder .getPath (), propertyName )
1235- + "' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'" );
1232+ + qualify ( propertyHolder .getPath (), propertyName )
1233+ + "' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'" );
12361234 }
12371235 }
12381236
@@ -1526,7 +1524,7 @@ TypeDetails getElementType() {
15261524 }
15271525 else {
15281526 throw new AnnotationException ( "Collection '" + safeCollectionRole ()
1529- + "' is declared with a raw type and has an explicit 'targetEntity'" );
1527+ + "' is declared with a raw type and has an explicit 'targetEntity'" );
15301528 }
15311529 }
15321530 else {
@@ -1844,7 +1842,7 @@ private void addFilterJoinTable(boolean hasAssociationTable, FilterJoinTable fil
18441842 }
18451843 else {
18461844 throw new AnnotationException ( "Collection '" + qualify ( propertyHolder .getPath (), propertyName )
1847- + "' is an association with no join table and may not have a '@FilterJoinTable'" );
1845+ + "' is an association with no join table and may not have a '@FilterJoinTable'" );
18481846 }
18491847 }
18501848
@@ -1866,15 +1864,15 @@ private String getDefaultFilterCondition(String name, Annotation annotation) {
18661864 final var definition = getMetadataCollector ().getFilterDefinition ( name );
18671865 if ( definition == null ) {
18681866 throw new AnnotationException ( "Collection '" + qualify ( propertyHolder .getPath (), propertyName )
1869- + "' has a '@" + annotation .annotationType ().getSimpleName ()
1870- + "' for an undefined filter named '" + name + "'" );
1867+ + "' has a '@" + annotation .annotationType ().getSimpleName ()
1868+ + "' for an undefined filter named '" + name + "'" );
18711869 }
18721870 final String defaultCondition = definition .getDefaultFilterCondition ();
18731871 if ( isBlank ( defaultCondition ) ) {
18741872 throw new AnnotationException ( "Collection '" + qualify ( propertyHolder .getPath (), propertyName ) +
1875- "' has a '@" + annotation .annotationType ().getSimpleName ()
1876- + "' with no 'condition' and no default condition was given by the '@FilterDef' named '"
1877- + name + "'" );
1873+ "' has a '@" + annotation .annotationType ().getSimpleName ()
1874+ + "' with no 'condition' and no default condition was given by the '@FilterDef' named '"
1875+ + name + "'" );
18781876 }
18791877 return defaultCondition ;
18801878 }
@@ -2485,8 +2483,8 @@ private static void addCheckToCollection(Table collectionTable, Check check) {
24852483 final String name = check .name ();
24862484 final String constraint = check .constraints ();
24872485 collectionTable .addCheck ( name .isBlank ()
2488- ? new CheckConstraint ( constraint )
2489- : new CheckConstraint ( name , constraint ) );
2486+ ? new CheckConstraint ( constraint )
2487+ : new CheckConstraint ( name , constraint ) );
24902488 }
24912489
24922490 private void processSoftDeletes () {
@@ -2515,7 +2513,7 @@ private void handleUnownedManyToMany(
25152513 boolean isCollectionOfEntities ) {
25162514 if ( !isCollectionOfEntities ) {
25172515 throw new AnnotationException ( "Association '" + safeCollectionRole () + "'"
2518- + targetEntityMessage ( elementType ) );
2516+ + targetEntityMessage ( elementType ) );
25192517 }
25202518
25212519 joinColumns .setManyToManyOwnerSideEntityName ( collectionEntity .getEntityName () );
@@ -2538,7 +2536,7 @@ private void checkCheckAnnotation() {
25382536 if ( property .hasDirectAnnotationUsage ( Checks .class )
25392537 || property .hasDirectAnnotationUsage ( Check .class ) ) {
25402538 throw new AnnotationException ( "Association '" + safeCollectionRole ()
2541- + " is an unowned collection and may not be annotated '@Check'" );
2539+ + " is an unowned collection and may not be annotated '@Check'" );
25422540 }
25432541 }
25442542
@@ -2551,20 +2549,20 @@ private void detectManyToManyProblems(
25512549 if ( property .hasDirectAnnotationUsage ( ManyToMany .class )
25522550 || property .hasDirectAnnotationUsage ( OneToMany .class ) ) {
25532551 throw new AnnotationException ( "Association '" + safeCollectionRole () + "'"
2554- + targetEntityMessage ( elementType ) );
2552+ + targetEntityMessage ( elementType ) );
25552553 }
25562554 else if ( isManyToAny ) {
25572555 if ( propertyHolder .getJoinTable ( property ) == null ) {
25582556 throw new AnnotationException ( "Association '" + safeCollectionRole ()
2559- + "' is a '@ManyToAny' and must specify a '@JoinTable'" );
2557+ + "' is a '@ManyToAny' and must specify a '@JoinTable'" );
25602558 }
25612559 }
25622560 else {
25632561 final var joinTableAnn = propertyHolder .getJoinTable ( property );
25642562 if ( joinTableAnn != null && !ArrayHelper .isEmpty ( joinTableAnn .inverseJoinColumns () ) ) {
25652563 throw new AnnotationException ( "Association '" + safeCollectionRole ()
2566- + " has a '@JoinTable' with 'inverseJoinColumns' and"
2567- + targetEntityMessage ( elementType ) );
2564+ + " has a '@JoinTable' with 'inverseJoinColumns' and"
2565+ + targetEntityMessage ( elementType ) );
25682566 }
25692567 }
25702568 }
0 commit comments