openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey (JIRA)" <>
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
             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

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

    select p from PermissionEntryEntity p where p.member = ?1 and 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(
        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.InExpression.initialize(
        at org.apache.openjpa.jdbc.kernel.exps.AndExpression.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(

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

View raw message