openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phill Moran" <pjmo...@rogers.com>
Subject RE: Named query created in error
Date Wed, 18 Apr 2007 20:08:15 GMT
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.


Mime
View raw message