The two changes I´ve done are:
the new set method
public void setAtrib_ (ArrayList<Atrib> atrib_) {this.atrib_ = atrib_;}
and the result property for attributes
<result property="atrib_" resultMap="Elemento.mapAtributos " />
where Elemento is the namespace of the sqlMap file, but it is in the same
sqlMap file as the <resultMap id="mapElementos" class="elemento">
If I debug the code using a breakpoint in the setAtrib_ method, I obtain
when the process arrives to the set method that the parameter atrib_ is null
and if I end the execution I get the error:
Cause: com.ibatis.sqlmap.client.SqlMapException: There is no result map
named elemento.getAtributos in this SqlMap.
In order to check if the null is caused for the select getAtributos, I´ve
call it directly from the application and it returns the correct values...
I´m lost!!! Thanks
From: "Francisco Exposito Aguilera" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: select doubt
Date: Sat, 21 Jul 2007 16:06:18 +0000
I´ve checked my code and I think I am doing something wrong in my
resultMap, but I don´t know how to solve it...
<resultMap id="mapElementos" class="elemento">
<result property="id" column="ID"/>
<result property="name" column="NAME"/>
<result property="atrib_id" column="ATRIB_ID"
select="getAtributos"/>
</resultMap>
In my old resultMap I had
<result property="atrib_id" column="ATRIB_ID" select="getAtributos"/>
and atrib_id is not an ArrayList<Atrib>
Now I have as property atrib_ which is an ArrayList<Atrib> and it gets the
Attributes with the function getAtributos. But there is no column for this
.
<result property="atrib_" column="????" select="getAtributos" />
If I put as column ATRIB_ID (which is not an ArrayList<Atrib>), then I
obtain the error
Error setting property 'setAtrib_' ... Cause:
java.lang.IllegalArgumentException: argument type mismatch
Any idea? Thanks
From: "Jeff Butler" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: select doubt
Date: Thu, 19 Jul 2007 10:08:58 -0500
I belive the issue is that your setter isn't quite right. Should be like
this:
public void setAtrib_ (ArrayList<Atrib> atrib_) {this.atrib_ = atrib_;}
If you do it this way, iBATIS will know to expect multiple values for the
attributes.
Jeff Butler
On 7/19/07, Francisco Exposito Aguilera <[EMAIL PROTECTED]> wrote:
Hello,
I have another typical issue of a beginner!!!!!
I have two tables:
ELEM: id, name, atrib_id
ATRIB: id, name, value
In Elem java class I´ve defined
private ArrayList<Atrib> atrib_ = new ArrayList<Atrib>();
public void setAtrib_ (Atrib atrib) {atrib_.add(atrib);}
and in sqlMap I´ve defined:
<resultMap id="mapAtributos" class="atributo">
<result property="id" column="ID"/>
<result property="name" column="NAME"/>
<result property="value" column="VALUE"/>
</resultMap>
<resultMap id="mapElementos" class="elemento">
<result property="id" column="ID"/>
<result property="name" column="NAME"/>
<result property="atrib_id" column="ATRIB_ID"
select="getAtributos"
/>
</resultMap>
<select id="getElementosTransaccion" resultMap="mapElementos">
select * from ELEM where ATRIB_ID=#value#
</select>
<select id="getAtributos" resultMap="mapAtributos">
select * from ATRIB oat_oet_id=#oet_id#
</select>
All this works properly if I have only one attribute for every element,
but
if there are two attribute for any element, the I obtain the error:
Cause: java.sql.SQLException: Error: executeQueryForObject returned too
many
results.
I understand the error, but I am not able to find the solution!!! How
could
I solve it? Thanks
_________________________________________________________________
Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN
Amor & Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
_________________________________________________________________
Un amor, una aventura, compañía para un viaje. Regístrate gratis en MSN Amor
& Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349