Package gwlpr.database.entities

Examples of gwlpr.database.entities.Npc


    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);
            }
View Full Code Here


    public void destroy(Integer id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Npc npc;
            try {
                npc = em.getReference(Npc.class, id);
                npc.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The npc with id " + id + " no longer exists.", enfe);
            }
            Weapon weapons = npc.getWeapons();
            if (weapons != null) {
                weapons.getNpcCollection().remove(npc);
                weapons = em.merge(weapons);
            }
            em.remove(npc);
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Npc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.