| See http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#entity-inheritance-discriminator-implicit : we can use @DiscriminatorValue( "null" ) to use SQL NULL as a discriminator value. But... Hibernate ORM itself will still generate a database schema with a NOT NULL constraint on the DTYPE column, resulting in errors at runtime:
This is actually worked around in the tests with an explicit ALTER COLUMN just before the test: https://github.com/hibernate/hibernate-orm/blob/0a2a5c622e3eb30724e80bc8661c0ac55ebfb2be/documentation/src/test/java/org/hibernate/userguide/inheritance/DiscriminatorNotNullSingleTableTest.java#L50 ... and unfortunately the workaround is not included in the code examples in the documentation. Either this needs to be documented (probably in a big warning panel, with a workaround), or Hibernate ORM should detect this case and should not add the NOT NULL constraint in the database schema. |