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 iBATIS Mapping
Date Fri, 27 Oct 2006 11:21:22 GMT
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

Mime
View raw message