Skip to content

Commit

Permalink
OGM-207 Removing AssociationKind enum as it is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Jan 24, 2014
1 parent 6a5014e commit 89030a2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 53 deletions.
12 changes: 0 additions & 12 deletions core/src/main/java/org/hibernate/ogm/grid/AssociationKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public final class AssociationKey implements Serializable {
//role and entity key are not part of the object identity
private transient String collectionRole;
private transient EntityKey entityKey;
private transient AssociationKind associationKind;

public AssociationKey(AssociationKeyMetadata metadata, Object[] columnValues) {
this.metadata = metadata;
Expand Down Expand Up @@ -80,13 +79,6 @@ public EntityKey getEntityKey() {
return entityKey;
}

/**
* Describe the type of association. May be null but is typically filled for collection of embeddable.
*/
public AssociationKind getAssociationKind() {
return associationKind;
}

public String[] getRowKeyColumnNames() {
return metadata.getRowKeyColumnNames();
}
Expand Down Expand Up @@ -143,10 +135,6 @@ public void setOwnerEntityKey(EntityKey entityKey) {
this.entityKey = entityKey;
}

public void setAssociationKind(AssociationKind kind) {
this.associationKind = kind;
}

/**
* Whether the given column is part of this key or not.
*
Expand Down
31 changes: 0 additions & 31 deletions core/src/main/java/org/hibernate/ogm/grid/AssociationKind.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.hibernate.ogm.dialect.GridDialect;
import org.hibernate.ogm.grid.AssociationKey;
import org.hibernate.ogm.grid.AssociationKeyMetadata;
import org.hibernate.ogm.grid.AssociationKind;
import org.hibernate.ogm.grid.EntityKey;
import org.hibernate.ogm.grid.RowKey;
import org.hibernate.ogm.options.spi.OptionsService;
Expand Down Expand Up @@ -170,13 +169,9 @@ private AssociationKey getCollectionMetadataKey() {
}
collectionMetadataKey.setOwnerEntityKey( entityKey );
//TODO add information on the collection type, set, map, bag, list etc

AssociationKind type = collectionPersister.getElementType().isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED;
collectionMetadataKey.setAssociationKind( type );
}
// We have a to-one on the main side
else if ( propertyType != null ) {
collectionMetadataKey.setAssociationKind( propertyType.isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED );
if ( propertyType instanceof EntityType ) {
EntityType entityType = (EntityType) propertyType;
OgmEntityPersister associatedPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( session.getFactory() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.ogm.datastore.mongodb.impl.AssociationStorageStrategy;
import org.hibernate.ogm.grid.AssociationKey;
import org.hibernate.ogm.grid.AssociationKind;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
Expand Down Expand Up @@ -60,8 +59,7 @@ public static DBObject associationKeyToObject(AssociationStorageStrategy storage
}

public static boolean isEmbeddedInEntity(AssociationKey key, AssociationStorageStrategy storageStrategy) {
return ( key != null && key.getAssociationKind() == AssociationKind.EMBEDDED )
|| storageStrategy.isEmbeddedInEntity();
return storageStrategy.isEmbeddedInEntity();
}

//only for embedded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.hibernate.ogm.dialect.mongodb.MongoDBDialect;
import org.hibernate.ogm.grid.AssociationKey;
import org.hibernate.ogm.grid.AssociationKeyMetadata;
import org.hibernate.ogm.grid.AssociationKind;
import org.hibernate.ogm.grid.EntityKey;
import org.hibernate.ogm.grid.EntityKeyMetadata;
import org.hibernate.ogm.options.generic.document.AssociationStorageType;
Expand Down Expand Up @@ -130,7 +129,6 @@ public void testLoadSelectedAssociationColumns() {
AssociationKeyMetadata metadata = new AssociationKeyMetadata( "Project_Module", new String[] { "Project_id" } );
metadata.setRowKeyColumnNames( new String[] { "Project_id", "module_id" } );
AssociationKey associationKey = new AssociationKey( metadata, new Object[] { "projectID" } );
associationKey.setAssociationKind( AssociationKind.ASSOCIATION );
associationKey.setCollectionRole( "modules" );
associationKey.setOwnerEntityKey( new EntityKey( new EntityKeyMetadata( "Project", new String[] { "id" } ), new String[] { "projectID" } ) );
AssociationContext associationContext = new AssociationContext( new PropertyOptionsContext( new WritableOptionsServiceContext(), Project.class, "modules" ) );
Expand Down

0 comments on commit 89030a2

Please sign in to comment.