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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
@Repository("BDAO")
public class BDAO implements IBDAO
{
private static final Log LOG = LogFactory.getLog(BDAO.class);
@PersistenceContext
private EntityManager entityManager;
//~------------------------------------------------------------------------
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#persist(com.clog.workey.data.model.AMDL)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#persist(com.clog.workey.data.model.BMDL)
*/
@Override
public void persist(BMDL transientBMDL)
{ if (LOG.isDebugEnabled()) LOG.debug("persisting AMDL instance");
try
{ entityManager.persist(transientBMDL);
if (LOG.isDebugEnabled()) LOG.debug("persist successful");
}
catch (RuntimeException re)
{ LOG.error("persist failed", re); }
entityManager.flush();
}
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#create(com.clog.workey.data.model.AMDL)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#create(com.clog.workey.data.model.BMDL)
*/
@Override
public BMDL create(BMDL aObj) {
//System.out.println("transaction used : " + entityManager.getTransaction().toString());
persist(aObj);
entityManager.flush();
return aObj;
}
//~------------------------------------------------------------------------
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#remove(com.clog.workey.data.model.AMDL)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#remove(com.clog.workey.data.model.BMDL)
*/
@Override
public void remove(BMDL persistentBMDL)
{ if (LOG.isDebugEnabled()) LOG.debug("removing AMDL instance");
try
{ entityManager.remove(persistentBMDL);
if (LOG.isDebugEnabled()) LOG.debug("remove successful");
}
catch (RuntimeException re)
{ LOG.error("remove failed", re); }
finally {
entityManager.flush();
}
}
//~------------------------------------------------------------------------
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#remove(java.lang.Object)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#remove(java.lang.Object)
*/
@Override
public void remove(Object oPK)
{ this.remove(this.findByPK(oPK));
entityManager.flush();}
//~------------------------------------------------------------------------
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#merge(com.clog.workey.data.model.AMDL)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#merge(com.clog.workey.data.model.BMDL)
*/
@Override
public BMDL merge(BMDL detachedBMDL)
{ if (LOG.isDebugEnabled()) LOG.debug("merging Actors instance");
try
{ BMDL result = entityManager.merge(detachedBMDL);
if (LOG.isDebugEnabled()) LOG.debug("merge successful");
return(result);
}
catch (RuntimeException re)
{ LOG.error("merge failed", re);
return(null);
}
finally {
entityManager.flush();
}
}
//~------------------------------------------------------------------------
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IADAO#findByPK(java.lang.Object)
*/
/* (non-Javadoc)
* @see com.clog.workey.data.dao.IBDAO#findByPK(java.lang.Object)
*/
@Override
public BMDL findByPK(Object oPK)
{
if (LOG.isDebugEnabled()) LOG.debug("getting BMDL instance with id: " + oPK);
try
{
//System.out.println("transaction used : " + entityManager.getTransaction().toString());
BMDL instance = entityManager.find(BMDL.class, oPK);
if (LOG.isDebugEnabled()) LOG.debug("findByPK successful");
return(instance);
}
catch (RuntimeException re)
{ LOG.error("findById failed", re);
return(null);
}
finally {
entityManager.flush();
}
}
} |
Partager