有人可以在启动我的websphere服务器时帮助解决与hibernate相关的以下错误:
基本上,L_SUBLIST_DETAIL是带有主键的主表。这与其他2个表L_SUBLIST_CSI_BU_MAPPING和L_SUBLIST_RULESET_MAPPING有一对多的映射。问题似乎与L_SUBLIST_RULESET_MAPPING表并存,其中sublist_id和ruleset_id形成复合键,sublist_id是引用L_SUBLIST_RULESET_MAPPING表的sublist_id的外键。
************************** Error ******************
Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.myProj.appName.ruleset.vo.LSublistRulesetMappingVO column: SUBLIST_ID (should be mapped with insert="false" update="false")
涉及的java类如下。
LSublistRulesetMappingVO
@Entity
@IdClass(LSublistRulesetMappingVOPK.class)
@Table(name = "L_SUBLIST_RULESET_MAPPING")
public class LSublistRulesetMappingVO implements IBaseVO{
@Id
Long sublistId;
@Id
Long rulesetId;
@Column(name = "CSIID")
private String csiid;
public LSublistRulesetMappingVO(){}
public Long getSublistId() {
return sublistId;
}
public void setSublistId(Long sublistId) {
this.sublistId = sublistId;
}
public Long getRulesetId() {
return rulesetId;
}
public void setRulesetId(Long rulesetId) {
this.rulesetId = rulesetId;
}
public String getCsiid() {
return csiid;
}
public void setCsiid(String csiid) {
this.csiid = csiid;
}
}
LSublistRulesetMappingVOPK
@Embeddable
public class LSublistRulesetMappingVOPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "SUBLIST_ID")
Long sublistId;
@Column(name = "RULESET_ID")
Long rulesetId;
public LSublistRulesetMappingVOPK() {}
public LSublistRulesetMappingVOPK(Long sublistId, Long rulesetId) {
this.sublistId = sublistId;
this.rulesetId = rulesetId;
}
public Long getSublistId() {
return sublistId;
}
public void setSublistId(Long sublistId) {
this.sublistId = sublistId;
}
public Long getRulesetId() {
return rulesetId;
}
public void setRulesetId(Long rulesetId) {
this.rulesetId = rulesetId;
}
}
LSublistCsiBUMappingVO
import com.myProj.appName.web.vo.IBaseVO;
@Entity
@Table(name = "L_SUBLIST_CSI_BU_MAPPING")
public class LSublistCsiBUMappingVO implements IBaseVO {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sublistCsiBuMapSeq")
@SequenceGenerator(name="sublistCsiBuMapSeq", sequenceName="L_SUBLIST_CSI_BU_MAPPING_SEQ", allocationSize = 1)
@Column(name = "MAPPING_ID")
private Long mappingId;
@Column(name = "SUBLIST_ID", insertable = false, updatable = false)
private Long sublistId;
@Column(name = "CSIID")
private String csiId;
@Column(name = "BU_INTERNAL_ID")
private Long buId;
@Column(name = "SOURCE_SUBLIST_ID")
private String sourceSublistId;
public Long getMappingId() {
return mappingId;
}
public void setMappingId(Long mappingId) {
this.mappingId = mappingId;
}
public Long getSublistId() {
return sublistId;
}
public void setSublistId(Long sublistId) {
this.sublistId = sublistId;
}
public String getCsiId() {
return csiId;
}
public void setCsiId(String csiId) {
this.csiId = csiId;
}
public Long getBuId() {
return buId;
}
public void setBuId(Long buId) {
this.buId = buId;
}
public String getSourceSublistId() {
return sourceSublistId;
}
public void setSourceSublistId(String sourceSublistId) {
this.sourceSublistId = sourceSublistId;
}
}
LSublistDetailVO
@Entity
@Table(name = "L_SUBLIST_DETAIL")
public class LSublistDetailVO implements IBaseVO{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sublistDetailSeq")
@SequenceGenerator(name="sublistDetailSeq", sequenceName="L_SUBLIST_DETAIL_SEQ", allocationSize = 1)
@Column(name = "SUBLIST_ID")
private Long sublistId;
@Column(name = "SUBLIST_NAME")
private String sublistName;
@Column(name = "SUBLIST_DESC")
private String sublistDesc;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval= true)
@JoinColumn(name="SUBLIST_ID", nullable = false)
private Set<LSublistCsiBUMappingVO> sublistCsiBUMappingVOSet;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval= true)
@JoinColumn( name="SUBLIST_ID", nullable = false)
private Set<LSublistRulesetMappingVO> sublistRulesetMappingVOSet;
public Long getSublistId() {
return sublistId;
}
public void setSublistId(Long sublistId) {
this.sublistId = sublistId;
}
public String getSublistName() {
return sublistName;
}
public void setSublistName(String sublistName) {
this.sublistName = sublistName;
}
public String getSublistDesc() {
return sublistDesc;
}
public void setSublistDesc(String sublistDesc) {
this.sublistDesc = sublistDesc;
}
public Set<LSublistCsiBUMappingVO> getSublistCsiBUMappingVOSet() {
return sublistCsiBUMappingVOSet;
}
public void setSublistCsiBUMappingVOSet(
Set<LSublistCsiBUMappingVO> sublistCsiBUMappingVOSet) {
this.sublistCsiBUMappingVOSet = sublistCsiBUMappingVOSet;
}
public Set<LSublistRulesetMappingVO> getSublistRulesetMappingVOSet() {
return sublistRulesetMappingVOSet;
}
public void setSublistRulesetMappingVOSet(
Set<LSublistRulesetMappingVO> sublistRulesetMappingVOSet) {
this.sublistRulesetMappingVOSet = sublistRulesetMappingVOSet;
}
}
答案 0 :(得分:0)
你不能在同一个类LSublistRulesetMappingVO中有两个主键@Id。
答案 1 :(得分:0)
我更改了以下2个语句的顺序,服务器已启动。 any1可以解释什么是问题??????????????
旧:
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
@JoinColumn(name =&#34; SUBLIST_ID&#34;,nullable = false)
private Set sublistCsiBUMappingVOSet;
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
@JoinColumn(name =&#34; SUBLIST_ID&#34;,nullable = false)
private Set sublistRulesetMappingVOSet;
新:
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
@JoinColumn(name =&#34; SUBLIST_ID&#34;,nullable = false)
private Set sublistRulesetMappingVOSet;
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
@JoinColumn(name =&#34; SUBLIST_ID&#34;,nullable = false)
private Set sublistCsiBUMappingVOSet;