Search code examples
jpaormeclipselinkjpqlsingle-table-inheritance

The state field path 'e.id' cannot be resolved to a valid type. Dynamic entity in orm.xml,


This simple SINGLE_TABLE inheritance hierarchy somehow fails when my application tries to access the inheriting entity RootFolderNode.

The entities are defined as dynamic entities access="VIRTUAL", without a Java class backing. The PersistenceUnit is loaded without any complaints.

Exception Description: Problem compiling 
    [SELECT DISTINCT e FROM RootFolderNode e WHERE  e.id =  :param1 ]. 
[46, 50] The state field path 'e.id' cannot be resolved to a valid type.

The relevant part of the ORM.xml

<entity class="FolderNode" access="VIRTUAL" >
    <table name="FOLDER_NODE_PREPARE" />
    <inheritance strategy="SINGLE_TABLE"/>
    <discriminator-value>F</discriminator-value>
    <attributes>
        <id name="id" attribute-type="Long">
            <column name="id" />
            <generated-value strategy="SEQUENCE" generator="FOLDER_NODE_SEQ" />
            <sequence-generator sequence-name="FOLDER_NODE_SEQ" name="FOLDER_NODE_SEQ" allocation-size="1" />
        </id>
        ...
    </attributes>
</entity>

<entity class="RootFolderNode" parent-class="FolderNode" access="VIRTUAL">
    <discriminator-value>R</discriminator-value>
</entity>

What am I missing here?

Products in use: EclipseLink 2.5.1. JBoss EAP 6.2.


Solution

  • Solution: Repeat inheritance specification:

    <entity class="RootFolderNode" parent-class="FolderNode" access="VIRTUAL">
        <inheritance strategy="SINGLE_TABLE"/>
        <discriminator-value>R</discriminator-value>
    </entity>