With a single-table inheritance model, there seems to be no way, using RawSql to map the discriminator column. From the Google Group:
I have an abstract entity and 2 subclasses in a single table with a discriminator column/value set. All is well for standard API queries. I am using RawSqlBuilder.unparsed(sql) for a complex case. I'm getting an error:
javax.persistence.PersistenceException: Inheritance type for discriminator value [170] was not found? at com.avaje.ebeaninternal.server.deploy.InheritInfo.readType(InheritInfo.java:223) at com.avaje.ebeaninternal.server.deploy.InheritInfo.readType(InheritInfo.java:208) at com.avaje.ebeaninternal.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:210) at com.avaje.ebeaninternal.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:308) at com.avaje.ebeaninternal.server.query.CQuery.readRow(CQuery.java:545)
(FWIW, 170 is the primary key of the entity to be instantiated.)
I've made various attempts to include the discriminator column in the query. How does one go about specifying/selecting/mapping the discriminator value for an unparsed (or parsed for that matter) RawSql?
[Rob:]It could be that you can't. I don't recall a test case for this so its likely a bug where you can't specify/map the discriminator.