0 Replies Latest reply on Jun 6, 2014 6:27 PM by 2688772

    Coherence : Grid Read Config. NPE on non-primary key queries

    2688772

      Hello,

       

      I've a JPA application which I'm trying to integrate with Coherence in a Grid Cache config. I'm using Coherence, Toplink Grid and Eclipselink jars provided with the 12c distribution.

       

      I'm getting a NPE when trying to execute a non-primary select query. Primary key queries are fine.

       

      Here are my 2 concerned entities-

       

      @Entity

      @Portable

      @Table(name = "DMA_POSTAL_CD")

      @Customizer(GridCacheCustomizer.class)

      @NamedQueries({ @NamedQuery(name = "PostalCode.findAllPostalCodes", query = "select p from PostalCode p") })

      public class PostalCode implements Serializable {

       

        private static final long serialVersionUID = 6148222846049677265L;

       

        @Id

        @Column(name = "POSTAL_CD")

        @PortableProperty(0)

        private String id;

       

        @Column(name = "DMA_KEY_VALUE")

        @PortableProperty(1)

        private String dmaKey;

       

        @OneToMany(fetch = FetchType.EAGER)

        @JoinColumn(name = "POSTAL_CD")

        @JoinFetch(JoinFetchType.INNER)

        @BatchFetch(value = BatchFetchType.JOIN)

        @PortableProperty(2)

        private List<Zone> zones;

       

      @Entity

      @Portable

      @Table(name = "ORG_ZONE")

      @Customizer(GridCacheCustomizer.class)

      public class Zone implements Serializable {

       

        private static final long serialVersionUID = 3944426161423505205L;

       

        @Id

        @Column(name = "ORG_ZONE_ID")

        @PortableProperty(0)

        private Long id;

       

        @OneToOne(fetch = FetchType.EAGER)

        @JoinColumn(name = "ORG_PTY_ID", insertable = false, updatable = false)

        @JoinFetch(JoinFetchType.INNER)

        @PortableProperty(2)

        private Org org;

       

        @OneToOne(fetch = FetchType.EAGER)

        @JoinColumn(name = "ZONE_NM_ID", insertable = false, updatable = false)

        @JoinFetch(JoinFetchType.INNER)

        @PortableProperty(3)

        private ZoneName zoneName;

       

      I'm able to connect my client application (Spring Data based Apache Wink Service) to the Weblogic Coherence cluster and join my distributed cache service defined in a GAR file.

       

      Here is the exception I see when executing a non-primary key query. The same query works fine when using eclipselink without the GridCacheCustomizer. Meaning not using Coherence distributed cache at all.

       

      Also, since my primary key queries are executed fine and put into cache, I don't think its a mapping issue.

       

      Any help is appreciated.

       

      [STDOUT] [EL Finer]: connection: 2014-06-06 13:11:44.104--ServerSession(1264930634)--Thread(Thread[qtp44523698-15,5,main])--client acquired: 1276996678

      [STDOUT] [EL Finer]: transaction: 2014-06-06 13:11:44.105--ClientSession(1276996678)--Thread(Thread[qtp44523698-15,5,main])--acquire unit of work: 531599028

      [STDOUT] [EL Finest]: query: 2014-06-06 13:11:44.105--UnitOfWork(531599028)--Thread(Thread[qtp44523698-15,5,main])--Execute query ReadAllQuery(referenceClass=PostalCode )

      [STDOUT] [EL Finest]: connection: 2014-06-06 13:11:44.108--ServerSession(1264930634)--Connection(965282394)--Thread(Thread[qtp44523698-15,5,main])--Connection acquired from connection pool [read].

      [STDOUT] [EL Finest]: connection: 2014-06-06 13:11:44.109--ServerSession(1264930634)--Thread(Thread[qtp44523698-15,5,main])--reconnecting to external connection pool

      [STDOUT] [EL Fine]: sql: 2014-06-06 13:11:44.109--ServerSession(1264930634)--Connection(703436204)--Thread(Thread[qtp44523698-15,5,main])--SELECT t1.POSTAL_CD, t1.DMA_KEY_VALUE, t0.ORG_ZONE_ID, t0.POSTAL_CD, t0.ORG_PTY_ID, t0.ZONE_NM_ID FROM ORG_ZONE t0, DMA_POSTAL_CD t1 WHERE ((t1.DMA_KEY_VALUE = ?) AND (t0.POSTAL_CD = t1.POSTAL_CD))

      [STDOUT] bind => [chicago]

      [STDOUT] [EL Finest]: connection: 2014-06-06 13:11:45.954--ServerSession(1264930634)--Connection(965282394)--Thread(Thread[qtp44523698-15,5,main])--Connection released to connection pool [read].

      [STDOUT] [EL Warning]: 2014-06-06 13:11:45.958--UnitOfWork(531599028)--Thread(Thread[qtp44523698-15,5,main])--java.lang.NullPointerException

      [STDOUT] at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromRow(ObjectBuilder.java:2570)

      [STDOUT] at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:788)

      [STDOUT] at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:434)

      [STDOUT] at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1150)

      [STDOUT] at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:852)

      [STDOUT] at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1109)

      [STDOUT] at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:393)

      [STDOUT] at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1197)

      [STDOUT] at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2879)

      [STDOUT] at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1607)

      [STDOUT] at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1589)

      [STDOUT] at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1554)

      [STDOUT] at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:231)

      [STDOUT] at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:411)

      [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      [STDOUT] at java.lang.reflect.Method.invoke(Method.java:601)

      [STDOUT] at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:311)

      [STDOUT] at com.sun.proxy.$Proxy25.getResultList(Unknown Source)

      [STDOUT] at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:96)

      [STDOUT] at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:61)

      [STDOUT] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:96)

      [STDOUT] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:86)

      [STDOUT] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337)

      [STDOUT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      [STDOUT] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)

      [STDOUT] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)

      [STDOUT] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)

      [STDOUT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      [STDOUT] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)

      [STDOUT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      [STDOUT] at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:105)

      [STDOUT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      [STDOUT] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)

      [STDOUT] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

      [STDOUT] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

      [STDOUT] at com.sun.proxy.$Proxy26.findAllPostalCodesByDmaKey(Unknown Source)

      .