如何在房间里制作组合钥匙 [英] How to make composite key in Room
本文介绍了如何在房间里制作组合钥匙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚在房间里找到@PrimaryKey批注.那么,如果我想制作组合键,该怎么做?
I have just found @PrimaryKey annotation in room. So If I want to make composite key so how can I do that?
推荐答案
使用primaryKeys()
.
Room
的
如果在Embeddeded字段上使用PrimaryKey批注,则所有列 从该嵌入式字段继承的内容成为复合主键 (包括其大子域).
If PrimaryKey annotation is used on a Embeddedd field, all columns inherited from that embedded field becomes the composite primary key (including its grand children fields).
使用Java的示例实现:
Example implementation in Java:
@Entity(primaryKeys = {"column1","column2","column3"})
class DummyClass {
...
}
以 Lalit Kushwah 为例.
这篇关于如何在房间里制作组合钥匙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文