Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package data.dao; import data.dao.parent.Dao; import data.entity.Scene; import data.entity.Sequence; import java.util.List; import logic.StrategyAfterStatic; import logic.StrategyBeforeStatic; import org.hibernate.Criteria; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Repository; /** * * @author bezdatiuzer */ @Repository("sequenceDao") public class SequenceDao extends Dao<Sequence> { @Override public Class getSupportedClass() { return Sequence.class; } public List<Sequence> findBySceneId(Scene sc) { Criteria cr = currentSession().createCriteria(getSupportedClass()); cr.createCriteria("scenes").add(Restrictions.eq("sceneId", sc.getId())); return cr.list(); } public List<Sequence> findWithoutScenes() { Criteria cr = currentSession().createCriteria(getSupportedClass()); //cr.add(Restrictions.isNull("scenes")); cr.add(Restrictions.isEmpty("scenes")); return cr.list(); } }