Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can add saveOrUpdate method in EbeanDao? #14

Open
thetcc opened this issue Jul 28, 2017 · 0 comments
Open

Can add saveOrUpdate method in EbeanDao? #14

thetcc opened this issue Jul 28, 2017 · 0 comments

Comments

@thetcc
Copy link

thetcc commented Jul 28, 2017

like this:

    @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);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant