ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leandro Saad" <leandro.s...@gmail.com>
Subject Re: R: iBATIS Mapping
Date Fri, 27 Oct 2006 13:32:35 GMT
Hi Caio.

Please check the iBatis manual (pdf) on how to load Complex Properties (i.e.
a property of a class defined by the user). page 26.

:: Leandro

On 10/27/06, Caio Zanchetti <caio.zanchetti@gmail.com> wrote:
>
> Rinaldo, tanks for reply.
> I don't understand what exactly is incorrect, can you explain please?
> But, anyway, i don't want to have the fields of Area in my Usuario.
> Only the object Area. (In Hibernate its possible through the mapping
> of a Component).
> Any doubt please ask me.
> Tanks
>
>
> On 10/27/06, Rinaldo <rbonazzo@sardiniapoint.it> wrote:
> > Hi,
> > Control your Usuario class, it's seems that it's not correct
> >
> > Example
> >
> > Integer  ID;
> > String  LOGIN;
> > String  SENHA;
> > ...
> > String EMAIL;
> > Integer areaId;
> > String  areaDesc;
> >
> >
> >
> > Regards Rinaldo
> >
> >
> >
> > -----Messaggio originale-----
> > Da: Caio Zanchetti [mailto:caio.zanchetti@gmail.com]
> > Inviato: venerdì 27 ottobre 2006 13.21
> > A: user-java@ibatis.apache.org
> > Oggetto: iBATIS Mapping
> >
> > Guys, i'm using the ibatis in a project in my company, could you please
> help
> > me?
> >
> > The problem consists just in a retrive an object (of type Usuario)
> > from the database, this object contains an object of type Area. All
> > the others fields are OK (are populated perfectly). Only this object
> > (Area) is not instanced (and populated) by ibatis.
> >
> > This situation happends very similar in the Demo ibatis jPetStore app,
> > with the classes Item and Procut. (Product is a field of Item). I
> > tryed to follow the same way they used to solve their problems in
> > their app.
> >
> > The mapping and the tables of my app:
> >
> > PS: The names are in brazilian portuguese:
> > Usuario - User
> > senha - password
> > grupo - group
> > nome - name
> > depto - dept
> > cargo - function
> > inativo - inactive
> >
> > descricao - description (of an area).
> >
> >
> > * My tables:
> >
> > USUARIO:
> >   "ID"   INTEGER NOT NULL,
> >   "LOGIN"        VARCHAR(15) NOT NULL,
> >   "SENHA"        CHAR(80),
> >   "GRUPO"        SMALLINT NOT NULL,
> >   "NOME"         VARCHAR(60),
> >   "DEPTO"        VARCHAR(20),
> >   "CARGO"        VARCHAR(20),
> >   "INATIVO"      VARCHAR(1),
> >   "EMAIL"        VARCHAR(60),
> >   "AREA"         INTEGER,
> >
> >
> > AREA
> >   "ID"   INTEGER,
> >   "DESCRICAO"    VARCHAR(30)
> >    ...
> >
> >
> > * My mapping file (the part where i'm working):
> > ...
> >         select id="getById" parameterClass="java.lang.Integer"
> > resultClass="Usuario"
> >                 SELECT usuarios.id, login, senha, grupo, inativo, nome,
> > depto, cargo, email,
> >                 area AS "area.id",
> >                 descricao AS "area.descricao"
> >
> >                 FROM usuarios, areas
> >                 WHERE usuarios.area = areas.id
> >                 AND usuarios.id=#id#
> > ...
> >
> >
> >
> > * The call in the DAO class:
> >
> >     public Usuario getById(Integer id) {
> >         return (Usuario)
> > super.getSqlMapClientTemplate().queryForObject("getById", id);
> >     }
> >
> >
> > I believe that the POJOS will not necessary because it have only the
> > same tables structure.
> >
> > There are two other solutions that are: Use a map for the return or
> > execute 2 selects in my DAO, I don't want to use no one of them.
> >
> >
> > Gratefful,
> >
> > --
> > Claudiomir G. Zanchetti (Caio)
> > Sun Certified Programmer for the Java 2 Plataform, Standard Edition 5.0
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.1.408 / Virus Database: 268.13.14/502 - Release Date:
> 27/10/2006
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.1.408 / Virus Database: 268.13.14/502 - Release Date:
> 27/10/2006
> >
> >
> >
> >
>
>
> --
> Claudiomir G. Zanchetti (Caio)
> Sun Certified Programmer for the Java 2 Plataform, Standard Edition 5.0
>

Mime
View raw message