Profession secondaryProfessionNew = character.getSecondaryProfession();
Profession primaryProfessionOld = persistentCharacter.getPrimaryProfession();
Profession primaryProfessionNew = character.getPrimaryProfession();
Level levelOld = persistentCharacter.getLevel();
Level levelNew = character.getLevel();
Map lastOutpostOld = persistentCharacter.getLastOutpost();
Map lastOutpostNew = character.getLastOutpost();
Inventory equipmentPackOld = persistentCharacter.getEquipmentPack();
Inventory equipmentPackNew = character.getEquipmentPack();
Inventory equipmentOld = persistentCharacter.getEquipment();
Inventory equipmentNew = character.getEquipment();
Inventory beltpouchOld = persistentCharacter.getBeltpouch();
Inventory beltpouchNew = character.getBeltpouch();
Inventory bag2Old = persistentCharacter.getBag2();
Inventory bag2New = character.getBag2();
Inventory bag1Old = persistentCharacter.getBag1();
Inventory bag1New = character.getBag1();
Inventory backpackOld = persistentCharacter.getBackpack();
Inventory backpackNew = character.getBackpack();
Account accountIDOld = persistentCharacter.getAccountID();
Account accountIDNew = character.getAccountID();
Collection<Skill> skillCollectionOld = persistentCharacter.getSkillCollection();
Collection<Skill> skillCollectionNew = character.getSkillCollection();
Collection<Profession> professionCollectionOld = persistentCharacter.getProfessionCollection();
Collection<Profession> professionCollectionNew = character.getProfessionCollection();
Collection<EquippedSkill> equippedSkillCollectionOld = persistentCharacter.getEquippedSkillCollection();
Collection<EquippedSkill> equippedSkillCollectionNew = character.getEquippedSkillCollection();
Collection<Weaponset> weaponsetCollectionOld = persistentCharacter.getWeaponsetCollection();
Collection<Weaponset> weaponsetCollectionNew = character.getWeaponsetCollection();
Collection<Item> itemCollectionOld = persistentCharacter.getItemCollection();
Collection<Item> itemCollectionNew = character.getItemCollection();
Collection<Attributepoint> attributepointCollectionOld = persistentCharacter.getAttributepointCollection();
Collection<Attributepoint> attributepointCollectionNew = character.getAttributepointCollection();
List<String> illegalOrphanMessages = null;
for (EquippedSkill equippedSkillCollectionOldEquippedSkill : equippedSkillCollectionOld) {
if (!equippedSkillCollectionNew.contains(equippedSkillCollectionOldEquippedSkill)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain EquippedSkill " + equippedSkillCollectionOldEquippedSkill + " since its character 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 character field is not nullable.");
}
}
for (Attributepoint attributepointCollectionOldAttributepoint : attributepointCollectionOld) {
if (!attributepointCollectionNew.contains(attributepointCollectionOldAttributepoint)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain Attributepoint " + attributepointCollectionOldAttributepoint + " since its character field is not nullable.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
if (secondaryProfessionNew != null) {
secondaryProfessionNew = em.getReference(secondaryProfessionNew.getClass(), secondaryProfessionNew.getId());
character.setSecondaryProfession(secondaryProfessionNew);
}
if (primaryProfessionNew != null) {
primaryProfessionNew = em.getReference(primaryProfessionNew.getClass(), primaryProfessionNew.getId());
character.setPrimaryProfession(primaryProfessionNew);
}
if (levelNew != null) {
levelNew = em.getReference(levelNew.getClass(), levelNew.getLevel());
character.setLevel(levelNew);
}
if (lastOutpostNew != null) {
lastOutpostNew = em.getReference(lastOutpostNew.getClass(), lastOutpostNew.getId());
character.setLastOutpost(lastOutpostNew);
}
if (equipmentPackNew != null) {
equipmentPackNew = em.getReference(equipmentPackNew.getClass(), equipmentPackNew.getId());
character.setEquipmentPack(equipmentPackNew);
}
if (equipmentNew != null) {
equipmentNew = em.getReference(equipmentNew.getClass(), equipmentNew.getId());
character.setEquipment(equipmentNew);
}
if (beltpouchNew != null) {
beltpouchNew = em.getReference(beltpouchNew.getClass(), beltpouchNew.getId());
character.setBeltpouch(beltpouchNew);
}
if (bag2New != null) {
bag2New = em.getReference(bag2New.getClass(), bag2New.getId());
character.setBag2(bag2New);
}
if (bag1New != null) {
bag1New = em.getReference(bag1New.getClass(), bag1New.getId());
character.setBag1(bag1New);
}
if (backpackNew != null) {
backpackNew = em.getReference(backpackNew.getClass(), backpackNew.getId());
character.setBackpack(backpackNew);
}
if (accountIDNew != null) {
accountIDNew = em.getReference(accountIDNew.getClass(), accountIDNew.getEMail());
character.setAccountID(accountIDNew);
}
Collection<Skill> attachedSkillCollectionNew = new ArrayList<Skill>();
for (Skill skillCollectionNewSkillToAttach : skillCollectionNew) {
skillCollectionNewSkillToAttach = em.getReference(skillCollectionNewSkillToAttach.getClass(), skillCollectionNewSkillToAttach.getId());
attachedSkillCollectionNew.add(skillCollectionNewSkillToAttach);
}
skillCollectionNew = attachedSkillCollectionNew;
character.setSkillCollection(skillCollectionNew);
Collection<Profession> attachedProfessionCollectionNew = new ArrayList<Profession>();
for (Profession professionCollectionNewProfessionToAttach : professionCollectionNew) {
professionCollectionNewProfessionToAttach = em.getReference(professionCollectionNewProfessionToAttach.getClass(), professionCollectionNewProfessionToAttach.getId());
attachedProfessionCollectionNew.add(professionCollectionNewProfessionToAttach);
}
professionCollectionNew = attachedProfessionCollectionNew;
character.setProfessionCollection(professionCollectionNew);
Collection<EquippedSkill> attachedEquippedSkillCollectionNew = new ArrayList<EquippedSkill>();
for (EquippedSkill equippedSkillCollectionNewEquippedSkillToAttach : equippedSkillCollectionNew) {
equippedSkillCollectionNewEquippedSkillToAttach = em.getReference(equippedSkillCollectionNewEquippedSkillToAttach.getClass(), equippedSkillCollectionNewEquippedSkillToAttach.getEquippedSkillPK());
attachedEquippedSkillCollectionNew.add(equippedSkillCollectionNewEquippedSkillToAttach);
}
equippedSkillCollectionNew = attachedEquippedSkillCollectionNew;
character.setEquippedSkillCollection(equippedSkillCollectionNew);
Collection<Weaponset> attachedWeaponsetCollectionNew = new ArrayList<Weaponset>();
for (Weaponset weaponsetCollectionNewWeaponsetToAttach : weaponsetCollectionNew) {
weaponsetCollectionNewWeaponsetToAttach = em.getReference(weaponsetCollectionNewWeaponsetToAttach.getClass(), weaponsetCollectionNewWeaponsetToAttach.getWeaponsetPK());
attachedWeaponsetCollectionNew.add(weaponsetCollectionNewWeaponsetToAttach);
}
weaponsetCollectionNew = attachedWeaponsetCollectionNew;
character.setWeaponsetCollection(weaponsetCollectionNew);
Collection<Item> attachedItemCollectionNew = new ArrayList<Item>();
for (Item itemCollectionNewItemToAttach : itemCollectionNew) {
itemCollectionNewItemToAttach = em.getReference(itemCollectionNewItemToAttach.getClass(), itemCollectionNewItemToAttach.getId());
attachedItemCollectionNew.add(itemCollectionNewItemToAttach);
}
itemCollectionNew = attachedItemCollectionNew;
character.setItemCollection(itemCollectionNew);
Collection<Attributepoint> attachedAttributepointCollectionNew = new ArrayList<Attributepoint>();
for (Attributepoint attributepointCollectionNewAttributepointToAttach : attributepointCollectionNew) {
attributepointCollectionNewAttributepointToAttach = em.getReference(attributepointCollectionNewAttributepointToAttach.getClass(), attributepointCollectionNewAttributepointToAttach.getAttributepointPK());
attachedAttributepointCollectionNew.add(attributepointCollectionNewAttributepointToAttach);
}
attributepointCollectionNew = attachedAttributepointCollectionNew;
character.setAttributepointCollection(attributepointCollectionNew);
character = em.merge(character);
if (secondaryProfessionOld != null && !secondaryProfessionOld.equals(secondaryProfessionNew)) {
secondaryProfessionOld.getCharacterCollection().remove(character);
secondaryProfessionOld = em.merge(secondaryProfessionOld);
}
if (secondaryProfessionNew != null && !secondaryProfessionNew.equals(secondaryProfessionOld)) {
secondaryProfessionNew.getCharacterCollection().add(character);
secondaryProfessionNew = em.merge(secondaryProfessionNew);
}
if (primaryProfessionOld != null && !primaryProfessionOld.equals(primaryProfessionNew)) {
primaryProfessionOld.getCharacterCollection().remove(character);
primaryProfessionOld = em.merge(primaryProfessionOld);
}
if (primaryProfessionNew != null && !primaryProfessionNew.equals(primaryProfessionOld)) {
primaryProfessionNew.getCharacterCollection().add(character);
primaryProfessionNew = em.merge(primaryProfessionNew);
}
if (levelOld != null && !levelOld.equals(levelNew)) {
levelOld.getCharacterCollection().remove(character);
levelOld = em.merge(levelOld);
}
if (levelNew != null && !levelNew.equals(levelOld)) {
levelNew.getCharacterCollection().add(character);
levelNew = em.merge(levelNew);
}
if (lastOutpostOld != null && !lastOutpostOld.equals(lastOutpostNew)) {
lastOutpostOld.getCharacterCollection().remove(character);
lastOutpostOld = em.merge(lastOutpostOld);
}
if (lastOutpostNew != null && !lastOutpostNew.equals(lastOutpostOld)) {
lastOutpostNew.getCharacterCollection().add(character);
lastOutpostNew = em.merge(lastOutpostNew);
}
if (equipmentPackOld != null && !equipmentPackOld.equals(equipmentPackNew)) {
equipmentPackOld.getCharacterCollection().remove(character);
equipmentPackOld = em.merge(equipmentPackOld);