eboix
05-09-2006, 05:28 PM
Hi all,
I'm developing a .Net app, and since I extensively use Spring.Java I started using Spring.Net.
Spring.Java has the JdbcTemplate support class which takes care of opening/closing connections and to coordinate the transactions (kind of, at least it helps in this process).
Spring.Net does not still have this, so I have to manage all this myself.
Now, how do I manage the SqlConnections ? I'm injecting my DAOs in my Business objects which in turn are injected in my ASPX files (all singleton).
What does make more sense ?
Do I create a "ConnectionFactory" bean, which creates the connections and hand them to the DAOs (on each method call) ?
Do I make the DAOs create their own connections (on each method) ?
In any case, this will led to trouble, since for example SQLServer ties a transaction to a connection, so using this method, I won't be able to create transactions reliably.
Do I create a "DaoFactory" which creates singleton DAO objects ? This way, I'll be able to use the same connection all the lifetime of the DAO, but I find this approach somewhat overkill...
Any suggestions ?
Regards,
Esteve
I'm developing a .Net app, and since I extensively use Spring.Java I started using Spring.Net.
Spring.Java has the JdbcTemplate support class which takes care of opening/closing connections and to coordinate the transactions (kind of, at least it helps in this process).
Spring.Net does not still have this, so I have to manage all this myself.
Now, how do I manage the SqlConnections ? I'm injecting my DAOs in my Business objects which in turn are injected in my ASPX files (all singleton).
What does make more sense ?
Do I create a "ConnectionFactory" bean, which creates the connections and hand them to the DAOs (on each method call) ?
Do I make the DAOs create their own connections (on each method) ?
In any case, this will led to trouble, since for example SQLServer ties a transaction to a connection, so using this method, I won't be able to create transactions reliably.
Do I create a "DaoFactory" which creates singleton DAO objects ? This way, I'll be able to use the same connection all the lifetime of the DAO, but I find this approach somewhat overkill...
Any suggestions ?
Regards,
Esteve