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
centos-6 64位安装 oracle xe,亲测
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 ...
If the device is a PCI G450, zero is returned. Otherwise 2 is returned.
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.
Keep the generation correct by bumping rptr until it matches the index returned by the rearm - 1.
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 atuomatically after some time(21KB)
ld returned 1 exit status;Makefile
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)
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.
Undelivered Mail Returned to Sender (3.95 KB).msg
Structure usb_handle describes our connection to the usb device via AdbWinApi.dll. This structure is returned usb_open() routine and is expected in each subsequent call that is accessing the device.
this could be a inner header returned in icmp packet in such cases we cannot update the checksum field since it is outside of the 8 bytes of transport layer headers we are guaranteed.