在实施物料清单概念时,我面临一个独特的问题。
使用的罐子:eclipselink 2.4.0、javax.persistence
实体如下:
@Id
@TableGenerator(name = "Config_Key_Incrementor", table = "id_generator", pkColumnName = "gen_name", valueColumnName = "gen_value", pkColumnValue = "conifg_id_gen", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = TABLE, generator = "Config_Key_Incrementor")
@Column(name = "config_id")
private int configId;
@Column(name = "config_name")
private String configName;
//bi-directional many-to-one association to Bill_Of_Material
@ManyToOne
@PrimaryKeyJoinColumn(name="config_id")
private Configuration parent;
//bi-directional many-to-one association to Bill_Of_Material
@OneToMany(mappedBy="parent")
private List<Configuration> children = new ArrayList<Configuration>();
public Configuration getParent() {
return parent;
}
public void setParent(Configuration parent) {
this.parent = parent;
}
public List<Configuration> getChildren() {
return children;
}
public void setChildren(List<Configuration> children) {
this.children = children;
}
public int getConfigId() {
return configId;
}
public void setConfigId(int configId) {
this.configId = configId;
}
public String getConfigName() {
return configName;
}
public void setConfigName(String configName) {
this.configName = configName;
}
当 IDE 环境是 eclipse juno 时,上面的代码可以正常工作。
输出(IDE是eclipse juno)-
CREATE TABLE configuration
(
config_id integer NOT NULL,
config_name character varying(255),
parent_config_id integer,
CONSTRAINT configuration_pkey PRIMARY KEY (config_id ),
CONSTRAINT fk_configuration_parent_config_id FOREIGN KEY (parent_config_id)
REFERENCES configuration (config_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
但是当 IDE 是 eclipse helios 时,相同的代码没有给出错误。
这里的输出(IDE是eclipse helios)是:
CREATE TABLE configuration
(
config_id integer NOT NULL,
config_name character varying(255),
CONSTRAINT configuration_pkey PRIMARY KEY (config_id ),
CONSTRAINT fk_configuration_config_id FOREIGN KEY (config_id)
REFERENCES configuration (config_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
上面的代码只需稍作修改即可工作(如帖子中的建议 - JPA 实体在实施物料清单概念时出现错误)
@ManyToOne
@JoinColumn(name="parent_config_id", referencedColumnName="config_id")
private Configuration parent;
问题:我无法弄清楚为什么仅在 IDE 版本更改时会显示此行为