deephacks / lmdbjni

LMDB for Java
Apache License 2.0
204 stars 28 forks source link

EntryIterator closes passed transaction #28

Closed raybellis closed 9 years ago

raybellis commented 9 years ago

EntryIterator has this code:

 /**
   * Close the cursor and the transaction.
   */
  @Override
  public void close() {
    if (tx != null) {
      tx.commit();
    }
    cursor.close();
  }

This is causing me problems when trying to iterate over two separate databases in the one transaction - the second iteration fails because the first iteration closes the transaction. Is there a good reason for this call to be present here?

[ my application is read-only, and currently single transaction ]

krisskross commented 9 years ago

This is definitely a bug. Users should be able to handle transactions as they see fit and I cannot see a valid case where you would like to tie the life cycle of cursor and transaction together.