> I get exception:
> --- Check the company.company-result.
> --- The error happened while setting a property on the result object.
> --- Cause: com.ibatis.sqlmap.client.SqlMapException: Error instantiating
> collection property for mapping 'address'. Cause:
> java.lang.ClassCastException:
The exception says: java.lang.ClassCastException.
Can you provide the source of class Company?
> I have Company.xml where is all typeAliases, resultMap, sql statement
> I use useStatementNamespaces="true", so I must have <sqlMap
> namespace="company">
I think, this is the best approach.
> DAO:
> return getSqlMapClientTemplate().queryForList("company.getAll");
I'am using Spring too.
> XML:
> <select id="getAll" resultMap="company-result">
> SELECT
> c.company_id, c.companyname,
> a.address_id, a.street
> FROM hh_companies c
> LEFT JOIN hh_addresses a ON c.address_id = a.address_id
> </select>
> ** all companies have its addresses; no null values
Than you should INNER JOIN instead of OUTER JOIN.
> <resultMap id="address-result" class="Address">
> <result property="addressId" column="address_id" />
> <result property="street" column="street" />
> </resultMap>
>
> <resultMap id="company-result" class="Company">
> <result property="companyId" column="company_id" />
> <result property="name" column="companyname" />
> <result property="address" javaType="Address"
> resultMap="company.address-result" />
> </resultMap>
You can omit the attribute javaType. I assume it is ignored due to the
presence of the resultMap attribute. Apart from that the type is
declared in the resultMap element.
Ingmar