FileDAO { public com.wipro.ats.bdre.md.beans.table.File getFile(com.wipro.ats.bdre.md.beans.table.File file) { Session session = sessionFactory.openSession(); com.wipro.ats.bdre.md.beans.table.File tableFile = new com.wipro.ats.bdre.md.beans.table.File(); try { session.beginTransaction(); Criteria countCriteria = session.createCriteria(File.class); int counter = countCriteria.list().size(); Batch jpaBatch = (Batch) session.get(Batch.class, file.getBatchId()); Criteria criteria = session.createCriteria(File.class).add(Restrictions.eq("batch", jpaBatch)); File jpaFile = (File) criteria.uniqueResult(); tableFile = new com.wipro.ats.bdre.md.beans.table.File(); if (jpaFile != null && jpaFile.getId() != null && jpaFile.getBatch() != null && jpaFile.getServers() != null) { tableFile.setBatchId(jpaFile.getBatch().getBatchId()); tableFile.setServerId(jpaFile.getServers().getServerId()); tableFile.setPath(jpaFile.getId().getPath()); tableFile.setFileSize(jpaFile.getId().getFileSize()); tableFile.setFileHash(jpaFile.getId().getFileHash()); tableFile.setCreationTS(jpaFile.getId().getCreationTs()); } tableFile.setCounter(counter); session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.info("Error Occured" + e); return null; } finally { session.close(); } return tableFile; }  List<File> list(Integer pageNum, Integer numResults); Long totalRecordCount(); File get(FileId fileId); FileId insert(File file); com.wipro.ats.bdre.md.beans.table.File update(com.wipro.ats.bdre.md.beans.table.File tableFile); void delete(Long batchId); List<com.wipro.ats.bdre.md.beans.FileInfo> getFiles(long minBatchId, long maxBatchId); com.wipro.ats.bdre.md.beans.table.File getFile(com.wipro.ats.bdre.md.beans.table.File file); com.wipro.ats.bdre.md.beans.table.File insert(com.wipro.ats.bdre.md.beans.table.File tableFile);  }
@Ignore @Test public void testGetFile() throws Exception { com.wipro.ats.bdre.md.beans.table.File file = new com.wipro.ats.bdre.md.beans.table.File(); file.setBatchId((long) 0); com.wipro.ats.bdre.md.beans.table.File returnedFile = fileDAO.getFile(file); LOGGER.info("Path is " + returnedFile.getPath()); }