Package sn.unitech.stock.dao

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

package sn.unitech.stock.dao;

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

import sn.unitech.common.dao.ReadProperties;
import sn.unitech.stock.dao.iface.ISysGroupProdDao;
import sn.unitech.stock.entity.SysActivite;
import sn.unitech.stock.entity.SysAdherGroupProd;
import sn.unitech.stock.entity.SysAdherGroupProdId;
import sn.unitech.stock.entity.SysAdherent;
import sn.unitech.stock.entity.SysGroupProd;

public class SysGroupProdDao extends DataAccess implements ISysGroupProdDao {
  private ReadProperties readProperties=ReadProperties.getReadProperties();

  public SysGroupProdDao(){
   
  }
 
  @SuppressWarnings("unchecked")
  public boolean saveGroupProduit(SysGroupProd sysGroupProd,SysAdherGroupProd sysAdherGroupProd){
    EntityManager em=getEntityManager();
    EntityTransaction tx= em.getTransaction();
    try{
    tx.begin()
    SysActivite activite =(SysActivite)this.find(SysActivite.class,sysGroupProd.getSysActivite().getIdActivite(),em);
    sysGroupProd.setSysActivite(activite);
    this.persist(sysGroupProd, em);
    sysAdherGroupProd.setSysGroupProd(sysGroupProd);
    SysAdherent adherent=(SysAdherent)this.find(SysAdherent.class,sysAdherGroupProd.getSysAdherent().getIdAdherent(), em);
    sysAdherGroupProd.setSysAdherent(adherent);
    sysAdherGroupProd.setId(new SysAdherGroupProdId(adherent.getIdAdherent(),sysGroupProd.getIdGroupProd()));
    this.persist(sysAdherGroupProd, em);
    tx.commit();
    return true;
    }
    catch(Exception ex){
    if((tx!=null)&&(tx.isActive()))tx.rollback();
    ex.printStackTrace();
    return false;
    }
    finally{
    em.close()
    }
  }

}
TOP

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

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.