Re: Named query created in error
On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: Here it is: [2007-04-18 18:37:07,937] INFO ca.BidSpec.testing.emall.UserFactoryTest Began transaction (1): transaction manager [EMAIL PROTECTED]; default rollback = true 25547 WARN [main] openjpa.MetaData - Found duplicate query PersonFXLastFirst in class ca.BidSpec.emall.user.Person. Ignoring. 33360 TRACE [main] openjpa.jdbc.SQL - t 19399109, conn 28442012 executing prepstmnt 23861335 SELECT t0.id, t0.lastUpdated, t0.active, t0.activeFrom, t0.activeUntil, t0.created, t0.displayName, t0.firstName, t0.lastLogin, t0.lastName, t0.locale, t0.loginName, t0.middleName, t2.id, t2.lastUpdated, t2.description, t3.id, t3.lastUpdated, t3.description, t2.value, t4.id, t4.lastUpdated, t4.description, t4.categoryTypeFK, t4.value, t5.id, t5.lastUpdated, t5.created, t5.description, t5.displayName, t5.name, t6.id, t6.lastUpdated, t6.description, t6.categoryTypeFK, t6.value, t0.title, t0.visible FROM bidspec.person t0 INNER JOIN bidspec.manufacturer t1 ON t0.manufacturerFK = t1.id LEFT OUTER JOIN bidspec.category t2 ON t0.roleFK = t2.id LEFT OUTER JOIN bidspec.category t4 ON t0.salutationFK = t4.id LEFT OUTER JOIN bidspec.manufacturer t5 ON t0.manufacturerFK = t5.id LEFT OUTER JOIN bidspec.categorytype t3 ON t2.categoryTypeFK = t3.id LEFT OUTER JOIN bidspec.category t6 ON t5.typeFK = t6.id WHERE (UPPER(t1.name) = ? AND UPPER(t0.loginName) = ?) ORDER BY t0.lastName ASC, t0.firstName ASC [params=(String) BIDSPEC, (String) PMORAN] 33360 TRACE [main] openjpa.jdbc.SQL - t 19399109, conn 28442012 [0 ms] spent 0|false|0.9.6-incubating org.apache.openjpa.persistence.PersistenceException: null at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:851) What database do you use? Show the line where the query is created and the parameters are passed. How do the persistence.xml look like? Do you happen to use orm.xml-like files? What Spring version is used? Show the Person entity (ca.BidSpec.emall.user.Person). I wonder why you only get the following warning message 25547 WARN [main] openjpa.MetaData - Found duplicate query PersonFXLastFirst in class ca.BidSpec.emall.user.Person. Ignoring. , but there's no corresponding warning message for the entity behind p.store (possibly package.Store). Do you happen to *not* annotate the Store class with @Entity? Could you attach the whole TRACE output of OpenJPA execution? Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
RE: Named query created in error
(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69 ) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ac cess$001(AbstractAnnotationAwareTransactionalTests.java:47) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1. run(AbstractAnnotationAwareTransactionalTests.java:115) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nTest(AbstractAnnotationAwareTransactionalTests.java:180) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nTestTimed(AbstractAnnotationAwareTransactionalTests.java:153) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nBare(AbstractAnnotationAwareTransactionalTests.java:111) at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:159) at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:239) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) at org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:29) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java :42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunne r.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen ce.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner .java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner .java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java :386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav a:196) Caused by: java.lang.NullPointerException at java.util.Locale.toLowerCase(Locale.java:1060) at java.util.Locale.convertOldISOCodes(Locale.java:1083) at java.util.Locale.init(Locale.java:272) at java.util.Locale.init(Locale.java:302) at ca.BidSpec.emall.user.Person.pcsetLocale(Person.java:375) at ca.BidSpec.emall.user.Person.pcClearFields(Person.java) at ca.BidSpec.emall.user.Person.pcNewInstance(Person.java) at org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:117) at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:247) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager .java:327) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java :252) at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManag er.java:108) at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:54) at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:870) at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:828) ... 69 more This is all I get -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacek Laskowski Sent: April 19, 2007 2:18 AM To: open-jpa-dev@incubator.apache.org Subject: Re: Named query created in error On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: Here it is: [2007-04-18 18:37:07,937] INFO ca.BidSpec.testing.emall.UserFactoryTest Began transaction (1): transaction manager [EMAIL PROTECTED]; default rollback = true 25547 WARN [main] openjpa.MetaData - Found duplicate query PersonFXLastFirst in class ca.BidSpec.emall.user.Person. Ignoring. 33360 TRACE [main] openjpa.jdbc.SQL - t 19399109, conn 28442012 executing prepstmnt 23861335 SELECT t0.id, t0.lastUpdated, t0.active, t0.activeFrom, t0.activeUntil, t0.created, t0.displayName, t0.firstName, t0.lastLogin, t0.lastName, t0.locale, t0.loginName, t0.middleName, t2.id, t2.lastUpdated, t2.description, t3.id, t3.lastUpdated, t3.description, t2.value, t4.id, t4.lastUpdated, t4.description, t4.categoryTypeFK, t4.value, t5.id, t5.lastUpdated, t5.created, t5.description, t5.displayName, t5.name, t6.id, t6.lastUpdated, t6.description, t6.categoryTypeFK, t6.value, t0.title, t0.visible FROM bidspec.person
Re: Named query created in error
On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: I am using MySQL version 5 The stack trace only shows because have wrapped this in a try/catch. The exception becomes NPE due to OpenJPA trying to make a Person object form more than just Person Object data, it fails to do this (silently) and the object it was to be assigned to become an NP Could you make sure that the entity behind p.store is really an entity? Is it annotated with @Entity? Nothing in the persistence.xml except class names (all persistable classes represented in here) and OpenJPA settings. Interesting questions on why the duplicate query exception suddenly showing up, It's because you use class and no exclude-unlisted-classes in persistence.xml. You should either remove the class elements or add exclude-unlisted-classes and the Ignoring. warning message should go away. Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
RE: Named query created in error
Thanks Jacek, Store is annotated with @Entity: @Entity @Table(name = manufacturer, schema = bidspec) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @NamedQueries( { @NamedQuery(name = StoreFXPK, query = SELECT s FROM Store s WHERE s.id = :primaryKey), @NamedQuery(name = StoreFXTypeAndName, query = SELECT s FROM Store s WHERE s.type = :type AND UPPER(s.name) = :storeName OR UPPER(s.displayName) = :storeName), @NamedQuery(name = StoreFXName, query = SELECT s FROM Store s WHERE UPPER(s.name) = :storeName OR UPPER(s.displayName) = :storeName) }) public class Store extends Persistable { I thought I needed to add the class names to persistence.xml to have them post-processed. I recognized (since using java agent right now) they are all looked at for persistence candidacy but figured this would be needed for compile time processing that I would switch to later. Let me know if I am way off here. Also must I list all other classes in the exclude-unlisted-classes section or can I simply list add exclude-unlisted-classes/ after my listed classes. - Clearly I am uncertain to the full purpose of this file Thanks for all this support Phill -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacek Laskowski Sent: April 19, 2007 10:15 AM To: open-jpa-dev@incubator.apache.org Subject: Re: Named query created in error On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: I am using MySQL version 5 The stack trace only shows because have wrapped this in a try/catch. The exception becomes NPE due to OpenJPA trying to make a Person object form more than just Person Object data, it fails to do this (silently) and the object it was to be assigned to become an NP Could you make sure that the entity behind p.store is really an entity? Is it annotated with @Entity? Nothing in the persistence.xml except class names (all persistable classes represented in here) and OpenJPA settings. Interesting questions on why the duplicate query exception suddenly showing up, It's because you use class and no exclude-unlisted-classes in persistence.xml. You should either remove the class elements or add exclude-unlisted-classes and the Ignoring. warning message should go away. Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
Re: Named query created in error
On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: Thanks Jacek, Store is annotated with @Entity: That might imply an incorrect behaviour of OpenJPA. I doubt if I can help more than just a spec guidance ;-) I'll have to set up the environment to reproduce the issue as OpenJPA doesn't seem to fail with Derby and my simple test case. I hope someone from the OpenJPA team will chime in and provide some additional hints. I thought I needed to add the class names to persistence.xml to have them post-processed. What do you mean by post-processed. There's no notion of post-processing in JPA. persistence.xml is a configuration file for persistence units (there can be more than one in a single persistence.xml file). Each and every PU is distinguished by its name (unique in the whole application). There's plenty of work to do for a jpa provider to set up a PU - see the spec's chapter 7. Container and Provider Contracts for Deployment and Bootstrapping. One of the tasks is to find all of the persistence classes (aka entities). Depending on your environment - Java SE or Java EE - the class element may be required. The spec reads in 6.2.1.6 mapping-file, jar-file, class, exclude-unlisted-classes page 138: A list of all named managed persistence classes must be specified in Java SE environments to insure portability. Portable Java SE applications should not rely on the other mechanisms described here to specify the managed persistence classes of a persistence unit. I recognized (since using java agent right now) they are all looked at for persistence candidacy but figured this would be needed for compile time processing that I would switch to later. Let me know if I am way off here. That's another thing. To let a jpa provider manage persistence classes (entities) they might be enhanced at build- or run-time. It's a choice you make when you run your application. Under a heavy load every second might be of great value so the sooner the classes are enhanced the better or else it might incur performance penalty. With Java you can process classes while they're loaded and enhance them to add capabilities like manageability. Also must I list all other classes in the exclude-unlisted-classes section or can I simply list add exclude-unlisted-classes/ after my listed classes. - Add exclude-unlisted-classes and give it a go. You should see the Ignoring. warning message go away. Clearly I am uncertain to the full purpose of this file persistence.xml? That's the most important file in the whole jpa application of yours so treat it gently and with great care so it won't cause troubles ;-) Read about it in the spec - 6.2 Persistence Unit Packaging page 134. It's easy to read so highly recommended to read (before you crash after struggling with setting up OpenJPA ;-)) Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
RE: Named query created in error
Will do and thanks again -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacek Laskowski Sent: April 19, 2007 10:57 AM To: open-jpa-dev@incubator.apache.org Subject: Re: Named query created in error On 4/19/07, Phill Moran [EMAIL PROTECTED] wrote: Thanks Jacek, Store is annotated with @Entity: That might imply an incorrect behaviour of OpenJPA. I doubt if I can help more than just a spec guidance ;-) I'll have to set up the environment to reproduce the issue as OpenJPA doesn't seem to fail with Derby and my simple test case. I hope someone from the OpenJPA team will chime in and provide some additional hints. I thought I needed to add the class names to persistence.xml to have them post-processed. What do you mean by post-processed. There's no notion of post-processing in JPA. persistence.xml is a configuration file for persistence units (there can be more than one in a single persistence.xml file). Each and every PU is distinguished by its name (unique in the whole application). There's plenty of work to do for a jpa provider to set up a PU - see the spec's chapter 7. Container and Provider Contracts for Deployment and Bootstrapping. One of the tasks is to find all of the persistence classes (aka entities). Depending on your environment - Java SE or Java EE - the class element may be required. The spec reads in 6.2.1.6 mapping-file, jar-file, class, exclude-unlisted-classes page 138: A list of all named managed persistence classes must be specified in Java SE environments to insure portability. Portable Java SE applications should not rely on the other mechanisms described here to specify the managed persistence classes of a persistence unit. I recognized (since using java agent right now) they are all looked at for persistence candidacy but figured this would be needed for compile time processing that I would switch to later. Let me know if I am way off here. That's another thing. To let a jpa provider manage persistence classes (entities) they might be enhanced at build- or run-time. It's a choice you make when you run your application. Under a heavy load every second might be of great value so the sooner the classes are enhanced the better or else it might incur performance penalty. With Java you can process classes while they're loaded and enhance them to add capabilities like manageability. Also must I list all other classes in the exclude-unlisted-classes section or can I simply list add exclude-unlisted-classes/ after my listed classes. - Add exclude-unlisted-classes and give it a go. You should see the Ignoring. warning message go away. Clearly I am uncertain to the full purpose of this file persistence.xml? That's the most important file in the whole jpa application of yours so treat it gently and with great care so it won't cause troubles ;-) Read about it in the spec - 6.2 Persistence Unit Packaging page 134. It's easy to read so highly recommended to read (before you crash after struggling with setting up OpenJPA ;-)) Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
RE: Named query created in error
What error do you get? I expect that it's joining extra data because your one-to-ones and many-to-ones are marked up to use eager fetching. Note that eager fetching is the default for one-to-one and many-to-one relations, so if you have not marked up these relations as lazy, then they're implicitly eager. -Patrick -- Patrick Linskey BEA Systems, Inc. ___ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. -Original Message- From: Phill Moran [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 18, 2007 12:23 PM To: open-jpa-dev@incubator.apache.org Subject: Named query created in error Anyone seen this before? I have the following named query @NamedQuery(name = PersonFXStoreAndLogin, query = SELECT p FROM Person p WHERE UPPER(p.store.name) = :storeName and UPPER(p.loginName) = :loginName ORDER BY p.lastName, p.firstName) That generated the following SQL statement SELECT t0.id, t0.lastUpdated, t0.active, t0.activeFrom, t0.activeUntil, t0.created, t0.displayName, t0.firstName, t0.lastLogin, t0.lastName, t0.locale, t0.loginName, t0.middleName, t2.id, t2.lastUpdated, t2.description, t3.id, t3.lastUpdated, t3.description, t2.value, t4.id, t4.lastUpdated, t4.description, t4.categoryTypeFK, t4.value, t1.id, t1.lastUpdated, t1.created, t1.description, t1.displayName, t1.name, t5.id, t5.lastUpdated, t5.description, t5.categoryTypeFK, t5.value, t0.title, t0.visible FROM bidspec.person t0 INNER JOIN bidspec.manufacturer t1 ON t0.manufacturerFK = t1.id LEFT OUTER JOIN bidspec.category t2 ON t0.roleFK = t2.id LEFT OUTER JOIN bidspec.category t4 ON t0.salutationFK = t4.id LEFT OUTER JOIN bidspec.category t5 ON t1.typeFK = t5.id LEFT OUTER JOIN bidspec.categorytype t3 ON t2.categoryTypeFK = t3.id WHERE (UPPER(t1.name) = ? AND UPPER(t0.loginName) = ?) ORDER BY t0.lastName ASC, t0.firstName ASC [params=(String) BIDSPEC, (String) PMORAN] Notice how it is grabbing columns from joined tables. This means it cannot build the object (Person) I am expecting to get returned and throws an exception. Cool huh? My guess is that I should not be drilling down with the UPPER(p.store.name) which is a field within one of these joined tables (t1). Thoughts? Phill Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
Re: Named query created in error
On 4/18/07, Phill Moran [EMAIL PROTECTED] wrote: The exception I get is null pointer from this line: ListPerson results = (ListPerson) q.getResultList(); Could you show the query creation and the stack trace you're getting? Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
RE: Named query created in error
) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.j ava:203) at $Proxy34.getLoginPersonValueObject(Unknown Source) at ca.BidSpec.testing.emall.UserFactoryTest.testDelete(UserFactoryTest.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav a:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69 ) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ac cess$001(AbstractAnnotationAwareTransactionalTests.java:47) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1. run(AbstractAnnotationAwareTransactionalTests.java:115) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nTest(AbstractAnnotationAwareTransactionalTests.java:180) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nTestTimed(AbstractAnnotationAwareTransactionalTests.java:153) at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.ru nBare(AbstractAnnotationAwareTransactionalTests.java:111) at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:159) at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:239) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) at org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:29) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java :42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunne r.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen ce.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner .java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner .java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java :386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav a:196) Caused by: java.lang.NullPointerException at java.util.Locale.toLowerCase(Locale.java:1060) at java.util.Locale.convertOldISOCodes(Locale.java:1083) at java.util.Locale.init(Locale.java:272) at java.util.Locale.init(Locale.java:302) at ca.BidSpec.emall.user.Person.pcsetLocale(Person.java:375) at ca.BidSpec.emall.user.Person.pcClearFields(Person.java) at ca.BidSpec.emall.user.Person.pcNewInstance(Person.java) at org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:117) at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:247) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager .java:327) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java :252) at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManag er.java:108) at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:54) at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:870) at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:828) ... 69 more -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacek Laskowski Sent: April 18, 2007 5:34 PM To: open-jpa-dev@incubator.apache.org Subject: Re: Named query created in error On 4/18/07, Phill Moran [EMAIL PROTECTED] wrote: The exception I get is null pointer from this line: ListPerson results = (ListPerson) q.getResultList(); Could you show the query creation and the stack trace you're getting? Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl