[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] NPE in DatabaseCall.translate() when page size is set

I'll provide the JPQL as well as SQL as soon as I get my office
machine. The "count" JPQL query actually returns the correct number of
rows, but when I change SELECT count(o) to SELECT o, and set first
result and max result size, the returning list is empty.

Just a question. I set setShouldOuterJoinSubclasses(true) only on the
base class. Should I set it on all subclasses as well?

serverSession.getClassDescriptor(org.mypackage.BaseClass.class).getInheritancePolicy()
                       .setShouldOuterJoinSubclasses(true);


On Mon, Sep 8, 2008 at 5:55 PM, James Sutherland <jamesssss@xxxxxxxxx> wrote:
>
> I can't think of any reason why the query results would be empty.
>
> Please include the JPQL query you are executing, and the SQL that
> EclipseLink is generating, and verify that the SQL returns the number of
> rows you are expecting.
>
>
>
> Mohsen Saboorian wrote:
>>
>> James,
>>
>> Thanks for your help.
>>
>> I've written the following code on my startup listener:
>>
>>       EntityManager em = PersistenceHelper.getEntityManager();
>>       EntityManagerImpl emi = (EntityManagerImpl) em.getDelegate();
>>       ServerSession serverSession = emi.getServerSession();
>>       DatabasePlatform plaf = serverSession.getPlatform();
>>
>>       ((OraclePlatform) plaf).setShouldUseRownumFiltering(false);
>>
>> serverSession.getClassDescriptor(org.mypackage.BaseClass.class).getInheritancePolicy()
>>                       .setShouldOuterJoinSubclasses(true);
>>
>> It resolved NPE problem, however the main issue is still there. When I
>> count(*) my data in BaseClass entity it returns correct value, however
>> when I want to get a page of the data, it returns an empty List.
>>
>> Thanks,
>> Mohsen.
>>
>> I've voted for the bug.
>>
>> On Mon, Aug 11, 2008 at 6:13 PM, James Sutherland <jamesssss@xxxxxxxxx>
>> wrote:
>>>
>>> Seems to be a bug with maxResults and inheritance.  This bug has already
>>> been
>>> logged see,
>>>
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=237743
>>>
>>> Please vote for the bug.
>>>
>>> As a wrokaround you can remove the maxResults, or call
>>> setShouldUseRownumFiltering(false) on your OraclePlatform.
>>>
>>> You could also set inheritance to be loaded through an outerjoin, which
>>> is
>>> probably the best solution anyway if you want to set a maxResults.  There
>>> is
>>> an InhertiancePolicy and query option setShouldOuterJoinSubclasses(true)
>>> that will configure this.  There is no annotation or query hint yet for
>>> this, so you may wish to log a bug for that.
>>>
>>>
>>>
>>>
>>> Mohsen Saboorian wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a base class (@Inheritance(strategy = InheritanceType.JOINED))
>>>> with a number of subclasses, all with string discriminator values.
>>>> When I rung the following query, I'm giving NPE exception: SELECT be
>>>> FROM BaseEntity be
>>>>
>>>> If I do not set q.setFirstResult(0).setMaxResults(x) (x can be any
>>>> number > 0, even if the size is more than query result), it works
>>>> good, but as I set some maxResults, it throws the following exception.
>>>>
>>>> [EL Warning]: 2008.08.09
>>>> 09:06:16.315--UnitOfWork(10250203)--java.lang.NullPointerException
>>>> java.lang.NullPointerException
>>>>       at
>>>> org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:925)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:203)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:190)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:261)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:594)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromConcreteTable(ExpressionQueryMechanism.java:2496)
>>>>       at
>>>> org.eclipse.persistence.descriptors.InheritancePolicy.selectAllRowUsingDefaultMultipleTableSubclassRead(InheritancePolicy.java:1265)
>>>>       at
>>>> org.eclipse.persistence.descriptors.InheritancePolicy.selectAllRowUsingMultipleTableSubclassRead(InheritancePolicy.java:1299)
>>>>       at
>>>> org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2461)
>>>>       at
>>>> org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:478)
>>>>       at
>>>> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:883)
>>>>       at
>>>> org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:666)
>>>>       at
>>>> org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:844)
>>>>       at
>>>> org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:456)
>>>>       at
>>>> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:906)
>>>>       at
>>>> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2588)
>>>>       at
>>>> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1178)
>>>>       at
>>>> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1162)
>>>>       at
>>>> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1136)
>>>>       at
>>>> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1118)
>>>>       at
>>>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:399)
>>>>       at
>>>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:517)
>>>>
>>>>
>>>> Thanks,
>>>> Mohsen.
>>
>>
>
>
> -----
> ---
> http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
> http://www.eclipse.org/eclipselink/
>  EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
> TopLink
> Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
> http://wiki.oracle.com/page/TopLink TopLink
> Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
> http://www.nabble.com/EclipseLink-f26430.html EclipseLink
> Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
> --
> View this message in context: http://www.nabble.com/NPE-in-DatabaseCall.translate%28%29-when-page-size-is-set-tp18902453p19373166.html
> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>