package com.megatim.fdxconsultation.dao.impl.administration;
|
|
import com.bekosoftware.genericdaolayer.dao.exceptions.GenericDAOException;
|
import javax.persistence.EntityManager;
|
import javax.persistence.PersistenceContext;
|
|
import com.bekosoftware.genericdaolayer.dao.impl.AbstractGenericDAO;
|
import com.megatim.fdxconsultation.dao.ifaces.administration.ActionDAO;
|
import com.megatim.fdxconsultation.model.administration.Action;
|
import javax.enterprise.context.Dependent;
|
import javax.persistence.TransactionRequiredException;
|
|
/**
|
*
|
* @author DYNABOOK
|
*/
|
@Dependent
|
public class ActionDAOImpl extends AbstractGenericDAO<Action, Long> implements ActionDAO {
|
|
@PersistenceContext(unitName = "fdxConsultationPersistenceUnit")
|
protected EntityManager em;
|
|
public ActionDAOImpl() {
|
}
|
|
@Override
|
public EntityManager getEntityManager() {
|
return em;
|
}
|
|
@Override
|
public Class<Action> getManagedEntityClass() {
|
return (Action.class);
|
}
|
|
/**
|
* Remove the parameter t in the data base
|
*
|
* @param entityID : id of the entity to delete
|
* @throws GenericDAOException if any problems
|
* @return
|
*/
|
@Override
|
public Action delete(Object entityID) {
|
|
//Verification de la validite de entityID
|
if (entityID == null) {
|
throw new GenericDAOException("genericentitymanager.delete.entityID.null");
|
}
|
try {
|
//chargement de l'netite en memoire
|
Action entity = getEntityManager().find(entityClass, entityID);
|
//Execution action de pre-delete
|
processBeforeDelete(entity);
|
//Suppression de entity en BD
|
getEntityManager().createNativeQuery("delete from FS_ACTION where id="+entityID).executeUpdate();
|
//Execution action de post-delete
|
processAfterDelete(entity);
|
return entity;
|
} catch (IllegalArgumentException e) {
|
//e.printStackTrace();
|
throw new GenericDAOException("genericentitymanager.delete.illegalargumentexception", e);
|
} catch (TransactionRequiredException e) {
|
throw new GenericDAOException("genericentitymanager.delete.transactionrequiredexception", e);
|
} catch (Exception e) {
|
throw new GenericDAOException("genericentitymanager.delete.error", e);
|
}
|
|
}
|
|
}
|