public void edit(Npc npc) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Npc persistentNpc = em.find(Npc.class, npc.getId());
Weapon weaponsOld = persistentNpc.getWeapons();
Weapon weaponsNew = npc.getWeapons();
if (weaponsNew != null) {
weaponsNew = em.getReference(weaponsNew.getClass(), weaponsNew.getId());
npc.setWeapons(weaponsNew);
}