On 8/18/06, Jeff Butler <[EMAIL PROTECTED]> wrote:
Multiple result maps should only be specified for stored procedures that return multiple result sets. Also, you shouldn't specify both resultMap and resultClass - just one of them.
Try this...
<resultMap class="Animal" id="AnimalResult">
<result property="id" column="animal_id"/>
<result property="name" column="name"/>
</resultMap>
<resultMap class="LandAnimal" id="LandAnimalResult" extends="AnimalResult">
<result property="numberOfFeet" column="num_feet"/>
</resultMap>
<select id="getLandAnimalByNumberOfFeet" resultMap="LandAnimalResult"
parameterClass="java.lang.Integer">
SELECT * FROM animals, land_animals
WHERE animal_id = land_animal_id AND num_feet = #value#
</select>
(I'm just guessing about the parameterClass)
Jeff Butler
On 8/18/06, Kevin Pauli <[EMAIL PROTECTED] > wrote:Hello, I am new to SQLMaps and I am evaluating version 2.2.0 for a new project. I have searched for an answer to the following problem but no joy (probably b/c everybody knows the answer already and I am thick)
I have an abstract base class Animal, with attributes "id" and "name", and a subclass LandAnimal that adds an attribute "numberOfFeet".
I have a table-per-subclass schema, with the following maps:
<resultMap class="Animal" id="AnimalResult">
<result property="id" column="animal_id"/>
<result property="name" column="name"/>
</resultMap>
<resultMap class="LandAnimal" id="LandAnimalResult">
<result property="numberOfFeet" column="num_feet"/>
</resultMap>
Here is my select statement to join the two tables and retrieve LandAnimals by number of feet:
<select id="getLandAnimalByNumberOfFeet" resultClass="LandAnimal" resultMap="AnimalResult, LandAnimalResult">
SELECT * FROM animals, land_animals
WHERE animal_id = land_animal_id AND num_feet = #value#
</select>
For some reason I cannot fathom, queryForList("getLandAnimalByNumberOfFeet", 4) is returning a List of Lists of LandAnimals, instead of just a List of LandAnimals. And queryForObject() returns a List of LandAnimals, instead of just the first LandAnimal. Is this the expected behavior? It does not seem intuitive.
--
Regards,Kevin Pauli
--
Regards,
Kevin Pauli
