Modelclass を更新すると、以下の例外が発生しました
18:27:15,203 ERROR [com.sinergia.ea.daoimpl.TypeOfArtifactDaoImpl] ERROR Exception in updateTypeOfArtifact() : o
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.getUpdateId(DefaultSaveOrUpdateEventListener.
at org.hibernate.event.def.DefaultUpdateEventListener.getUpdateId(DefaultUpdateEventListener.java:46) [:3
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventList
at org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListen
at org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:564) [:3.2.6.ga]
at org.hibernate.impl.SessionImpl.update(SessionImpl.java:552) [:3.2.6.ga]
at org.hibernate.impl.SessionImpl.update(SessionImpl.java:544) [:3.2.6.ga]
at com.sinergia.ea.daoimpl.TypeOfArtifactDaoImpl.updateTypeOfArtifact(TypeOfArtifactDaoImpl.java:67) [:]
モデル クラス :
@Entity
@Table(name="TYPE_OF_ARTIFACT")
public class TypeOfArtifactModel implements java.io.Serializable , Identifiable{
/**
*
*/
private static final long serialVersionUID = 2662289176706818360L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TYPE_OF_ARTIFACT_SEQ")
@SequenceGenerator(name = "TYPE_OF_ARTIFACT_SEQ", sequenceName = "TYPE_OF_ARTIFACT_SEQ")
@Column(name="ID",unique=true, nullable=false)
private Integer id;
@Column(name="DESCRIPTION", nullable=true, length=400)
private String description;
@Column(name="NAME", nullable=false, length=50)
private String name;
@OneToMany(fetch = FetchType.LAZY, targetEntity = AdditionalInfoModel.class, mappedBy = "typeOfArtifactID")
private Set<AdditionalInfoModel> additionalInfos = new HashSet<AdditionalInfoModel>(0);
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "TYPE_ARTIFACT_OPERATE_RELATION", joinColumns = { @JoinColumn(name = "TYPE_OF_ARTIFACT_ID") }, inverseJoinColumns = { @JoinColumn(name = "OPERATE_ARTIFACT_ID") })
private Set<TypeOfArtifactModel> checkedItems = new HashSet<TypeOfArtifactModel>(0);
@Column(name="FLAG",length=1)
boolean editable;
public TypeOfArtifactModel() {
}
DaoImppl の実装:
@Override
@Transactional(readOnly = true)
public Boolean updateTypeOfArtifact(@NotNull final TypeOfArtifactModel tipoModel,final Set<AdditionalInfoModel> additionalInfos,final Set<TypeOfArtifactModel> checkedItems) {
try {
System.out.println("Dao Impl Name :"+tipoModel.getName());
System.out.println("Dao Impl Description :"+tipoModel.getDescription());
System.out.println("Dao Impl CheckedItems :"+tipoModel.getCheckedItems());
if(additionalInfos !=null && !(additionalInfos.isEmpty())){
for(AdditionalInfoModel item : additionalInfos){
getSession().update(item);
}
tipoModel.setAdditionalInfos(additionalInfos);
}
getSession().update(tipoModel);
return Boolean.TRUE;
} catch (Exception e) {
log.error(" ERROR Exception in updateTypeOfArtifact() ", e);
return Boolean.FALSE;
}
}
update() メソッドを使用する場合にのみ上記の例外が発生しましたが、saveOrUpdate() メソッドを使用する場合は例外はありませんが、saveOrUpdate() メソッドで新しいレコードが作成され、レコードが更新されません。何が間違っているのか教えてください。その中で