openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Tenner (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1166) Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails
Date Tue, 21 Jul 2009 14:37:14 GMT


Jeff Tenner commented on OPENJPA-1166:

I believe this concerns a documented restriction of OpenJPA regarding polymorphic relations
and TABLE_PER_CLASS. The rootEntity in this JIRA and System in the related post are both non-leaf
classes. So, the query is attempting to traverse to a non-leaf class with table-per-class
inheritance. OpenJPA documents the following:  

Table-per-class inheritance mapping has the following limitations:


      You cannot traverse polymorphic relations to non-leaf classes in a table-per-class inheritance
hierarchy in queries.

      You cannot map a one-sided polymorphic relation to a non-leaf class in a table-per-class
inheritance hierarchy using an inverse foreign key. 

I think the question should be can this restriction be lifted by implementing the JPQL query
 as a SQL UNION of the subclass tables. 

> Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced
through a relationship fails
> -------------------------------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-1166
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 1.2.1
>            Reporter: Jody Grassel
> Queries that try to reference a common persistable attribute that is defined by a Table-Per-Class
entity hierarchy through a relationship does not seem to work.  The following query: "SELECT
e FROM PartnerEntity e  WHERE e.rootEntity.rootEntityIntData = ?1" will throw the following
> <openjpa-1.2.2-SNAPSHOT-r422266:789525M fatal user error> org.apache.openjpa.persistence.ArgumentException:
Cannot join across "org.apache.openjpa.persistence.inheritance.entities.mscid.concrete.PIDPartnerEntity.rootEntity".
 The related type has unjoined subclasses.
>         at org.apache.openjpa.jdbc.meta.strats.RelationStrategies.unjoinable(
>         at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(
>         at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(
>         at org.apache.openjpa.jdbc.kernel.exps.CompareEqualExpression.initialize(
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(
>         at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(
>         at org.apache.openjpa.kernel.QueryImpl.execute(
>         at org.apache.openjpa.kernel.QueryImpl.execute(
>         at org.apache.openjpa.kernel.QueryImpl.execute(
>         at org.apache.openjpa.kernel.DelegatingQuery.execute(
>         at org.apache.openjpa.persistence.QueryImpl.execute(
>         at org.apache.openjpa.persistence.QueryImpl.getResultList(
> Where the following entities are defined:
> @Entity
> public class PartnerEntity  {
>    @Id private int id;
>    @OneToOne  private RootEntity rootEntity;
>    ...
> }
> @Entity
> @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
> public class RootEntity {
>    @Id private int id;
>    private int rootEntityIntData;
> ...
> }
> [there exist a number of entities which inherit from RootEntity, the example above targets
the persistable attribute "rootEntityIntData" which is inherited by every entity extending

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message