You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by WPrecht <wp...@umuc.edu> on 2008/10/16 19:56:38 UTC

Trouble with Constructor Expressions

Hello,

I am getting the following error message when attempting a NamedNativeQuery:

Error in named query: uCourseSectionId = a9047cea83ab0a6400961dff823ffa16
[No query with that name ('Conference.GetConferenceList'). [Result type
"class edu.umuc.tycho.feature.conference.entity.helper.ConfExtended" does
not have any public fields or setter methods for the projection or aggregate
result element "null", nor does it have a generic put(Object,Object) method
that can be used, nor does it have a public constructor that takes the types
null.]]

The constructed object, which is not an entity, has the following
constructor signature:

public ConfExtended(String confId, int unreadCnt, int noteCnt) {...

None of these three values are ever going to be null coming from the
database.  The first is a PK, the other two are aggregates (COUNTs).  I
originally had this returning several other values as well from the selected
entities, but some could be null and took them out in case that was the
problem, but that didn't change the error.

Does anyone have a hint on what's causing this error?  I traced it backwards
a ways into the src, but the parser is a bit over my head.

Also, is there a problem if one of the returned values is null?  For the
final solution I am working up to I am going to have to have some nulls in
some of the columns.

Thanks in advance.
-- 
View this message in context: http://n2.nabble.com/Trouble-with-Constructor-Expressions-tp1342024p1342024.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Trouble with Constructor Expressions

Posted by Dinkar Rao <di...@gmail.com>.
Another possibility is that because ConfExtended is not an entity, and
because the results are all scalars, the native query might need to
use the @SqlResultSetMapping with the @ColumnResult clause.

Thanks,
Dinkar

On Thu, Oct 16, 2008 at 2:12 PM, Jeremy Bauer <te...@gmail.com> wrote:
> Roops..  I missed the key statement:  "The constructed object, which
> is not an entity, ..."  :-)
>
> I haven't verified, but there could be a problem with using the int
> primitives (non-nullable) on the constructor.  Changing them to
> Integer (nullable) may correct the problem.  I'll try a few variations
> as well.
>
> -Jeremy
>

Re: Trouble with Constructor Expressions

Posted by WPrecht <wp...@umuc.edu>.
Well, by changing ConfExtended into an entity and putting two dummy columns
on the table, the query now works.  I didn't try the mapping annotations
yet, I would like to figure out how to do without making it an entity, so I
may give that a try still.

Thanks for the suggestions.

Wayne
-- 
View this message in context: http://n2.nabble.com/Trouble-with-Constructor-Expressions-tp1342024p1346299.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Trouble with Constructor Expressions

Posted by WPrecht <wp...@umuc.edu>.

Jeremy Bauer wrote:
> 
> I haven't verified, but there could be a problem with using the int
> primitives (non-nullable) on the constructor.  Changing them to Integer
> (nullable) may correct the problem.  I'll try a few variations as well.
> 

I tried that and it didn't make a difference.  I am going to try Dinkar's
suggestion just as soon as I sort out the syntax.
-- 
View this message in context: http://n2.nabble.com/Trouble-with-Constructor-Expressions-tp1342024p1345266.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Trouble with Constructor Expressions

Posted by Jeremy Bauer <te...@gmail.com>.
Roops..  I missed the key statement:  "The constructed object, which
is not an entity, ..."  :-)

I haven't verified, but there could be a problem with using the int
primitives (non-nullable) on the constructor.  Changing them to
Integer (nullable) may correct the problem.  I'll try a few variations
as well.

-Jeremy

Re: Trouble with Constructor Expressions

Posted by WPrecht <wp...@umuc.edu>.
Hi Jeremy, 

It's not an entity.  According to 4.8.2 of the spec: "The specified class is
not required to be an entity or to be mapped to the database. The
constructor name must be fully qualified"

I gave it a try anyways and got the same error.

Thanks, 

Wayne.
-- 
View this message in context: http://n2.nabble.com/Trouble-with-Constructor-Expressions-tp1342024p1342561.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Trouble with Constructor Expressions

Posted by Jeremy Bauer <te...@gmail.com>.
Hi there,

According to the JPA spec, section 2.1:

The entity class must have a no-arg constructor. The entity class may
have other constructors as well.
The no-arg constructor must be public or protected.

If you don't have one, try adding a default constructor to
ConfExtended.  That should correct the issue.  If you are using the
compile-time PCEnhancer it should add a default constructor for you by
default (-adc option), which would indicate there is a different
problem.

-Jeremy