openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-1711) missing optimization in JPQL queries that traverse the @Id field in an abstract unmapped entity
Date Tue, 29 Jun 2010 22:56:50 GMT
missing optimization in JPQL queries that traverse the @Id field in an abstract unmapped entity
-----------------------------------------------------------------------------------------------

                 Key: OPENJPA-1711
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1711
             Project: OpenJPA
          Issue Type: Bug
          Components: query
    Affects Versions: 2.0.0
            Reporter: Patrick Linskey
            Priority: Minor


I have a one-to-many relationship between a concrete class and an abstract class. The abstract
class is unmapped, and uses table-per-class inheritance, and there are a number of concrete
subclasses implementing that abstract class.

My object model is as follows: PermissionableEntity is the abstract entity, and PermissionEntryEntity
is a concrete entity with a field of type PermissionableEntity called 'permissionable' marked
@ManyToOne.

When I perform the following query, things work well:

    select p from PermissionEntryEntity p where p.member = ?1 and p.permissionable in (?2)

However, when I attempt to dereference the id field (which is marked @Id), I get an exception
[1]:

    select p from PermissionEntryEntity p where p.member = ?1 and p.permissionable.id in (?2)

The exception complains that OpenJPA can't dig into the abstract type since its fields are
not mapped to a common table. Which is fair enough, except that the id field is already resident
in the PermissionEntryEntity class and its corresponding table (which is why the first query
works fine). OpenJPA is smart enough to do this optimization, but is getting short-circuited
by the unjoinable check.

OpenJPA should at the least have an improved error message in the case where the field being
traversed to is part of the primary key; at best, it should handle this query automatically.


[1] The exception that I get when attempting to dig into the object:

<openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.persistence.ArgumentException:
Cannot join across "com.example.entity.PermissionEntryEntity.permissionable".  The related
type has unjoined subclasses.
        at org.apache.openjpa.jdbc.meta.strats.RelationStrategies.unjoinable(RelationStrategies.java:54)
        at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.joinRelation(RelationFieldStrategy.java:921)
        at org.apache.openjpa.jdbc.meta.FieldMapping.joinRelation(FieldMapping.java:983)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.joinRelation(PCPath.java:825)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.traverseField(PCPath.java:804)
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.initialize(PCPath.java:579)
        at org.apache.openjpa.jdbc.kernel.exps.InExpression.initialize(InExpression.java:70)
        at org.apache.openjpa.jdbc.kernel.exps.AndExpression.initialize(AndExpression.java:48)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.initialize(SelectConstructor.java:231)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.newSelect(SelectConstructor.java:172)
        at org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:87)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:349)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:187)
        at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:753)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1003)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
        at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
        at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)


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


Mime
View raw message