ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caio Zanchetti" <caio.zanche...@gmail.com>
Subject Re: iBATIS Mapping
Date Fri, 27 Oct 2006 14:13:16 GMT
Hi Clinton, that's true, should work. But doesn't.
I will explain what is the Area class (i don't know if it was what you
ask me before): The Area class represents an Dept or Proccess in a
Company, this class has several fields but i believe that is not too
important.
I followed step by step of jPetStore app because the problem with Item
and Product is really simillar..
Maybe the problem could be the sql statement that i created.


Regards,



On 10/27/06, Clinton Begin <clinton.begin@gmail.com> wrote:
> That should work....
>
> What does the area class look like?
>
> Cheers,
> Clinton
>
>
> On 10/27/06, Caio Zanchetti < caio.zanchetti@gmail.com> wrote:
> > 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
> >
>
>


-- 
Claudiomir G. Zanchetti (Caio)
Sun Certified Programmer for the Java 2 Plataform, Standard Edition 5.0

Mime
View raw message