giangio
03/20/2024, 1:08 PMupdate a whole domain object? I need to update a whole domain object passing a parameters Map. Something like this:
@CurrentTenant
@Service(TPerson)
abstract class PersonService {
protected abstract TPerson get(Serializable id)
protected abstract TPerson getByName(String name)
protected abstract Long count()
protected abstract List<TPerson> list(Map args)
protected abstract TPerson save(TPerson obj)
// *** THIS IS NOT COMPILING ***
protected abstract TPerson update(Serializable id, TPerson obj)
protected abstract void delete(Serializable id)
TPerson create(Map properties) {
TPerson obj = new TPerson(properties)
obj.validate()
if (obj.hasErrors()) {
return obj
}
return save(obj)
}
TPerson update(Serializable id, Map properties) {
TPerson obj = get(id)
obj.properties = properties
obj.validate()
if (obj.hasErrors()) {
return obj
}
return update(id, obj)
}
}