code: public synchronized long next() throws PersistenceException {
          logger.debug("enter - next()");
          try {
              Connection conn = null;
              
              sequence++;
              if( logger.isInfoEnabled() ) {
                  logger.info("Getting next ID for " + getName() +
                              " (" + sequence + ").");
              }
              if( sequence == nextKey ) {
                  logger.info("Key space exhausted for " + getName() + ".");
                  try {
                      InitialContext ctx = new InitialContext();
                      DataSource ds = (DataSource)ctx.lookup(dataSourceName);
                      conn = ds.getConnection();
                      conn.setReadOnly(false); // force read-only to be reset to false
                      reseed(conn);
                      if( !conn.getAutoCommit() ) {
                          conn.commit();
                      }
                  }
                  catch( SQLException e ) {
                      throw new PersistenceException(e);
                  }
                  catch( NamingException e ) {
                      throw new PersistenceException(e);
                  }
                  finally {
                      if( conn != null ) {
                          try { conn.close(); }
                          catch( SQLException ignore ) { /* ignore */ }
                      }
                  }
              }
              logger.info("Returning sequence " + sequence + " for " +
                          getName() + ".");
              // the next key for this sequencer
              return sequence;
          }
          finally {
              logger.debug("exit - next()");
          }
      }
docs: Generates a new unique number. The unique number is based on the
  following algorithm:<br/>
  <i>unique number</i> = <i>seed</i> multiple by
  <i>maximum keys per seed</i> added to <i>seed sequence</i>
  <br/>
  The method then increments the seed sequence for the next
  ID to be generated. If the ID to be generated would exhaust
  the seed, then a new seed is retrieved from the database.
  @return a unique number
  @throws org.dasein.persist.PersistenceException a data store error
  occurred while generating the number