@Override @Transactional public void deleteAddress(List<Address> address) throws SpartanPersistenceException { try { javax.persistence.EntityManager emanager = emfResource.getResource(); for (project.app.shared.location.Address _address : address) { project.app.shared.location.Address s = emanager.find(project.app.shared.location.Address.class, _address.getAddressId()); emanager.remove(s); } } catch (javax.persistence.PersistenceException e) { throw new SpartanPersistenceException("Error in deleting entity", e); } }
@Override @Transactional public CoreContacts save(CoreContacts entity) throws SpartanPersistenceException { try { javax.persistence.EntityManager emanager = emfResource.getResource(); java.util.List<project.app.shared.location.Address> address = new java.util.ArrayList<project.app.shared.location.Address>(); for (java.util.Iterator iterator = entity.getAddress().iterator(); iterator.hasNext(); ) { project.app.shared.location.Address childEntity = (project.app.shared.location.Address) iterator.next(); if (childEntity.getPrimaryKey() != null) { project.app.shared.location.Address ans = emanager.find(Address.class, childEntity.getPrimaryKey()); address.add(ans); } else { address.add(childEntity); } } java.util.List<project.app.shared.contacts.CommunicationData> communicationdata = new java.util.ArrayList<project.app.shared.contacts.CommunicationData>(); for (java.util.Iterator iterator = entity.getCommunicationData().iterator(); iterator.hasNext(); ) { project.app.shared.contacts.CommunicationData childEntity = (project.app.shared.contacts.CommunicationData) iterator.next(); if (childEntity.getPrimaryKey() != null) { project.app.shared.contacts.CommunicationData ans = emanager.find(CommunicationData.class, childEntity.getPrimaryKey()); communicationdata.add(ans); } else { communicationdata.add(childEntity); } } entity.setAddress(address); entity.setCommunicationData(communicationdata); emanager.persist(entity); return entity; } catch (javax.persistence.PersistenceException e) { throw new com.athena.framework.server.exception.repository.SpartanPersistenceException( "Error in entity creation", e); } }