`

Hibernate中No row with the given identifier exists

阅读更多

今天做价格策略,报如下异常:

org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists

 

查了下,发现我的Model是这样写的:

@ManyToOne(fetch = FetchType.EAGER , targetEntity=TProductType.class)
@JoinColumn(name = "PRODUCT_NUM", unique=true, nullable = false, insertable = false, updatable = false)
public TProductType getProductType() {
	
	return productType;
}

@ManyToOne(fetch = FetchType.EAGER, targetEntity=TCommissionType.class)
@JoinColumn(name = "TYPE_NUM",nullable = false, insertable = false, updatable = false)
public TCommissionType getCommissionType() {
	
	return commissionType;
}
 

 其中productType和commissionType映射为联合主键(分别为PRODUCT_NUM、TYPE_NUM),分别从TProductType表、TCommission表引用主键。

一种策略对应1W中产品,即TYPE_NUM是可以重复了,但是映射时候unique = true,错误!!!

1.@JoinColumn(name = "TYPE_NUM")必须去掉unique = true。

2.targetEntity=TCommissionType.class,必须有,否则映射不到实体。

 

分享到:
评论

相关推荐

    no resource

    fe ge 2007 programe

    Hibernate+中文文档

    3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 3.10. JTA TransactionManagers 9.1. 继承映射特性(Features of inheritance mappings) 16.1. 别名注射(alias injection names) 19.1. ...

    Hibernate中文详细学习文档

    1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个Hibernate应用程序 1.2.1. 第一个class 1.2.2. 映射文件 1.2.3. Hibernate配置 1.2.4. 用Ant构建 1.2.5. 启动和辅助类 1.2.6. 加载并存储对象 1.3. 第...

    hibernate3.2中文文档(chm格式)

    HIBERNATE - 符合Java习惯的关系数据库持久化 Hibernate参考文档 3.2 -------------------------------------------------------------------------------- 目录 前言 1. 翻译说明 2. 版权声明 1. Hibernate...

    apktool_AndResGuard:修复apktool打包出现No resource found...

    No resource found that matches the given name..... ....... 使用apktool-2.0.3也可以回编译,但是比如微信回编译后会增加到110M左右,很不友好。 而使用apktool-2.3.2和原包大小一样,65M左右。 基于apktool

    Hibernate中文API

    1.2. 第一部分 - 第一个Hibernate应用程序 首先我们将创建一个简单的基于控制台的(console-based)Hibernate应用程序。由于我们使用Java数据库(HSQL DB),所以不必安装任何数据库服务器。 假设我们希望有一个小...

    Hibernate 中文 html 帮助文档

    1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个Hibernate应用程序 1.2.1. 第一个class 1.2.2. 映射文件 1.2.3. Hibernate配置 1.2.4. 用Ant构建 1.2.5. 启动和辅助类 1.2.6. 加载并存储对象 1.3. 第...

    The Digital Object Identifier initiative: metadata implications

    The Digital Object Identifier initiative: metadata implications Context/status information The purpose of this document is to generate a DOI Foundation consensus paper on metadata, as a companion ...

    不常用的TParser类解析(文本文件中相关字符串)

    Raises an EParserError exception with the given message procedure ErrorFmt(); Raises an EParserError exception and formats the message. procedure ErrorStr(); Raises an EParserError exception with ...

    hibernate.properties

    ## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager #hibernate.transaction.manager_lookup_class org.hibernate.transaction....

    HibernateAPI中文版.chm

    HIBERNATE - 符合Java习惯的关系数据库持久化 Hibernate参考文档 3.2 -------------------------------------------------------------------------------- 目录 前言 1. 翻译说明 2. 版权声明 1. Hibernate...

    Hibernate Tutorial 03 (Object Identifier).pdf

    上web tools课时老师发的关于hibernate的教程之一。大概内容看标题就知道了。需要注意的是文档全部是英文的。英文不好的童鞋就不要下了。。。

    微软内部资料-SQL性能优化5

    If there is no clustered index, there is a sysindexes row for the table with an indid value of 0, and that row will keep track of the address of the first IAM for the table. The IAM is a giant bitmap...

    Hibernate Reference Documentation3.1

    1.2. Part 1 - The first Hibernate Application 1.2.1. The first class 1.2.2. The mapping file 1.2.3. Hibernate configuration 1.2.4. Building with Ant 1.2.5. Startup and helpers 1.2.6. Loading and ...

    windows程序设计

    created with the default settings in Microsoft Visual C++ 6 with one major exception: aside from other compiler and linker flags, the executable in the DEBUG directory has been compiled with the ...

    servlet2.4doc

    Returns the value of the named attribute as an Object, or null if no attribute of the given name exists. getAttribute(String) - Method in interface javax.servlet.http.HttpSession Returns the object ...

    最全Hibernate 参考文档

    1. 在Tomcat中快速上手 1.1. 开始Hibernate之旅 1.2. 第一个持久化类 1.3. 映射cat 1.4. 与Cat同乐 1.5. 结语 2. 架构(Architecture) 2.1. 概况(Overview) 2.2. 实例状态 2.3. JMX整合 2.4. 对JCA的支持 3. 配置 ...

    Hibernate注释大全收藏

    • Single Table per Class Hierarchy Strategy: the <subclass> element in Hibernate 每个类层次结构一张表 • Joined Subclass Strategy: the <joined-subclass> element in Hibernate 连接的子类策略 @...

    hibernate 教程

    提供一个标识属性(identifier property)(可选) 4.1.4. 建议使用不是final的类 (可选) 4.2. 实现继承(Inheritance) 4.3. 实现equals()和hashCode() 4.4. 持久化生命周期(Lifecycle)中的回调...

    Hibernate_二级缓存总结

    HIBERNATE 中的 CACHE 有两级 . 一级是在 Session 范围内的 CACHE . 即每个 Session 有自己的一个 CACHE, 当前操作的对象都会被保留在 CACHE 中 . 但是 Session 关闭后这个 CACHE 也就没有 . 可见这级 CACHE 的生命...

Global site tag (gtag.js) - Google Analytics