File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
hibernate-core/src/main/java/org/hibernate/boot/model Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -508,6 +508,18 @@ private void handleNaturalId(Property property) {
508508 + "' belongs to an entity subclass and may not be annotated '@NaturalId'" +
509509 " (only a property of a root '@Entity' or a '@MappedSuperclass' may be a '@NaturalId')" );
510510 }
511+ if ( memberDetails .hasDirectAnnotationUsage ( ManyToOne .class ) ) {
512+ if ( memberDetails .getDirectAnnotationUsage ( ManyToOne .class ).fetch () == LAZY ) {
513+ throw new AnnotationException ( "Property '" + qualify ( holder .getPath (), name )
514+ + " is annotated '@NaturalId' and '@ManyToOne(fetch=LAZY)' (natural id fields may not be lazy)" );
515+ }
516+ }
517+ if ( memberDetails .hasDirectAnnotationUsage ( Basic .class ) ) {
518+ if ( memberDetails .getDirectAnnotationUsage ( Basic .class ).fetch () == LAZY ) {
519+ throw new AnnotationException ( "Property '" + qualify ( holder .getPath (), name )
520+ + " is annotated '@NaturalId' and '@Basic(fetch=LAZY)' (natural id fields may not be lazy)" );
521+ }
522+ }
511523 if ( !naturalId .mutable () ) {
512524 updatable = false ;
513525 }
Original file line number Diff line number Diff line change @@ -2022,11 +2022,7 @@ private Property createManyToOneAttribute(
20222022
20232023 Property prop = new Property ();
20242024 prop .setValue ( manyToOneBinding );
2025- bindProperty (
2026- sourceDocument ,
2027- manyToOneSource ,
2028- prop
2029- );
2025+ bindProperty ( sourceDocument , manyToOneSource , prop );
20302026
20312027 if ( isNotEmpty ( manyToOneSource .getCascadeStyleName () ) ) {
20322028 // todo : would be better to delay this the end of binding (second pass, etc)
You can’t perform that action at this time.
0 commit comments