`

hibernate:ids for this class must be manually assigned before calling save 解决方案

    博客分类:
  • db
阅读更多
出现该错误,说明保存对象的主键没有自动生成,需要根据不同的数据库,设计主键的生成方式,例如:
Oracle数据库:
在Hibernate的映射文件中,需要声明主键是根据序列自动生成的。
<id name="numitemid" type="java.lang.Integer">
			<column name="NUMITEMID" precision="20" scale="0" />
			<generator class="sequence">
				<param name="sequence">SEQ_TL_COMMON_ITEM</param>
			</generator>
		</id>


SQLite数据库:
在Hibernate的映射文件中,需要声明主键是自增的。
<id name="numitemid" type="java.lang.Integer">
			<column name="NUMITEMID" precision="20" scale="0" />
			<generator class="increment"></generator>
		</id>


关于主键generator 的类型,请参考文章:《Hibernate 主键generator类型》
http://javapub.iteye.com/blog/981993
分享到:
评论

相关推荐

    SSH整合项目中容易出现的错误

    1. org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save() 这个错误是由于在Hibernate的mapping文件中,元素没有正确配置,缺少了其子元素的配置...

    hibernate常见问题及处理.doc

    4. `org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():` 此异常意味着在尝试保存对象前,对象的主键没有被正确设置。通常,这是由于在映射...

    ssh框架报错分析集合

    1. `org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()` 这个异常通常是因为Hibernate在尝试保存对象时,发现对象的ID没有被正确地设置或生成...

    框架集合错误解决方案

    org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save() ``` **问题描述:** 当尝试保存一个实体对象时,如果该对象的`id`字段没有被手动赋值,...

    工作周报10221

    - **Hibernate逆向工程**:解决`ids for this class must be manually assigned`错误,修改了自动生成的ID配置,添加了`dynamic-update`和`dynamic-insert`属性以优化数据库操作。 - **Spring与Hibernate集成**:...

    EurekaLog_7.5.0.0_Enterprise

    This also reduces memory footprint for ecc32/emake 8)....Added: Showing call stacks for 2 new types of fatal memory errors 9)....Added: EMemLeaks._ReserveOutOfMemory to control reserve size of out of...

    qt动态场景源码

    在本文中,我们将深入探讨如何使用Qt框架来创建动态场景,特别是基于C++实现的案例。Qt是一个跨平台的应用程序开发框架,广泛用于GUI(图形用户界面)开发,同时也支持非GUI应用程序。它提供了丰富的API,使开发者...

    for linux PyV8-0.7.zip

    标题中的"for linux PyV8-0.7.zip"指的是适用于Linux操作系统的PyV8库的版本0.7的压缩包。PyV8是Python的一个扩展模块,它封装了Google的V8 JavaScript引擎,允许Python程序与JavaScript代码进行交互。在Python环境...

    Delphi RAD XE 不能安装,提示:JSharp Runtime 2.0 could not be installed.

    Please use Windows Update to manually install this update on your system. Embarcadero RAD Studio XE Setup cannot continue.” 从这条信息可以看出,Delphi RAD XE 的安装程序检测到系统上缺少必要的 JSharp ...

    c++ Strings

    For instance, to assign one string to another, the `strcpy()` function must be used instead of a simple assignment operator. Similarly, comparing two strings requires the `strcmp()` function rather ...

    dev_ids.tsv

    glue_data的MRPC数据集映射文件

    rubygems-master-(1).zip_GEM

    You must have an installation of RubyGems before this update can be applied. See Gem for information on RubyGems (or `ri Gem`) To upgrade to the latest RubyGems, run: $ gem update --system # you ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    If this is enabled, by calling the VsEnableImplicitPalette() function, the driver will define the settings for a given wavelength once, then saves the results within the VariSpec for faster access ...

    IOS5 Programming Cookbook

    - **Error Handling**: Compilation errors are common and must be addressed before your app can run. Common issues include syntax errors, missing imports, and type mismatches. ### 4. Running iOS Apps ...

    vb写的ole 回调函数

    'manually and everything should be set for your client app to call the server through 'OLE. 'Note6: Every time you build a new exe of your server, VB will generate a new 'unique ID for each of its ...

    UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY

    "UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY" 是一个常见的错误消息,它出现在Linux操作系统中,尤其是在系统突然关机或非正常关闭后。这个错误表明文件系统(File System)存在一致性问题,需要进行检查和修复。...

    acpi控制笔记本风扇转速

    ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by ...

    seagrid-master.zip

    SeaGrid is a Matlab 5.2+ application for generating an orthogonal grid within a curved perimeter, suitable for oceanographic modeling. With SeaGrid, one can: Select a conformal map projection. ...

    Python For ArcGIS 数据

    After that, the next assignment will be to answer the same question based on monthly species inventory datasets for fi sh and invertebrates.Performing this process manually for one dataset could be ...

    ULPBench - Beyond the Data Sheets of Ultra-Low-Power MCU.pdf

    Note: the USB driver must be manually installed because the USB driver is not recognized by the PC. The appropriate drivers are located in the /bin/USB_CDC folder. Connect the terminals +3 V (VCC) ...

Global site tag (gtag.js) - Google Analytics