Skip to content

Commit c397d18

Browse files
committed
HHH-19711 Improve mapped-by + join-column exception message with the full property path
1 parent bc29bca commit c397d18

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumn.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import jakarta.persistence.JoinColumn;
2323
import jakarta.persistence.PrimaryKeyJoinColumn;
2424

25-
import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
25+
import java.util.Locale;
26+
2627
import static org.hibernate.internal.util.StringHelper.isEmpty;
2728
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
2829
import static org.hibernate.internal.util.StringHelper.isQuoted;
@@ -109,9 +110,13 @@ static AnnotatedJoinColumn buildJoinColumn(
109110
String defaultColumnSuffix) {
110111
if ( joinColumn != null ) {
111112
if ( mappedBy != null ) {
112-
throw new AnnotationException( "Association '"
113-
+ getRelativePath( propertyHolder, inferredData.getPropertyName() )
114-
+ "' is 'mappedBy' a different entity and may not explicitly specify the '@JoinColumn'" );
113+
throw new AnnotationException(
114+
String.format(
115+
Locale.ENGLISH,
116+
"Association '%s' of entity '%s' is 'mappedBy' a different entity and may not explicitly specify the '@JoinColumn'",
117+
inferredData.getPropertyName(),
118+
propertyHolder.getPath() )
119+
);
115120
}
116121
return explicitJoinColumn( joinColumn, parent, inferredData, defaultColumnSuffix );
117122
}

0 commit comments

Comments
 (0)