Hibernate Mapping Exception:-9

if("true".equals(map.get("isAudited"))){
isAudited="=";//已审核
}else{
isAudited="<>";//待审核
}
String sql ="SELECT t.ORIGIN_DISTRICT2,t.ORIGIN_TOWN2,t.CORP_NAME,t.CONTACT_PERSON,t.MOBILE_PHONE,t.CORP_TYPE," +
"t.CORP_NATURE2,t.MAIN_PROD_TYPE,t.ANNUAL_SALES,t.ADDRESS_CITY2||t.ADDRESS_DISTRICT2||c.DQMC|| t.ADDRESS " +
"as addr,t.REGIST_TIME,t.CHECK_STATUS FROM (SELECT t.*,c.DQMC AS ADDRESS_DISTRICT2 FROM (SELECT t.*,s.NAME " +
"as CORP_NATURE2,c.DQMC as ADDRESS_CITY2 FROM (SELECT a.NAME99 as ORIGIN_DISTRICT2,b.dqjc as ORIGIN_TOWN2," +
"t.CORP_NAME,t.CONTACT_PERSON,t.MOBILE_PHONE,s.NAME as CORP_TYPE,t.CORP_NATURE,t.MAIN_PROD_TYPE,t.ANNUAL_SALES" +
",t.ADDRESS_CITY,t.ADDRESS_DISTRICT,t.ADDRESS_TOWN,t.ADDRESS,t.REGIST_TIME, t.CHECK_STATUS FROM BASE_CORP_INFO" +
" t LEFT JOIN SYS_DATA_DICT s on t.CORP_TYPE=s.DATA_DICT_NO LEFT JOIN base_coutry a on t.origin_district=(" +
"a.adcode99||‘000000‘) LEFT JOIN chongqing_temp b on t.origin_town=b.dqbm where t.check_status"+isAudited+"3)t LEFT JOIN " +
"SYS_DATA_DICT s on t.CORP_NATURE=s.DATA_DICT_NO LEFT JOIN CHINA_TEMP c on t.ADDRESS_CITY=c.DQBM )t LEFT " +
"JOIN CHINA_TEMP c on t.ADDRESS_DISTRICT=c.DQBM )t LEFT JOIN CHINA_TEMP c on t.ADDRESS_TOWN=c.DQBM order " +
"by t.ORIGIN_DISTRICT2,t.ORIGIN_TOWN2";

Query q=getSession().createSQLQuery(sql);

q.list();

会抛映射异常

使用笨办法解决:

Query q=getSession().createSQLQuery(sql).addScalar("ORIGIN_DISTRICT2", StringType.INSTANCE).addScalar("ORIGIN_TOWN2", StringType.INSTANCE)
.addScalar("CORP_NAME", StringType.INSTANCE).addScalar("CONTACT_PERSON", StringType.INSTANCE)
.addScalar("MOBILE_PHONE", StringType.INSTANCE).addScalar("CORP_TYPE", StringType.INSTANCE)
.addScalar("CORP_NATURE2", StringType.INSTANCE).addScalar("MAIN_PROD_TYPE", StringType.INSTANCE)
.addScalar("ANNUAL_SALES", StringType.INSTANCE).addScalar("addr", StringType.INSTANCE)
.addScalar("REGIST_TIME", StringType.INSTANCE).addScalar("CHECK_STATUS", StringType.INSTANCE);

即指定返回值的类型。有的hibernate版本是Hibernate.STRING,.INTEGER这么指定的。

时间: 2024-10-06 19:14:30

Hibernate Mapping Exception:-9的相关文章

hibernate mapping 主键配置方式

1. 主键(id) Hibernate的主键生成策略有如下几种: 1)  assigned 主键由外部程序负责生成,在 save() 之前指定. 2)  hilo 通过hi/lo 算法实现的主键生成机制,需要额外的数据库表或字段提供高位值来源. 3)  seqhilo 与hilo 类似,通过hi/lo 算法实现的主键生成机制,需要数据库中的 Sequence,适用于支持 Sequence 的数据库,如Oracle. 4)  increment 主键按数值顺序递增.此方式的实现机制为在当前应用实例

hibernate mapping文件中 xmlns会导致linq to xml 查询不到对应的节点

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Linq; using System.Xml.Linq; using System.Xml; using System.Windows.Forms; namespace ConsoleApplication27 { class Program

Spring Data JPA使用getOne方法报错:Method threw &#39;org.hibernate.LazyInitializationException&#39; exception. Cannot evaluate

getOne是懒加载,需要增加这个配置: spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true,但这种方式不太友好,建议不要使用. 解释:https://vladmihalcea.com/2016... 每次初始化一个实体的关联就会创建一个临时的session来加载,每个临时的session都会获取一个临时的数据库连接,开启一个新的事物.这就导致对底层连接池压力很大,而且事物日志也会被每次flush.设想一下:假如我们查询了

ERROR org.hibernate.search.exception.impl.LogErrorHandler - HSEARCH000058: HSEARCH000183: Unable to index instance of type

2019-06-12 10:17:42 [Hibernate Search: entityloader-1] ERROR org.hibernate.search.exception.impl.LogErrorHandler - HSEARCH000058: HSEARCH000183: Unable to index instance of type net.shopxx.entity.Product while batch indexing: Entity of type net.shopx

IDEA + SSH OA 第一天(Hibernate : Mapping (RESOURCE) not found)

切入主题,看看今天的错误是如何发生的: 首先这是我的项目路径,java 是 Sources Root , resources 是 Resources Root ,放了所需要的配置文件,其中 Hibernate 的配置,显示的是绿色,说明没有问题 在 eclipse 中,这样是行得通的,运行也没问题.但是在 IDEA 中会报这样一个错误 Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not fo

hibernate映射exception

错误原因:在通过hibernate指示生成两个表之间的外键关系之后,一个表中引用的外键不在另一个表的参考范围里面. 解决:使之满足参考完整性 org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing 错误原因:在将classes持久化到数据库之前数据库中并没有students表 publi

Could not parse mapping document from input stream hibernate配置异常

十二月 18, 2016 4:24:29 下午 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.B

hibernate 级联删除报更新失败的问题(org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)

首先hibernate级联删除的前提是,首先需要在映射文件中配置,配置多表之间的关联关系: 下面以部门表(Dept)和员工表(Emp)为例: 1.在Emp.hbm.xml映射文件中配置many-to-one关系 1 <?xml version="1.0"?> 2 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 3 "http:/

org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert=&quot;false&quot; update=&quot;false&quot;)

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDup