Monday, November 07, 2005

O/R libraries

htomasso suggested in a comment to my last blog entry that I should take a look at NHibernate for my object/relational mapping needs. I remember learning about object oriented databases, but this seems solve the problem as well, i.e., persisting objects to a database (for retrieval).

My current problem is storing data from a hierarchal DTO model to a database. This data is used to calculate summary statistics, doing trend analysis, profiling, and debugging. But the DTOs are never actually retrieved back as DTOs from the database. So, although it looked promising initially (simplified the storing part), I think that O/R libraries are not suited for this scenario.

I did some web-research to find out what was being said as to when O/R libraries apply, but could not find any definite guidelines :(


htomasso said...

Could you please explain the DTO model part a bit. Are you talking about "Data Transfer Objects" pattern as used in remote calls, or does maybe your problem domain use this acronym for something else. Does one DTO thingy map to an entity/entry in your DB, or are the DTOs simply used for calculations and the outcome is stored in the DB? (I'm a bit confused sorry ;)

Ari said...

DTO is, as you say, data-transfer-object. We are, actually, using a whole inheritance-tree of DTOs.

I have a publish-subscribe application. One of the subscribers is a logger, i.e., it subscribes to all the DTOs being sent from the publisher and stores them to a database. This is not done for auditing, but rather to do post-processing on the data contained in the DTOs (statistical work mostly). The DTOs are never actually revived from the DB.

I think in this case it would not be useful to use NHibernate, or what do you think?

htomasso said...

If your DTOs map very easily/well to its database entity then you can use Hibernate for this case, even though you are not using it for "read". But if you are not thinking of using Hibernate for other objects, then it is probably a waste of time indroducing hibernate to the project. It's an art to select the right tool for the right job ;)