d

    Damien

    4 years ago
    I'm use the version 0.10.2 Yes, company is an UUIDEntity
    tapac

    tapac

    4 years ago
    How you create/get your
    company
    instance?
    d

    Damien

    4 years ago
    Currently I use "company = Company.all().first()", because it is not possible to create more than one company
    and my definition is "lateinit var company: Company"
    tapac

    tapac

    4 years ago
    You mean that such code will fail?
    connect()
    transaction {
       val company = Company.all().first()
       company.name = "Foo"
    }
    transaction {
       val company = Company.all().first()
       assertEquals("Foo", company.name)
    }
    d

    Damien

    4 years ago
    yes
    I think the problem is, that my code works like
    lateinit var company = Company()
    connect()
    transaction {
       company = Company.all().first()
    }
    transaction {
       company.name = "Foo"
    }
    transaction {
       val company = Company.all().first()
       assertEquals("Foo", company.name)
    }
    tapac

    tapac

    4 years ago
    You should not construct Company like this :
    Company()
    . Replace it with
    Company.new {}
    BTW, I don't see why your code should not work...
    d

    Damien

    4 years ago
    Thank you for your answers. I think it is not possible to select an object in one function and change this in another function. Now I save the ID and select the data in both functions and it works.
    tapac

    tapac

    4 years ago
    d

    Damien

    4 years ago
    This might be possible, but I did select the data in my init method and change the data within a listener