@PostAction("/save")
public void update(User user) {
ebeanDao.saveOrUpdate(user);
// if user.id == null, insert user to database.
// if user.id != null,update user fields(not null) by user.id,if user.name is null,don't update user.name
}
@PostAction("/save")
public void update(User user) {
//now, i have to do like this:
User u = ebeanDao.getById(user.id);
if(user.name!=null){
u.name = user.name;
}
if(user.age!=null){
u.age = user.age;
}
// ... if user has other fields
ebeanDao.save(u);
}
like this: