Skip to content

Commit bb28b03

Browse files
author
Vincent Bouthinon
committed
HHH-18750 : @onetomany with @Any mapped in secondary table KO (ClassCastException)
Proposed solution: Follow the same approach as @manytoone for the second pass. For your information : @onetomany with @manytoone that uses a @SecondaryTable works perfectly. https://hibernate.atlassian.net/browse/HHH-18750
1 parent a6b5f16 commit bb28b03

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ManyToManyCollectionPart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ else if ( getNature() == Nature.INDEX ) {
398398
}
399399
else if ( StringHelper.isNotEmpty( bootCollectionDescriptor.getMappedByProperty() ) ) {
400400
final ModelPart mappedByPart = resolveNamedTargetPart( bootCollectionDescriptor.getMappedByProperty(), getAssociatedEntityMappingType(), collectionDescriptor );
401-
if ( mappedByPart instanceof ToOneAttributeMapping ) {
401+
if ( mappedByPart instanceof ToOneAttributeMapping || mappedByPart instanceof DiscriminatedAssociationAttributeMapping ) {
402402
////////////////////////////////////////////////
403403
// E.g.
404404
//
@@ -425,7 +425,7 @@ else if ( StringHelper.isNotEmpty( bootCollectionDescriptor.getMappedByProperty(
425425
final ManyToOne elementDescriptor = (ManyToOne) bootCollectionDescriptor.getElement();
426426
assert elementDescriptor.isReferenceToPrimaryKey();
427427

428-
final String collectionTableName = ( (BasicCollectionPersister) collectionDescriptor ).getTableName();
428+
final String collectionTableName = collectionDescriptor.getTableName();
429429

430430
// this fk will refer to the associated entity's id. if that id is not ready yet, delay this creation
431431
if ( getAssociatedEntityMappingType().getIdentifierMapping() == null ) {

0 commit comments

Comments
 (0)