Skip to content

Commit

Permalink
HSEARCH-4156 Don't try to infer mappedBy information from ManyToOne
Browse files Browse the repository at this point in the history
ManyToOne never has any mappedBy information, it's always on the other
side. Worse: it sometimes holds a reference to a synthetic property
instead of the mappedBy, and trying to resolve that property leads to a
bootstrap failure since it doesn't exist.

Signed-off-by: Yoann Rodière <yoann@hibernate.org>
  • Loading branch information
yrodiere authored and fax4ever committed Feb 23, 2021
1 parent b2c973b commit 311605c
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -17,6 +17,7 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable;
Expand Down Expand Up @@ -139,10 +140,12 @@ private void collectPropertyMetadataContributors(PropertyDelegatesCollector coll
);
}
}
else if ( value instanceof ToOne ) {
ToOne toOneValue = (ToOne) value;
else if ( value instanceof OneToOne ) {
// ManyToOne never carries any useful inverse side information:
// either it refers to nothing or to a synthetic property that we're not interested in.
// OneToOne, on the other hand, uses ReferencedPropertyName to store the "mappedBy" information.
OneToOne toOneValue = (OneToOne) value;
String referencedEntityName = toOneValue.getReferencedEntityName();
// For *ToOne, the "mappedBy" information is apparently stored in the ReferencedPropertyName
String mappedByPath = toOneValue.getReferencedPropertyName();
if ( mappedByPath != null && !mappedByPath.isEmpty() ) {
collector.collect(
Expand Down

0 comments on commit 311605c

Please sign in to comment.