You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Anthony Hong <an...@gmail.com> on 2006/09/11 16:09:30 UTC

How to use sqlmap to create an object with not empty construnctor

I have a class,

class testA() {
  public testA(String  name) {

}
}

can it be used in result-map, if can how to write result map

-- 

Anthony Hong

Re: How to use sqlmap to create an object with not empty construnctor

Posted by Anthony Hong <an...@gmail.com>.
Thanks Gareth,
It's clear for me now.

Re: How to use sqlmap to create an object with not empty construnctor

Posted by Gareth Moorst <ga...@yahoo.co.uk>.
The classes used in iBatis need to conform to the JavaBeans spec - they need to have a no-arg constructor.

If you really need to use the class with a string constructor, I'd suggest returning a Map from the sqlmap queryForObject method, then constructing your java object in your DAO.

Gareth.

----- Original Message ----
From: Anthony Hong <an...@gmail.com>
To: user-java@ibatis.apache.org
Sent: Tuesday, 12 September, 2006 12:51:13 AM
Subject: Re: How to use sqlmap to create an object with not empty construnctor

I use iBatis as my DAO Layer for now. It works fine with no-args
constructor class.
Then it can setter properties in result map.
But If I have a class without no-args constuctor, how to instantiate
in iBatis,  As there is a column in selection that can be used to pass
in constructor to create a new instance, how to achieve this goal.





Re: How to use sqlmap to create an object with not empty construnctor

Posted by Anthony Hong <an...@gmail.com>.
I use iBatis as my DAO Layer for now. It works fine with no-args
constructor class.
Then it can setter properties in result map.
But If I have a class without no-args constuctor, how to instantiate
in iBatis,  As there is a column in selection that can be used to pass
in constructor to create a new instance, how to achieve this goal.

Re: How to use sqlmap to create an object with not empty construnctor

Posted by Nathan Maves <na...@gmail.com>.
Ahh how about you just add an empty constructor...

public TestA() {
    this("");
}

Problem solved.


On 9/11/06, Anthony Hong <an...@gmail.com> wrote:
> I have a class,
>
> class testA() {
>   public testA(String  name) {
>
> }
> }
>
> can it be used in result-map, if can how to write result map
>
> --
>
> Anthony Hong
>