Hibernate.cfg.xml配置文件配置错误出现的问题
2013-08-02 23:30
603 查看
1.把配置多对一关系的语句中_和 - 写错误了:正确:<many-to-one name="depart" column="depart_id" />,错误配置:<many-to-one
name="depart" column="depart - id" />。sql语句中字段可以用_但是不能用—!!害得我找这个错误找了一天。
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [cw.ok.hibernate.bean.Employee]Caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-id) values ('?????‰',
2)' at line 1
2.配置信息是正确的,但是我把实体类中的id字段的属性的类型设置成String类型了,id应该是int 类型的。private int id ;
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [cw.ok.hibernate.bean.Department]Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'bbs.department' doesn't exist
3. 配置map集合的时候不map-key中type=“string” 写成了大写的String;报错!
<map name="employees">
<key column="depart_id" />
<map-key type="string" column="name" />
<one-to-many class="EmployeeList"/>
</map>
Caused by: org.hibernate.MappingException: Could not determine type for: String, for columns: [org.hibernate.mapping.Column(name)]4.配置hibernate.cfg.xml文件时,若配置的实体xml文件时,两文件名一样,包名是另一个子包;会报错~,程序不知道去父包中,还是子包中的配置文件;
<mapping resource="cw/ok/hibernate/bean/extend/Department.hbm.xml" /><mapping resource="cw/ok/hibernate/bean/extend/Employee.hbm.xml" />
<mapping resource="cw/ok/hibernate/bean/Department.hbm.xml" />
<mapping resource="cw/ok/hibernate/bean/Employee.hbm.xml" />
相关文章推荐
- 配置文件路径错误:ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml]
- hibernate.cfg.xml文件的配置问题
- 关于ssh 框架 applicationContext.xml文件中配置hibernate数据库出现的一个小问题
- SSH框架问题——hbm.xml配置出现的org.hibernate.MappingException: Could not determine type for:(貌似叫数据类型转换错误)问题
- hibernate+sqlserver2005连接对hibernate.cfg.xml文件的配置
- hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml配置文件详解
- Hibernate.cfg.xml注解和*.hbm.xml配置文件
- SpringMVC+HibernateValidator,配置在properties文件中的错误信息回显前端页面出现中文乱码
- 【Hibernate】Hibernate.cfg.xml配置文件详解
- hibernate.cfg.xml配置文件
- Hibernate_主配置文件(Hibernate.cfg.xml)
- 关于Myeclipse10中建立web工程添加spring配置文件出现红叉错误提示的问题
- hibernate配置文件(hibernate.cfg.xml)
- Maven项目总是出现org.hibernate.HibernateException: /hibernate.cfg.xml not found错误的解决方法
- Hibernate连接SQL Server2008时候hibernate.cfg.xml和table.hbm.xml文件的配置详情
- 解决在Spring整合Hibernate配置tx事务管理器出现错误的问题
- 关于Struts2在web.xml中配置后出现404错误的问题,完美解决方案!
- Hibernate3源码分析之hibernate.cfg.xml配置文件与SessionFactory类
- 总结:NHibernate——配置文件hibernate.cfg.xml