Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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);
        }
 
    }
    
}