You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jody Grassel (JIRA)" <ji...@apache.org> on 2009/07/08 21:23:14 UTC

[jira] Created: (OPENJPA-1166) Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails

Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails
-------------------------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-1166
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1166
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.1, 1.2.0
            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 Exception:

<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(RelationStrategies.java:53)
        at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(RelationFieldStrategy.java:819)
        at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(FieldMapping.java:860)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(PCPath.java:610)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(PCPath.java:589)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(PCPath.java:461)
        at org.apache.openjpa.jdbc.kernel.exps.CompareEqualExpression.initialize(CompareEqualExpression.java:78)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(SelectConstructor.java:180)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(SelectConstructor.java:121)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:75)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:339)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:179)
        at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:681)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:988)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
        at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
        at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)

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 RootEntity.)

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


[jira] Commented: (OPENJPA-1166) Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails

Posted by "Jeff Tenner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733642#action_12733642 ] 

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: https://issues.apache.org/jira/browse/OPENJPA-1166
>             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 Exception:
> <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(RelationStrategies.java:53)
>         at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(RelationFieldStrategy.java:819)
>         at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(FieldMapping.java:860)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(PCPath.java:610)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(PCPath.java:589)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(PCPath.java:461)
>         at org.apache.openjpa.jdbc.kernel.exps.CompareEqualExpression.initialize(CompareEqualExpression.java:78)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(SelectConstructor.java:180)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(SelectConstructor.java:121)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:75)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:339)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:179)
>         at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:681)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:988)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
>         at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
>         at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
>         at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
> 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 RootEntity.)

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


[jira] Commented: (OPENJPA-1166) Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails

Posted by "Kevin Sutter (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728946#action_12728946 ] 

Kevin Sutter commented on OPENJPA-1166:
---------------------------------------

This JIRA was created based on the following posts...

http://n2.nabble.com/Open-JPA-1.2---getting-error-%22The-related-type-has-unjoined-subclasses%22-td3190219.html#a3190219

What is the problem being reported by this JIRA?  From the posting, it sounds like the problem is resolved by using the @Type annotation.  But, the poster was asking how this @Type solution could be applied across more than a single subtype.

So, is this JIRA meant to address the original problem and not require an explicit @Type annotation?  Or, is this JIRA meant to address the new requirement to allow for more than a single subtype?  These are two separate requests and I'm trying to figure out which one is being pursued.

Thanks,
Kevin

> Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1166
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1166
>             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 Exception:
> <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(RelationStrategies.java:53)
>         at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(RelationFieldStrategy.java:819)
>         at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(FieldMapping.java:860)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(PCPath.java:610)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(PCPath.java:589)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(PCPath.java:461)
>         at org.apache.openjpa.jdbc.kernel.exps.CompareEqualExpression.initialize(CompareEqualExpression.java:78)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(SelectConstructor.java:180)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(SelectConstructor.java:121)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:75)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:339)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:179)
>         at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:681)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:988)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
>         at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
>         at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
>         at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
> 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 RootEntity.)

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


[jira] Commented: (OPENJPA-1166) Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails

Posted by "Heather Sterling (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733251#action_12733251 ] 

Heather Sterling commented on OPENJPA-1166:
-------------------------------------------

Hi Kevin,

I don't think we really care how this problem is solved.  We were trying to solve the original problem and explored using @Type to get around it.  However, because it doesn't work for multiple subtypes, we hit a dead end.

Therefore, I would say the request is to fix the problem, not a feature request.

> Query targetting a common attribute defined in a Table-Per-Class entity heirarchy referenced through a relationship fails
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1166
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1166
>             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 Exception:
> <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(RelationStrategies.java:53)
>         at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(RelationFieldStrategy.java:819)
>         at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(FieldMapping.java:860)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(PCPath.java:610)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(PCPath.java:589)
>         at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(PCPath.java:461)
>         at org.apache.openjpa.jdbc.kernel.exps.CompareEqualExpression.initialize(CompareEqualExpression.java:78)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(SelectConstructor.java:180)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(SelectConstructor.java:121)
>         at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:75)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:339)
>         at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:179)
>         at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:681)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:988)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
>         at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
>         at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
>         at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
> 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 RootEntity.)

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