Skip to content

Commit

Permalink
OGM-931 Log unexpected null Association owner
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD authored and gunnarmorling committed Dec 15, 2015
1 parent 52c3ded commit 6f19c65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Expand Up @@ -158,6 +158,10 @@ private void addNavigationalInformationForInverseSide(int propertyIndex, Associa
}
associationPersister.getAssociation().put( rowKey, associationRow );

if ( associationPersister.getAssociationContext().getEntityTuple() == null ) {
throw log.entityTupleNotFound( associationPersister.getAssociationKey().getEntityKey() );
}

associationPersister.flushToDatastore();
}

Expand Down
Expand Up @@ -35,6 +35,8 @@
* @author Gunnar Morling
*/
public class AssociationPersister {
private static final Log log = LoggerFactory.make();

private GridType keyGridType;
private Object key;
private SessionImplementor session;
Expand Down Expand Up @@ -220,7 +222,7 @@ private EntityPersister getHostingEntityPersister() {
* Returns an {@link AssociationContext} to be passed to {@link GridDialect} operations targeting the association
* managed by this persister.
*/
private AssociationContext getAssociationContext() {
public AssociationContext getAssociationContext() {
if ( associationContext == null ) {
associationContext = new AssociationContextImpl(
associationTypeContext,
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/hibernate/ogm/util/impl/Log.java
Expand Up @@ -22,6 +22,7 @@
import org.hibernate.ogm.cfg.OgmProperties;
import org.hibernate.ogm.dialect.spi.GridDialect;
import org.hibernate.ogm.exception.EntityAlreadyExistsException;
import org.hibernate.ogm.model.key.spi.EntityKey;
import org.hibernate.ogm.options.spi.AnnotationConverter;
import org.hibernate.service.spi.ServiceException;
import org.jboss.logging.BasicLogger;
Expand Down Expand Up @@ -274,4 +275,7 @@ public interface Log extends BasicLogger {

@Message(id = 81, value = "The value set for the configuration property '%1$s' must be a long number. Found '%2$s'.")
HibernateException notALong(String propertyName, String value);

@Message(id = 82, value = "The owner of the association cannot be found in the session: %s")
HibernateException entityTupleNotFound(EntityKey entityKey);
}

0 comments on commit 6f19c65

Please sign in to comment.