Character customizedFor = item.getCustomizedFor();
if (customizedFor != null) {
customizedFor = em.getReference(customizedFor.getClass(), customizedFor.getId());
item.setCustomizedFor(customizedFor);
}
Itembase baseID = item.getBaseID();
if (baseID != null) {
baseID = em.getReference(baseID.getClass(), baseID.getId());
item.setBaseID(baseID);
}
Collection<Itemstat> attachedItemstatCollection = new ArrayList<Itemstat>();
for (Itemstat itemstatCollectionItemstatToAttach : item.getItemstatCollection()) {
itemstatCollectionItemstatToAttach = em.getReference(itemstatCollectionItemstatToAttach.getClass(), itemstatCollectionItemstatToAttach.getItemstatPK());
attachedItemstatCollection.add(itemstatCollectionItemstatToAttach);
}
item.setItemstatCollection(attachedItemstatCollection);
Collection<Storeditem> attachedStoreditemCollection = new ArrayList<Storeditem>();
for (Storeditem storeditemCollectionStoreditemToAttach : item.getStoreditemCollection()) {
storeditemCollectionStoreditemToAttach = em.getReference(storeditemCollectionStoreditemToAttach.getClass(), storeditemCollectionStoreditemToAttach.getStoreditemPK());
attachedStoreditemCollection.add(storeditemCollectionStoreditemToAttach);
}
item.setStoreditemCollection(attachedStoreditemCollection);
Collection<Weapon> attachedWeaponCollection = new ArrayList<Weapon>();
for (Weapon weaponCollectionWeaponToAttach : item.getWeaponCollection()) {
weaponCollectionWeaponToAttach = em.getReference(weaponCollectionWeaponToAttach.getClass(), weaponCollectionWeaponToAttach.getId());
attachedWeaponCollection.add(weaponCollectionWeaponToAttach);
}
item.setWeaponCollection(attachedWeaponCollection);
Collection<Weapon> attachedWeaponCollection1 = new ArrayList<Weapon>();
for (Weapon weaponCollection1WeaponToAttach : item.getWeaponCollection1()) {
weaponCollection1WeaponToAttach = em.getReference(weaponCollection1WeaponToAttach.getClass(), weaponCollection1WeaponToAttach.getId());
attachedWeaponCollection1.add(weaponCollection1WeaponToAttach);
}
item.setWeaponCollection1(attachedWeaponCollection1);
em.persist(item);
if (customizedFor != null) {
customizedFor.getItemCollection().add(item);
customizedFor = em.merge(customizedFor);
}
if (baseID != null) {
baseID.getItemCollection().add(item);
baseID = em.merge(baseID);
}
for (Itemstat itemstatCollectionItemstat : item.getItemstatCollection()) {
Item oldItemOfItemstatCollectionItemstat = itemstatCollectionItemstat.getItem();
itemstatCollectionItemstat.setItem(item);