检索数据时出错

Error to retrieve data

我的table:

CREATE TABLE [dbo].[R_ACADEMIE](
    [ID_ACADEMIE] [dbo].[IDENTIFIANT] NOT NULL,
    [LC_ACADEMIE_CODE] [dbo].[LIBELLE_COURT] NOT NULL,
    [LM_ACADEMIE_LIBELLE] [dbo].[LIBELLE_MOYEN] NOT NULL
) ON [PRIMARY]

我的结果图:

<resultMap class="business.bo.AcademieBO"
    id="AcademieBOResult">
    <result column="ID_ACADEMIE" jdbcType="NUMERIC"
        property="idAcademie" />
    <result column="LC_ACADEMIE_CODE" jdbcType="VARCHAR"
        property="lcAcademieCode" />
    <result column="LM_ACADEMIE_LIBELLE" jdbcType="VARCHAR"
        property="lmAcademieLibelle" />
</resultMap>

AcademiBO.java:

import java.io.Serializable;
import java.math.BigDecimal;

public class AcademieBO implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
     * <code>idCivilite</code> the idCivilite
     */
    private BigDecimal idAcademie;

    /**
     * <code>lcCivCode</code> the lcCivCode
     */
    private String lcAcademieCode;

    /**
     * <code>lmCivLibelle</code> the lmCivLibelle
     */
    private String lmAcademieLibelle;

    public BigDecimal getIdAcademie() {
        return idAcademie;
    }

    public void setIdAcademie(BigDecimal idAcademie) {
        this.idAcademie = idAcademie;
    }

    public String getLcAcademieCode() {
        return lcAcademieCode;
    }

    public void setLcAcademieCode(String lcAcademieCode) {
        this.lcAcademieCode = lcAcademieCode;
    }

    public String getLmAcademieLibelle() {
        return lmAcademieLibelle;
    }

    public void setLmAcademieLibelle(String lmAcademieLibelle) {
        this.lmAcademieLibelle = lmAcademieLibelle;
    }


}

dbo_ACADEMIE_SqlMap.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="dbo_ACADEMIE">
    <resultMap class="business.bo.AcademieBO"
        id="AcademieBOResult">
        <result column="ID_ACADEMIE" jdbcType="NUMERIC" property="idAcademie" />
        <result column="LC_ACADEMIE_CODE" jdbcType="VARCHAR" property="lcAcademieCode" />
        <result column="LM_ACADEMIE_LIBELLE" jdbcType="VARCHAR"
            property="lmAcademieLibelle" />
    </resultMap>

    <select id="listAll" resultMap="AcademieBOResult">
        select * from dbo.R_ACADEMIE
        ORDER BY ID_ACADEMIE ASC
    </select>

    <select id="selectByIdCivilite" resultMap="AcademieBOResult">
        select * from dbo.R_ACADEMIE where ID_ACADEMIE = #idAcademie:INTEGER#
    </select>
</sqlMap>

错误:

SqlMapClient operation; uncategorized SQLException for SQL [];
SQL state [null];
error code [0];
The error occurred in
dao/maps/dbo_ACADEMIE_SqlMap.xml.
The error occurred while applying a result map.
Check the dbo_ACADEMIE.AcademieBOResult. Check the result mapping for the 'idAcademie' property.
Cause: com.ibatis.sqlmap.client.SqlMapException: Error getting nested result map values for 'academie'.
Cause: java.sql.SQLException: Invalid column name ID_ACADEMIE.;
nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
The error occurred in dao/maps/dbo_ACADEMIE_SqlMap.xml.
The error occurred while applying a result map.
Check the dbo_ACADEMIE.AcademieBOResult.
Check the result mapping for the 'idAcademie' property.
Cause: com.ibatis.sqlmap.client.SqlMapException: Error getting nested result map values for 'academie'.
Cause: java.sql.SQLException: Invalid column name ID_ACADEMIE.

你不能在 iBatis 中使用 select *,你需要给出所有的列名以便 iBatis 能够将正确的列映射到正确的对象 属性.

   <select id="listAll" resultMap="AcademieBOResult">
        select ID_ACADEMIE, LC_ACADEMIE_CODE, LM_ACADEMIE_LIBELLE from dbo.R_ACADEMIE
        ORDER BY ID_ACADEMIE ASC
    </select>

在单独的工具(SQL 开发人员)中再次检查您的 SQL 请求以确保其有效。我不太了解您的创建 table 脚本:我不熟悉 SQL 服务器,您重新定义列名的方式以及没有列类型的事实对我来说似乎很奇怪,也许问题出在这里......