Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate mapping and inheritance issues with @SecondaryTable
    primarykey
    data
    text
    <p>I have a pretty simple class hierarchy structure that is listed below, each sub class having a @DiscriminatorValue enumeration type, which works very well.</p> <p><em>Abstract class:</em></p> <p><strong>AbstractNode</strong> (abstract class mapped to the Node table)</p> <p><em>Subclassed classes:</em></p> <p><strong>FieldNode</strong> (simple class mapped to Node table as well, but with different @DiscriminatorValue value)</p> <p><strong>SynonymNode</strong> (problem class, this class also maps to the Node table with a different @DiscriminatorValue value)</p> <p>but <strong>ALSO</strong> has a @SecondaryTable attribute and has extra columns, such as deletedDate, createdDate, etc... each which map to coumns in the table defined in the @SecondaryTable attribute.</p> <p>Im issue comes when I do a simple hibernate query for that Node table</p> <p>I get errors like:</p> <p>org.hibernate.exception.GenericJDBCException: could not execute query ... stack trace ... Caused by: java.sql.SQLException: Invalid column name</p> <p>and in my logs I can see:</p> <p>Hibernate: Select * from vocab_node where lower(name) like '%' || ? || '%'</p> <p>INFO [NullableType.java:132] : could not read column value from result set: DELETED_DATE; Invalid column name</p> <p>My guess is that it finds a row in the DB table, then identifies that is is a <strong>SynonymNode</strong> class type (by the @DiscriminatorValue column) then tries to populate the class including the extra columns table mapped with the @SecondaryTable.</p> <p>How can I tell it to either, left join the @SecondaryTable, or exclude it altogether for this particular query?</p> <p>Thanks heaps! This issue is killing me!</p> <p>Im running Hibernate 3.2.1, and Java 1.5</p> <p>Cheers, Mark</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload