RE: Updating DB with large collections

From: gwenda (gwenda_at_discussions.microsoft.com)
Date: 10/13/04


Date: Wed, 13 Oct 2004 16:03:03 -0700

Hi Sam,

Thanks for your answer. There are few points I would like to point out
regarding your answer:

Generally, I intend to update all the properties of any object. However, I
don’t want to update (if I don’t have to) two types of properties:

Collections –usually contains other objects. I would like to
insert/update/delete only the objects in the collection that were modified by
the client. Some of my objects contain rather large collections and some may
contain more than one property which is a collection.

Large sub-objects – that is an object which is contained in the main object
and is large enough to reconsider updating it for no reason.

Performance is indeed a consideration but another motive was the DB
concurrency. Naturally those sub-objects and collections usually reside in
other tables in the DB and may have been modified but other users. Although I
have a mechanism to prevent it, I’ve learned that those big updates which
wipe everything an re-insert new date usually turn to be messy.

Although the “dirty” flag is a possibility, it is a “dirty” one… :-) And in
case of external systems/other UI that will update my system, I will have to
make sure that the flags were used.
 
I was thinking about having my business component in the middle tier
comparing the cached object with the modified object. According to the
comparison results the relevant main-object and/or sub-objects and/or
collections objects will be sent to the data layer components. The
collections can be serialized to XML strings and sent to the DB as such. But
this seems like a complex solution to what I imagined should be quite common
problem and I kind of hoped for a “by-the-book” solution.

Thanks Again,

Gwenda

 

"gwenda" wrote:

> Hi,
> My application is composed of business entities which are in the form of
> classes instances. Some of these entities contains large arraylists of other
> entities. These entities are being sent to the client - where the user might
> add/modify/delete some items in the arraylists. Natuaraly, I don't want to
> send to the DB the part of the entities which the user hadn't changed.
> I'm keeping a copy of the original entity in my middle tier so when the
> modified entity is returned from the client I can check what was changed and
> according to this decide what to send to my data layer.
> The question is what would be the best method to do the comparison?
> I was advised to use dataset. I've tried to serialize my arraylists - both
> of the original object and the modified one - into datasets and use the merge
> method. But I couldn't get it to work (note that the client is not getting a
> dataset but rather a class instance). Is there a way to make it work
> following the above scenario? If there isn't what would be the most
> appropriate way to perform that kind of operation?
> Thanks,
> Gwenda



Relevant Pages

  • Re: Opinions on the Law Of Demeter
    ... > implementation of rectangle is sensible or not, ... > rectangle has no way of knowing what's going on....how does the client ... rectangle would have to modify its 'bottom' to some number greater than ... arbitrary changes to those sub-objects. ...
    (comp.object)
  • Re: Serialization, RMI and deep copy
    ... However you don't have to *explicitly* serialize anything at all, RMI ... > vs what the store now contains). ... > a client of the store and can insert configuration changes. ...
    (comp.lang.java.programmer)
  • Re: Serializing XmlDocument to SerializationInfo
    ... Are you worried about the size of data being transmitted to/from a remoting client? ... If you are using binary serialization over Tcp that will help to decrease the size of messages transmitted to/from a remoting ... Just add the stream reference to the SerializationInfo with a custom key like, ... and serialize a path string. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: problem in InvalidCastException-Return argument has an invalid type
    ... DataSet is always serialized to XML. ... DataSet is not shared between the client and server. ... always serialized to XML, so you can just use WriteXml to serialize it ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: problems returning ArrayList from webServices
    ... - Collections are always serialized as simple arrays. ... If you want to serialize as a specific collection class rather than just an ... On the client side, ... > instead of return an ArrayList object, ...
    (microsoft.public.dotnet.framework.aspnet.webservices)