Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink-6069 when using BatchFetch and Inheritance
EclipseLink-6069 when using BatchFetch and Inheritance [message #1067695] Wed, 10 July 2013 07:36 Go to next message
Philip Mair is currently offline Philip Mair
Messages: 5
Registered: July 2013
Junior Member
Can't read Entity with OneToOne Mapping together with BatchFetch.

Without BatchFetch the hole thing works, but every OneToOne Entity will be fetched with 1 til 3 selects ( for each subclass of TestEntityExtension ) which is extremely slow.


I have following Sample with 4 Enties:

TestEntity.java
package tests;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.TableGenerator;

import org.eclipse.persistence.annotations.BatchFetch;
import org.eclipse.persistence.annotations.BatchFetchType;

@Entity(name="tests")
public class TestEntity {

    @Id
    
    @TableGenerator(
            name="TestEntityIdGenerator", 
            table="jpa_hilo",
            pkColumnName="name",
            valueColumnName="hilo",
            pkColumnValue="TestEntity",
            allocationSize=127
    )
    @GeneratedValue( strategy=GenerationType.TABLE, generator="TestEntityIdGenerator" )
    public long id;
    
    @OneToOne(optional=true, fetch=FetchType.EAGER, cascade={ CascadeType.ALL } )
    //@BatchFetch(value=BatchFetchType.IN,size=1024)
    @JoinColumn(name="extension_id", nullable=true)
    public TestEntityExtension extension;
    
    public TestEntity() 
    {
        
    }
}


TestEntityExtension.java
package tests;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.TableGenerator;

@Entity(name="tests_extensions")
@Inheritance( strategy=InheritanceType.TABLE_PER_CLASS )
public class TestEntityExtension 
{
    @Id
    @TableGenerator(
            name="TestEntityExtensionIdGenerator", 
            table="jpa_hilo",
            pkColumnName="name",
            valueColumnName="hilo",
            pkColumnValue="TestEntityExtension"
    )
    @GeneratedValue( strategy=GenerationType.TABLE, generator="TestEntityExtensionIdGenerator" )
    public long id;
}


TestEntityExtensionA.java
package tests;
import javax.persistence.Entity;

@Entity(name="tests_extensions_a")
public class TestEntityExtensionA extends TestEntityExtension {

    public TestEntityExtensionA() {
    }

}


TestEntityExtensionB.java
package tests;
import javax.persistence.Entity;

@Entity(name="tests_extensions_b")
public class TestEntityExtensionB extends TestEntityExtension {

    public TestEntityExtensionB() {
    }

}


With following Sample Code:
package tests;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;

public class BugDemo {

    public static void main(String[] args) throws Exception {

        ...
        
        
        final EntityManager em = emf.createEntityManager();
        
        em.getTransaction().begin();
        
        for( int i=0; i<1000; i++ )
        {
            TestEntity test = new TestEntity();
            test.extension = ( new TestEntityExtension() );
            em.persist( test );
            
            TestEntity test2 = new TestEntity();
            test2.extension = ( new TestEntityExtensionA() );
            em.persist( test2 );
    
            TestEntity test3 = new TestEntity();
            test3.extension = ( new TestEntityExtensionB() );
            em.persist( test3 );
        }
        
        em.getTransaction().commit();
        
        em.clear();
        em.getEntityManagerFactory().getCache().evictAll();
        
        
        final CriteriaBuilder cb = em.getCriteriaBuilder();
        final CriteriaQuery<TestEntity> cq = cb.createQuery( TestEntity.class );
        
        List<TestEntity> result = 
                em.createQuery( cq )
                /*  
                    .setHint( QueryHints.BATCH, "e.extension" )
                    .setHint( QueryHints.BATCH_SIZE, Integer.valueOf( 1024 ) )
                    .setHint( QueryHints.BATCH_TYPE, "IN" )
                */
                .getResultList();
        
        for( TestEntity e : result )
        {
            System.out.println( "Test Entity: " + e.id + " / " + ( e.extension == null ? "null" : e.extension.getClass().getName() ) );
        }
     
    }

}


The creation of the TestEntity with TestEntityExtension, TestEntityExtensionA or TestEntityExtenstionB works fine.

Without setting @BatchFetch to TestEntity#extension or setHint( QueryHints.BATCH, "e.extension" ) the loading works, but is very slow.

This is caused by fetching every TextEntityExtension by a single select per Object for each sub-class:

[EL Fine]: sql: 2013-07-10 10:45:12.734--ServerSession(735164739)--Connection(812495793)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [28]
[EL Fine]: sql: 2013-07-10 10:45:12.739--ServerSession(735164739)--Connection(812495793)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [28]
[EL Fine]: sql: 2013-07-10 10:45:12.739--ServerSession(735164739)--Connection(812495793)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [28]


Setting the BatchFetch to IN or using the query hint causes following Exception:

[EL Fine]: sql: 2013-07-10 10:56:26.927--ServerSession(846374761)--Connection(28273754)--SELECT ID, extension_id FROM TESTS
[EL Fine]: sql: 2013-07-10 10:56:26.932--ServerSession(846374761)--Connection(28273754)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))
	bind => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
