Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 结果映射Mybati不起作用_Xml_Mybatis - Fatal编程技术网

Xml 结果映射Mybati不起作用

Xml 结果映射Mybati不起作用,xml,mybatis,Xml,Mybatis,我有一个简单的映射器 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0 Powerhouse//EN" "http://mybatis.org/dtd/mybatis-3-Powerhouse-mapper.dtd"> <mapper namespace="nl.powerhouse.data.domain.CountryMa

我有一个简单的映射器

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0 Powerhouse//EN" "http://mybatis.org/dtd/mybatis-3-Powerhouse-mapper.dtd">

<mapper namespace="nl.powerhouse.data.domain.CountryMapper">
<resultMap id="countryDsoMap" type="nl.powerhouse.domain.common.types.algemeen.Land">
    <id column="land_id"/>
    <association property="landId" columnPrefix="land_" column="id"/>
    <association property="landcode" columnPrefix="land_" column="landcode"/>
    <association property="landnaam" columnPrefix="land_" column="landnaam"/>
    <association property="landnummer" columnPrefix="land_" column="landnummer"/>
    <association property="handelsland" columnPrefix="land_" column="handelsland"/>
</resultMap>

<select id="findCountryByCode" resultMap="countryDsoMap">
    select <includeColumns tableAlias="land" columnPrefix="land_" refid="nl.powerhouse.data.dao.algemeen.LandMapper.Base_Column_List"/>
    from alg_t_land land
    where landcode = #{countryCode}
</select>
但是,当我尝试使用它时,我得到以下错误:

org.mybatis.spring.MyBatisSystemException: nested exception is    org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in nl/powerhouse/data/domain/CountryMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
...
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)

我知道查询正在运行,问题在于结果映射,有什么提示吗?

问题在于您正在使用

结果图

结果–注入字段或JavaBean属性的正常结果

关联——一种复杂类型的关联;许多结果将会出现 进入这个

确切地说,映射不是复杂的类型关联,因此必须使用
而不是

您的结果图将是:

<resultMap id="countryDsoMap" type="nl.powerhouse.domain.common.types.algemeen.Land">
    <id column="land_id"/>
    <result property="landId" columnPrefix="land_" column="id"/>
    <result property="landcode" columnPrefix="land_" column="landcode"/>
    <result property="landnaam" columnPrefix="land_" column="landnaam"/>
    <result property="landnummer" columnPrefix="land_" column="landnummer"/>
    <result property="handelsland" columnPrefix="land_" column="handelsland"/>
</resultMap>


您的id:
没有属性
属性
。我想你需要把
或者属性id如何在
土地中调用
我试过了,但没有成功,否则,你为什么要使用标签
关联
?代替。示例:
结果有效,谢谢!
<resultMap id="countryDsoMap" type="nl.powerhouse.domain.common.types.algemeen.Land">
    <id column="land_id"/>
    <result property="landId" columnPrefix="land_" column="id"/>
    <result property="landcode" columnPrefix="land_" column="landcode"/>
    <result property="landnaam" columnPrefix="land_" column="landnaam"/>
    <result property="landnummer" columnPrefix="land_" column="landnummer"/>
    <result property="handelsland" columnPrefix="land_" column="handelsland"/>
</resultMap>