public InfoImg getInfoMainImg(Long infoId) { Criteria cri = getSession().createCriteria(InfoImg.class); Info info = new Info(); info.setId(infoId); cri.add(Restrictions.eq("info", info)); cri.add(Restrictions.eq("isMainImg", true)); return (InfoImg) cri.uniqueResult(); }
@Override public List<Criterion> getCriterions(ParamCondition paramCondition) { List<Criterion> criterions = new ArrayList<Criterion>(); if (!paramCondition.isParameterNull("infoId")) { Long infoId = paramCondition.getLong("infoId"); Info info = new Info(); info.setId(infoId); criterions.add(Restrictions.eq("info", info)); } return criterions; }