Results 1 to 2 of 2

Thread: IoC newbie question

  1. #1
    Join Date
    Mar 2005

    Default IoC newbie question


    Sorry for my english.

    Suppose I have byref classes in .Net Remoting:

    class Master
    private IDBMS _dbms; // it has SqlTransaction Inside
    private Detail _detail;

    public void Save()
    // using _dbms to save Data

    _dbms is a wrapper class of ADO.NET which both Master and Detail objects need it. I have problem, if I inject _dbms for both Master and Detail objects by using singleton=false, they will have two difference Ado.NET's SqlTransaction for both Master and Detail. But if singleton=true, I think it might have concurrency problem, which share same connection/transaction for every client. (I might be wrong).

    Is injection not a good idea in this situation? all I can think now is to: change the calling from
    _detail.Save() to _detail.Save(_dbms) and inject singleton=false to only Master. don't know if this is a good idea, any hint?

  2. #2
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    New York, NY



    If your IDBMS implementation is using connection pooling then you certainly won't get the same connection for each usage if your implemenation is asking for a new connnection each time and not keeping a reference to the connection as a private data member. Generally speaking, if your dbms helper class is stateless and uses connections pools, then you shoul d be all right using it as singleton. This is the design behind the various database/orm template classes in spring. (both Java and .NET)

    Hope this helps. Sorry I didn't see your post till now. :oops:


Similar Threads

  1. Question on SqlConnections, DAOs and Spring
    By eboix in forum Architecture, Design and Best Practices
    Replies: 2
    Last Post: 05-10-2006, 02:24 PM
  2. A question about the Transaction attribute
    By dimitrod in forum Data Access
    Replies: 11
    Last Post: 03-23-2006, 10:05 PM
  3. potentially unrelated question about proxies
    By smhinsey in forum Remoting and Web Services
    Replies: 24
    Last Post: 01-16-2006, 05:59 PM
  4. First Time Remoting Question
    By telmore in forum Remoting and Web Services
    Replies: 3
    Last Post: 12-30-2005, 05:49 PM
  5. installer question
    By MNBob in forum Core Container
    Replies: 2
    Last Post: 09-27-2005, 03:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts