我有bean classr FolderStructure 有一些注释如下。我想更新嵌入式类中的一些属性(FolderStructureCompositeKey类中的nodeId)。怎么实现呢?
@Entity
@Table(name = "T_PROGRAM_STRUCTURE", schema = "PROGRAM")
public class FolderStructure implements Serializable, BaseDomain{
private static final long serialVersionUID = 2984032007505132468L;
@EmbeddedId
private FolderStructureCompositeKey pk;
@Transient
private Integer nodeID;
@Transient
private Integer parentID;
@Column(name = "CHILD_COUNT")
private Integer childCount;
@Column(name = "OBJECT_TYPE")
private String type;
public FolderStructure(){
}
public FolderStructure(Integer nodeID, Integer parentID, Integer childCount, String type) {
this.pk = new FolderStructureCompositeKey(nodeID, parentID);
this.nodeID = nodeID;
this.parentID = parentID;
this.childCount = childCount;
this.type = type;
}
public Integer getNodeID() {
return nodeID;
}
public void setNodeID(Integer nodeID) {
createPK();
this.nodeID = nodeID;
}
public Integer getParentID() {
return parentID;
}
public void setParentID(Integer parentID) {
createPK();
this.parentID = parentID;
}
public Integer getChildCount() {
return childCount;
}
public void setChildCount(Integer childCount) {
this.childCount = childCount;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public FolderStructureCompositeKey getPk(){
return pk;
}
public void setPk(FolderStructureCompositeKey pk) {
this.pk = pk;
}
@Override
public String toString() {
return "FolderStructure [folderStructureCompositeKey=" + pk + ", nodeID=" + nodeID
+ ", parentID=" + parentID + ", childCount=" + childCount + ", type=" + type + "]";
}
@Override
public void createPK() {
if (pk == null) {
pk = new FolderStructureCompositeKey();
}
}
}
我有这样的嵌入式课程。
@Embeddable
public class FolderStructureCompositeKey implements Serializable {
private static final long serialVersionUID = 4049555022783005378L;
@Column(name = "OBJECT_ID")
private Integer nodeID;
@Column(name = "PARENT_ID")
private Integer parentID;
public FolderStructureCompositeKey() {
}
public FolderStructureCompositeKey(Integer nodeID, Integer parentID) {
this.nodeID = nodeID;
this.parentID = parentID;
}
public Integer getNodeID() {
return nodeID;
}
public void setNodeID(Integer nodeID) {
this.nodeID = nodeID;
}
public Integer getParentID() {
return parentID;
}
public void setParentID(Integer parentID) {
this.parentID = parentID;
}
@Override
public String toString() {
return "FolderStructureCompositeKey [nodeID=" + nodeID
+ ", parentID=" + parentID + "]";
}
}
谢谢