HibernateArtifact result;
if (aid.getPk() == 0) {
Query query = HibernateUtil.getCurrentSession().createQuery("FROM net.sf.collabreview.hibernate.HibernateArtifact " +
"WHERE id.name = :name AND id.revision = :rev AND id.branch = :branch");
query.setParameter("name", aid.getName(), new StringType());
query.setParameter("rev", aid.getRevision(), new IntegerType());
query.setParameter("branch", aid.getBranch(), new StringType());
result = (HibernateArtifact) query.uniqueResult();
} else {
result = ((HibernateArtifact) HibernateUtil.getCurrentSession().get(HibernateArtifact.class, aid.getPk()));
}