-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem using varargs with NamedQuery
PostPosted: Mon Aug 17, 2009 6:45 pm 
Newbie

Joined: Mon Aug 17, 2009 5:38 pm
Posts: 1
Hi,

We are trying to use varargs(jdk 5) with named query(hibernate 3).When the named query is invoked the runtime error thrown is "Unable to locate appropriate constructor on class"

We are defining this named query
SELECT new org.dto.EmployeeInfo(str(t.useremployeeID),t.userFname ,t.userLname) FROM TblUsers t WHERE str(t.useremployeeID) LIKE :wildcard OR t.userLname LIKE :wildcard OR t.userFname LIKE :wildcard"


The EmployeeInfo class is defined as

public class EmployeeInfo {


private String[] data;

public EmployeeInfo(String... strings) {
//do something

}
}

Please help.

Thanks in advance,
Pratim


Top
 Profile  
 
 Post subject: Re: Problem using varargs with NamedQuery
PostPosted: Wed Sep 22, 2010 12:54 pm 
Newbie

Joined: Wed Sep 22, 2010 5:35 am
Posts: 2
Hi All,

I am also stuck in exactly the same problem. Do anybody have any idea regarding this.

Please share the best possible solution for this problem.

Thanks in advance,
Gourav


Top
 Profile  
 
 Post subject: Re: Problem using varargs with NamedQuery
PostPosted: Thu Feb 27, 2014 4:14 am 
Newbie

Joined: Thu Feb 27, 2014 4:08 am
Posts: 3
Location: Frankfurt, Germany
I could make it work by changing the variable types in the constructor to Object and making a casting, like this_

public Hospital(Object hospitalId, Object hospitalName){

log.debug("Hospital Id: {}",hospitalId);
log.debug("HospitalName: {}",hospitalName);

this.hospitalId= hospitalId.toString();
this.hospitalName= hospitalName.toString();

}

But in the named query it´s all strings. I am migrating from EclipseLink to hibernate and everything was working fine with strings before :-(


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.