Re: Does ibatis support Constructor with arguments?
hi jaggernat12345 ,
im not so sure if ibatis does (or doesnt) support your case, but why dont you add a no-argument constructor?
Is there any reason why you dont do that?
hi guys
Is it a MUST that my resultClass have a no -arg constructor ?
I have been struggling whole day resolving this issue. I am using Spring with Ibatis. This is my complete code.
I have in my xml file
------------------------------------------
<typeAlias alias ="userInfo" type ="nj.ado.UserInformation"/>
<select id ="my.query" resultClass="userInfo" parameterclass="java.lang.String">
select A.username,A.Id from User A where A.username= #username:CHAR#
</select>
-------------------------------------------
This is my UserInformation.java
----------------------------------------
public class UserInformation extends org.springframework.security.userdetails.User
{
public String accountId = null;
public UserInformation(String username,String password,boolean enabled,GrantedAuthority[]
authorities, String accountId) throws IllegalArgumentException
{
super(username,password,enabled,authorities); // calls superclass constructor
this.accountId = accountId;
}
setAccountId();
getAccountId();
}
-------------------------------------
This is how i am calling the query
----------------------------------------------
UserInformation ui = (UserInformation)SqlMapClientTemplate.queryForObject("my.query" , username);
------------------------------------------------
pretty straightforward.
AND this is the error i get
>>>>
InstantiationException. UserInformation canot be instantiated
I am assuming it is because i dont have a no argument constructor in UserInformation.java ? Is that the problem?
PS: I cannot have a no argument constructor in UserInformation.java because spring doesnt allow me to do that.
Any help would be greatly greatly appreciated
thanks.