ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ingmar Lötzsch <iloetz...@asci-systemhaus.de>
Subject Re: [resultMap] related objects
Date Thu, 02 Apr 2009 12:21:02 GMT
> Do I have to use TypeHandler? But how?

You don't need a custom TypeHandler. But perhaps you have to provide
more information.

What are the column names of the tables "companies" and "adresses"?

Your first message shows that they are different from the class properties.

Which packages contain the classes Company and Address?

Did you declare aliases for these classes?

Which files contain the resultMap elements?

Which packages contain these files?

How looks your <select> element?

How do you invoke the SQL-Statement?

What exceptions do you get?

What DBMS do you use?

Assuming that you have tables

	id int,
	name text,
	adress_id int

	address_id int,
	street text

Than you can write basically

<resultMap id="address-result" class="Address">
	<result property="addressId" column="adress_id" />
	<result property="street" column="street" />

<resultMap id="comp-result" class="Company">
	<result property="id" column="id" />
	<result property="name" column="name" />
	<result property="address" resultMap="address-result" />

<select id="selectAllCompanies" resultMap="comp-result">
	FROM companies c, addresses a
	WHERE a.address_id = c.address_id

In your DAO

List<Company> list = sqlMapClient.queryForList("selectAllCompanies");


View raw message