Enhancement 411 : RawSql to support discriminator column mapping.
Priority 
Medium
Reported Version 
 
Logged By 
Daryl Stultz
Status 
Fixed
Fixed Version 
github
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
09/07/2012
Updated 
09/07/2012
Type 
Enhancement
 
Attachments 
No attachments

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.

 
woResponse

Upload a file