[EL Warning]: 2013-07-10 10:56:26.937--ServerSession(846374761)--Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:479)
	at tests.BugDemo.main(BugDemo.java:59)
Caused by: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
	at org.eclipse.persistence.exceptions.QueryException.invalidTableForFieldInExpression(QueryException.java:743)
	at org.eclipse.persistence.internal.expressions.FieldExpression.validateNode(FieldExpression.java:281)
	at org.eclipse.persistence.expressions.Expression.normalize(Expression.java:3259)
	at org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:369)
	at org.eclipse.persistence.internal.expressions.FieldExpression.normalize(FieldExpression.java:208)
	at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:219)
	at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:547)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1402)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:549)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1708)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:785)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:716)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:888)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjects(InterfacePolicy.java:231)
	at org.eclipse.persistence.descriptors.TablePerClassPolicy.selectAllObjects(TablePerClassPolicy.java:213)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjectsUsingMultipleTableSubclassRead(InterfacePolicy.java:249)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:512)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.mappings.OneToOneMapping.executeBatchQuery(OneToOneMapping.java:794)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:643)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:297)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:275)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2115)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.refreshObjectIfRequired(ObjectBuilder.java:3957)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:893)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:777)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:730)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:629)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:587)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:571)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:782)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:848)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:490)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:468)
	... 1 more


The first in Statement for TestEntityExtension is executed correctly, but EclipseLink generates a wrong statement for the subclasses TestEntityExtensionA and fails with the given Exception.

[Updated on: Thu, 11 July 2013 09:24]

Report message to a moderator

