1

I have an application that maps views into an existing Hibernate schema that makes extensive use of single table inheritance with a discriminator-value in the CLASSNAME column. What makes my situation unusual is that I do not what to support all the subclasses (discriminator-value in the Hibernate mappings) in the data, just those of interest to the application.

The problem is that if the application encounters an unsupported discriminator-value, Hibernate throws a "org.hibernate.WrongClassException" because it cannot find a mapping with the required discriminator-value.

What I would like to do is to create subclass that Hibernate will use if the discriminator-value is unknown (instead of throwing an exception).

Is there a way to do this?

Thanks, Ed

1 Answer 1

0

I found the answer here for those using annotation:

Mapping Hibernate entity for unknown DiscriminatorValue for InheritanceType.SINGLE_TABLE.

What this does not tell you is what to use in a mapping file. I checked the open source code and it appears that the discriminator-value="<not null discriminator>" will do the trick. Hibernate checks for this value (and <null discriminator>), and gives them special handling.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.