You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Phill Moran <pj...@rogers.com> on 2007/04/18 21:23:06 UTC

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


Re: Post processing in JPA

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/19/07, Craig L Russell <Cr...@sun.com> wrote:

> Post processing is a common term used to describe anything done to
> a .class file after being generated by the compiler. And there
> certainly is the notion of post processing class files in JPA.

I stand corrected. Great you spot it and corrected. Thanks for the
info. I think I need to take a look at some of the chapters again.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Post processing in JPA

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Jacek,

On Apr 19, 2007, at 7:56 AM, Jacek Laskowski wrote:

>> 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.

Post processing is a common term used to describe anything done to  
a .class file after being generated by the compiler. And there  
certainly is the notion of post processing class files in JPA.

In a container, the JPA provider is given the chance to post process  
entities by an explicit callback. See section 7.1.

Outside the container, JPA providers typically use the java agent  
technology to perform post processing on the classes.

Some JPA providers have a static post processor that allows you to  
deploy applications without using agents or transformers at runtime.  
OpenJPA's processor is the PCEnhancer.

Craig

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


RE: Named query created in error

Posted by Phill Moran <pj...@rogers.com>.
Will do and thanks again 

-----Original Message-----
From: eljotpl@gmail.com [mailto:eljotpl@gmail.com] 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 <pj...@rogers.com> 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

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/19/07, Phill Moran <pj...@rogers.com> 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

Posted by Phill Moran <pj...@rogers.com>.
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: eljotpl@gmail.com [mailto:eljotpl@gmail.com] 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 <pj...@rogers.com> 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

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/19/07, Phill Moran <pj...@rogers.com> 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

Posted by Phill Moran <pj...@rogers.com>.
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

I use annotations for this project so no ORM file

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,
but a search on workspace tells me it is the only one with that name
Store is annotated as well. In fact both Person and Store both have other named
queries in them that are working. I also get other reports of dup queries and
they work as well. Another thread (Patrick I believe) described the reason for
these but not sure the impact of them

Here is the whole trace-not sure why the whole thing did not show up before

<0|false|0.9.6-incubating> org.apache.openjpa.persistence.PersistenceException:
null
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:851)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:748)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:773)
	at
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:254)
	at
org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2115)
	at
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:248)
	at
org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(Inst
anceResultObjectProvider.java:56)
	at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:33)
	at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1203)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:979)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:832)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:763)
	at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:520)
	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:212)
	at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:251)
	at
ca.BidSpec.emall.user.PersonFactoryImpl.getLoginPersonValueObject(PersonFactoryI
mpl.java:98)
	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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils
.java:304)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Ref
lectiveMethodInvocation.java:172)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:139)
	at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Transa
ctionInterceptor.java:107)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:161)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.j
ava:203)
	at $Proxy34.getLoginPersonValueObject(Unknown Source)
	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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils
.java:304)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Ref
lectiveMethodInvocation.java:172)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:139)
	at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Transa
ctionInterceptor.java:107)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:161)
	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
This is all I get



-----Original Message-----
From: eljotpl@gmail.com [mailto:eljotpl@gmail.com] 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 <pj...@rogers.com> wrote:
> Here it is:
>
> [2007-04-18 18:37:07,937] INFO  
> ca.BidSpec.testing.emall.UserFactoryTest Began transaction (1): 
> transaction manager 
> [org.springframework.orm.jpa.JpaTransactionManager@749ebc]; 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

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/19/07, Phill Moran <pj...@rogers.com> wrote:
> Here it is:
>
> [2007-04-18 18:37:07,937] INFO  ca.BidSpec.testing.emall.UserFactoryTest Began
> transaction (1): transaction manager
> [org.springframework.orm.jpa.JpaTransactionManager@749ebc]; 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

Posted by Phill Moran <pj...@rogers.com>.
Here it is:

[2007-04-18 18:37:07,937] INFO  ca.BidSpec.testing.emall.UserFactoryTest Began
transaction (1): transaction manager
[org.springframework.orm.jpa.JpaTransactionManager@749ebc]; 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)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:748)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:773)
	at
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:254)
	at
org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2115)
	at
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:248)
	at
org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(Inst
anceResultObjectProvider.java:56)
	at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:33)
	at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1203)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:979)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:832)
	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:763)
	at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:520)
	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:212)
	at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:251)
	at
ca.BidSpec.emall.user.PersonFactoryImpl.getLoginPersonValueObject(PersonFactoryI
mpl.java:98)
	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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils
.java:304)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Ref
lectiveMethodInvocation.java:172)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:139)
	at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Transa
ctionInterceptor.java:107)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:161)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.j
ava:203)
	at $Proxy34.getLoginPersonValueObject(Unknown Source)
	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
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils
.java:304)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(Ref
lectiveMethodInvocation.java:172)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:139)
	at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Transa
ctionInterceptor.java:107)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:161)
	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: eljotpl@gmail.com [mailto:eljotpl@gmail.com] 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 <pj...@rogers.com> wrote:

> The exception I get is null pointer from this line:
>
> List<Person> results = (List<Person>) 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

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/18/07, Phill Moran <pj...@rogers.com> wrote:

> The exception I get is null pointer from this line:
>
> List<Person> results = (List<Person>) 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

Posted by Phill Moran <pj...@rogers.com>.
These are all mainly many-to-one, but regardless are these not suppose to build
persistent objects? How can they do this if they mix data from several tables (I
am using table/class inheritance).

The exception I get is null pointer from this line: 

List<Person> results = (List<Person>) q.getResultList();

The query has both params populated on the input side.

I can change to lazy fetch but I would hope that his would not change the query
and cause it to suddenly work.

An interesting aside - I changed the named query to look like this

@NamedQuery(name = "PersonFXStoreAndLogin", query = "SELECT p FROM Person p,
IN(p.store) s WHERE UPPER(s.name) = :storeName and UPPER(p.loginName) =
:loginName ORDER BY p.lastName, p.firstName") })

And got the duplicate query I have asked about in the past. Also this generates
a similar SQL statement and resulted in a NPE

-----Original Message-----
From: Patrick Linskey [mailto:plinskey@bea.com] 
Sent: April 18, 2007 3:56 PM
To: open-jpa-dev@incubator.apache.org
Subject: 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:pjmoran@rogers.com]
> 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

Posted by Patrick Linskey <pl...@bea.com>.
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:pjmoran@rogers.com] 
> 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.