Re: EclipseLink-6069 when using BatchFetch and Inheritance [message #1067833 is a reply to message #1067695] Wed, 10 July 2013 19:19 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1026
Registered: July 2009
Senior Member
OneToOne to a root entity using table per class doesn't allow for constraints since the foreign key can point to any of the 3 tables involved in the hierarchy. Any reason you don't want to use joined or single table inheritance?

You should file a bug and try using the default batch read setting instead of BatchFetchType.IN, as table per class might not have support for different BatchFetchTypes.
Re: EclipseLink-6069 when using BatchFetch and Inheritance [message #1067920 is a reply to message #1067833] Thu, 11 July 2013 09:07 Go to previous messageGo to next message
Philip Mair is currently offline Philip Mair
Messages: 5
Registered: July 2013
Junior Member
You're right with the Foreign Key, this is just a Sample. I have the same Issue with ManyToOne Mapping.

ManyToOne / OneToOne without BatchFetch configuration works, but is extremly slow with much data, cause every sub-entity is fetched by single select:
[EL Fine]: sql: 2013-07-11 11:02:48.606--ServerSession(718725127)--Connection(408848189)--SELECT ID, extension_id FROM TESTS
[EL Fine]: sql: 2013-07-11 11:02:48.606--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [1]
[EL Fine]: sql: 2013-07-11 11:02:48.606--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [1]
[EL Fine]: sql: 2013-07-11 11:02:48.606--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [1]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [2]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [3]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [3]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [4]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [4]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [4]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [5]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [6]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [6]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [7]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [7]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [7]
[EL Fine]: sql: 2013-07-11 11:02:48.611--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [8]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [9]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [9]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [10]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [10]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [10]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [11]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [12]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [12]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [13]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [13]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [13]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [14]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [15]
[EL Fine]: sql: 2013-07-11 11:02:48.616--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [15]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [16]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [16]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [16]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [17]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [18]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [18]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [19]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [19]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [19]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [20]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [21]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [21]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [22]
[EL Fine]: sql: 2013-07-11 11:02:48.621--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [22]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [22]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [23]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [24]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [24]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [25]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [25]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [25]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [26]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [27]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [27]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [28]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [28]
[EL Fine]: sql: 2013-07-11 11:02:48.626--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS WHERE (ID = ?)
	bind => [28]
[EL Fine]: sql: 2013-07-11 11:02:48.631--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [29]
[EL Fine]: sql: 2013-07-11 11:02:48.631--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_A WHERE (ID = ?)
	bind => [30]
[EL Fine]: sql: 2013-07-11 11:02:48.631--ServerSession(718725127)--Connection(408848189)--SELECT ID FROM TESTS_EXTENSIONS_B WHERE (ID = ?)
	bind => [30]


ManyToOne with BatchFetchType.EXISTS causes:
[EL Fine]: sql: 2013-07-11 10:59:15.655--ServerSession(1950438601)--Connection(506627525)--SELECT ID, extension_id FROM TESTS
[EL Fine]: sql: 2013-07-11 10:59:15.655--ServerSession(1950438601)--Connection(506627525)--SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0 WHERE EXISTS (SELECT t1.ID FROM TESTS t1 WHERE (t0.ID = t1.extension_id)) 
[EL Warning]: 2013-07-11 10:59:15.66--ServerSession(1950438601)--Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0 WHERE EXISTS (SELECT t1.ID FROM TESTS t1 WHERE (t0.ID = t1.extension_id)) ")
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0 WHERE EXISTS (SELECT t1.ID FROM TESTS t1 WHERE (t0.ID = t1.extension_id)) ")
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:479)
	at tests.BugDemo.main(BugDemo.java:61)
Caused by: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0 WHERE EXISTS (SELECT t1.ID FROM TESTS t1 WHERE (t0.ID = t1.extension_id)) ")
	at org.eclipse.persistence.exceptions.QueryException.invalidTableForFieldInExpression(QueryException.java:743)
	at org.eclipse.persistence.internal.expressions.FieldExpression.validateNode(FieldExpression.java:281)
	at org.eclipse.persistence.expressions.Expression.normalize(Expression.java:3259)
	at org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:369)
	at org.eclipse.persistence.internal.expressions.FieldExpression.normalize(FieldExpression.java:208)
	at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:219)
	at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:547)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1402)
	at org.eclipse.persistence.internal.expressions.SubSelectExpression.normalizeSubSelect(SubSelectExpression.java:205)
	at org.eclipse.persistence.internal.expressions.ExpressionNormalizer.normalizeSubSelects(ExpressionNormalizer.java:105)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1476)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:549)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1708)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:785)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:716)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:888)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjects(InterfacePolicy.java:231)
	at org.eclipse.persistence.descriptors.TablePerClassPolicy.selectAllObjects(TablePerClassPolicy.java:213)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjectsUsingMultipleTableSubclassRead(InterfacePolicy.java:249)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:512)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.mappings.OneToOneMapping.executeBatchQuery(OneToOneMapping.java:794)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:643)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:297)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:275)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2115)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.refreshObjectIfRequired(ObjectBuilder.java:3957)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:893)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:777)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:730)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:629)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:587)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:571)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:782)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:848)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:490)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:468)
	... 1 more


ManyToOne with BatchFetchType.IN causes:
[EL Fine]: sql: 2013-07-11 11:00:27.307--ServerSession(1073559455)--Connection(753864924)--SELECT ID, extension_id FROM TESTS
[EL Fine]: sql: 2013-07-11 11:00:27.312--ServerSession(1073559455)--Connection(753864924)--SELECT DISTINCT ID FROM TESTS_EXTENSIONS WHERE (ID IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))
	bind => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
[EL Warning]: 2013-07-11 11:00:27.317--ServerSession(1073559455)--Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:479)
	at tests.BugDemo.main(BugDemo.java:61)
Caused by: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT ID FROM TESTS_EXTENSIONS WHERE (ID IN ?)")
	at org.eclipse.persistence.exceptions.QueryException.invalidTableForFieldInExpression(QueryException.java:743)
	at org.eclipse.persistence.internal.expressions.FieldExpression.validateNode(FieldExpression.java:281)
	at org.eclipse.persistence.expressions.Expression.normalize(Expression.java:3259)
	at org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:369)
	at org.eclipse.persistence.internal.expressions.FieldExpression.normalize(FieldExpression.java:208)
	at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:219)
	at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:547)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1402)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:549)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1708)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:785)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:716)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:888)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjects(InterfacePolicy.java:231)
	at org.eclipse.persistence.descriptors.TablePerClassPolicy.selectAllObjects(TablePerClassPolicy.java:213)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjectsUsingMultipleTableSubclassRead(InterfacePolicy.java:249)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:512)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.mappings.OneToOneMapping.executeBatchQuery(OneToOneMapping.java:794)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:643)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:297)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:275)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2115)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.refreshObjectIfRequired(ObjectBuilder.java:3957)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:893)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:777)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:730)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:629)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:587)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:571)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:782)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:848)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:490)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:468)
	... 1 more


ManyToOne with BatchFetchType.JOIN causes:
[EL Fine]: sql: 2013-07-11 11:01:05.883--ServerSession(1138670684)--Connection(559413587)--SELECT ID, extension_id FROM TESTS
[EL Fine]: sql: 2013-07-11 11:01:05.883--ServerSession(1138670684)--Connection(559413587)--SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0, TESTS t1 WHERE (t0.ID = t1.extension_id)
[EL Warning]: 2013-07-11 11:01:05.888--ServerSession(1138670684)--Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0, TESTS t1 WHERE (t0.ID = t1.extension_id)")
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0, TESTS t1 WHERE (t0.ID = t1.extension_id)")
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:479)
	at tests.BugDemo.main(BugDemo.java:61)
Caused by: Exception [EclipseLink-6069] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
Exception Description: The field [TESTS_EXTENSIONS.ID] in this expression has an invalid table in this context.
Query: ReadAllQuery(name="extension" referenceClass=TestEntityExtensionA sql="SELECT DISTINCT t0.ID FROM TESTS_EXTENSIONS t0, TESTS t1 WHERE (t0.ID = t1.extension_id)")
	at org.eclipse.persistence.exceptions.QueryException.invalidTableForFieldInExpression(QueryException.java:743)
	at org.eclipse.persistence.internal.expressions.FieldExpression.validateNode(FieldExpression.java:281)
	at org.eclipse.persistence.expressions.Expression.normalize(Expression.java:3259)
	at org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:369)
	at org.eclipse.persistence.internal.expressions.FieldExpression.normalize(FieldExpression.java:208)
	at org.eclipse.persistence.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:219)
	at org.eclipse.persistence.internal.expressions.RelationExpression.normalize(RelationExpression.java:547)
	at org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1402)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildNormalSelectStatement(ExpressionQueryMechanism.java:549)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareSelectAllRows(ExpressionQueryMechanism.java:1708)
	at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:785)
	at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:716)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:661)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:888)
	at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjects(InterfacePolicy.java:231)
	at org.eclipse.persistence.descriptors.TablePerClassPolicy.selectAllObjects(TablePerClassPolicy.java:213)
	at org.eclipse.persistence.descriptors.InterfacePolicy.selectAllObjectsUsingMultipleTableSubclassRead(InterfacePolicy.java:249)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:512)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.mappings.OneToOneMapping.executeBatchQuery(OneToOneMapping.java:794)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:643)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:297)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:275)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2115)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:455)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.refreshObjectIfRequired(ObjectBuilder.java:3957)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:893)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:777)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:730)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:629)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:587)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:571)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:782)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:848)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:490)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:468)
	... 1 more



I have tested this Mapping with Hibernate and it works like i expected. But in Hibernate i can define a default-batch-fetch-size (f.e. 1024).



Target of this Mapping is to provide a customer based extension of a common class without changing the common class ...

Any suggestions?
Re: EclipseLink-6069 when using BatchFetch and Inheritance [message #1069739 is a reply to message #1067920] Tue, 16 July 2013 13:20 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

In general I would recommend using SINGLE_TABLE or JOINED inheritance instead of TABLE_PER_CLASS. TABLE_PER_CLASS has many limitations.

The issue with batch fetching and TABLE_PER_CLASS inheritance was recently fixed in the 2.6 development stream,

https://twitter.com/j_b_sutherland/status/354656557872586753


James : Wiki : Book : Blog : Twitter
Re: EclipseLink-6069 when using BatchFetch and Inheritance [message #1070102 is a reply to message #1069739] Wed, 17 July 2013 08:40 Go to previous message
Philip Mair is currently offline Philip Mair
Messages: 5
Registered: July 2013
Junior Member
Thanks for the information!

With the nightly 2.6 EclipseLink the whole thing worked!

Can you explain the limitations of TABLE_PER_CLASS ?

Thanks

[Updated on: Wed, 17 July 2013 08:44]

Report message to a moderator

Previous Topic:How to use datepart function in expression
Next Topic:ERROR - Predicate "OR" is NULL --solved
Goto Forum:
  


Current Time: Wed Oct 01 22:22:23 GMT 2014

Powered by FUDForum. Page generated in 0.03911 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software