嗨我有一个方法应该返回一个列表,但我得到了 查询数据库时出错。原因:com.microsoft.sqlserver.jdbc.SQLServerException:无效的对象名称'CATSTATUSPRINT'。 ,该错误可能存在于com / mapper / CatStatusPrintMapper.xml中 ,该错误可能涉及defaultParameterMap ,设置参数时发生错误
这是我的映射器CatStatusPrintMapper.xml:
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="statusMapper">
<select id="consultCatStatus" resultMap="catStatusMap">
SELECT
C.ID_STATUS,
C.NAME_STATUS,
C.DESC_STATUS,
C.ACTIVE
FROM CATSTATUSPRINT C
WHERE C.ACTIVE = 1
ORDER BY C.NAME_STATUS ASC
</select>
<select id="consultCatStatus2" resultMap="catStatusMap">
SELECT
C.ID_STATUS,
C.NAME_STATUS,
C.DESC_STATUS,
C.ACTIVE
FROM CATSTATUSPRINT C
WHERE C.ACTIVE = 2
ORDER BY C.NAME_STATUS ASC
</select>
<resultMap id="catStatusMap" type="catStatus">
<result column="ID_STATUS" property="idStatus"></result>
<result column="NAME_STATUS" property="nameStatus"></result>
<result column="DESC_STATUS" property="descStatus"></result>
<result column="ACTIVE" property="active"></result>
</resultMap>
</mapper>
这是我的实体bean:
@Entity
@Table(name = "CatStatusPrint")
public class CatStatusPrintBean implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "ID_STATUS")
private Integer idStatus;
@Basic(optional = false)
@Column(name = "NAME_STATUS")
private String nameStatus;
@Column(name = "DESC_STATUS")
private String descStatus;
@Basic(optional = false)
@Column(name = "ACTIVE")
private Integer active;
public CatStatusPrintBean() {
}
public CatStatusPrintBean(Integer idStatus) {
this.idStatus = idStatus;
}
public CatStatusPrintBean(Integer idStatus, String nameStatus, Integer active) {
this.idStatus = idStatus;
this.nameStatus = nameStatus;
this.active = active;
}
public Integer getIdStatus() {
return idStatus;
}
public void setIdStatus(Integer idStatus) {
this.idStatus = idStatus;
}
public String getNameStatus() {
return nameStatus;
}
public void setNameStatus(String nameStatus) {
this.nameStatus = nameStatus;
}
public String getDescStatus() {
return descStatus;
}
public void setDescStatus(String descStatus) {
this.descStatus = descStatus;
}
public Integer getActive() {
return active;
}
public void setActive(Integer active) {
this.active = active;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idStatus != null ? idStatus.hashCode() : 0);
return hash;
}
}
这是我的方法里面的方法:
public List<CatStatusPrintBean> getCatStatusPrint2(){
session2 = sqlSessionFactory2.openSession();
try {
List<CatStatusPrintBean> lstStatus = session2.selectList(TagsPrintConstants.MAPPER_CONSULT_STATUS);
return lstStatus;
} catch (Exception e) {
LOG.error(TagsPrintConstants.ERROR_OBTENER_CAT_IMPRESION + e.getMessage());
return null;
} finally {
session2.close();
}
}
为什么我得到并且错误??????? 在此先感谢!!
答案 0 :(得分:1)
我的配置似乎指向不同的数据库。 一旦我将它指向正确的数据库就可以了。