Best Practices question
Best Practices question
- Subject: Best Practices question
- From: Jerald Dawson <email@hidden>
- Date: Wed, 25 Nov 2009 11:52:40 -0600
Hi All
I have a question about best practices for database access from a wo app. I will attempt to explain my situation and hopefully someone will give me some pointers (fingers crossed).
I have an application that listens to our trading server for trade notifications. It then writes those trades into a database. The way I'm handling it right now is my TradeController class keeps an array list of all the trades. My Application instance has the singleton instance of TradeController. I have it belong to the Application instance because it defines a connection to the trade server and I only want one of those, not one for every session. I also need to be getting trade notifications even when no sessions are present. When someone wants to put the trades into the database, they connect to the application and go to the Trades page. This page has a list of all non-processed trades from the TradeController object. The user then initiates a process which results in all trades from TradeController being written into the database.
What I would like to do is for the TradeController to have its own path into the database. That way, as trades come in, the TradeController could just write them directly into the database without user intervention. The problem is that the database connections are handled by session() by default. I would like to just have the TradeController instance create its own editingContext to the database and use it to write the trades into the database. The users could then log in and just query the database for position and P&L info without manually importing the trades.
I'm a bit nervous about having something outside of a session do database access, mainly because I've never done it before. I wanted to find out if its ok to do it before I went down that path. I don't want to spend time writing it only to find out there are show stopping bugs (or design decisions).
Hopefully I've made myself clear. Any wisdom from the list is appreciated.
-j _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden