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

Damien

06/06/2018, 7:51 PM
I'm use the version 0.10.2 Yes, company is an UUIDEntity
t

tapac

06/07/2018, 9:49 AM
How you create/get your
company
instance?
d

Damien

06/07/2018, 9:51 AM
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"
t

tapac

06/07/2018, 9:53 AM
You mean that such code will fail?
Copy code
connect()
transaction {
   val company = Company.all().first()
   company.name = "Foo"
}
transaction {
   val company = Company.all().first()
   assertEquals("Foo", company.name)
}
d

Damien

06/07/2018, 10:07 AM
yes
I think the problem is, that my code works like
Copy code
lateinit var company = Company()
connect()
transaction {
   company = Company.all().first()
}
transaction {
   company.name = "Foo"
}
transaction {
   val company = Company.all().first()
   assertEquals("Foo", company.name)
}
t

tapac

06/07/2018, 1:13 PM
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

06/08/2018, 6:06 AM
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.
t

tapac

06/08/2018, 11:09 AM
d

Damien

06/09/2018, 4:48 PM
This might be possible, but I did select the data in my init method and change the data within a listener
2 Views