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

最新文章

  1. Atitit onvif协议获取rtsp地址播放java语言 attilx总结
  2. zookeeper3.3.6 伪分布式安装
  3. LUA之string的使用
  4. mysql笔记02 创建高性能的索引
  5. CSS实现图片快速等比例缩放,效果佳
  6. SQL中N $ # @的作用
  7. VMware10.0.4下 CentOS 6.5 cmake安装 MySQL 5.5.32
  8. excel多个文件合并
  9. jQuery Validate验证框架使用
  10. qtcreator增加doxygen注释
  11. 吐槽CSDN编辑
  12. File和byte[]转换
  13. java解析上传的excel
  14. Idea中执行TestNg报错
  15. TCP/IP滑动窗口
  16. scala中Either的一种使用场景
  17. uni-app开发小程序准备阶段
  18. A1104. Sum of Number Segments
  19. Hadoop+HBase+Spark+Hive环境搭建
  20. 疑犯追踪第一季/全集Person Of Interest迅雷下载

热门文章

  1. vsto excel 任务窗体操作
  2. Ribbon Control
  3. Keepalived+HAProxy实现RabbtiMQ高可用的负载均衡
  4. c 结构体的队列
  5. Oracle Grid control 11g及Active DataGuard 11g安装部署
  6. 如何检测NFC芯片型号?NFC手机即可!
  7. webpack创建library及从零开始发布一个npm包
  8. c++开发环境搭建
  9. bzoj 1414: [ZJOI2009]对称的正方形
  10. 学习笔记之Bitbucket