Created
September 21, 2018 15:27
-
-
Save eldermoraes/6490ac12a1a403fab85ed1585faa842d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stateless | |
public class PlayerBean { | |
@PersistenceContext(unitName = "micro-PU") | |
private EntityManager em; | |
public void save(Player player){ | |
em.merge(player); | |
} | |
public void remove(Player player){ | |
em.remove(findById(player.getId())); | |
} | |
public Player findById(Long id){ | |
return em.find(Player.class, id); | |
} | |
public List<Player> findAll(){ | |
return em.createQuery("SELECT p FROM Player p").getResultList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment