【发布时间】:2012-01-23 14:16:02
【问题描述】:
我正在使用 Playframework 1.2.4 和 PostgresSQL 9.1.2。我有以下实体:Recipe 和 RecipeItem。一个Recipe 有一组RecipeItems。我在 Recipe 类中对一组配方项进行了如下注释:
@Required
@MinSize(1)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable( name = "RecipeItemForIngredients",
joinColumns = @JoinColumn(name = "recipeId"),
inverseJoinColumns = @JoinColumn(name = "recipeItemId"),
uniqueConstraints = @UniqueConstraint(name = "uq_recipeItemPerRecipe",
columnNames = {"recipeId", "recipeItemId"}))
public Set<RecipeItem> items = Sets.newHashSet();
但是当我检查 PgAdmin 以查看约束是否已应用于 RecipeItemForIngredients 表时,我找不到它。这就是 PgAdmin 显示的内容。
CREATE TABLE recipeitemforingredients
(
recipeid bigint NOT NULL,
recipeitemid bigint NOT NULL,
CONSTRAINT recipeitemforingredients_pkey PRIMARY KEY (recipeid, recipeitemid),
CONSTRAINT fk5ac547a883708db FOREIGN KEY (recipeid)
REFERENCES recipe (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk5ac547ad6e1da8f FOREIGN KEY (recipeitemid)
REFERENCES "recipe$recipeitem" (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT recipeitemforingredients_recipeitemid_key UNIQUE (recipeitemid)
)
有谁知道为什么会发生这种情况?也许 Playframework 使用的 ORM 不支持这个注解。
【问题讨论】:
标签: jpa orm playframework