Skip to content

Commit

Permalink
OGM-732 Avoid exception when querying on polymorphic entities
Browse files Browse the repository at this point in the history
  We don't always return the right values when dealing with the different strategies.

  The default values returned are the one used by ORM.
  • Loading branch information
DavideD committed Nov 29, 2016
1 parent bfa2d9f commit 74de1ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
import org.hibernate.type.CollectionType;
import org.hibernate.type.ComponentType;
import org.hibernate.type.EntityType;
import org.hibernate.type.IntegerType;
import org.hibernate.type.OneToOneType;
import org.hibernate.type.Type;
/**
Expand Down Expand Up @@ -1805,7 +1804,7 @@ public String getTableName() {

@Override
public Type getDiscriminatorType() {
return IntegerType.INSTANCE;
return discriminator.getType();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Subclass;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;

/**
Expand All @@ -21,6 +22,8 @@
*/
public class TablePerClassDiscriminator implements EntityDiscriminator {

private static final String DISCRIMINATOR_ALIAS = "clazz_";

private final Integer subclassId;
private final Map<Object, String> subclassesByValue;

Expand Down Expand Up @@ -71,12 +74,12 @@ public String getColumnName() {

@Override
public String getAlias() {
return null;
return DISCRIMINATOR_ALIAS;
}

@Override
public Type getType() {
return null;
return StandardBasicTypes.INTEGER;
}

@Override
Expand Down

0 comments on commit 74de1ad

Please sign in to comment.