| 1 |
|
package org.itracker.persistence.dao; |
| 2 |
|
|
| 3 |
|
import java.util.List; |
| 4 |
|
|
| 5 |
|
import org.hibernate.HibernateException; |
| 6 |
|
import org.hibernate.Query; |
| 7 |
|
import org.itracker.model.IssueAttachment; |
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
@author |
| 13 |
|
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 13 |
Complexity Density: 0.35 |
|
| 14 |
|
public class IssueAttachmentDAOImpl extends BaseHibernateDAOImpl<IssueAttachment> |
| 15 |
|
implements IssueAttachmentDAO { |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 17 |
0
|
public IssueAttachment findByPrimaryKey(Integer attachmentId) {... |
| 18 |
0
|
try { |
| 19 |
0
|
return (IssueAttachment)getSession().get(IssueAttachment.class, |
| 20 |
|
attachmentId); |
| 21 |
|
} catch (HibernateException ex) { |
| 22 |
0
|
throw convertHibernateAccessException(ex); |
| 23 |
|
} |
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 26 |
0
|
public IssueAttachment findByFileName(String fileName) {... |
| 27 |
0
|
IssueAttachment attachment; |
| 28 |
|
|
| 29 |
0
|
try { |
| 30 |
0
|
Query query = getSession().getNamedQuery( |
| 31 |
|
"AttachmentByFileNameQuery"); |
| 32 |
0
|
query.setString("fileName", fileName); |
| 33 |
0
|
attachment = (IssueAttachment)query.uniqueResult(); |
| 34 |
|
} catch (HibernateException ex) { |
| 35 |
0
|
throw convertHibernateAccessException(ex); |
| 36 |
|
} |
| 37 |
0
|
return attachment; |
| 38 |
|
} |
| 39 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 40 |
0
|
@SuppressWarnings("unchecked")... |
| 41 |
|
public List<IssueAttachment> findAll() { |
| 42 |
0
|
List<IssueAttachment> attachments; |
| 43 |
|
|
| 44 |
0
|
try { |
| 45 |
0
|
Query query = getSession().getNamedQuery( |
| 46 |
|
"AttachmentsAllQuery"); |
| 47 |
0
|
attachments = query.list(); |
| 48 |
|
} catch (HibernateException ex) { |
| 49 |
0
|
throw convertHibernateAccessException(ex); |
| 50 |
|
} |
| 51 |
0
|
return attachments; |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 54 |
0
|
@SuppressWarnings("unchecked")... |
| 55 |
|
public List<IssueAttachment> findByIssue(Integer issueId) { |
| 56 |
0
|
List<IssueAttachment> attachments; |
| 57 |
|
|
| 58 |
0
|
try { |
| 59 |
0
|
Query query = getSession().getNamedQuery( |
| 60 |
|
"AttachmentsByIssueQuery"); |
| 61 |
0
|
query.setInteger("issueId", issueId); |
| 62 |
0
|
attachments = query.list(); |
| 63 |
|
} catch (HibernateException ex) { |
| 64 |
0
|
throw convertHibernateAccessException(ex); |
| 65 |
|
} |
| 66 |
0
|
return attachments; |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 69 |
0
|
public Long countAll() {... |
| 70 |
0
|
Long count; |
| 71 |
0
|
try { |
| 72 |
0
|
Query query = getSession().getNamedQuery( |
| 73 |
|
"AttachmentsCountAllQuery"); |
| 74 |
0
|
count = (Long)query.uniqueResult(); |
| 75 |
|
} catch (HibernateException ex) { |
| 76 |
0
|
throw convertHibernateAccessException(ex); |
| 77 |
|
} |
| 78 |
0
|
return count; |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 81 |
0
|
public Long totalAttachmentsSize() {... |
| 82 |
0
|
Long count; |
| 83 |
0
|
try { |
| 84 |
0
|
Query query = getSession().getNamedQuery( |
| 85 |
|
"TotalAttachmentsSizeQuery"); |
| 86 |
0
|
count = (Long)query.uniqueResult(); |
| 87 |
|
} catch (HibernateException ex) { |
| 88 |
0
|
throw convertHibernateAccessException(ex); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
0
|
if( count == null ) { |
| 92 |
0
|
count = 0L; |
| 93 |
|
} |
| 94 |
|
|
| 95 |
0
|
return count; |
| 96 |
|
} |
| 97 |
|
} |