Hibernate实践异常记录self
2017-06-14 23:28
357 查看
小序
或许网上搜罗下就能得到相关异常得解决方案了,个人相信这之后再遇到类似的异常,定会走同样的路。既然如此,何不深刻的理解下并记录下来,即使只是一些简单的问题也好。[不积跬步无以成千里]异常记录
org.hibernate.AnnotationException: No identifier specified for entity: Student对象关系映射的未加上主键 @Id
hibernate.cfg.xml 配置文件中未添加对 Student 对象的 < mapping > 标签声明
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned beforeQuery calling save():Student
“assigned”指示对象当中的主键未分配相应的属性值,这里我给 int 类型的主键加上自增注解 @GeneratedValue
org.hibernate.exception.SQLGrammarException: error performing isolated work
hibernate.cfg.xml 配置文件中添加< property name=”hibernate.hbm2ddl.auto” >validate< /property >
No default (no-argument) constructor for class: Student (class must be instantiated by Interceptor)
Student 对象须实现不带参数的默认构造函数,不然无法完成 hibernate 数据映射
check the manual that corresponds to your MySQL server version for the rightonds to your MySQL server version for the right syntax to use near ‘type=MyISAM’ at line 7
MySQL 版本兼容问题,方言< property name=”dialect”>设置为如下:
org.hibernate.dialect.MySQLInnoDBDialect(mysql5.0以前使用)
org.hibernate.dialect.MySQL5InnoDBDialect(mysq5.1-5.5)
org.hibernate.dialect.MySQLDialect(这个试了好像没用)
org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]
…
org.hibernate.PropertyNotFoundException: Could not locate getter method for property [Address#mPostcode]
- 如异常内容提示可知,是属性映射 getter 对应属性出错。后发现是属性命名与 getter/setter 存在命名问题,如经设置“mPostcode”这个属性在生成 getter/setter 后为 getPostcode(),其正确写法应该是 getmPostcode()。很奇怪这种情况对普通类型的属性并没有影响,这里是组合属性映射出现的问题。
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
需要将对应的 mysql-connector-java-*-bin.jar 包放置 Tomcat 的 lib 目录下
另外还要将该文件名配置于 jre 的 CLASS_PATH 路径下
相关文章推荐
- Android实践异常记录self
- Spring实践异常记录self
- MySQL实践异常记录self
- 关于hibernate 在Oracle中使用的一个异常记录
- hibernate异常记录(更新中)
- Hibernate实践程序1——DB中增加一条记录
- CXF实践中异常总结【记录收藏篇】
- Spring JPA 缺少 JAR 引起异常 记录整合中缺少 JAR 文件引起的异常 版本 Spring 3+ Hibernate 4+ JPA
- OneAPM大讲堂 | Java 异常日志记录最佳实践
- CXF实践中异常总结【记录收藏篇】
- 异常记录001—hibernate 4.2.4 Final 测试出现Connection cannot be null when 'hibernate.dialect' not set
- Hibernate ORM(2):Hibernate实践记录之一
- 记录org.hibernate.exception.GenericJDBCException: could not execute query异常
- 转载hadoop实践路上异常问题以及相关解决方法记录
- SSH框架开发异常记录:nested exception is org.hibernate.hql.ast.QuerySyntaxException
- Java 理论与实践: 关于异常的争论 ***推荐***
- [Hibernate]在用hibernate3.0进行查询时,java.lang.NoClassDefFoundError: antlr/ANTLRException【问题记录】
- Hibernate性能测试(load10000条记录的简单测试 仅供参考)
- 使用Application_Error事件处理程序把异常记录到系统事件日志
- [原创]hibernate 一对一实践 by hjack