473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

OO Programming and Relational Databases - please help!

Hi,

I have a couple of classes:

Customer, Contact, ContactList, Agency, HostingCustomer and
OtherCustomer.

The Customer class is a base class and contains all the common
properties and methods associated with the customer including methods
such as Add, Delete and Get.

The Agency, HostingCustomer and OtherCustomer classes inherit from the
Customer Class and provide additional properties and methods specific to
those types of customers. They also override the Add, Delete and Get
methods of Customer in which they call the base methods first and then
perform additional tasks.

The ContactList class implements (amongst other things) ICollection to
act as an ArrayList of Contact objects and like the Customer class, the
Contact class contains methods such as Add, Update and get etc. There is
a property of type ContactList in the customer class to hold a
collection of contacts for the customer.

Using this model, I am able to itterate through the ContactList in the
Customer class and call the Add method of each Contact contained within
the list by means of Polymorphism - which I like.

My problem occurs when I want to use transactions with the data. For
example, I don't want to add a new customer to the database if there was
a problem with one of the contacts - I'd like to roll back the
transaction. My question is how would I manage transactions in this sort
of model/environment ?

Any help or advice would be welcomed.

Thanks,
Rob


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
3 1422
Rob,

In this situation, you would have your objects listed as requiring a
transaction. This way, if a transaction doesn't exist, it would create a
new one. If it was already in the context of another transaction, then it
would join that context and be able to vote on its outcome.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Rob Thomas" <ro*@rtcomputersystems.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a couple of classes:

Customer, Contact, ContactList, Agency, HostingCustomer and
OtherCustomer.

The Customer class is a base class and contains all the common
properties and methods associated with the customer including methods
such as Add, Delete and Get.

The Agency, HostingCustomer and OtherCustomer classes inherit from the
Customer Class and provide additional properties and methods specific to
those types of customers. They also override the Add, Delete and Get
methods of Customer in which they call the base methods first and then
perform additional tasks.

The ContactList class implements (amongst other things) ICollection to
act as an ArrayList of Contact objects and like the Customer class, the
Contact class contains methods such as Add, Update and get etc. There is
a property of type ContactList in the customer class to hold a
collection of contacts for the customer.

Using this model, I am able to itterate through the ContactList in the
Customer class and call the Add method of each Contact contained within
the list by means of Polymorphism - which I like.

My problem occurs when I want to use transactions with the data. For
example, I don't want to add a new customer to the database if there was
a problem with one of the contacts - I'd like to roll back the
transaction. My question is how would I manage transactions in this sort
of model/environment ?

Any help or advice would be welcomed.

Thanks,
Rob


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2
Rob,

In this situation, you would have your objects listed as requiring a
transaction. This way, if a transaction doesn't exist, it would create a
new one. If it was already in the context of another transaction, then it
would join that context and be able to vote on its outcome.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Rob Thomas" <ro*@rtcomputersystems.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a couple of classes:

Customer, Contact, ContactList, Agency, HostingCustomer and
OtherCustomer.

The Customer class is a base class and contains all the common
properties and methods associated with the customer including methods
such as Add, Delete and Get.

The Agency, HostingCustomer and OtherCustomer classes inherit from the
Customer Class and provide additional properties and methods specific to
those types of customers. They also override the Add, Delete and Get
methods of Customer in which they call the base methods first and then
perform additional tasks.

The ContactList class implements (amongst other things) ICollection to
act as an ArrayList of Contact objects and like the Customer class, the
Contact class contains methods such as Add, Update and get etc. There is
a property of type ContactList in the customer class to hold a
collection of contacts for the customer.

Using this model, I am able to itterate through the ContactList in the
Customer class and call the Add method of each Contact contained within
the list by means of Polymorphism - which I like.

My problem occurs when I want to use transactions with the data. For
example, I don't want to add a new customer to the database if there was
a problem with one of the contacts - I'd like to roll back the
transaction. My question is how would I manage transactions in this sort
of model/environment ?

Any help or advice would be welcomed.

Thanks,
Rob


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #3
Did you ever ytry looking ant O/R mappers?

They allow you to write code in EAXACTLY this fashion and handle al the
nifty details for you - reducing your coding efforts by about 40% for these
classes.

AND they handle all this stuff like transactions :-)

There are a couple of them - like the EntityBroker :-)
(http://www.thona-consulting.com/, under Products)

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)

"Rob Thomas" <ro*@rtcomputersystems.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a couple of classes:

Customer, Contact, ContactList, Agency, HostingCustomer and
OtherCustomer.

The Customer class is a base class and contains all the common
properties and methods associated with the customer including methods
such as Add, Delete and Get.

The Agency, HostingCustomer and OtherCustomer classes inherit from the
Customer Class and provide additional properties and methods specific to
those types of customers. They also override the Add, Delete and Get
methods of Customer in which they call the base methods first and then
perform additional tasks.

The ContactList class implements (amongst other things) ICollection to
act as an ArrayList of Contact objects and like the Customer class, the
Contact class contains methods such as Add, Update and get etc. There is
a property of type ContactList in the customer class to hold a
collection of contacts for the customer.

Using this model, I am able to itterate through the ContactList in the
Customer class and call the Add method of each Contact contained within
the list by means of Polymorphism - which I like.

My problem occurs when I want to use transactions with the data. For
example, I don't want to add a new customer to the database if there was
a problem with one of the contacts - I'd like to roll back the
transaction. My question is how would I manage transactions in this sort
of model/environment ?

Any help or advice would be welcomed.

Thanks,
Rob


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Hobbs | last post by:
Yeah, yeah, another X-Oriented paradigm, but please hear me out. I have recently been studying up on EJB's in order to extend my resume. I have looked at J2EE several times over the past years,...
24
by: Kanthi Kiran Narisetti | last post by:
Hi All, I am Windows Systems Administrator(planning to migrate to Linux administration in near future), I have occassionally written few batch files and Vbscripts to automate my tasks. Now I...
34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
5
by: Markus Seibold | last post by:
Dear NG, I am working on a student project about a mobile tourism information system and among others I have to answer the question whether to use: - a relational database - a XML-native database...
49
by: Mike MacSween | last post by:
I frequently hear that there isn't a commercially available dbms that fully implements the relational model. Why not? And which product comes closest. Mike MacSween
0
by: Rob Thomas | last post by:
Hi, I have a couple of classes: Customer, Contact, ContactList, Agency, HostingCustomer and OtherCustomer. The Customer class is a base class and contains all the common properties and...
6
by: Shwetabh | last post by:
Hi, I have a very simple question. In what cases are relational databases necessary? Are they really necessary in cases where only a single type of query is to be performed based on one unique...
6
by: lennon1 | last post by:
Hi, I have already started learning .NET and I have a question. If I want to do anything - Display Data, Navigate, Update - with database (SQL Server) in Visual Studio 2005, do I have to use all...
16
by: Malcolm McLean | last post by:
I want this to be a serious, fruitful thread. Sabateurs will be plonked. Table-based programming is a new paradigm, similar to object-orientation, procedural decomposition, or functional...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.