Hibernate more picky on character type discriminators

Thursday, November 20th, 2008

On a project I’m working on, I’ve got one abstract base class and two subclasses, which are mapped to one same table, with a single character column as the discriminator. I got this error when Hibernate initializes:

org.hibernate.MappingException: multiple or zero characters found parsing string

Turns out if the discriminator type is “character”, the base class must have a discriminator-value attribute declared, even though obviously due to the abstractness there will never be any row carrying that discriminator value. And apparently for “string” type discriminators, there isn’t such a limitation.