Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self join many-to-many relationships #106

Closed
3ricL opened this issue May 1, 2017 · 0 comments
Closed

self join many-to-many relationships #106

3ricL opened this issue May 1, 2017 · 0 comments

Comments

@3ricL
Copy link

3ricL commented May 1, 2017

I found no way of doing this (see title)
I tried this, but it doesn't work because there is no way to know which column is the source

object Users : IntIdTable() {
    val name = varchar("name", 50).index()
}
object UsersToUsers : Table() {
    val parent = reference("parent_user_id", Users)
    val child = reference("child_user_id", Users)
}
class User(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<User>(Users)

    var name by Users.name
    var users by User via UsersToUsers //Doesn't work
}

Exception in thread "main" java.lang.IllegalStateException: Table does not reference source
at org.jetbrains.exposed.dao.InnerTableLink.getSourceRefColumn(Entity.kt:124)
at org.jetbrains.exposed.dao.InnerTableLink.setValue(Entity.kt:147)

I don't know if it's the best way, but I would like to specify the "source ref column"
something like this

class User(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<User>(Users)

    var name by Users.name
    var users by User via UsersToUsers.parent
}

The solution am using right now
3ricL@fff5f6f

Tapac added a commit that referenced this issue Feb 10, 2019
@Tapac Tapac closed this as completed Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants