ManyToOne with embedded Id #928
Answered
by
nakamura-to
Distractic
asked this question in
Q&A
-
Hello ! I have these classes : @KomapperEntity
@KomapperTable("guild")
@KomapperOneToMany(GuildMemberDef::class, "members")
public data class Guild(
@KomapperId
@KomapperAutoIncrement
val id: Int,
val name: String,
val owner: UUID,
@KomapperCreatedAt
val createdAt: Instant,
)
public data class GuildMemberDefId(
public val guildId: Int,
public val memberId: UUID,
)
public enum class GuildMemberState {
MEMBER,
PENDING,
}
@KomapperEntity
@KomapperTable("guild_member")
@KomapperManyToOne(Guild::class, "guild", KomapperLink("id.guildId", "id"))
public data class GuildMemberDef(
@KomapperEmbeddedId
val id: GuildMemberDefId,
@KomapperEnum(EnumType.NAME)
val state: GuildMemberState,
@KomapperCreatedAt
val createdAt: Instant,
) However, for the
How can I use the |
Beta Was this translation helpful? Give feedback.
Answered by
nakamura-to
Mar 23, 2023
Replies: 1 comment 2 replies
-
Hi, You do not need to use KomapperLink in your case. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Distractic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
You do not need to use KomapperLink in your case.
KomapperLink is used to identify a single name from multiple names specified in the KomapperEntity's aliases property.