Package gwlpr.database.entities

Examples of gwlpr.database.entities.Item


            if (baseID != null) {
                baseID.getItemCollection().add(item);
                baseID = em.merge(baseID);
            }
            for (Itemstat itemstatCollectionItemstat : item.getItemstatCollection()) {
                Item oldItemOfItemstatCollectionItemstat = itemstatCollectionItemstat.getItem();
                itemstatCollectionItemstat.setItem(item);
                itemstatCollectionItemstat = em.merge(itemstatCollectionItemstat);
                if (oldItemOfItemstatCollectionItemstat != null) {
                    oldItemOfItemstatCollectionItemstat.getItemstatCollection().remove(itemstatCollectionItemstat);
                    oldItemOfItemstatCollectionItemstat = em.merge(oldItemOfItemstatCollectionItemstat);
                }
            }
            for (Storeditem storeditemCollectionStoreditem : item.getStoreditemCollection()) {
                Item oldItemIDOfStoreditemCollectionStoreditem = storeditemCollectionStoreditem.getItemID();
                storeditemCollectionStoreditem.setItemID(item);
                storeditemCollectionStoreditem = em.merge(storeditemCollectionStoreditem);
                if (oldItemIDOfStoreditemCollectionStoreditem != null) {
                    oldItemIDOfStoreditemCollectionStoreditem.getStoreditemCollection().remove(storeditemCollectionStoreditem);
                    oldItemIDOfStoreditemCollectionStoreditem = em.merge(oldItemIDOfStoreditemCollectionStoreditem);
                }
            }
            for (Weapon weaponCollectionWeapon : item.getWeaponCollection()) {
                Item oldOffhandOfWeaponCollectionWeapon = weaponCollectionWeapon.getOffhand();
                weaponCollectionWeapon.setOffhand(item);
                weaponCollectionWeapon = em.merge(weaponCollectionWeapon);
                if (oldOffhandOfWeaponCollectionWeapon != null) {
                    oldOffhandOfWeaponCollectionWeapon.getWeaponCollection().remove(weaponCollectionWeapon);
                    oldOffhandOfWeaponCollectionWeapon = em.merge(oldOffhandOfWeaponCollectionWeapon);
                }
            }
            for (Weapon weaponCollection1Weapon : item.getWeaponCollection1()) {
                Item oldLeadhandOfWeaponCollection1Weapon = weaponCollection1Weapon.getLeadhand();
                weaponCollection1Weapon.setLeadhand(item);
                weaponCollection1Weapon = em.merge(weaponCollection1Weapon);
                if (oldLeadhandOfWeaponCollection1Weapon != null) {
                    oldLeadhandOfWeaponCollection1Weapon.getWeaponCollection1().remove(weaponCollection1Weapon);
                    oldLeadhandOfWeaponCollection1Weapon = em.merge(oldLeadhandOfWeaponCollection1Weapon);
                }
            }
            em.getTransaction().commit();
        } finally {
View Full Code Here


    public void edit(Item item) throws IllegalOrphanException, NonexistentEntityException, Exception {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Item persistentItem = em.find(Item.class, item.getId());
            Character customizedForOld = persistentItem.getCustomizedFor();
            Character customizedForNew = item.getCustomizedFor();
            Itembase baseIDOld = persistentItem.getBaseID();
            Itembase baseIDNew = item.getBaseID();
            Collection<Itemstat> itemstatCollectionOld = persistentItem.getItemstatCollection();
            Collection<Itemstat> itemstatCollectionNew = item.getItemstatCollection();
            Collection<Storeditem> storeditemCollectionOld = persistentItem.getStoreditemCollection();
            Collection<Storeditem> storeditemCollectionNew = item.getStoreditemCollection();
            Collection<Weapon> weaponCollectionOld = persistentItem.getWeaponCollection();
            Collection<Weapon> weaponCollectionNew = item.getWeaponCollection();
            Collection<Weapon> weaponCollection1Old = persistentItem.getWeaponCollection1();
            Collection<Weapon> weaponCollection1New = item.getWeaponCollection1();
            List<String> illegalOrphanMessages = null;
            for (Itemstat itemstatCollectionOldItemstat : itemstatCollectionOld) {
                if (!itemstatCollectionNew.contains(itemstatCollectionOldItemstat)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Itemstat " + itemstatCollectionOldItemstat + " since its item field is not nullable.");
                }
            }
            for (Storeditem storeditemCollectionOldStoreditem : storeditemCollectionOld) {
                if (!storeditemCollectionNew.contains(storeditemCollectionOldStoreditem)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Storeditem " + storeditemCollectionOldStoreditem + " since its itemID field is not nullable.");
                }
            }
            for (Weapon weaponCollectionOldWeapon : weaponCollectionOld) {
                if (!weaponCollectionNew.contains(weaponCollectionOldWeapon)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Weapon " + weaponCollectionOldWeapon + " since its offhand field is not nullable.");
                }
            }
            for (Weapon weaponCollection1OldWeapon : weaponCollection1Old) {
                if (!weaponCollection1New.contains(weaponCollection1OldWeapon)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Weapon " + weaponCollection1OldWeapon + " since its leadhand field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (customizedForNew != null) {
                customizedForNew = em.getReference(customizedForNew.getClass(), customizedForNew.getId());
                item.setCustomizedFor(customizedForNew);
            }
            if (baseIDNew != null) {
                baseIDNew = em.getReference(baseIDNew.getClass(), baseIDNew.getId());
                item.setBaseID(baseIDNew);
            }
            Collection<Itemstat> attachedItemstatCollectionNew = new ArrayList<Itemstat>();
            for (Itemstat itemstatCollectionNewItemstatToAttach : itemstatCollectionNew) {
                itemstatCollectionNewItemstatToAttach = em.getReference(itemstatCollectionNewItemstatToAttach.getClass(), itemstatCollectionNewItemstatToAttach.getItemstatPK());
                attachedItemstatCollectionNew.add(itemstatCollectionNewItemstatToAttach);
            }
            itemstatCollectionNew = attachedItemstatCollectionNew;
            item.setItemstatCollection(itemstatCollectionNew);
            Collection<Storeditem> attachedStoreditemCollectionNew = new ArrayList<Storeditem>();
            for (Storeditem storeditemCollectionNewStoreditemToAttach : storeditemCollectionNew) {
                storeditemCollectionNewStoreditemToAttach = em.getReference(storeditemCollectionNewStoreditemToAttach.getClass(), storeditemCollectionNewStoreditemToAttach.getStoreditemPK());
                attachedStoreditemCollectionNew.add(storeditemCollectionNewStoreditemToAttach);
            }
            storeditemCollectionNew = attachedStoreditemCollectionNew;
            item.setStoreditemCollection(storeditemCollectionNew);
            Collection<Weapon> attachedWeaponCollectionNew = new ArrayList<Weapon>();
            for (Weapon weaponCollectionNewWeaponToAttach : weaponCollectionNew) {
                weaponCollectionNewWeaponToAttach = em.getReference(weaponCollectionNewWeaponToAttach.getClass(), weaponCollectionNewWeaponToAttach.getId());
                attachedWeaponCollectionNew.add(weaponCollectionNewWeaponToAttach);
            }
            weaponCollectionNew = attachedWeaponCollectionNew;
            item.setWeaponCollection(weaponCollectionNew);
            Collection<Weapon> attachedWeaponCollection1New = new ArrayList<Weapon>();
            for (Weapon weaponCollection1NewWeaponToAttach : weaponCollection1New) {
                weaponCollection1NewWeaponToAttach = em.getReference(weaponCollection1NewWeaponToAttach.getClass(), weaponCollection1NewWeaponToAttach.getId());
                attachedWeaponCollection1New.add(weaponCollection1NewWeaponToAttach);
            }
            weaponCollection1New = attachedWeaponCollection1New;
            item.setWeaponCollection1(weaponCollection1New);
            item = em.merge(item);
            if (customizedForOld != null && !customizedForOld.equals(customizedForNew)) {
                customizedForOld.getItemCollection().remove(item);
                customizedForOld = em.merge(customizedForOld);
            }
            if (customizedForNew != null && !customizedForNew.equals(customizedForOld)) {
                customizedForNew.getItemCollection().add(item);
                customizedForNew = em.merge(customizedForNew);
            }
            if (baseIDOld != null && !baseIDOld.equals(baseIDNew)) {
                baseIDOld.getItemCollection().remove(item);
                baseIDOld = em.merge(baseIDOld);
            }
            if (baseIDNew != null && !baseIDNew.equals(baseIDOld)) {
                baseIDNew.getItemCollection().add(item);
                baseIDNew = em.merge(baseIDNew);
            }
            for (Itemstat itemstatCollectionNewItemstat : itemstatCollectionNew) {
                if (!itemstatCollectionOld.contains(itemstatCollectionNewItemstat)) {
                    Item oldItemOfItemstatCollectionNewItemstat = itemstatCollectionNewItemstat.getItem();
                    itemstatCollectionNewItemstat.setItem(item);
                    itemstatCollectionNewItemstat = em.merge(itemstatCollectionNewItemstat);
                    if (oldItemOfItemstatCollectionNewItemstat != null && !oldItemOfItemstatCollectionNewItemstat.equals(item)) {
                        oldItemOfItemstatCollectionNewItemstat.getItemstatCollection().remove(itemstatCollectionNewItemstat);
                        oldItemOfItemstatCollectionNewItemstat = em.merge(oldItemOfItemstatCollectionNewItemstat);
                    }
                }
            }
            for (Storeditem storeditemCollectionNewStoreditem : storeditemCollectionNew) {
                if (!storeditemCollectionOld.contains(storeditemCollectionNewStoreditem)) {
                    Item oldItemIDOfStoreditemCollectionNewStoreditem = storeditemCollectionNewStoreditem.getItemID();
                    storeditemCollectionNewStoreditem.setItemID(item);
                    storeditemCollectionNewStoreditem = em.merge(storeditemCollectionNewStoreditem);
                    if (oldItemIDOfStoreditemCollectionNewStoreditem != null && !oldItemIDOfStoreditemCollectionNewStoreditem.equals(item)) {
                        oldItemIDOfStoreditemCollectionNewStoreditem.getStoreditemCollection().remove(storeditemCollectionNewStoreditem);
                        oldItemIDOfStoreditemCollectionNewStoreditem = em.merge(oldItemIDOfStoreditemCollectionNewStoreditem);
                    }
                }
            }
            for (Weapon weaponCollectionNewWeapon : weaponCollectionNew) {
                if (!weaponCollectionOld.contains(weaponCollectionNewWeapon)) {
                    Item oldOffhandOfWeaponCollectionNewWeapon = weaponCollectionNewWeapon.getOffhand();
                    weaponCollectionNewWeapon.setOffhand(item);
                    weaponCollectionNewWeapon = em.merge(weaponCollectionNewWeapon);
                    if (oldOffhandOfWeaponCollectionNewWeapon != null && !oldOffhandOfWeaponCollectionNewWeapon.equals(item)) {
                        oldOffhandOfWeaponCollectionNewWeapon.getWeaponCollection().remove(weaponCollectionNewWeapon);
                        oldOffhandOfWeaponCollectionNewWeapon = em.merge(oldOffhandOfWeaponCollectionNewWeapon);
                    }
                }
            }
            for (Weapon weaponCollection1NewWeapon : weaponCollection1New) {
                if (!weaponCollection1Old.contains(weaponCollection1NewWeapon)) {
                    Item oldLeadhandOfWeaponCollection1NewWeapon = weaponCollection1NewWeapon.getLeadhand();
                    weaponCollection1NewWeapon.setLeadhand(item);
                    weaponCollection1NewWeapon = em.merge(weaponCollection1NewWeapon);
                    if (oldLeadhandOfWeaponCollection1NewWeapon != null && !oldLeadhandOfWeaponCollection1NewWeapon.equals(item)) {
                        oldLeadhandOfWeaponCollection1NewWeapon.getWeaponCollection1().remove(weaponCollection1NewWeapon);
                        oldLeadhandOfWeaponCollection1NewWeapon = em.merge(oldLeadhandOfWeaponCollection1NewWeapon);
                    }
                }
            }
            em.getTransaction().commit();
View Full Code Here

    public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Item item;
            try {
                item = em.getReference(Item.class, id);
                item.getId();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The item with id " + id + " no longer exists.", enfe);
            }
            List<String> illegalOrphanMessages = null;
            Collection<Itemstat> itemstatCollectionOrphanCheck = item.getItemstatCollection();
            for (Itemstat itemstatCollectionOrphanCheckItemstat : itemstatCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Item (" + item + ") cannot be destroyed since the Itemstat " + itemstatCollectionOrphanCheckItemstat + " in its itemstatCollection field has a non-nullable item field.");
            }
            Collection<Storeditem> storeditemCollectionOrphanCheck = item.getStoreditemCollection();
            for (Storeditem storeditemCollectionOrphanCheckStoreditem : storeditemCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Item (" + item + ") cannot be destroyed since the Storeditem " + storeditemCollectionOrphanCheckStoreditem + " in its storeditemCollection field has a non-nullable itemID field.");
            }
            Collection<Weapon> weaponCollectionOrphanCheck = item.getWeaponCollection();
            for (Weapon weaponCollectionOrphanCheckWeapon : weaponCollectionOrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Item (" + item + ") cannot be destroyed since the Weapon " + weaponCollectionOrphanCheckWeapon + " in its weaponCollection field has a non-nullable offhand field.");
            }
            Collection<Weapon> weaponCollection1OrphanCheck = item.getWeaponCollection1();
            for (Weapon weaponCollection1OrphanCheckWeapon : weaponCollection1OrphanCheck) {
                if (illegalOrphanMessages == null) {
                    illegalOrphanMessages = new ArrayList<String>();
                }
                illegalOrphanMessages.add("This Item (" + item + ") cannot be destroyed since the Weapon " + weaponCollection1OrphanCheckWeapon + " in its weaponCollection1 field has a non-nullable leadhand field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Character customizedFor = item.getCustomizedFor();
            if (customizedFor != null) {
                customizedFor.getItemCollection().remove(item);
                customizedFor = em.merge(customizedFor);
            }
            Itembase baseID = item.getBaseID();
            if (baseID != null) {
                baseID.getItemCollection().remove(item);
                baseID = em.merge(baseID);
            }
            em.remove(item);
View Full Code Here

        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Item offhand = weapon.getOffhand();
            if (offhand != null) {
                offhand = em.getReference(offhand.getClass(), offhand.getId());
                weapon.setOffhand(offhand);
            }
            Item leadhand = weapon.getLeadhand();
            if (leadhand != null) {
                leadhand = em.getReference(leadhand.getClass(), leadhand.getId());
                weapon.setLeadhand(leadhand);
            }
            Collection<Npc> attachedNpcCollection = new ArrayList<Npc>();
            for (Npc npcCollectionNpcToAttach : weapon.getNpcCollection()) {
                npcCollectionNpcToAttach = em.getReference(npcCollectionNpcToAttach.getClass(), npcCollectionNpcToAttach.getId());
                attachedNpcCollection.add(npcCollectionNpcToAttach);
            }
            weapon.setNpcCollection(attachedNpcCollection);
            Collection<Weaponset> attachedWeaponsetCollection = new ArrayList<Weaponset>();
            for (Weaponset weaponsetCollectionWeaponsetToAttach : weapon.getWeaponsetCollection()) {
                weaponsetCollectionWeaponsetToAttach = em.getReference(weaponsetCollectionWeaponsetToAttach.getClass(), weaponsetCollectionWeaponsetToAttach.getWeaponsetPK());
                attachedWeaponsetCollection.add(weaponsetCollectionWeaponsetToAttach);
            }
            weapon.setWeaponsetCollection(attachedWeaponsetCollection);
            em.persist(weapon);
            if (offhand != null) {
                offhand.getWeaponCollection().add(weapon);
                offhand = em.merge(offhand);
            }
            if (leadhand != null) {
                leadhand.getWeaponCollection().add(weapon);
                leadhand = em.merge(leadhand);
            }
            for (Npc npcCollectionNpc : weapon.getNpcCollection()) {
                Weapon oldWeaponsOfNpcCollectionNpc = npcCollectionNpc.getWeapons();
                npcCollectionNpc.setWeapons(weapon);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Weapon persistentWeapon = em.find(Weapon.class, weapon.getId());
            Item offhandOld = persistentWeapon.getOffhand();
            Item offhandNew = weapon.getOffhand();
            Item leadhandOld = persistentWeapon.getLeadhand();
            Item leadhandNew = weapon.getLeadhand();
            Collection<Npc> npcCollectionOld = persistentWeapon.getNpcCollection();
            Collection<Npc> npcCollectionNew = weapon.getNpcCollection();
            Collection<Weaponset> weaponsetCollectionOld = persistentWeapon.getWeaponsetCollection();
            Collection<Weaponset> weaponsetCollectionNew = weapon.getWeaponsetCollection();
            List<String> illegalOrphanMessages = null;
            for (Npc npcCollectionOldNpc : npcCollectionOld) {
                if (!npcCollectionNew.contains(npcCollectionOldNpc)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Npc " + npcCollectionOldNpc + " since its weapons field is not nullable.");
                }
            }
            for (Weaponset weaponsetCollectionOldWeaponset : weaponsetCollectionOld) {
                if (!weaponsetCollectionNew.contains(weaponsetCollectionOldWeaponset)) {
                    if (illegalOrphanMessages == null) {
                        illegalOrphanMessages = new ArrayList<String>();
                    }
                    illegalOrphanMessages.add("You must retain Weaponset " + weaponsetCollectionOldWeaponset + " since its weapons field is not nullable.");
                }
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            if (offhandNew != null) {
                offhandNew = em.getReference(offhandNew.getClass(), offhandNew.getId());
                weapon.setOffhand(offhandNew);
            }
            if (leadhandNew != null) {
                leadhandNew = em.getReference(leadhandNew.getClass(), leadhandNew.getId());
                weapon.setLeadhand(leadhandNew);
            }
            Collection<Npc> attachedNpcCollectionNew = new ArrayList<Npc>();
            for (Npc npcCollectionNewNpcToAttach : npcCollectionNew) {
                npcCollectionNewNpcToAttach = em.getReference(npcCollectionNewNpcToAttach.getClass(), npcCollectionNewNpcToAttach.getId());
                attachedNpcCollectionNew.add(npcCollectionNewNpcToAttach);
            }
            npcCollectionNew = attachedNpcCollectionNew;
            weapon.setNpcCollection(npcCollectionNew);
            Collection<Weaponset> attachedWeaponsetCollectionNew = new ArrayList<Weaponset>();
            for (Weaponset weaponsetCollectionNewWeaponsetToAttach : weaponsetCollectionNew) {
                weaponsetCollectionNewWeaponsetToAttach = em.getReference(weaponsetCollectionNewWeaponsetToAttach.getClass(), weaponsetCollectionNewWeaponsetToAttach.getWeaponsetPK());
                attachedWeaponsetCollectionNew.add(weaponsetCollectionNewWeaponsetToAttach);
            }
            weaponsetCollectionNew = attachedWeaponsetCollectionNew;
            weapon.setWeaponsetCollection(weaponsetCollectionNew);
            weapon = em.merge(weapon);
            if (offhandOld != null && !offhandOld.equals(offhandNew)) {
                offhandOld.getWeaponCollection().remove(weapon);
                offhandOld = em.merge(offhandOld);
            }
            if (offhandNew != null && !offhandNew.equals(offhandOld)) {
                offhandNew.getWeaponCollection().add(weapon);
                offhandNew = em.merge(offhandNew);
            }
            if (leadhandOld != null && !leadhandOld.equals(leadhandNew)) {
                leadhandOld.getWeaponCollection().remove(weapon);
                leadhandOld = em.merge(leadhandOld);
            }
            if (leadhandNew != null && !leadhandNew.equals(leadhandOld)) {
                leadhandNew.getWeaponCollection().add(weapon);
                leadhandNew = em.merge(leadhandNew);
            }
            for (Npc npcCollectionNewNpc : npcCollectionNew) {
                if (!npcCollectionOld.contains(npcCollectionNewNpc)) {
                    Weapon oldWeaponsOfNpcCollectionNewNpc = npcCollectionNewNpc.getWeapons();
View Full Code Here

                illegalOrphanMessages.add("This Weapon (" + weapon + ") cannot be destroyed since the Weaponset " + weaponsetCollectionOrphanCheckWeaponset + " in its weaponsetCollection field has a non-nullable weapons field.");
            }
            if (illegalOrphanMessages != null) {
                throw new IllegalOrphanException(illegalOrphanMessages);
            }
            Item offhand = weapon.getOffhand();
            if (offhand != null) {
                offhand.getWeaponCollection().remove(weapon);
                offhand = em.merge(offhand);
            }
            Item leadhand = weapon.getLeadhand();
            if (leadhand != null) {
                leadhand.getWeaponCollection().remove(weapon);
                leadhand = em.merge(leadhand);
            }
            em.remove(weapon);
            em.getTransaction().commit();
        } finally {
View Full Code Here

        storeditem.getStoreditemPK().setInventoryID(storeditem.getInventory().getId());
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Item itemID = storeditem.getItemID();
            if (itemID != null) {
                itemID = em.getReference(itemID.getClass(), itemID.getId());
                storeditem.setItemID(itemID);
            }
            Inventory inventory = storeditem.getInventory();
            if (inventory != null) {
                inventory = em.getReference(inventory.getClass(), inventory.getId());
                storeditem.setInventory(inventory);
            }
            em.persist(storeditem);
            if (itemID != null) {
                itemID.getStoreditemCollection().add(storeditem);
                itemID = em.merge(itemID);
            }
            if (inventory != null) {
                inventory.getStoreditemCollection().add(storeditem);
                inventory = em.merge(inventory);
View Full Code Here

        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Storeditem persistentStoreditem = em.find(Storeditem.class, storeditem.getStoreditemPK());
            Item itemIDOld = persistentStoreditem.getItemID();
            Item itemIDNew = storeditem.getItemID();
            Inventory inventoryOld = persistentStoreditem.getInventory();
            Inventory inventoryNew = storeditem.getInventory();
            if (itemIDNew != null) {
                itemIDNew = em.getReference(itemIDNew.getClass(), itemIDNew.getId());
                storeditem.setItemID(itemIDNew);
            }
            if (inventoryNew != null) {
                inventoryNew = em.getReference(inventoryNew.getClass(), inventoryNew.getId());
                storeditem.setInventory(inventoryNew);
            }
            storeditem = em.merge(storeditem);
            if (itemIDOld != null && !itemIDOld.equals(itemIDNew)) {
                itemIDOld.getStoreditemCollection().remove(storeditem);
                itemIDOld = em.merge(itemIDOld);
            }
            if (itemIDNew != null && !itemIDNew.equals(itemIDOld)) {
                itemIDNew.getStoreditemCollection().add(storeditem);
                itemIDNew = em.merge(itemIDNew);
            }
            if (inventoryOld != null && !inventoryOld.equals(inventoryNew)) {
                inventoryOld.getStoreditemCollection().remove(storeditem);
                inventoryOld = em.merge(inventoryOld);
View Full Code Here

                storeditem = em.getReference(Storeditem.class, id);
                storeditem.getStoreditemPK();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The storeditem with id " + id + " no longer exists.", enfe);
            }
            Item itemID = storeditem.getItemID();
            if (itemID != null) {
                itemID.getStoreditemCollection().remove(storeditem);
                itemID = em.merge(itemID);
            }
            Inventory inventory = storeditem.getInventory();
            if (inventory != null) {
                inventory.getStoreditemCollection().remove(storeditem);
View Full Code Here

        itemstat.getItemstatPK().setItemID(itemstat.getItem().getId());
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Item item = itemstat.getItem();
            if (item != null) {
                item = em.getReference(item.getClass(), item.getId());
                itemstat.setItem(item);
            }
            em.persist(itemstat);
            if (item != null) {
                item.getItemstatCollection().add(itemstat);
                item = em.merge(item);
            }
            em.getTransaction().commit();
        } catch (Exception ex) {
            if (findItemstat(itemstat.getItemstatPK()) != null) {
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Item

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.