gpt4 book ai didi

android - 如何使用多个主键

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:47 26 4
gpt4 key购买 nike

我为我的 android 应用程序创建了数据库,女巫有 16 个表。我想使用 ORMlite 映射。问题是我没有找到你有复合 id(多个主键)的例子。例如我有表:

CREATE  TABLE IF NOT EXISTS `Tourist_Guide`.`Cultural_activity` (
`City_Id` INT NOT NULL ,
`activity_Id` INT NOT NULL ,
`Cultural_activity_Id` INT NOT NULL AUTO_INCREMENT ,
`Name_Of_Cultural_activity` VARCHAR(30) NOT NULL ,
PRIMARY KEY (`Cultural_activity_Id`, `City_Id`, `activity_Id`) ,
INDEX `fk_Cultural_activity_activity1` (`City_Id` ASC, `activity_Id` ASC) ,
CONSTRAINT `fk_Cultural_activity_activity1`
FOREIGN KEY (`City_Id` , `activity_Id` )
REFERENCES `Tourist_Guide`.`activity` (`City_Id` , `activity_Id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

你能不能告诉我如何将这个表映射到类(这个类应该是什么样子),这可能吗?

最佳答案

您必须在每个唯一字段上方使用以下注释:

@DatabaseField (uniqueCombo = true)

Here are the docs on uniqueCombo.

关于android - 如何使用多个主键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10469562/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com