| 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("grpusrDao") |
| 11 | 0 | public class GrpusrDao extends AbstractDao { |
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
public Grpusr getByGrpusrid(Integer grpusrid) { |
| 16 | 0 | Grpusr cnd = new Grpusr(); |
| 17 | 0 | cnd.setGrpusrid(grpusrid); |
| 18 | 0 | List<Grpusr> 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<Grpusr> get() { |
| 26 | 0 | Grpusr cnd = new Grpusr(); |
| 27 | 0 | cnd.setDeleted(AppDef.FLASE); |
| 28 | 0 | return get(cnd); |
| 29 | |
} |
| 30 | |
|
| 31 | |
public List<Grpusr> get(Grpusr cnd) { |
| 32 | 0 | if(cnd != null) { |
| 33 | 0 | cnd.setDeleted(AppDef.FLASE); |
| 34 | |
} |
| 35 | 0 | HibernateTemplate hibernateTemplate = getHibernateTemplate(); |
| 36 | 0 | DetachedCriteria dc = DetachedCriteria.forClass(Grpusr.class); |
| 37 | 0 | dc.add(Example.create(cnd)); |
| 38 | |
@SuppressWarnings("unchecked") |
| 39 | 0 | List<Grpusr> list = (List<Grpusr>) hibernateTemplate.findByCriteria(dc); |
| 40 | 0 | hibernateTemplate.clear(); |
| 41 | 0 | return list; |
| 42 | |
} |
| 43 | |
|
| 44 | |
|
| 45 | |
private static final String ENTITYNAME = "Grpusr"; |
| 46 | |
private static final String PKEYNAME = "grpusrid"; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public void add(Grpusr item, Integer updateusrid) { |
| 56 | |
|
| 57 | 0 | item.setGrpusrid(getNextId(ENTITYNAME, PKEYNAME)); |
| 58 | |
|
| 59 | 0 | super.add(item, updateusrid); |
| 60 | 0 | } |
| 61 | |
public void update(Grpusr item, Integer updateusrid) { |
| 62 | 0 | super.update(item, updateusrid); |
| 63 | 0 | } |
| 64 | |
public void removeLogical(Grpusr item, Integer updateusrid) { |
| 65 | 0 | super.removeLogical(item, updateusrid); |
| 66 | 0 | } |
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
public String getMembercount参加中AsString(Integer grpid) { |
| 75 | 0 | return String.valueOf(getMembercount参加中(grpid)); |
| 76 | |
} |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public Integer getMembercount参加中(Integer grpid) { |
| 83 | 0 | Grpusr cndGu = new Grpusr(); |
| 84 | 0 | cndGu.setGrpid(grpid); |
| 85 | 0 | cndGu.setStatus(Grpusr.STATUS_参加中); |
| 86 | 0 | List<Grpusr> member = this.get(cndGu); |
| 87 | 0 | return member.size(); |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
} |