List of usage examples for org.hibernate CacheMode NORMAL
CacheMode NORMAL
To view the source code for org.hibernate CacheMode NORMAL.
Click Source Link
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public Long getNextStageFileId(FileType fileType, StatusType... statusTypes) { Criteria criteria = currentSession().createCriteria(StageFile.class); criteria.add(Restrictions.eq("fileType", fileType)); criteria.add(Restrictions.in("status", statusTypes)); criteria.setProjection(Projections.min("id")); criteria.setCacheable(true);//from w w w .j a v a2s.co m criteria.setCacheMode(CacheMode.NORMAL); return (Long) criteria.uniqueResult(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<StageDirectory> getRootDirectories() { Criteria criteria = currentSession().createCriteria(StageDirectory.class); criteria.add(Restrictions.isNull("parentDirectory")); criteria.setCacheable(true);/*from ww w .java 2 s . c o m*/ criteria.setCacheMode(CacheMode.NORMAL); return criteria.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<StageDirectory> getChildDirectories(StageDirectory stageDirectory) { if (stageDirectory == null) { return Collections.emptyList(); }// w ww. ja v a 2 s. com Criteria criteria = currentSession().createCriteria(StageDirectory.class); criteria.add(Restrictions.eq("parentDirectory", stageDirectory)); criteria.setCacheable(true); criteria.setCacheMode(CacheMode.NORMAL); return criteria.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<VideoData> findVideoDatas(String baseName, StageDirectory stageDirectory) { if (stageDirectory == null) { return Collections.emptyList(); }//from w w w .jav a 2 s .co m StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct vd "); sb.append("FROM VideoData vd "); sb.append("JOIN vd.mediaFiles mf "); sb.append("JOIN mf.stageFiles sf "); sb.append("WHERE sf.fileType=:fileType "); sb.append("AND mf.extra=:extra "); if (baseName != null) { sb.append("AND lower(sf.baseName)=:baseName "); } sb.append("AND sf.stageDirectory=:stageDirectory "); sb.append("AND sf.status != :deleted "); Query query = currentSession().createQuery(sb.toString()); query.setParameter("fileType", FileType.VIDEO); query.setBoolean("extra", Boolean.FALSE); if (baseName != null) { query.setString("baseName", baseName.toLowerCase()); } query.setParameter("stageDirectory", stageDirectory); query.setParameter("deleted", StatusType.DELETED); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<VideoData> findVideoDatas(String baseName, Library library) { if (library == null) { return Collections.emptyList(); }/*from w w w .ja va2 s .co m*/ StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct vd "); sb.append("FROM VideoData vd "); sb.append("JOIN vd.mediaFiles mf "); sb.append("JOIN mf.stageFiles sf "); sb.append("JOIN sf.stageDirectory sd "); sb.append("WHERE sf.fileType=:fileType "); sb.append("AND mf.extra=:extra "); sb.append("AND lower(sf.baseName)=:baseName "); sb.append("AND sd.library=:library "); sb.append("AND sf.status != :deleted "); Query query = currentSession().createQuery(sb.toString()); query.setParameter("fileType", FileType.VIDEO); query.setBoolean("extra", Boolean.FALSE); query.setString("baseName", baseName.toLowerCase()); query.setParameter("library", library); query.setParameter("deleted", StatusType.DELETED); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<VideoData> findVideoDatas(Collection<StageDirectory> stageDirectories) { if (CollectionUtils.isEmpty(stageDirectories)) { return Collections.emptyList(); }/*from w w w .ja va2 s. c o m*/ StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct vd "); sb.append("FROM VideoData vd "); sb.append("JOIN vd.mediaFiles mf "); sb.append("JOIN mf.stageFiles sf "); sb.append("WHERE sf.fileType=:fileType "); sb.append("AND mf.extra=:extra "); sb.append("AND sf.stageDirectory in (:stageDirectories) "); sb.append("AND sf.status != :deleted "); Query query = currentSession().createQuery(sb.toString()); query.setParameter("fileType", FileType.VIDEO); query.setBoolean("extra", Boolean.FALSE); query.setParameterList("stageDirectories", stageDirectories); query.setParameter("deleted", StatusType.DELETED); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public StageFile findNfoFile(String searchName, StageDirectory stageDirectory) { if (stageDirectory == null) { return null; }/*from w ww. j a v a 2 s . c o m*/ StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct sf "); sb.append("FROM StageFile sf "); sb.append("WHERE sf.fileType=:fileType "); sb.append("AND lower(sf.baseName)=:searchName "); sb.append("AND sf.stageDirectory=:stageDirectory "); sb.append("AND sf.status != :deleted "); Query query = currentSession().createQuery(sb.toString()); query.setParameter("fileType", FileType.NFO); query.setString("searchName", searchName.toLowerCase()); query.setParameter("stageDirectory", stageDirectory); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); query.setParameter("deleted", StatusType.DELETED); return (StageFile) query.uniqueResult(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<StageFile> getValidNFOFilesForVideo(long videoDataId) { StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct sf "); sb.append("FROM StageFile sf "); sb.append("JOIN sf.nfoRelations nfrel "); sb.append("JOIN nfrel.nfoRelationPK.videoData vd "); sb.append("WHERE vd.id=:videoDataId "); sb.append("AND sf.fileType=:fileType "); sb.append("AND sf.status in (:statusSet) "); sb.append("ORDER by nfrel.priority DESC"); Set<StatusType> statusSet = new HashSet<>(); statusSet.add(StatusType.NEW);//from w w w.ja v a 2 s . c o m statusSet.add(StatusType.UPDATED); statusSet.add(StatusType.DONE); Query query = currentSession().createQuery(sb.toString()); query.setParameter("videoDataId", videoDataId); query.setParameter("fileType", FileType.NFO); query.setParameterList("statusSet", statusSet); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<StageFile> getValidNFOFilesForSeries(long seriesId) { StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct sf "); sb.append("FROM StageFile sf "); sb.append("JOIN sf.nfoRelations nfrel "); sb.append("JOIN nfrel.nfoRelationPK.videoData vd "); sb.append("JOIN vd.season sea "); sb.append("JOIN sea.series ser "); sb.append("WHERE ser.id=:seriesId "); sb.append("AND sf.fileType=:fileType "); sb.append("AND sf.status in (:statusSet) "); sb.append("ORDER by nfrel.priority DESC"); Set<StatusType> statusSet = new HashSet<>(); statusSet.add(StatusType.NEW);/*w w w . j a v a 2 s .c om*/ statusSet.add(StatusType.UPDATED); statusSet.add(StatusType.DONE); Query query = currentSession().createQuery(sb.toString()); query.setParameter("seriesId", seriesId); query.setParameter("fileType", FileType.NFO); query.setParameterList("statusSet", statusSet); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }
From source file:org.yamj.core.database.dao.StagingDao.java
License:Open Source License
public List<StageFile> findStageFiles(FileType fileType, String searchName, String searchExtension, StageDirectory stageDirectory) { StringBuilder sb = new StringBuilder(); sb.append("SELECT distinct sf "); sb.append("FROM StageFile sf "); sb.append("WHERE sf.fileType=:fileType "); sb.append("AND lower(sf.baseName)=:searchName "); if (searchExtension != null) { sb.append("AND lower(sf.extension)=:searchExtension "); }//from ww w . j ava 2 s . c om sb.append("AND sf.stageDirectory=:stageDirectory "); sb.append("AND sf.status != :duplicate "); sb.append("AND sf.status != :deleted "); Query query = currentSession().createQuery(sb.toString()); query.setParameter("fileType", fileType); query.setString("searchName", searchName.toLowerCase()); if (searchExtension != null) { query.setString("searchExtension", searchExtension.toLowerCase()); } query.setParameter("stageDirectory", stageDirectory); query.setParameter("duplicate", StatusType.DUPLICATE); query.setParameter("deleted", StatusType.DELETED); query.setCacheable(true); query.setCacheMode(CacheMode.NORMAL); return query.list(); }