You have an error in your SQL syntax; check the manual that corresponds to your MySQL 完美解决
2016-05-16 14:11
633 查看
1.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 '5 cproduct0_.id as id0_, cproduct0_.bphoto as bphoto0_, cproduct0_.carMessage as' at line 1
2.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 '5 cproduct0_.id as id0_, cproduct0_.bphoto as bphoto0_, cproduct0_.carMessage as' at line 1
遇到这种情况,要看控制台输出的语句
Hibernate:
select
top 5 cproduct0_.id as id0_,
cproduct0_.bphoto as bphoto0_,
cproduct0_.carMessage as carMessage0_,
cproduct0_.created as created0_,
cproduct0_.price as price0_,
cproduct0_.sphoto as sphoto0_,
cproduct0_.status as status0_,
cproduct0_.tags as tags0_,
cproduct0_.text as text0_,
cproduct0_.title as title0_,
cproduct0_.updated as updated0_,
cproduct0_.video as video0_
from
c_product cproduct0_
我将这个带进去我的mysql数据查询说语句错误,然后将top5删除之后就可以了,因为mysql是不支持top的,所以不应该出现top 我出现top的原因是这里
看好了
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.hbm2ddl">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<!--<prop key="hibernate.current_session_context_class">thread</prop> -->
</props>
</property>
看出问题了吗。问题出现在第一个方言
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
这个是sqlserver的并不是mysql的,所以才会出现top。
改为
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
这就对了
2.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 '5 cproduct0_.id as id0_, cproduct0_.bphoto as bphoto0_, cproduct0_.carMessage as' at line 1
遇到这种情况,要看控制台输出的语句
Hibernate:
select
top 5 cproduct0_.id as id0_,
cproduct0_.bphoto as bphoto0_,
cproduct0_.carMessage as carMessage0_,
cproduct0_.created as created0_,
cproduct0_.price as price0_,
cproduct0_.sphoto as sphoto0_,
cproduct0_.status as status0_,
cproduct0_.tags as tags0_,
cproduct0_.text as text0_,
cproduct0_.title as title0_,
cproduct0_.updated as updated0_,
cproduct0_.video as video0_
from
c_product cproduct0_
我将这个带进去我的mysql数据查询说语句错误,然后将top5删除之后就可以了,因为mysql是不支持top的,所以不应该出现top 我出现top的原因是这里
看好了
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.hbm2ddl">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<!--<prop key="hibernate.current_session_context_class">thread</prop> -->
</props>
</property>
看出问题了吗。问题出现在第一个方言
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
这个是sqlserver的并不是mysql的,所以才会出现top。
改为
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
这就对了
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- Android之获取手机上的图片和视频缩略图thumbnails
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- 数据库链接字符串查询网站
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列