@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
em.close();
ModuleLoadCmd moduleLoadCmd;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingModuleLoadCmd == null) {
moduleLoadCmd = new ModuleLoadCmd();
} else {
moduleLoadCmd = existingModuleLoadCmd;
}
moduleLoadCmd.setCmd(getCmd());
moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class, getAppDeploymentId());
moduleLoadCmd.setApplicationDeployment(applicationDeployment);
if (existingModuleLoadCmd == null) {
em.persist(moduleLoadCmd);
} else {
em.merge(moduleLoadCmd);
}