java - JPA: The column name DTYPE was not found in this ResultSet -


in spring application have entity called resource::

@entity public class resource {  list<resource> list = em.createnativequery("select r.* ...", resource.class).getresultlist(); 

for 1 specific purpose, need few more fields added results. created subclass extendedresource:

@entity public class arearesource extends resource {     @column(name="extra_field")     private integer field;  list<extendedresource> list = em.createnativequery("select extra_field, r.* ...", extendedresource.class).getresultlist(); 

this works fine when query extendedresource, resource get:

org.postgresql.util.psqlexception: column name dtype not found in resultset. 

is there way around this, without bothering discriminator column? guess mappedsuperclass solution, avoid making classes.

thanks

a trivial problem, no way around without coding :)

other creating @mappedsuperclass (which, said, solution), or creating entity hierarchy (with dtype), call em.createnativequery(sql) without resulting class, give result in form of list<object[]>. then, each row create new instance of extendedresource in loop. if go option, make sure specify columns 1 one instead of using *, ensure order in returned.

this way, might create @transient field in resource class, , eliminate need additional class.

it's matter of personal preference of approaches suites best. @mappedsuperclass seems involve least amount of coding.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -