UserServiceSpring.java 651 Bytes
package org.legrog.web.user;

import org.legrog.entities.User;
import org.legrog.entities.UserRepository;

import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;

@Stateless
public class UserServiceSpring implements UserService {
    @Inject
    UserRepository userRepository;

    public void addUser(User user) {
        userRepository.save(user);
    }

    public List<User> getAllUsers() {
        return userRepository.findAll();
    }

    public User findUserById(int id) {
        return userRepository.findOne(new Integer(id));
    }

    public void updateUser(User user) {
        userRepository.save(user);
    }
}