public boolean existsPage ( int pageID ) { // This is a hack to provide a much quicker way to test whether a page exists. // Encoding the title in this way surpasses the normal way of creating a title first. // Anyway, I do not like this hack :-| if ( pageID < 0 ) { return false ; } Session session = this . __getHibernateSession ( ) ; session . beginTransaction ( ) ; List returnList = session . createNativeQuery ( "select p.id from PageMapLine as p where p.pageID = :pageId" ) . setParameter ( "pageId" , pageID , IntegerType . INSTANCE ) . list ( ) ; session . getTransaction ( ) . commit ( ) ; return returnList . size ( ) != 0 ; }
Tests whether a page with the given pageID exists . Trying to retrieve a pageID that does not exist in Wikipedia throws an exception .