Cannot query by primary key column #97

Closed
dstrawson opened this Issue Aug 2, 2012 · 5 comments

Comments

Projects
None yet
3 participants

I want to use the Id column in a query, for example:

SELECT t FROM Thing t WHERE t.id = :idParam

(id is type Long, @id in the entity definition class)

(and before you ask, I know that there is a em.find() method of course, the above is a simplified version of a more complex query)

Kundera throws the following exception:

java.lang.NullPointerException
at com.impetus.kundera.metadata.model.EntityMetadata.getFieldType(EntityMetadata.java:847)
at com.impetus.kundera.query.KunderaQuery.filterJPAParameterInfo(KunderaQuery.java:527)
at com.impetus.kundera.query.KunderaQuery.onTypedParameter(KunderaQuery.java:489)
at com.impetus.kundera.query.KunderaQuery.initFilter(KunderaQuery.java:456)
at com.impetus.kundera.query.KunderaQuery.postParsingInit(KunderaQuery.java:331)
at com.impetus.kundera.query.QueryResolver.getQueryImplementation(QueryResolver.java:75)
at com.impetus.kundera.persistence.PersistenceDelegator.createQuery(PersistenceDelegator.java:550)
at com.impetus.kundera.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:337)
at example.Test1.testQueryByPK(Test1.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I've updated dstrawson/kunderatest with this as a test case and pushed back to github.

Collaborator

mevivs commented Aug 2, 2012

Hi Daniel,
As query support over Cassandra works over Secondary index, Secondary indexes can be done over columns only!
Hence we have limited Kundera not to support. But team is working to convert such invocations in to "findById()" implicitly.

2.0.8 will have this change in. I would request you to let this open.

Thanks,
Vivek

kkmishra was assigned Aug 2, 2012

I guess that this won't work as a range query, eg id>5 AND id<50 (with OPP this should work ok in CQL I think for example).

Collaborator

mevivs commented Aug 2, 2012

Yes. With OPP it should work with Kundera as well.

Collaborator

mevivs commented Jan 23, 2013

Working fine. Closing it

mevivs closed this Jan 23, 2013

kkmishra was unassigned by dstrawson Feb 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment