.net - Fluent NHibernate sessions closes the database connection -


i'm using fluent nhibernate write oracle 11g database. i'm not sure if it's problem, nhibernate drivers have configuration settings 9 , 10g databases. anyways, when had instantiated 1 nhibernate sessionfactory , 1 nhibernate session (a used both regular session , istatelesssession). anytime performed read or write database, oracle sys.aud$ table have log of transactions being performed. our dba said because connection logging in , logging off after each read or write transaction. large amount of queries, end killing audit table. we're going create second database user tweaked auditing account, default nature nhibernate close , open connection each transaction? there way prevent connection logging in , logging off?

here's sessionfactory configuration

public static isessionfactory getsessionfactory() {         var cfg = fluentnhibernate.cfg.db.oracleclientconfiguration.oracle10;         cfg.connectionstring(c => {             c.instance(...);             c.username(...);             c.password(...);             c.server(...);         });           return fluently.configure().database(cfg).mappings(m => {             m.fluentmappings.add<dummydatamap>();         }).buildsessionfactory();     } 

and here's main method tests wrote

 static void main(string[] args) {         try {             var sessionfactory = getsessionfactory();              /*using (var statelesssession = sessionfactory.openstatelesssession()) {                 (int = 0; < 1000; i++) {                     var dd = new dummydata();                     dd.first_column = i;                     using (var t = statelesssession.begintransaction()) {                         statelesssession.insert(dd);                         t.commit();                     }                 }             }*/             /*using (var statefulsession = sessionfactory.opensession()) {                 (int = 0; < 1000; i++) {                     var dd = new dummydata();                     dd.first_column = i;                     using (var t = statefulsession.begintransaction()) {                         statefulsession.save(dd);                         t.commit();                     }                 }             }*/              using (var statefulsession = sessionfactory.opensession()) {                  (int = 0; < 1000; i++) {                     statefulsession.query<dummydata>().where(dd => dd.first_column == i).foreach(dd =>                         console.out.writeline(dd.first_column));                 }             }         } catch (exception ex) {             console.out.writeline(ex.message);         } 

opening , closing connection each use case recommended way in ado.net

using connections

high performance applications keep connections data source in use minimal amount of time, take advantage of performance enhancing technology such connection pooling.

double check connectionpooling enabled , supported ado.net driver using.

if need have 1 global connection implement iconnectionprovider opens connection on first createconnection , hands out created each time, have make sure no 2 databaseoperations performed @ same time because not supported connection.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -