@Override @Transaction public void deleteCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("deleteCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isInfoEnabled()) { log.info("delete camion " + camion.getTopiaId()); } chauffeur.removeCamions(camion); } dao.update(chauffeur); }
@Override @Transaction public void deleteCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("deleteCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isInfoEnabled()) { log.info("delete camion " + camion.getTopiaId()); } chauffeur.removeCamions(camion); } dao.update(chauffeur); }
@Override public void delete(E entity) throws TopiaException { { List<Tour> list = getContext() .getDAO(Tour.class) .findAllByProperties(Tour.PROPERTY_CAMION, entity); for (Tour item : list) { // sletellier : Set null only if target is concerned by deletion if (entity.equals(item.getCamion())) { item.setCamion(null); } } } { List<Chauffeur> list = getContext().getHibernate().createSQLQuery( "SELECT main.topiaid " + "from chauffeur main, camions_defautchauffeurs secondary " + "where main.topiaid=secondary.defautChauffeurs" + " and secondary.camions='" + entity.getTopiaId() + "'") .addEntity("main", com.cybelia.sandra.SandraDAOHelper.getImplementationClass(Chauffeur.class)).list(); for (Chauffeur item : list) { item.removeCamions(entity); } } super.delete(entity); }