primefaces使用复合主键在表格中编辑单元格

问题描述:

我正在使用primefaces 3.2单元格编辑组件更新具有复合主键的Oracle数据库表格。用户应该能够也编辑的主键值,但以这种方式,如果我使用primefaces使用复合主键在表格中编辑单元格

em.merge(entity); 

我有以下错误

Exception [EclipseLink-7251] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException 
Exception Description: The attribute [voce] of class [entity.competenze_distaccati.CompetenzeDistaccatiPK] is mapped to a primary key column in the database. Updates are not allowed. 

...这听起来合理的给我。问题是:我如何给用户改变主键值的可能性? rowEdit事件侦听器是用更改的值调用的,所以我不知道哪个是执行delete-insert的原始记录。

允许修改主键不正确处理数据的方式。相反,允许删除并再次添加记录与所需的值。这样,你将会遵循标准,并且你的问题也会得到解决。

+0

谢谢,使用你的建议,我仍然允许用户修改pk,但修改后的记录列表不会立即复制到数据库,而是在提交用户命令之后。这样,在提交我做:listOfRecordToRemove = listFromDB.removeAll(listEdited),而listOfRecordToInsert = listEdited.removeAll(listFromDB)。只知道要更新的记录我有一个由rowEdit事件监听器填充的HashSet。这对我有用。 – maxqua72 2012-03-19 07:32:26