code: public Map<Integer, Long> getIdMappingCategories() {
          Map<Integer, Long> idMapping = new HashMap<Integer, Long>();
  
          Session session = WikiHibernateUtil.getSessionFactory(this.dbConfig).getCurrentSession();
          session.beginTransaction();
          Iterator results = session.createQuery("select cat.id, cat.pageId from Category as cat").list().iterator();
          while (results.hasNext()) {
              Object[] row = (Object[]) results.next();
              // put (pageID, id)
              idMapping.put((Integer) row[1], (Long) row[0]);
          }
          session.getTransaction().commit();
          return idMapping;
      }
docs: Hibernate IDs are needed to load an object from the database.
  Internal references are via pageIDs.
  @return A mapping of pageIDs to hibernate IDs.