`
alyouge
  • 浏览: 193714 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

ids for this class must be manually assigned before calling save() composite-id

阅读更多
hibernate  composite-id 存储的售后一定要指明ID



例如 

[code="xml"]

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.model.entity.AcctUserRole" table="ACCT_USER_ROLE" schema="MODEL">
        <composite-id name="id" class="com.model.entity.AcctUserRoleId">
            <key-many-to-one name="acctUser" class="com.model.entity.AcctUser">
                <column name="USER_ID" precision="9" scale="0" />
            </key-many-to-one>
            <key-many-to-one name="acctRole" class="com.model.entity.AcctRole">
                <column name="ROLE_ID" precision="9" scale="0" />
            </key-many-to-one>
        </composite-id>
        <many-to-one name="acctUser" class="com.model.entity.AcctUser" update="false" insert="false" fetch="select">
            <column name="USER_ID" precision="9" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="acctRole" class="com.model.entity.AcctRole" update="false" insert="false" fetch="select">
            <column name="ROLE_ID" precision="9" scale="0" not-null="true" />
        </many-to-one>
    </class>
</hibernate-mapping>




AcctUserRole 需要保存的时候

调用如下

AcctUserRole aur = new AcctUserRole();
AcctUserRoleId auri = new AcctUserRoleId();
AcctRole ar = new AcctRole();
ar.setId(id_);
auri.setAcctRole(ar);
auri.setAcctUser(entity);
aur.setId(auri);
acctUserRoleDAO.save(aur);
分享到:
评论

相关推荐

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

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

    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():` 此异常意味着在尝试保存对象前,对象的主键没有被正确设置。通常,这是由于在映射...

    框架集合错误解决方案

    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集成**:...

    qt动态场景源码

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

    win 3.11 for workgroup tcpip支持

    RELEASE NOTES FOR MICROSOFT(R) TCP/IP-32 FOR WINDOWS(TM) FOR WORKGROUPS 3.11 PLEASE READ THIS ENTIRE DOCUMENT General ------- This product is compatible with, and supported exclusively on, the ...

    Diskeeper 2008 v12.0.759.0

    Note that Windows 2000 systems must be running Service Pack 3 or higher. The Windows versions supported vary by Diskeeper edition. See the Table of Supported Operating Systems later in this ...

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

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

    一个win32下的ARM开源编译器

    This package is an ARM assembler add-on for FASM. FASMARM currently supports the full range of instructions for 32-bit and 64-bit ARM processors and coprocessors up to and including v8. Contents: ...

    macOS Unlocker 2.1 for VMware Workstation 11/12/14(VM14破解补丁)

    You will have to manually mount the darwin.iso for example on Workstation 11 and Player 7. The vmwarebase code does not need to be patched on macOS or ESXi so you will see a message on those systems ...

    Android代码-react-native-ble-manager

    npm i --save react-native-ble-manager After installing, you need to link the native library. You can either: Link native library with react-native link, or Link native library manually Both ...

    ICS delphixe10源码版

    The origin of this software must not be misrepresented, you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product ...

    dwl-g122 b1 c1

    10. Add XP64 & Vista64 drivers for DWL-G122 (rev.C) 11. Add XP64 drivers for DWL-G122 (rev.B) ------------------------------------------------------------------------------------------- Setup Version:...

    EhLib 8.0 Build 8.0.023 Pro Edition FullSource for D7-XE8

    EhLib 8.0 Build 8.0.023 Pro Edition FullSource for D7-XE8 亲测可用,含全部源码及 Demo The Library contains components and classes for Borland Delphi versions 7, 9, Developer Studio 2006, Delphi 2007...

    dev_ids.tsv

    glue_data的MRPC数据集映射文件

    apktool documentation

    We must get HTC framework resources before decoding this apk. We pull com.htc.resources.apk from our device and install it $ apktool if com.htc.resources.apk I: Framework installed to: 2.apk Now we ...

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

    vmware workstation 11 unlock

    The python.exe file must be on the executable PATH. If it is not on PATH please edit win-install.cmd to point to the installation path. 3. Limitations -------------- The Unlocker currently does not...

Global site tag (gtag.js) - Google Analytics