<commit_before>#include <QMetaOrm/session.h>
#include <QMetaOrm/exceptions.h>
#include <qthread.h>

using namespace QMetaOrm;

QString GetThreadIdentifier() {
   return QString::number((int)QThread::currentThreadId());
}

Session::Session(
   DatabaseFactory::Ptr databaseFactory,
   EntitySqlBuilder::Ptr entitySqlBuilder,
   EntityMapper::Ptr entityMapper,
   ConverterStore::Ptr converterStore)
   : m_database(databaseFactory->createDatabase(GetThreadIdentifier()))
   , m_entitySqlBuilder(entitySqlBuilder)
   , m_entityMapper(entityMapper)
   , m_converterStore(converterStore)
{
}

Session::~Session() {
   m_database.rollback();
   m_database.close();
}

void Session::commit() {
   if (!m_database.commit())
      throw TransactionException(m_database.lastError());
}

void Session::rollback() {
   if (!m_database.rollback())
      throw TransactionException(m_database.lastError());<commit_msg>Sessions should actually not close a connection because others still use it.<commit_after>#include <QMetaOrm/session.h>
#include <QMetaOrm/exceptions.h>
#include <qthread.h>

using namespace QMetaOrm;

QString GetThreadIdentifier() {
   return QString::number((int)QThread::currentThreadId());
}

Session::Session(
   DatabaseFactory::Ptr databaseFactory,
   EntitySqlBuilder::Ptr entitySqlBuilder,
   EntityMapper::Ptr entityMapper,
   ConverterStore::Ptr converterStore)
   : m_database(databaseFactory->createDatabase(GetThreadIdentifier()))
   , m_entitySqlBuilder(entitySqlBuilder)
   , m_entityMapper(entityMapper)
   , m_converterStore(converterStore)
{
}

Session::~Session() {
}

void Session::commit() {
   if (!m_database.commit())
      throw TransactionException(m_database.lastError());
}

void Session::rollback() {
   if (!m_database.rollback())
      throw TransactionException(m_database.lastError());
{'fraction_non_alphanumeric': 0.12554824561403508, 'fraction_numerical': 0.0, 'mean_word_length': 6.388663967611336, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6047445', 'n_tokens_mistral': 546, 'n_tokens_neox': 543, 'n_words': 90}