https://kotlinlang.org logo
#exposed
Title
# exposed
m

mattiascrofani

03/09/2018, 11:18 AM
Hello there. Real noob here with kotlin and exposed. I'm trying to run a simple join but clearly I'm missing something obvious so I was trying to recreate what I read on the wiki. AccessToken.idStaff and Staff.id are both int. The exception says that "Cannot join as there is no matching primary key/ foreign key pair and constraint missing". Isn't that "select" the condition for the join?
Copy code
(AccessToken innerJoin Staff).slice(Staff.id, Staff.userName).select {AccessToken.idStaff eq Staff.id}
OK, I did it.
Copy code
AccessToken.join(Staff, JoinType.INNER, AccessToken.idStaff, Staff.id).slice(Staff.id, Staff.userName).select { AccessToken.token eq accessToken }
👍 1
t

tapac

03/09/2018, 9:12 PM
If
AccessToken
table has reference to
Staff
table, than your first code will also work. Look here https://github.com/JetBrains/Exposed/wiki/DAO#simple-reference
👍 1
3 Views