錯誤如下:
Data Access Failure
identifier of an instance of com.tar.model.CargoType was altered from 402881821bdb7471011bdb75c08e0002 to 402881821bdb7471011bdb7586530001; nested exception is org.hibernate.HibernateException: identifier of an instance of com.tar.model.CargoType was altered from 402881821bdb7471011bdb75c08e0002 to 402881821bdb7471011bdb7586530001
我在論壇上看看別以前發的帖子,沒有找到答案,求解呀!
子類:
public class Cargo extends BaseObject implements java.io.Serializable {
private CargoType cargoType = new CargoType();
@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
@JoinColumn(name = "cargo_type_id")
public CargoType getCargoType() {
return this.cargoType;
}
public void setCargoType(CargoType cargoType) {
this.cargoType = cargoType;
}
}
父類:
public class CargoType extends BaseObject implements java.io.Serializable {
private String cargoTypeId;
private String cargoTypeName;
private Set<Cargo> cargos = new HashSet<Cargo>(0);
@Column(name = "cargo_type_name", nullable = false)
public String getCargoTypeName() {
return this.cargoTypeName;
}
public void setCargoTypeName(String cargoTypeName) {
this.cargoTypeName = cargoTypeName;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "cargoType")
public Set<Cargo> getCargos() {
return this.cargos;
}
public void setCargos(Set<Cargo> cargos) {
this.cargos = cargos;
}
}
form jsp的內容如下:
<form:select path="cargoType.cargoTypeId" cssClass="select medium" cssErrorClass="select medium error" id="cargoType.cargoTypeId" >
<form:option value="" label="Please Select"/>
<form:options items="${cargoTypeList}" itemValue="cargoTypeId" itemLabel="cargoTypeName"/>
</form:select>
有沒有下面這兩行都是報那個錯誤.
String cargoTypeId = request.getParameter("cargoType.cargoTypeId");
cargo.setCargoType(cargoTypeManager.get(cargoTypeId));
cargoManager.save(cargo);//調用的是這個方法getHibernateTemplate().merge(object)
cascade變成:
@ManyToOne(cascade = {CascadeType.PERSIST}),不讓它級聯更新,也可以,但這只是一個暫的辦法
分享到:
相关推荐
7.5.1. one to many / many to one 7.5.2. one to one 7.5.3. many to many 7.6. More complex association mappings 8. Component Mapping 8.1. Dependent objects 8.2. Collections of dependent objects 8.3. ...
"硬件精灵Unknown Device Identifier"是一款专门用于识别和解决电脑中未知设备问题的工具软件。它在IT领域中扮演着重要角色,特别是在系统维护和硬件升级过程中。未知设备是指操作系统无法正确识别或驱动程序缺失的...
While it has been tested and has even been used in at least two production applications for several months now prior to initial release, there are so many combinations of property settings, ...
标题和描述中提到的"PC-IDENTIFIER-**.**.**.**-**.**.**.**安装包-链接地址.txt"和"PC_IDENTIFIER_**.**.**.**_**.**.**.**安装包_链接地址"是文件的名称和描述,它们所指的知识点是关于一个特定版本的软件或插件的...
Introduction Many organizations use disk image cloning to perform mass rollouts of Windows. This technique involves copying the disks of a fully installed and configured Windows computer onto the disk...
connector's end point moving, the link is breaks if the move was not on one of the flex-controls connection points. Contain False as default. - ADD Added ControlDocRect parameter in event ...
在Oracle数据库管理中,"Connect to Idle Instance"问题通常是由于实例未启动或配置不正确导致的,这使得用户无法成功连接到数据库实例。本文将详细解释这个问题的成因、检查步骤以及解决方法。 首先,Oracle SID...
Each index row in node pages contains an index key (or set of keys for a composite index) and a pointer to a page at the next level for which the first key value is the same as the key value in the ...
1. A practical approach to motion generation and control for an omnidirectional mobile robot Paromtchik, I.E.; Rembold, U. Robotics and Automation, 1994. Proceedings., 1994 IEEE International ...
Many of these data centers are located in, or close to, lower tier ISPs. Therefore, when Google delivers content to a user, it often can bypass higher tier ISPs. What motivates content providers to ...
- **`clonePosition(element, source[, options])`**: Clones the positioning properties of one element to another. - **`cumulativeOffset(element)`**: Computes the cumulative offset of an element from ...
7.2.4. 值集合于多对多关联(Collections of values and many-to-many associations) 7.2.5. 一对多关联(One-to-many Associations) 7.3. 高级集合映射(Advanced collection mappings) 7.3.1. 有序集合(Sorted...
### 解决Error C2065:'_beginthreadex':Undeclared Identifier #### 错误概述 在编译过程中遇到“Error C2065:'_beginthreadex':undeclared identifier”这一错误信息时,通常意味着编译器无法识别`_...
Java实现标识符对类的访问控制代码Java implementation of access control identifier code of the class
CPU-Identifier, 检查你的A9芯片制造商 CPU标识符这个小应用程序可以检测你的iPhone的CPU芯片组。 对于 iPhone/6s,它还可以检测到A9芯片的制造商。编译的( 签名) 二进制文件将把芯片模型。设备模型和一个惟一 id ( ...
一对多(one to many) /多对一( many to one) 8.5.2. 一对一(one to one) 8.5.3. 多对多(many to many) 9. 组件(Component)映射 9.1. 依赖对象(Dependent objects) 9.2. 在集合中出现的依赖对象 ...
7.4.1. 一对多(one to many) / 多对一(many to one) 7.4.2. 一对一(one to one) 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) 7.5.1. 一对多(one to many) /多对一( many to ...
7.4.1. 一对多(one to many) / 多对一(many to one) 7.4.2. 一对一(one to one) 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) 7.5.1. 一对多(one to many) /多对一( many ...
7.5.1. 一对多(one to many) /多对一( many to one) 7.5.2. 一对一(one to one) 7.5.3. 多对多(many to many) 8. 组件(Component)映射 8.1. 依赖对象(Dependent objects) 8.2. 在集合中出现的依赖对象 ...