| 1 | 0 | package jp.co.y_net.amm.dao; |
| 2 | |
import java.util.List; |
| 3 | |
|
| 4 | |
import org.hibernate.criterion.DetachedCriteria; |
| 5 | |
import org.hibernate.criterion.Example; |
| 6 | |
import org.springframework.orm.hibernate3.HibernateTemplate; |
| 7 | |
import org.springframework.stereotype.Component; |
| 8 | |
|
| 9 | |
|
| 10 | |
@Component("grpDao") |
| 11 | 0 | public class GrpDao extends AbstractDao { |
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
public Grp getByGrpid(Integer grpid) { |
| 16 | 0 | Grp cnd = new Grp(); |
| 17 | 0 | cnd.setGrpid(grpid); |
| 18 | 0 | List<Grp> list = get(cnd); |
| 19 | 0 | if(list.size() == 1) { |
| 20 | 0 | return list.get(0); |
| 21 | |
} |
| 22 | 0 | return null; |
| 23 | |
} |
| 24 | |
|
| 25 | |
public List<Grp> get() { |
| 26 | 0 | Grp cnd = new Grp(); |
| 27 | 0 | cnd.setDeleted(AppDef.FLASE); |
| 28 | 0 | return get(cnd); |
| 29 | |
} |
| 30 | |
|
| 31 | |
public List<Grp> get(Grp cnd) { |
| 32 | 0 | if(cnd != null) { |
| 33 | 0 | cnd.setDeleted(AppDef.FLASE); |
| 34 | |
} |
| 35 | 0 | HibernateTemplate hibernateTemplate = getHibernateTemplate(); |
| 36 | 0 | DetachedCriteria dc = DetachedCriteria.forClass(Grp.class); |
| 37 | 0 | dc.add(Example.create(cnd)); |
| 38 | |
@SuppressWarnings("unchecked") |
| 39 | 0 | List<Grp> list = (List<Grp>) hibernateTemplate.findByCriteria(dc); |
| 40 | 0 | hibernateTemplate.clear(); |
| 41 | 0 | return list; |
| 42 | |
} |
| 43 | |
|
| 44 | |
|
| 45 | |
private static final String ENTITYNAME = "Grp"; |
| 46 | |
private static final String PKEYNAME = "grpid"; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public void add(Grp item, Integer updateusrid) { |
| 56 | |
|
| 57 | 0 | item.setGrpid(getNextId(ENTITYNAME, PKEYNAME, 1000000001)); |
| 58 | |
|
| 59 | 0 | super.add(item, updateusrid); |
| 60 | 0 | } |
| 61 | |
|
| 62 | 0 | public void update(Grp item, Integer updateusrid) { |
| 63 | 0 | super.update(item, updateusrid); |
| 64 | 0 | } |
| 65 | 0 | public void removeLogical(Grp item, Integer updateusrid) { |
| 66 | 0 | super.removeLogical(item, updateusrid); |
| 67 | 0 | } |
| 68 | |
} |