hibernate 异常
1.异常:org.hibernate.AnnotationException: No identifier specified for entity异常。
entity类是必须要主键的,否则就会报出这个异常。
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Integer id;
2.异常:exception just for purpose of providing stack trace
count(*) 返回的结果为Long类型,而非Integer
3.异常 org.hibernate.UnknownEntityTypeException
在使用spring的orm时,entity类没在hibernate sessionFactory的扫描中,导致。@entity要使用javax的entity而不是hibernate的。
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<!-- 可以加多个包 -->
<value>com.test.common.entity</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
4. org.hibernate.HibernateException: identifier of an instance of com.*.*DO was altered from 27 to null
出现这样的异常是从get中获取do对象,在进行更新前,将主键id给置为null导致。注意 BeanUtils.copyProperties,会将导入对象的null也给导入过来。
5. org.hibernate.HibernateException:Multiple references to database, sequence [**] were encountered attempting toset conflict values for initial value
出现的原因是在entity中有两个重复的实体类对应了sequence,多见于实体类重命名后mvn没有重新clean导致。 mvn clean package
hibernate 异常的更多相关文章
- Hibernate 异常总结
异常一 异常一 异常描述: Sax解析异常:cvc-复杂的类型,发现了以元素maping开头的无效内容,应该是以 ‘{“http://www.hibernate.org/xsd/orm/cfg“:pr ...
- Hibernate 异常 —— No CurrentSessionContext configured
在使用 SessionFactory 的 getCurrentSession 方法时遇到如下异常 “No CurrentSessionContext configured ” 原因是: 在hibern ...
- Hibernate 异常 —— Unable to instantiate default tuplize
出现这个异常 —— Unable to instantiate default tuplizer ,是 Hibernate 的映射文件(*.hbm.xml)导致的.仔细检查一下工程里的映射文件吧. 笔 ...
- Hibernate 异常 集锦
异常1.Error parsing JNDI name [foo] 异常信息摘要: org.hibernate.engine.jndi.JndiException: Error parsing JND ...
- hibernate异常:org.hibernate.exception.GenericJDBCException
异常:org.hibernate.exception.GenericJDBCException 提示:Cannot open connection 提示:不能打开链接 一般这个异常是由 java.sq ...
- hibernate异常:org.hibernate.MappingException
这个是映射文件配置错误 异常:org.hibernate.MappingException 提示:Could not determine type for: java.lang,String, at ...
- hibernate异常:org.hibernate.NonUniqueObjectException
异常:org.hibernate.NonUniqueObjectException 提示:a different object with the same identifier value was a ...
- Hibernate异常之命名查询节点未找到
异常信息: java.lang.IllegalArgumentException: No query defined for that name [salaryEmps] at org.hiberna ...
- Hibernate异常之Integer转float(自动类型转换错误)
错误代码: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Float at org.hiber ...
- Java EE 之Hibernate异常总结【1】org.hibernate.LazyInitializationException: could not initialize proxy - no Session
字面意义就是不能被初始化. 简单理解就是因为,你使用了lazy=true,这样hibernate在从数据库中调数据的时候是不会把关联的对象查出来的,而是保存一个获取值得方法,在你使用getXXX()调 ...
随机推荐
- 【转】每天一个linux命令(58):telnet命令
原文网址:http://www.cnblogs.com/peida/archive/2013/03/13/2956992.html telnet命令通常用来远程登录.telnet程序是基于TELNET ...
- AppBox下调用HighCharts画曲线
例子见本博文件下载. 注意 xAxis: { categories: [<%= xAxisCategories %>], ...
- Linux中的其他命令
1. 修改文件的所有者 chown 用户名 文件名 2. 修改文件所属组 chgrp 组名 文件名 3. 创建用户,创建组,将用户添加到组中等 修改film文件夹的所有者和所属组 修改film文 ...
- github高效搜索使用总结
swoole 普通搜索 in:name swoole 搜索仓库的名称,搜索仓库名称包含swoole关键字的所有项目 in:description swoole 搜索描述中包含swoole关键字的项目 ...
- JS怎么把字符串数组转换成整型数组
今天在学习highcharts时,遇到了一个把字符串数组转换为整形数组的问题,拿在这里讨论一下: 比如有一个字符串: var dataStr="1,2,3,4,5"; 现在需要把它 ...
- PAT 乙级 1038 统计同成绩的学生C++版
1038. 统计同成绩学生(20) 时间限制 250 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 本题要求读入N名学生的成绩,将 ...
- Web(click and script) 与 Web(HTTP/HTML)协议区别
先从最简单的说明上来看, Web(HTTP/HTML): Emulation of communication between a browser and Web Serve ...
- 操作系统-移动操作系统-百科: iOS(苹果公司的移动操作系统)
ylbtech-操作系统-移动操作系统-百科: iOS(苹果公司的移动操作系统) iOS是由苹果公司开发的移动操作系统.苹果公司最早于2007年1月9日的Macworld大会上公布这个系统,最初是设计 ...
- 接口测试3-2csv格式
csv文件数据 IntellJ IDEA打开终端:view-tool windows-terminal,可以在终端中查看文件路径 阿里 马云 京东 刘强东 京东 马化腾 #java //读取csv文件 ...
- Windows7无法访问共享文件夹(0x800704cf,0x80070035)解决方法
Windows7系统突然无法访问Linux的samba服务器,出现0x800704cf或者0x80070035错误,也不能访问其他windows机器的共享文件夹,解决方案如下两张图,配置与下面两张图为 ...