1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-13 17:56:20 +00:00

List orphan files

This commit is contained in:
jendib
2015-03-06 21:23:50 +01:00
parent 2347483676
commit d0c259ead2
3 changed files with 29 additions and 11 deletions

View File

@@ -125,6 +125,10 @@ public class FileDao {
@SuppressWarnings("unchecked")
public List<File> getByDocumentId(String documentId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
if (documentId == null) {
Query q = em.createQuery("select f from File f where f.documentId is null and f.deleteDate is null order by f.createDate asc");
return q.getResultList();
}
Query q = em.createQuery("select f from File f where f.documentId = :documentId and f.deleteDate is null order by f.order asc");
q.setParameter("documentId", documentId);
return q.getResultList();