473,382 Members | 1,353 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,382 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 1421
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.