mmaillot

    mmaillot

    2 years ago
    Hi! I have a
    UUIDTable
    Interventionwith a child:
    val foreignEnterprise = reference("foreign_enterprise", ForeignEnterprises.id)
    . I want to get the foreign enteprise for an intervention. I have the
    InterventionUuid
    . How can I do ? In SQL, I do: SELECT foreign_enterprise.* from foreign_enterprise, intervention WHERE intervention.foreign_enteprise_id = foreign_enterprise_id AND intervention.id ='INPUT_UUID'.
    Ok, after review the doc, I did this :
    ForeignEnterprises.join(
                Interventions,
                JoinType.INNER
            )
                .slice(ForeignEnterprises.columns)
                .select { Interventions.id eq interventionId.value }
                .map { ForeignEnterprises.toModel(it) }
                .first()
    Joel

    Joel

    2 years ago
    ForeignEnterprises innerJoin Interventions
    should also be valid. The
    reference
    you've added ties them together.
    mmaillot

    mmaillot

    2 years ago
    Ok, I have this now:
    ForeignEnterprises.innerJoin(Interventions)
                .slice(ForeignEnterprises.columns)
                .select { Interventions.id eq interventionId.value }
                .map { ForeignEnterprises.toModel(it) }
                .first()
    Is it what you mean ?