This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not map discriminator value

 
eion martin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic