[ 
https://issues.apache.org/jira/browse/OPENJPA-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673400#action_12673400
 ] 

B.J. Reed commented on OPENJPA-895:
-----------------------------------

I haven't figured the root cause yet, but one way around this is to move the 
fetch=FetchType.EAGER to the @ManyToOne annotation so your code would look like 
this.

    @OneToMany(mappedBy="oneSide",cascade=CascadeType.ALL)
    private Collection<Entity_1> manySide = new ArrayList<Entity_1>();
    @ManyToOne(fetch=FetchType.EAGER)
    private Entity_1 oneSide;

or you could leave off the fetch=FetchType.EAGER all together since that is the 
default for the @ManyToOne annotation.

I believe that FetchType should be valid on the @OneToMany annotation and I 
also get a different (similar, but different) exception when I specify 
FetchType.LAZY on the @OneToMany annotation.  Seems really bizarre to me that 
neither work when specified.

> InternalException when querying entity that participates in both inheritance 
> and relationships
> ----------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-895
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-895
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.1
>            Reporter: Dinkar Rao
>         Attachments: Entity_1.java, Entity_11.java, Entity_12.java, Test.java
>
>
> Can someone please take a look at this  ? This is with 1.2.x.
> I have Entity_1 that is extended by Entity_11 and Entity_12. Entity_1 has a 
> 1-m bidirectional relationship with itself. When I query Entity_1 I get the 
> following exception. Entities and Test are attached.
> Thanks
> Dinkar
> Trace:
> 13349  inheritance-test  TRACE  [main] openjpa.Query - Executing query: 
> select e from Entity_1 e
> Exception in thread "main" <openjpa-1.2.1-SNAPSHOT-runknown fatal general 
> error> org.apache.openjpa.persistence.PersistenceException: null
>       at 
> org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.join(RelationToManyInverseKeyFieldStrategy.java:98)
>       at 
> org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.join(RelationCollectionInverseKeyFieldStrategy.java:80)
>       at 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.selectEager(StoreCollectionFieldStrategy.java:214)
>       at 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.access$0(StoreCollectionFieldStrategy.java:194)
>       at 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy$1.select(StoreCollectionFieldStrategy.java:167)
>       at 
> org.apache.openjpa.jdbc.sql.LogicalUnion.select(LogicalUnion.java:297)
>       at 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.selectEagerParallel(StoreCollectionFieldStrategy.java:164)
>       at 
> org.apache.openjpa.jdbc.meta.FieldMapping.selectEagerParallel(FieldMapping.java:725)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.selectBaseMappings(JDBCStoreManager.java:1273)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.select(JDBCStoreManager.java:1104)
>       at org.apache.openjpa.jdbc.sql.SelectImpl.select(SelectImpl.java:1018)
>       at 
> org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.select(LogicalUnion.java:626)
>       at 
> org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.selectIdentifier(LogicalUnion.java:648)
>       at 
> org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.select(SelectConstructor.java:268)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.populateSelect(JDBCStoreQuery.java:279)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.access$0(JDBCStoreQuery.java:264)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreQuery$1.select(JDBCStoreQuery.java:253)
>       at 
> org.apache.openjpa.jdbc.sql.LogicalUnion.select(LogicalUnion.java:297)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.populateUnion(JDBCStoreQuery.java:249)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:197)
>       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.QueryImpl.execute(QueryImpl.java:771)
>       at 
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517)
>       at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
>       at 
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:293)
>       at Test.main(Test.java:39)

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

Reply via email to