@@ -243,8 +243,6 @@ public static void bindCollection(
243243 collectionBinder .setInheritanceStatePerClass ( inheritanceStatePerClass );
244244 collectionBinder .setDeclaringClass ( inferredData .getDeclaringClass () );
245245
246- final var hibernateCascade = memberDetails .getAnnotationUsage ( Cascade .class , modelsContext );
247-
248246 collectionBinder .setElementColumns ( elementColumns (
249247 propertyHolder ,
250248 nullability ,
@@ -287,8 +285,7 @@ public static void bindCollection(
287285 oneToManyAnn ,
288286 manyToManyAnn ,
289287 elementCollectionAnn ,
290- collectionBinder ,
291- hibernateCascade
288+ collectionBinder
292289 )
293290 );
294291
@@ -302,20 +299,12 @@ public static void bindCollection(
302299 final HashMap <String , IdentifierGeneratorDefinition > availableGenerators = new HashMap <>();
303300 visitIdGeneratorDefinitions (
304301 memberDetails .getDeclaringType (),
305- definition -> {
306- if ( !definition .getName ().isEmpty () ) {
307- availableGenerators .put ( definition .getName (), definition );
308- }
309- },
302+ definition -> addDefinition ( definition , availableGenerators ),
310303 context
311304 );
312305 visitIdGeneratorDefinitions (
313306 memberDetails ,
314- definition -> {
315- if ( !definition .getName ().isEmpty () ) {
316- availableGenerators .put ( definition .getName (), definition );
317- }
318- },
307+ definition -> addDefinition ( definition , availableGenerators ),
319308 context
320309 );
321310 collectionBinder .setLocalGenerators ( availableGenerators );
@@ -324,6 +313,15 @@ public static void bindCollection(
324313 collectionBinder .bind ();
325314 }
326315
316+ private static void addDefinition (
317+ IdentifierGeneratorDefinition definition ,
318+ Map <String , IdentifierGeneratorDefinition > availableGenerators ) {
319+ final String definitionName = definition .getName ();
320+ if ( !definitionName .isEmpty () ) {
321+ availableGenerators .put ( definitionName , definition );
322+ }
323+ }
324+
327325 private static NotFoundAction notFoundAction (
328326 PropertyHolder propertyHolder ,
329327 PropertyData inferredData ,
@@ -443,8 +441,7 @@ private static String handleTargetEntity(
443441 OneToMany oneToManyAnn ,
444442 ManyToMany manyToManyAnn ,
445443 ElementCollection elementCollectionAnn ,
446- CollectionBinder collectionBinder ,
447- Cascade hibernateCascade ) {
444+ CollectionBinder collectionBinder ) {
448445
449446 //TODO enhance exception with @ManyToAny and @CollectionOfElements
450447 if ( oneToManyAnn != null && manyToManyAnn != null ) {
@@ -461,7 +458,7 @@ private static String handleTargetEntity(
461458 mappedBy = nullIfEmpty ( oneToManyAnn .mappedBy () );
462459 collectionBinder .setTargetEntity ( oneToManyAnn .targetEntity () );
463460 collectionBinder .setCascadeStrategy (
464- aggregateCascadeTypes ( oneToManyAnn .cascade (), hibernateCascade ,
461+ aggregateCascadeTypes ( oneToManyAnn .cascade (), property ,
465462 oneToManyAnn .orphanRemoval (), context ) );
466463 collectionBinder .setOneToMany ( true );
467464 }
@@ -479,14 +476,14 @@ else if ( manyToManyAnn != null ) {
479476 mappedBy = nullIfEmpty ( manyToManyAnn .mappedBy () );
480477 collectionBinder .setTargetEntity ( manyToManyAnn .targetEntity () );
481478 collectionBinder .setCascadeStrategy (
482- aggregateCascadeTypes ( manyToManyAnn .cascade (), hibernateCascade , false , context ) );
479+ aggregateCascadeTypes ( manyToManyAnn .cascade (), property , false , context ) );
483480 collectionBinder .setOneToMany ( false );
484481 }
485482 else if ( property .hasDirectAnnotationUsage ( ManyToAny .class ) ) {
486483 mappedBy = null ;
487484 collectionBinder .setTargetEntity ( ClassDetails .VOID_CLASS_DETAILS );
488485 collectionBinder .setCascadeStrategy (
489- aggregateCascadeTypes ( null , hibernateCascade , false , context ) );
486+ aggregateCascadeTypes ( null , property , false , context ) );
490487 collectionBinder .setOneToMany ( false );
491488 }
492489 else {
@@ -1387,14 +1384,14 @@ private ModelsContext modelsContext() {
13871384 }
13881385
13891386 private void handleFetchProfileOverrides () {
1390- property .forEachAnnotationUsage ( FetchProfileOverride .class , modelsContext (), ( usage ) -> {
1391- getMetadataCollector (). addSecondPass ( new FetchSecondPass (
1392- usage ,
1393- propertyHolder ,
1394- propertyName ,
1395- buildingContext
1396- ) );
1397- } );
1387+ property .forEachAnnotationUsage ( FetchProfileOverride .class , modelsContext (),
1388+ usage -> getMetadataCollector ()
1389+ . addSecondPass ( new FetchSecondPass (
1390+ usage ,
1391+ propertyHolder ,
1392+ propertyName ,
1393+ buildingContext
1394+ ) ) );
13981395 }
13991396
14001397 private void handleFetch () {
@@ -1602,11 +1599,8 @@ private void createOneToManyBackref(org.hibernate.mapping.OneToMany oneToMany) {
16021599 // for non-inverse one-to-many, with a not-null fk, add a backref!
16031600 final String entityName = oneToMany .getReferencedEntityName ();
16041601 final var referencedEntity = collector .getEntityBinding ( entityName );
1605- final Backref backref = new Backref ();
1606- final String backrefName = '_' + foreignJoinColumns .getPropertyName ()
1607- + '_' + foreignJoinColumns .getColumns ().get (0 ).getLogicalColumnName ()
1608- + "Backref" ;
1609- backref .setName ( backrefName );
1602+ final var backref = new Backref ();
1603+ backref .setName ( backrefName () );
16101604 backref .setOptional ( true );
16111605 backref .setUpdatable ( false );
16121606 backref .setSelectable ( false );
@@ -1616,6 +1610,12 @@ private void createOneToManyBackref(org.hibernate.mapping.OneToMany oneToMany) {
16161610 referencedEntity .addProperty ( backref );
16171611 }
16181612
1613+ private String backrefName () {
1614+ return '_' + foreignJoinColumns .getPropertyName ()
1615+ + '_' + foreignJoinColumns .getColumns ().get ( 0 ).getLogicalColumnName ()
1616+ + "Backref" ;
1617+ }
1618+
16191619 private void handleJpaOrderBy (Collection collection , PersistentClass associatedClass ) {
16201620 final String hqlOrderBy = extractHqlOrderBy ( jpaOrderBy );
16211621 if ( hqlOrderBy != null ) {
0 commit comments