List of usage examples for org.hibernate Query setParameterList
Query<R> setParameterList(int position, Object[] values);
From source file:edu.umn.msi.tropix.persistence.dao.hibernate.TropixObjectDaoImpl.java
License:Open Source License
public boolean filesExistAndCanReadAll(String[] fileIds, String callerIdentity) { boolean allReadable = true; for (final List<String> fileIdsPartition : partition(Arrays.asList(fileIds))) { final Query query = getSession().getNamedQuery("filesExistAndCanReadAll"); query.setParameter("userId", callerIdentity); query.setParameterList("fileIds", fileIdsPartition); final Long partitionReadableCount = (Long) query.uniqueResult(); allReadable = partitionReadableCount >= fileIdsPartition.size(); if (!allReadable) { break; }/*ww w .ja va 2 s .co m*/ } return allReadable; }
From source file:edu.umn.msi.tropix.persistence.service.security.impl.SecurityProviderImpl.java
License:Open Source License
private boolean allHaveParentId(final Iterable<String> tropixObjectIds, final String parentId) { boolean allHaveParentId = true; for (final List<String> objectIdsPartition : partition(tropixObjectIds)) { final Query query = getSession().getNamedQuery("allHaveParentId"); query.setParameter("parentId", parentId); query.setParameterList("objectIds", objectIdsPartition); allHaveParentId = ((Long) query.uniqueResult()) >= objectIdsPartition.size(); if (!allHaveParentId) { break; }//from ww w . j a v a2 s .c om } return allHaveParentId; }
From source file:edu.umn.msi.tropix.persistence.service.security.impl.SecurityProviderImpl.java
License:Open Source License
private boolean canReadAllNonEmpty(final Iterable<String> tropixObjectIds, final String userGridId) { // Highly questionable optimization we are no longer using, does reduce joining though /*/*from w ww. j ava2s . c om*/ * final String firstId = tropixObjectIds.iterator().next(); * final String parentId = getParentId(firstId); * // Optimization to prevent huge joins: Just check the parent is readable and they all share the same parent * // the way the API is used this will always be the case. * if(parentId != null && * canRead(parentId, userGridId) && * allHaveParentId(tropixObjectIds, parentId)) { * return true; * } */ boolean canReadAll = true; for (final List<String> objectIdsPartition : partition(tropixObjectIds)) { final Query query = getSession().getNamedQuery("canReadAll"); query.setParameter("userId", userGridId); query.setParameterList("objectIds", objectIdsPartition); canReadAll = ((Long) query.uniqueResult()) >= objectIdsPartition.size(); if (!canReadAll) { break; } } return canReadAll; }
From source file:edu.ur.hibernate.ir.groupspace.db.HbGroupWorkspaceFileDAO.java
License:Apache License
/** * Get the files for group workspace id and listed file ids. If the list of fileIds * is null no files are returned.//from www . ja va 2 s . c o m * * @param groupWorkspaceId - id of the group workspace to look in * @param fileIds - list of file ids within the group workspace * * @return the found files */ @SuppressWarnings("unchecked") public List<GroupWorkspaceFile> getFiles(Long groupWorkspaceId, List<Long> fileIds) { if (fileIds.size() > 0) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getGroupWorkspaceFiles"); q.setParameter("groupWorkspaceId", groupWorkspaceId); q.setParameterList("fileIds", fileIds); return q.list(); } else { return new LinkedList<GroupWorkspaceFile>(); } }
From source file:edu.ur.hibernate.ir.groupspace.db.HbGroupWorkspaceFolderDAO.java
License:Apache License
/** * Get the group workspace folders in the given list with the specified ids. If the list * of folderIds is empty, no folders are returned. * /* www. j a v a2s . c o m*/ * @param groupWorkspaceId - id of the group workspace * @param folderIds - list of folder ids to retrieve * * @return the found folders */ @SuppressWarnings("unchecked") public List<GroupWorkspaceFolder> getFolders(Long groupWorkspaceId, List<Long> folderIds) { if (folderIds.size() > 0) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession().getNamedQuery("getGroupWorkspaceFolders"); q.setParameter("groupWorkspaceId", groupWorkspaceId); q.setParameterList("folderIds", folderIds); return q.list(); } else { return new LinkedList<GroupWorkspaceFolder>(); } }
From source file:edu.ur.hibernate.ir.institution.db.HbDeletedInstitutionalItemVersionDAO.java
License:Apache License
/** * Get a list of deleted institutional items ordered by institutional item version id order ascending. * /*w w w . ja va2 s.co m*/ * @param lastDeletedInstitutionalItemVersionId - the last deleted institutional item version id * to be processed. Use 0 if no items have yet been processed. Will grab max results * of where ids are greater than the given id. * * @param institutional collection ids - the collections to look within * @param maxResults - maximum number of results * * @return - deleted items greater than the given id and belong to the specified set */ @SuppressWarnings("unchecked") public List<DeletedInstitutionalItemVersion> getItemsIdOrder(long lastDeletedItemVersionId, List<Long> institutionalCollectionIds, int maxResults) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession() .getNamedQuery("getDeletedInstitutionalItemVersionByLastIdSetOrderedById"); q.setParameter("lastId", lastDeletedItemVersionId); q.setParameterList("collectionIds", institutionalCollectionIds); q.setMaxResults(maxResults); return (List<DeletedInstitutionalItemVersion>) q.list(); }
From source file:edu.ur.hibernate.ir.institution.db.HbDeletedInstitutionalItemVersionDAO.java
License:Apache License
/** * Get a count of deleted institutional item versions within a collection * //from w ww. ja v a 2s.c om * @param institutional collection ids - the collections to look within * * @return the count */ public Long getCount(List<Long> institutionalCollectionIds) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession() .getNamedQuery("getDeletedInstitutionalItemVersionBySetCount"); q.setParameterList("collectionIds", institutionalCollectionIds); return (Long) q.uniqueResult(); }
From source file:edu.ur.hibernate.ir.institution.db.HbDeletedInstitutionalItemVersionDAO.java
License:Apache License
/** * Get a count of the deleted institutional item versions that have been deleted * between the specified dates - this includes new additions to the repository * /* w w w .j av a2s. c om*/ * @param fromDeletedDate - from date deleted * @param untilDeletedDate - until date deleted * @param institutional collection ids - the collections to look within * * @return - count of items found */ public Long getItemsBetweenDeletedDatesCount(Date fromDeletedDate, Date untilDeletedDate, List<Long> institutionalCollectionIds) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession() .getNamedQuery("getDeletedInstitutionalItemVersionSetBetweenDatesCount"); q.setParameterList("collectionIds", institutionalCollectionIds); q.setParameter("fromDate", fromDeletedDate); q.setParameter("untilDate", untilDeletedDate); return (Long) q.uniqueResult(); }
From source file:edu.ur.hibernate.ir.institution.db.HbDeletedInstitutionalItemVersionDAO.java
License:Apache License
/** * Get a count of deleted items within a given collection that have a deleted date * greater than or equal to the specified date. This includes sub collections. * //www . ja v a2 s . c o m * @param fromDeletedDate - date the deletion must be greater than or equal to * @param institutional collection ids - the collections to look within * * @return the count of the number of items found greater than the specified date and within the specified collection * or sub collections */ public Long getItemsFromDeletedDateCount(Date fromDeletedDate, List<Long> institutionalCollectionIds) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession() .getNamedQuery("getDeletedInstitutionalItemVersionSetFromDateCount"); q.setParameterList("collectionIds", institutionalCollectionIds); q.setParameter("fromDate", fromDeletedDate); return (Long) q.uniqueResult(); }
From source file:edu.ur.hibernate.ir.institution.db.HbDeletedInstitutionalItemVersionDAO.java
License:Apache License
/** * Get a count of deleted items within a given collection that have a deletion date * less than or equal to the specified date. This includes sub collections. * // w w w. j ava 2 s .com * @param fromDeletedDate - date the deletion must be greater than or equal to * @param institutional collection ids - the collections to look within * * @return the count of the number of items found less than or equal to the specified date and within the specified collection * or sub collections */ public Long getItemsUntilDeletedDateCount(Date untilDeletedDate, List<Long> institutionalCollectionIds) { Query q = hbCrudDAO.getSessionFactory().getCurrentSession() .getNamedQuery("getDeletedInstitutionalItemVersionSetUntilDateCount"); q.setParameterList("collectionIds", institutionalCollectionIds); q.setParameter("untilDate", untilDeletedDate); return (Long) q.uniqueResult(); }