database returned no natively generated 分类:Hibernatehbm.xml中的配置如下:
<id name="logId" type="integer" column="LOGID">
<generator class="native"/>
</id>
native的功能是:
由数据库从identity,sequence和hilo中选取一个生成器来生成ID。
这样就需要主键设置成自增长的,一定要小心
采用的是Mysql5数据库,但在执行插入的时候报错:
The database returned no natively generated identity value
最后确认原因是数据库的表结构中关于logid,没有设置auto increment。
正确的建库如下:
CREATE TABLE `log` (
`LOGID` int(11) NOT NULL
auto_increment,
`LOGUSER` varchar(10) default NULL,
`LOGTIME` datetime default NULL,
`LOGTYPE` char(1) default NULL,
PRIMARY KEY (`LOGID`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk
完整的hbm.xml如下:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.shinyv.dao.hibernate.test">
<class name="Log" table="log" proxy="Log" dynamic-insert="true" dynamic-update="true">
<id name="logId" type="integer" column="LOGID">
<generator class="native"/>
</id>
<property name="logTime" column="LOGTIME" not-null="true"/>
<property name="userName" type="string" column="LOGUSER"/>
<property name="logType" column="LOGTYPE"/>
</class>
</hibernate-mapping>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zwhfyy/archive/2007/05/15/1610157.aspx
分享到:
相关推荐
java was started but returned exit code=1; 关于Android最新的SDK下载解压后出现java was started but returned exit code=1;时的解决方法,我在网上参考相关文献后得出的,希望对你有用!
Instead of being freed when released, however, connections are returned to a pool of available connections managed by VDB. When the application needs a connection, it is taken from the pool. The ...
git首次提交代码到远程仓库提示413错误,错误信息如下 git push --set-upstream origin master Enumerating objects: 153, done. ... HTTP 413 curl 22 The requested URL returned error: 413 Req
Dev C++编写C-C++程序出现[Error] ld returned 1 exit status报错分析及解决 在使用Dev C++编写C/C++程序时,经常会出现[Error] ld returned 1 exit status报错,这个报错信息非常让人头疼。下面我们来分析和解决这...
在区块链开发领域,EOS作为一种新兴的高性能区块链平台,其智能合约和链上操作涉及到大量的技术细节和状态检查。为了确保操作的正确性,EOS提供了丰富的错误代码以帮助开发者识别和定位问题。本文集整理了EOS区块链...
在本文中,我们将详细探讨如何在CentOS 6 64位系统上安装Oracle 11g Express Edition (XE)。Oracle XE是一款轻量级的数据库管理系统,适合开发和测试环境,它提供了与标准版Oracle数据库类似的功能,但资源消耗更低...
If the number being returned from Oracle Database is not an integer, the fractional part is discarded, and no error or other indication is returned. If the number to be returned exceeds the capacity ...
DUMP TRANSACTION @db WITH NO_LOG; BACKUP LOG @db WITH NO_LOG; DBCC SHRINKFILE('omis_log'); ``` 注意:在执行上述操作之前,请确保理解其含义及可能产生的影响,并在测试环境中验证其效果。 2. **优化硬件...
声明 ... 概述: ...服务器理解请求方的请求,但是拒绝处理请求,通常是因为服务器上的文件设置权限导致的请求访问报错403。...报错Server returned HTTP response code 403 for URL.txt》里面的内容操作。
This writes up to nbytes bytes to the FIFO If the head runs in to the tail, not all bytes are written The number of bytes written is returned
Machine description operations are to be surrounded by grab and release calls. The mdesc_handle returned the grab is the first argument to all of the operational calls that work on mdescs.
标题中的"pci-swiotlb.rar_The_Returned"暗示了我们正在处理与PCI(Peripheral Component Interconnect)总线相关的软件I/O页表别名(Software I/O Translation Lookaside Buffer)的更新或修复工作,其中"The_...
NULL 博文链接:https://angelguo.iteye.com/blog/2282002
Returns a ui::Event wrapping a native event. Ownership of the returned value is transferred to the caller.
标题中的"The system Message Box that is closed automatically after some time"指的是一个自动关闭的系统消息框,这种消息框在显示一段时间后会自动消失。在编程中,这样的功能常常用于提示用户一些临时性信息,...
The classical KMP algorithm for string matching (the target string can be modified in the main function, if any match is found, the matching position would be returned)
From a given image, this code returns it in the following colour spaces RGB,NTCS,YCBCR,HSV. The fields are returned in a matrix of dimensions (:,:,12)
标题 "mga_drv.rar_The Returned" 暗示我们关注的是一个与图形处理相关的驱动程序,特别是针对MGA(可能是指Matrox G450)显卡的驱动。描述中提到,如果设备是PCI G450,函数将返回0,否则返回2。这表明在驱动程序中...
EXPORTPLOTDATA_CMENU Context menu to export plot data to workspace or file ... as returned by PLOT), which allows the user to export the line s data to a workspace variable or a file
The "unknown" protocol. This is what is used for protocols we don t understand. It s returned by ip_ct_find_proto, Linux API.