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

Calvin

02/07/2022, 1:52 PM
Is there a efficient way to update entities without manually setting every field ? In repositories we update fields the following way:
Copy code
Entity[id].apply {
      	updatedField = "test123"
      }
But this is a bit tedious if the objects are very large and/or contain lists. Is there a method that detects the changes between two objects (the entity object and an updated version of the object) and updates the entity accordingly?
b

Bogdan

02/07/2022, 3:25 PM
Exposed
has its own checks, the main thing is that the correct
equals
are defined
i.e. you should just set the values. Alas, there is no automatic mapping. You can look at the libraries
c

Calvin

02/07/2022, 3:30 PM
thats unfortunate
b

Bogdan

02/07/2022, 3:38 PM
if the names match, then you can use reflection
3 Views