openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kai Feng Zhang (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-1802) Named query throws exception but normal query works
Date Tue, 21 Sep 2010 07:57:32 GMT

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

Kai Feng Zhang commented on OPENJPA-1802:
-----------------------------------------

The newly exception is:

The newly exception is :

10282 openjpa TRACE [http-8080-1] openjpa.jdbc.SQL - <t 24933899, conn 2742328> executing
prepstmnt 16757598 SELECT t0.oid, t0.version, t0.about_me, t0.age, t0.birthday, t1.oid, t1.version,
t1.build, t1.eye_color, t1.hair_color, t1.height, t1.weight, t0.children, t2.oid, t3.oid,
t4.oid, t2.version, t2.country, t2.formatted, t2.latitude, t2.locality, t2.longitude, t2.postal_code,
t2.primary_address, t2.region, t2.street_address, t2.type, t3.organization_id, t3.primary_organization,
t3.type, t4.person_id, t4.primary_address, t4.type, t0.display_name, t0.drinker, t0.ethnicity,
t0.fashion, t0.gender, t0.happiest_when, t0.humor, t0.job_interests, t0.living_arrangement,
t5.oid, t5.version, t5.additional_name, t5.family_name, t5.formatted, t5.given_name, t5.honorific_prefix,
t5.honorific_suffix, t0.network_presence, t0.nickname, t0.pets, t0.person_id, t0.political_views,
t0.preferredUsername, t0.relationship_status, t0.religion, t0.romance, t0.scared_of, t0.sexual_orientation,
t0.smoker, t0.status, t0.updated, t0.utc_offset FROM person t0 LEFT OUTER JOIN body_type t1
ON t0.body_type_id = t1.oid LEFT OUTER JOIN address t2 ON t0.address_id = t2.oid LEFT OUTER
JOIN name t5 ON t0.name_id = t5.oid LEFT OUTER JOIN organizational_address t3 ON t2.oid =
t3.oid LEFT OUTER JOIN person_address t4 ON t2.oid = t4.oid WHERE (t0.person_id = ?) [params=?]
10282 openjpa TRACE [http-8080-1] openjpa.jdbc.SQL - <t 24933899, conn 2742328> [0 ms]
spent
10313 openjpa TRACE [http-8080-1] openjpa.jdbc.SQL - <t 24933899, conn 2742328> executing
prepstmnt 15748500 SELECT t0.oid FROM email t0 WHERE t0.person_id = ? [params=?]
10313 openjpa TRACE [http-8080-1] openjpa.jdbc.SQL - <t 24933899, conn 2742328> [0 ms]
spent
2010-9-21 15:50:55 org.apache.shindig.protocol.ApiServlet responseItemFromException
警告: Returning a response error as result of an exception
<openjpa-2.0.1-r422266:989424 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
org.apache.openjpa.util.Id
FailedObject: select p from PersonDb p where p.pid = :pid [java.lang.String]
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:986)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:885)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1030)
at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2344)
at org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:90)
at org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldStrategy.java:76)
at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:556)
at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:934)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:691)
at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:117)
at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3047)
at org.apache.openjpa.kernel.StateManagerImpl.load(StateManagerImpl.java:451)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:973)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:885)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1030)
at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2344)
at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
at org.apache.openjpa.lib.rop.RangeResultObjectProvider.getResultObject(RangeResultObjectProvider.java:80)
at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1246)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
at org.apache.shindig.social.opensocial.jpa.spi.PersonServiceDb.getPerson(PersonServiceDb.java:169)
at org.apache.shindig.social.opensocial.service.PersonHandler.get(PersonHandler.java:83)
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:592)
at org.apache.shindig.protocol.DefaultHandlerRegistry$MethodCaller.call(DefaultHandlerRegistry.java:483)
at org.apache.shindig.protocol.DefaultHandlerRegistry$RestInvocationHandler.execute(DefaultHandlerRegistry.java:369)
at org.apache.shindig.protocol.DefaultHandlerRegistry$RestInvocationWrapper.execute(DefaultHandlerRegistry.java:394)
at org.apache.shindig.protocol.DataServiceServlet.handleSingleRequest(DataServiceServlet.java:162)
at org.apache.shindig.protocol.DataServiceServlet.executeRequest(DataServiceServlet.java:111)
at org.apache.shindig.protocol.DataServiceServlet.doGet(DataServiceServlet.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.shindig.auth.AuthenticationServletFilter.callChain(AuthenticationServletFilter.java:125)
at org.apache.shindig.auth.AuthenticationServletFilter.doFilter(AuthenticationServletFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: org.apache.openjpa.util.Id
at org.apache.shindig.social.opensocial.jpa.ListFieldDb.pcCopyKeyFieldsFromObjectId(ListFieldDb.java)
at org.apache.shindig.social.opensocial.jpa.EmailDb.pcNewInstance(EmailDb.java)
at org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:117)
at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:322)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:396)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:322)
at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1005)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:963)
... 59 more 

> Named query throws exception but normal query works
> ---------------------------------------------------
>
>                 Key: OPENJPA-1802
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1802
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 2.0.1
>            Reporter: Kai Feng Zhang
>         Attachments: PersonDb.java
>
>
> I have a named query on PersonDb entity,
> @NamedQuery(name = PersonDb.FINDBY_PERSONID, query = "select p from PersonDb p where
p.id = :id "),
> Then I use following code to get person entity:
>     Query q = entiyManager.createNamedQuery(PersonDb.FINDBY_PERSONID);
>     // Query q = entiyManager.createQuery("select p from PersonDb p where p.id = :id");
>     q.setParameter("id", uid);
>     q.setFirstResult(0);
>     q.setMaxResults(1);
>     List<?> plist = q.getResultList();
>     Person person = null;
>     if (plist != null && !plist.isEmpty()) {
>       person = (Person) plist.get(0);
>     }
> There is exception then. But if I use createQuery() as the commented line, it works,
and person is got from table.
> The exception from name query is:
> <openjpa-2.0.1-r422266:989424 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
org.apache.openjpa.util.Id cannot be cast to org.apache.openjpa.util.LongId
> FailedObject: select p from PersonDb p where p.id = :id [java.lang.String]
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:986)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:885)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1030)
> 	at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
> 	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2344)
> 	at org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:90)
> 	at org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldStrategy.java:76)
> 	at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:556)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:934)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:691)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:117)
> 	at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3047)
> 	at org.apache.openjpa.kernel.StateManagerImpl.load(StateManagerImpl.java:451)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:973)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:885)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1030)
> 	at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
> 	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2344)
> 	at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
> 	at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
> 	at org.apache.openjpa.lib.rop.RangeResultObjectProvider.getResultObject(RangeResultObjectProvider.java:80)
> 	at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
> 	at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1246)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:861)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:792)
> 	at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
> 	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:288)
> 	at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
> 	at org.apache.shindig.social.opensocial.jpa.test.PersonDbToJsonTest.getJohnDoe(PersonDbToJsonTest.java:125)
> 	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.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	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:236)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
> 	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)
> Caused by: java.lang.ClassCastException: org.apache.openjpa.util.Id cannot be cast to
org.apache.openjpa.util.LongId
> 	at org.apache.shindig.social.opensocial.jpa.ListFieldDb.pcCopyKeyFieldsFromObjectId(ListFieldDb.java)
> 	at org.apache.shindig.social.opensocial.jpa.EmailDb.pcNewInstance(EmailDb.java)
> 	at org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:117)
> 	at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:322)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:396)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:322)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
> 	at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1005)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:963)
> 	... 54 more

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


Mime
View raw message