aspose file tools*
The moose likes Object Relational Mapping and the fly likes Could not map discriminator value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Could not map discriminator value " Watch "Could not map discriminator value " New topic
Author

Could not map discriminator value

eion martin
Greenhorn

Joined: May 01, 2013
Posts: 1
Hello
I have an inheritance relationship configured for attributes of a product.

@Entity(name="AbstractFlexAttribute")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name="flex_attribute_value_master")
@DiscriminatorColumn(name="ATTRIBUTE_NM", discriminatorType=DiscriminatorType.STRING)

public abstract class AbstractFlexAttribute {

}


@Entity(name="DistributionFlexAttribute")
@DiscriminatorValue("RETAIL_COMMERCIAL_IND")
public class DistributionFlexAttribute extends AbstractFlexAttribute {


//~--- methods ------------------------------------------------------------

}

In order to retrieve retail-commercial data relevant to a product we have used a jointable in the product class.

@OneToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "PROD_GRP_FLEX_ATTR_MAPPING",
joinColumns = { @JoinColumn(name = "PROD_GROUP_ID") },
inverseJoinColumns = { @JoinColumn(name = "ATTRIBUTE_VALUE_ID") }
)

public Collection<DistributionFlexAttribute> getDistributionFlexAttributes() {
return distributionFlexAttributes;
}

This was working as expected until an additional attribute type was added to the flex attribute table. Pages began to not render and the following error message was found in the logs:

Could not map discriminator value "BIOPREFERRED_CONTENT" to any known subclasses of the requested class "com.usg.model.pir.AbstractFlexAttribute" (known discriminator values: [AbstractFlexAttribute, RETAIL_COMMERCIAL_IND]).

Is there a way to avoid this error as I cannot be sure that the business will not add additional attributes in the future? It seems that a warning may be more appropriate.

I am using version 1.2.3 as called for in our pom file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not map discriminator value
 
Similar Threads
doubts mapping several relations
DiscriminatorColumn neither getting created or populated
Writing a JPA query against a member field that's a Set
Error book Hibernate Recipes a problemsolution approach(@OneToMany bidirectional Using a Join Table)
Simple JOIN in JPA proving difficult