Code example for AtomicInteger

0
 * @author Stuart Douglas 
 */ 
@Stateless 
public class JpaRemoteBean implements JpaRemote { 
 
    private static final AtomicInteger idGenerator = new AtomicInteger(0);
 
    @PersistenceContext 
    private EntityManager entityManager;
 
    @Override 
    public void addEmployee(final String name) {
        Employee e = new Employee();
        e.setId(idGenerator.incrementAndGet());
        e.setName(name);
        entityManager.persist(e);
    } 
 
    @Override 
    public Set<String> getEmployees() {
        final List<Employee> emps = entityManager.createQuery("from Employee").getResultList();