Package sn.unitech.stock.dao

Source Code of sn.unitech.stock.dao.SysAdherentDao

package sn.unitech.stock.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import sn.unitech.stock.dao.iface.ISysAdherActiviteDao;
import sn.unitech.stock.dao.iface.ISysAdherEventDao;
import sn.unitech.stock.dao.iface.ISysAdherentDao;
import sn.unitech.stock.entity.SysAdherActivite;
import sn.unitech.stock.entity.SysAdherEvent;
import sn.unitech.stock.entity.SysAdherent;
import sn.unitech.stock.modal.Resultat;

public class SysAdherentDao<E> extends DataAccess<SysAdherent> implements ISysAdherentDao<SysAdherent>{
private ISysAdherEventDao<SysAdherEvent> iAdherEventDao=new SysAdherEventDao<SysAdherEvent>();
private ISysAdherActiviteDao<SysAdherActivite> iAdherActiviteDao=new SysAdherActiviteDao<SysAdherActivite>();
    public SysAdherentDao() {
    }

    @Override
    public Resultat persistAdherent(SysAdherent adherent) {
      EntityManager em=getEntityManager();
      EntityTransaction tx=em.getTransaction();
      tx.begin();
      this.persist(adherent, em);
      for(SysAdherEvent adherEvent:adherent.getSysAdherEvents()){
        this.iAdherEventDao.persist(adherEvent, em);
      }
      for(SysAdherActivite adherActivite:adherent.getSysAdherActivites()){
        this.iAdherActiviteDao.persist(adherActivite, em);
      }
      tx.commit();
      em.close();
      return new Resultat(true,"Validation reussie!");
    }
}
TOP

Related Classes of sn.unitech.stock.dao.SysAdherentDao

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.