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,必须有,否则映射不到实体。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值