`
wytkings
  • 浏览: 6474 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

ids for this class must be manually assigned ....

阅读更多
错误篇1:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): ***(POJO类,及持久化类名)

分析及解决:

你要操作的数据表中的id(即主键)的类型设置成了“自动增长类型”,而在你的

hibernate.cfg.xml中,id的生成方式是assigned,即
<id name="id" type="integer">
            <column name="id" />
            <generator class="assigned" />
</id>
这种搭配是矛盾的!

主键的assigned生成方式由程序自动生成表的主键,即在你的测试程序中要调用setId()方法,且必

须在调用save()前调用(或者说在调用save()前必须指定id,其实就是说,主键值不能为空!)。
把主键的生成方式改为native,它的特征是能够根据底层数据库自动选择主键生成方式。
分享到:
评论

相关推荐

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

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

    Solution for Designer error when opening WorldWind.cs in WW1.4.0

    When I load the WW ... The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. ...

    ssh框架报错分析集合

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

    hibernate常见问题及处理.doc

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

    工作周报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...

    dev_ids.tsv

    glue_data的MRPC数据集映射文件

    unidac 5.3.10

    Versions of UniDAC with Source Code must be installed manually. For more information, see the Installation topic of the UniDAC Help documentation. It is important to know that UniDAC, ODAC, SDAC, ...

    框架集合错误解决方案

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

    FastReport.v4.9.81 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版

    FastReport.v4.9.81 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版 delphi2010中文完美支持。 D2010安装必读 delphi2010使用者安装时,请将res\frccD14.exe更名名为frcc.exe frccD14.exe 是专门的...

    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 ...

    Developing Flex Applications 910p dda_doc88_cracker.zip

    Class hierarchy for components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Using styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    raid工作原理

    RAID(Redundant Array of Independent Disks,独立磁盘冗余阵列)是一种通过将数据分布在多个硬盘上,以提高存储性能、可靠性和容错性的技术。在本篇文章中,我们将深入探讨RAID的不同级别,包括RAID 0、RAID 1以及...

    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 ...

    Device Console (DevCon) Tool_01_源码修正编译通过,VS2013可调试.rar

    install Install a device manually. listclass List all devices in a setup class. reboot Reboot the local computer. remove Remove devices. rescan Scan for new hardware. resources List hardware resources...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持Delphi 4-XE5 and C++Builder 6-XE5. D2010以上版本(D14_D19)安装必读 delphi2010以上版本(D14_D19)使用者安装时,请将res\frccD14_...

    Fix_Damaged_FAT_Manually.rar_Damaged

    标题 "Fix_Damaged_FAT_Manually.rar_Damaged" 暗示了这是一个关于手动修复损坏FAT(File Allocation Table)的教程。FAT是文件系统的一部分,尤其在较老的操作系统如DOS和Windows 9x中广泛使用,用于管理硬盘上的...

    apktool documentation

    For the most part any apk in /system/framework on a device will be a framework file. On some devices they might reside in /data/system-framework and even cleverly hidden in /system/app or /system/priv...

    基于ssm+mysql的编程类在线答题系统源码数据库论文.docx

    In this thesis, the design and implementation of an online answer system for programming classes based on the SSM (Spring, SpringMVC, MyBatis) framework and MySQL database will be discussed....

Global site tag (gtag.js) - Google Analytics