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
| public class ProduitsStockDAO extends BaseHibernateDAO {
private static final Logger log = LoggerFactory.getLogger(ProduitsStockDAO.class);
// property constants
public static final String CODE_PDT = "codePdt";
public static final String QTE_PDT = "qtePdt";
/*public Session getSession() {
return HibernateSessionFactory.getSession();}*/
public String doSomeThing() {
// TODO Auto-generated method stub
return "Hello World DAO";
}
public void save(ProduitsStock transientInstance) {
log.debug("saving ProduitsStock instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(ProduitsStock persistentInstance) {
log.debug("deleting ProduitsStock instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public ProduitsStock findById(java.lang.Integer id) {
log.debug("getting ProduitsStock instance with id: " + id);
try {
ProduitsStock instance = (ProduitsStock) getSession().get(
"dao.ProduitsStock", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(ProduitsStock instance) {
log.debug("finding ProduitsStock instance by example");
try {
List results = getSession().createCriteria("dao.ProduitsStock")
.add(Example.create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding ProduitsStock instance with property: "
+ propertyName + ", value: " + value);
try {
String queryString = "from ProduitsStock as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByCodePdt(Object codePdt) {
return findByProperty(CODE_PDT, codePdt);
}
public List findByQtePdt(Object qtePdt) {
return findByProperty(QTE_PDT, qtePdt);
}
public List findAll() {
log.debug("finding all ProduitsStock instances");
try {
String queryString = "from ProduitsStock";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public ProduitsStock merge(ProduitsStock detachedInstance) {
log.debug("merging ProduitsStock instance");
try {
ProduitsStock result = (ProduitsStock) getSession().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(ProduitsStock instance) {
log.debug("attaching dirty ProduitsStock instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(ProduitsStock instance) {
log.debug("attaching clean ProduitsStock instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
} |
Partager