org.hibernate.exception.SQLGrammarException: could notinsert: [com.michael.model.Storen]
来源:互联网 发布:淘宝达人账号简介 编辑:程序博客网 时间:2024/06/06 01:00
在做hibernate多对一关联时发现这样的异常
1.org.hibernate.exception.SQLGrammarException: could notinsert: [com.michael.model.Storen]
2.Caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table'hibernate.storen' doesn't exist
<!----------------------------hibernate映射文件-------------------------->
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
]>
<hibernate-mapping package="com.michael.model">
<class name="Storen" table="storen">
<id name="storenId"type="java.lang.String">
<column name="storen_Id"/>
<generatorclass="identity"></generator>
</id>
<property name="address"type="java.lang.String" />
<property name="storenName"type="java.lang.String" />
</class>
</hibernate-mapping>
从异常中可以看出来‘hibernate.storen’表不存在,注意这个测试的数据库名就是hibernate,一般出现这个异常把hibernate映射文件中catalog=“hibernate”去掉就行。
如果你发现在映射文件中的catalog="hibernate"存不存在,程序还是报Caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table'hibernate.storen' doesn't exist
异常。
这时你应该看看在hibernate映射文件中主键的类型是不是java.lang.String,如果是那么把它改成java.lang.Integer。在对应的持久化类中也改过来就ok了。
(欢迎转载)转载必须以链接方式声明原文来处,不然将追究法律责任!
- org.hibernate.exception.SQLGrammarException: could notinsert: [com.michael.model.Storen]
- org.hibernate.exception.SQLGrammarException: could not insert:
- org.hibernate.exception.SQLGrammarException: could not insert:
- org.hibernate.exception.SQLGrammarException: could not insert
- org.hibernate.exception.SQLGrammarException
- org.hibernate.exception.SQLGrammarException
- org.hibernate.exception.SQLGrammarException
- org.hibernate.exception.SQLGrammarException
- hibernate出现异常org.hibernate.exception.SQLGrammarException:could not execute
- Hibernate: org.hibernate.exception.SQLGrammarException: could not insert: 错误
- org.hibernate.exception.SQLGrammarException: could not execute query
- org.hibernate.exception.SQLGrammarException: could not execute query
- org.hibernate.exception.SQLGrammarException: could not execute query
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: could not execute query
- org.hibernate.exception.SQLGrammarException: could not execute query处理方式
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- 关于org.hibernate.exception.SQLGrammarException: could not insert:
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack问题解决
- struts2下载文件
- struts2自定义拦截器
- 移动互联网入口论之超级 APP
- hibernate集合映射
- org.hibernate.exception.SQLGrammarException: could notinsert: [com.michael.model.Storen]
- el表达式
- Struts2的Stack Context和ValueStack
- spring一些知识
- 黑马程序员——GUI
- [自学问题总结]静态成员和非静态成员的区别
- struts2类型转换
- struts2标签不显示Label属性
- jsp自定义标签