diff --git a/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java b/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java index f4110d7cdc..d20ac43150 100644 --- a/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java +++ b/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java @@ -133,6 +133,13 @@ private static MapStorageType getMapStorage(AssociationContext associationContex return associationContext.getAssociationTypeContext().getOptionsContext().getUnique( MapStorageOption.class ); } + /** + * Returns the shared prefix with a trailing dot (.) of the association columns or {@literal null} if there is no shared prefix. + * + * @param associationKey the association key + * + * @return the shared prefix with a trailing dot (.) of the association columns or {@literal null} + */ public static String getColumnSharedPrefixOfAssociatedEntityLink(AssociationKey associationKey) { String[] associationKeyColumns = associationKey.getMetadata() .getAssociatedEntityKeyMetadata() diff --git a/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java b/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java index 0e7c53cd7b..1422c04ca9 100644 --- a/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java +++ b/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java @@ -6,6 +6,7 @@ */ package org.hibernate.ogm.datastore.mongodb; +import static org.hibernate.ogm.datastore.document.impl.DotPatternMapHelpers.getColumnSharedPrefixOfAssociatedEntityLink; import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot.SnapshotType.INSERT; import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot.SnapshotType.UPDATE; import static org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoHelpers.hasField; @@ -591,17 +592,6 @@ private Object getAssociationRow(Tuple row, AssociationKey associationKey) { } } - private String getColumnSharedPrefixOfAssociatedEntityLink(AssociationKey associationKey) { - String[] associationKeyColumns = associationKey.getMetadata() - .getAssociatedEntityKeyMetadata() - .getAssociationKeyColumns(); - // we used to check that columns are the same (in an ordered fashion) - // but to handle List and Map and store indexes / keys at the same level as the id columns - // this check is removed - String prefix = DocumentHelpers.getColumnSharedPrefix( associationKeyColumns ); - return prefix == null ? "" : prefix + "."; - } - @Override public void insertOrUpdateAssociation(AssociationKey key, Association association, AssociationContext associationContext) { DBCollection collection;