Hi to all. I have a
Infracction Class with a List field called reclamacion wich is to be populated
with objects of Reclamation type, using the 1:N & N:M solution for N+1
querys i´m able to populate this property with a simple query. Here the code I
use: public class Infraction
extends BaseObject {
private static final long serialVersionUID = 1L;
private Integer idInfraccion;
private java.lang.String codExpediente;
.
.
.
.
private List
reclamation; } With corresponding
getters and setters Reclamation class
is a javabean Here´s my sqlMap
config file for Infraction: <resultMap
id="infraccionMapaReclamaciones"
class="com.amap.multas.model.Infraction"
extends="infractionMapa" groupBy="idInfraction">
<result property="reclamacion"
resultMap="Reclamation.reclamacionMapa" "/> </resultMap> <select id="findByPrimaryKeyWithReclamacion"
resultMap="infraccionMapaReclamaciones"
parameterClass="infraccion">
SELECT * FROM INFRACCION LEFT JOIN RECLAMACION ON
INFRACCION.ID_INFRACCION=RECLAMACION.ID_INFRACCION
WHERE INFRACCION.ID_INFRACCION=#idInfraccion# </select> The only problem i
have with this approach is that it always creates the Reclamation List with at
least one element with all fields with null value, but the List is there. I would like this
List to be null, a TypeHandler for this property dosen´t seem to work because
Ibatis don´t set the List directly but it makes calls to
getReclamation().add(Object) instead. Anyone knows a
solution for this issue apart from a manual parsing of the List after ibatis?
Apart of that, now
my boss want me to change the reclamacion field´s type from List to
Reclamacion[] and the above solution didn´t work because Ibatis seems to not
support arrays as types to populate. I ´ve search the documentation and mailing
list and all point to that. I have ways to overcome this, creating a subclass
of Infraction with List instead of array and use it only from Ibatis, a getter
method to transform and so on. But I would like to
be sure there´s no way to do this from Ibatis before doing that, custom
TypeHandler seems not to be the solution because Ibatis don´t set a List
directly, so… There´s some way to
accomplish this using Ibatis? Thanks in advance
and sorry for the long post and poor english. Raúl Arabaolaza |
- M:N solution and populating arrays instead of Li... Raúl Arabaolaza Barquín
- Re: M:N solution and populating arrays inst... Zoran Avtarovski