我已经尝试使用以下JDO课程,我尝试使用DataNucleus 4.1.0-release
:
@PersistenceCapable(table = "accounts", identityType = IdentityType.APPLICATION, detachable = "true")
public final class Account {
@Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
@Column(allowsNull = "false")
private long id;
// A Set of enum constants.
@Persistent(table = "account_roles")
@Join(column = "account_id", primaryKey = "account_roles_account_id_role_pkey", foreignKey = "account_roles_account_id_fkey", index = "account_roles_account_id_idx")
@Element(column = "role")
private Set<SecurityRole> roles;
}
针对PostgreSQL运行此表的模式生成给了我以下内容:
-- Table "accounts" for classes [com.trickle.api.accounts.Account]
CREATE TABLE "accounts"
(
"id" SERIAL,
CONSTRAINT "accounts_PK" PRIMARY KEY ("id")
);
-- Table "account_roles" for join relationship
CREATE TABLE "account_roles"
(
"account_id" int8 NOT NULL,
"role" varchar(255) NOT NULL,
CONSTRAINT "account_roles_account_id_role_pkey" PRIMARY KEY ("account_id","role")
);
-- Constraints for table "accounts" for class(es) [com.trickle.api.accounts.Account]
-- Constraints for table "account_roles"
ALTER TABLE "account_roles" ADD CONSTRAINT "account_roles_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts" ("id") INITIALLY DEFERRED ;
CREATE INDEX "account_roles_N49" ON "account_roles" ("account_id");
请注意&#34; account_roles_N49
&#34;的索引名称,而不是&#34; account_roles_account_id_idx
&#34;我在课堂上指定的#39;注解。我在这里做错了什么?