org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exc
2015-10-21 13:02
645 查看
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exc
分类: hibernate Javae 开发2012-08-15 14:16 4856人阅读 评论(4) 收藏 举报
nestedquerygeneratorschemaclasssqlserver
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException:
could not execute query
我的SSH项目原本使用的sqlserver2005数据库现在改用MySql。我改了applicationcontex的配置,我运行了就出现上面的异常错误!
在网上查了一下,有网友说是说没有表什么的,结果查了一下
我以为applicationcontex配置错误,改了又改,参照了又参照····没有查到什么错
我看到网友说 *.hbm.xml配置可能有问题,我就查看了下,然后再看看文档,文档配置如下:
6 <hibernate-mapping package="包名">
7 <class name="类名" table="表名">
8 <id name="主键在java类中的字段名" column="对应表中字段" type="类型 ">
9 <generator class="主键生成策略"/>
10 </id>
11
12 ……
13 </class>
14 </hibernate-mapping>
1. 主键(id)<class name="com.front.model.user.User" table="t_user" >
<!-- schema="dbo" catalog="stronger -->
而我的配置写的是:
<hibernate-mapping>
<class name="com.front.model.user.User" table="t_user" schema="dbo" catalog="stronger" >
<id name="userId" column="userId" type="java.lang.Integer">
<generator class="identity"/>
</id>
<property name="userName" column="userName" type="java.lang.String"></property>
<property name="password" column="password" type="java.lang.String"></property>
</class>
</hibernate-mapping>
于是我吧不同的schema和catalog注释了
<hibernate-mapping>
<class name="com.front.model.user.User" table="t_user" > <!-- schema="dbo" catalog="stronger -->
<id name="userId" column="userId" type="java.lang.Integer">
<generator class="identity"/>
</id>
<property name="userName" column="userName" type="java.lang.String"></property>
<property name="password" column="password" type="java.lang.String"></property>
</class>
</hibernate-mapping>
终于!弄了两天的东西终于出来了!
本人新手,遇到小问题的解决希望能对新手们有用。同时希望有人共同讨论web开发!有高手指点!
加我!!评论!!一起来学习!!
版权声明:本文为博主原创文章,未经博主允许不得转载。
相关文章推荐
- Java Volatile关键字
- 函数式编程在Java
- Junit入门(java测试)
- 关于查看jdk32位还是64位的超简单方法
- java学习之浅谈多线程3--线程间协作
- 第8周-位置类 Location
- 第8周-矩形类
- Eclipse sdkManager使用代理域名更新sdk
- Java基础--API 集合
- Java基础--API String
- Java加密技术(八)——初探SSL
- 从Java转iOS第一个项目总结(常用第三方,工具介绍)
- Java之JDK环境配置过程(图)
- Java IO: 管道
- java开源验证框架OVAL应用实例
- struts2国际化的两种方法
- java.lang.IllegalStateException: Fragment already added问题
- java.lang.IllegalStateException: getAttribute: Session already invalidated
- java上传excel并读取excel
- Spring事务配置的五种方式