Also, don't get stuck in the hole that 1 DB table = 1
Service/Gateway/DAO objects.  You may have flattened your service layers
out a bit too much.  It can be done if you always map a DB table to a
service object, DAO and bean for *each* DB table.  I wouldn't use your
DB model as guide here. For example, an Order have an "array" of order
statuses (i.e. placed, processing, ready to ship, shipped, arrived).  It
doesn't make sense to create an OrderStatusService or OrderStatusDAO
because an order status cannot exist independently of an Order.
 Therefore if you went that route -- you've flattened out your model
with "extra" un-needed layers.  Just combine the OrderStatus stuff as
part of the OrderService.

Personally, I've flattened things out too much in the past and it just
causes some headaches -- combining things down into logicial service
objects which may interact a few inter-related tables in the datastore
is more sensible.  So a service may manipulate several inter-related
beans (like my OrderStatus and Order example).  There is no need to have
a 1 to 1 translation -- 1 bean != need for a service layer for that bean
-- a lot of times another service layer is highly related to it.

What exactly are the relationships of tables A, B and C?  If you share
their purpose, we might be able to discuss this in a better context than
the A/B/C abstraction.

Best,
.Peter

Kurt Wiersma said the following on 03/22/2011 04:34 PM:
> Two ideas come to mind.
>
> 1. Use a transaction in service A to save object A for table A and
> then call serviceB.saveB(b) inside that transaction.
>
> 2. Use ColdSpring's AOP to start a transaction when are you saving the
> object for table A. This is the more complicated to setup option but
> the most transparent in the code. If are not familiar with AOP then I
> wouldn't recommend this method.
>
> --Kurt
>
> On Tue, Mar 22, 2011 at 3:31 PM, Brian <[email protected]> wrote:
>> I am in the process of incorporating coldspring into a web
>> application. My question is this, I have three tables call them table
>> A,B, and C. Table A is dependent on B and table B is dependent on C.
>> This means on an insert to table A  I would have to create a record in
>> table C, get that ID, create the record in table B, get the ID and
>> finally create the record in table A. If each table is being
>> represented as a Service bean in my coldspring.xml is there some way
>> to define this table/bean dependency in coldspring or is it easier to
>> handle this as separate calls to listener methods in the machII.xml.
>>
>> --
>> To post to this group, send email to [email protected]
>> For more options and to unsubscribe, visit this group at 
>> http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
>>
>> SVN: http://svn.mach-ii.com/machii/
>> Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/
>>

-- 
To post to this group, send email to [email protected]
For more options and to unsubscribe, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en

SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/

Reply via email to