Home  >  Article  >  Database  >  用hibernate操作数据库时,由于字段名称设置问题导致报错_MySQL

用hibernate操作数据库时,由于字段名称设置问题导致报错_MySQL

WBOY
WBOYOriginal
2016-06-01 13:07:19870browse

Hibernate

用ssh框架写的一个小项目,创建的表里边有几个int型的列,在往数据库里添加和往外读取的时候总是出错。

在网上查了一下之后发现int型的值如果想在数据库保存为null就得映射为Integer。如果映射为int,默认存储的是0.

然后修改成Integer映射的,结果读取不出错了,可是添加依然出错,简直崩溃。。。

幸运的是,我想到了将hibernate转化成的sql语句放在了mysql中直接执行了一下,发现也报错,这个时候我突然意识到,应该是语句的问题,根据报的错误号(1064),在网上搜了一下,发现是因为有字段名字是mysql的保留字,改完名字程序立马复活了。

记录一下,别再被这错误坑了。。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn