本文介绍了批注不能用作批注参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到一个错误,尽管执行的操作与文档所说的完全相同。Documentation:
data class PlaylistWithSongs(
@Embedded val playlist: Playlist,
@Relation(
parentColumn = "playlistId",
entityColumn = "songId",
associateBy = @Junction(PlaylistSongCrossRef::class)
)
val songs: List<Song>
)
我的问题:
data class FileEntryWithTags(
@Embedded val fileEntry: FileEntry,
@Relation(
parentColumn = FileEntry.COLUMN_UUID,
entityColumn = Tag.COLUMN_ID,
associateBy = @Junction(FileEntryTagCrossRef::class)
)
val tags: List<Tag>
)
推荐答案
看起来安卓文档有误。Kotlin参考中的Annotations - Kotlin Programming Language页告诉我们:
所以您的代码应该是:
data class FileEntryWithTags(
@Embedded val fileEntry: FileEntry,
@Relation(
parentColumn = FileEntry.COLUMN_UUID,
entityColumn = Tag.COLUMN_ID,
associateBy = Junction(FileEntryTagCrossRef::class)
)
val tags: List<Tag>
)
这篇关于批注不能用作批注参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!