Home > Software engineering >  How to get "base" object from Exposed ResultRow
How to get "base" object from Exposed ResultRow

Time:08-03

I'm defining an inner join as follows (done like this since, as far as I can tell, Exposed does not support additional values besides the composite primary key in the intermediate table):

val settingOrganisationList = (OrganisationTable innerJoin SettingOrganisationTable innerJoin SettingTable)
    .select { SettingOrganisationTable.organisationId eq organisation.id }

This join works fine, but I want to call functions on the Organisation, SettingOrganisation, and Setting objects using .map{ }, and I'm not sure how to get these.

I can get the individual object properties like this just fine:

val settingOrganisationList = (OrganisationTable innerJoin SettingOrganisationTable innerJoin SettingTable)
    .select { SettingOrganisationTable.organisationId eq organisation.id }
    .map {
        println(it[OrganisationTable.name])
    }

but I'm not sure how to get the entire OrganisationTable object.

Sorry if this question has been answered before, I haven't been able to word it in a way that gets me useful results from Google.

CodePudding user response:

Please check the wiki on how to wrap query and get entities. If you'd like to make it in a map call you can use:

(OrganisationTable innerJoin SettingOrganisationTable innerJoin SettingTable)
    .select { SettingOrganisationTable.organisationId eq organisation.id }
    .map { Organization.wrapRow(it) }
  • Related