-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: select new throwing Exception
PostPosted: Tue Feb 14, 2006 12:41 pm 
Beginner
Beginner

Joined: Sun Jan 22, 2006 8:47 pm
Posts: 31
Hibernate version: 3.0

Hi ,
Iam trying to use select "new" in Hql,Iam getting excetion..

String SQL_QUERY="select new PatRow (pat.mpi,pat.nameDisplay,pat.birthDate) from Pat pat ";

PatRow is a class which has all the constructors for creating the objects..

Hibernate: select pat0_.mpi as col_0_0_, pat0_.name_display as col_1_0_, pat0_.birthdate as col_2_0_ from pat pat0_
**************END***************** at : 0
org.hibernate.QueryException: Could not instantiate: class fccc.phs.hibernate.PatRow
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:117)
at org.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:62)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:382)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:278)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:865)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
at fccc.phs.hibernate.PatDAO.getPatInfo(PatDAO.java:48)
at fccc.phs.hibernate.GetPatientInfo.main(GetPatientInfo.java:15)

Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:113)
... 7 more:


If i use only one argument for the constructor like :

select new PatRow(pat.mpi) from Pat pat


Iam not having any problem for the one argument..

While i have constructors for the 3 arguments used in first hql query,I dont undestand why is it complaining about illegal number of arguments..Any help is appreciated..

Thnx.


Top
 Profile  
 
 Post subject: Re: select new throwing Exception
PostPosted: Wed Feb 15, 2006 7:04 am 
Beginner
Beginner

Joined: Mon Jan 30, 2006 2:28 am
Posts: 47
Location: INDIA
Hi!

Pls see
Ordinary Query display all the field is :
Select * from <table name>;

Hibernate Query is:
from <table name>

_________________
A.Edward Durai
"The things which are impossible with men are possible with God."


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.