PDA

View Full Version : DAO or ORM or ?. objects <-> rdbms



darkadept
15th March 2007, 22:50
I'm designing a database app where I want clearly defined lines between my UI, Business Objects, and Data Access Layer. I've found a ton of Java material on the subject but almost no C++ material. And pretty near zero amount of Qt material on this. I'm creating a test program to flesh this idea out. The test program is a simple contact database with a single business object, the Contact object. I know DAO/ORM is overkill for this test program, but I'm doing this research for a much larger application.

I first stumbled upon the DAO (Data Access Objects) design pattern and that seems to fit the bill. I have a rough implementation of DAO already (complete with factories) but the problem exists where I have to change my DAO factory interfaces and add a new DAO object for each Business object I create. This seems like a lot of extra work (which is ok if it's the only way to go.... but I'm always on the lookout for a "Better Way[TM]")

I have discovered this website (http://www.javaworld.com/javaworld/jw-03-2002/jw-0301-dao.html) that explains how to make a generic DAO object (based on CRUD) so that when you implement a new database type (let's say CSV text files instead of sql) you only have to implement this generic DAO object. With Qt4 I would use the plugin architecture to provide generic libMysql.so, libCSV.so, ... plugins. This would be a beautiful solution in my eyes but that website is for Java and I have trouble making the leap to C++.

This approach sounds very much like the ORM (object relational mapping) model to me. So I started to research ORM. Of course a ton of Java information abounds focusing a lot on Java's Hibernate libraries.

Thinking ORM might be too much for me I tried messing around with C++ templating and generics. I managed to make a few changes to simplify the DAO layer but not a whole lot.

So my questions are which way should I go? Is there a decent/easy-to-use ORM library for C++ (or more specifically Qt4)? Is there a better way to do DAO? Is there another method altogether?

Remember I'm trying to stick to C++ and Qt4 and OpenSource if at all possible. It also has to be a cross-platform solution. Why is it the Java people have all the fun in this topic? :p

zeki709
18th March 2007, 05:06
I didn't heard any ORM solution for QT4.

patrik08
18th March 2007, 09:51
I'm designing a database app where I want clearly defined lines between my UI, Business Objects, and Data Access Layer.
So my questions are which way should I go? Is there a decent/easy-to-use ORM library for C++ (or more specifically Qt4)? Is there a better way to do DAO? Is there another method altogether?

Remember I'm trying to stick to C++ and Qt4 and OpenSource if at all possible. It also has to be a cross-platform solution. Why is it the Java people have all the fun in this topic? :p

If you want to write open SOURCE,
Why the complicated look, if it simply goes...

SOAP (Simple Object Access Protocol) , XML-RPC (remote procedure call), DAO (Data Access Objects) ,

http://en.wikipedia.org/wiki/SOAP
http://de.wikipedia.org/wiki/Data_Access_Object
http://en.wikipedia.org/wiki/XML-RPC

that are all method based data to get or store data or Object.


Today all Data can handle on XML ,
Formally defined languages based on XML (such as RSS, MathML, GraphML, XHTML, Scalable Vector Graphics, MusicXML and thousands of other examples)
& WDDX ( http://en.wikipedia.org/wiki/XML )
( http://en.wikipedia.org/wiki/WDDX exchange data ) and validate via
http://en.wikipedia.org/wiki/RELAX_NG if necessary, and Binary data to ...
or Extensible Stylesheet Language Transformations (XSLT) you can transform XML data to other
format , like PDF, OpenOffice, Latex, Excel, and so much other,
or directly write and read on the server via Webdav http://en.wikipedia.org/wiki/WebDAV
without to change the firewall setting and Secure Socket Layer are possible.

And we have Mysql ( mysql 5 Stored Procedure call ) or Object-Relational DBMS PostgreSQL
or direct Database xml like DB2 express from IMB ... that are all opensource....
And all known database can access on ODBC qt included.


Why the complicated look? :confused:

darkadept
19th March 2007, 22:06
I guess what I'm asking is is there an simpler/easier/better way to separate the business objects from the data access layer that is easier than DAO and not as complex as ORM?

SOAP (which seems to come from WDDX and XML-RPC) seems like a good way to talk between layers/processes/applications but it also seems really heavy for an in-house client/server database application.

As for the different kinds of databases, I can't assume that my client uses backend X, Y, or Z. Or even which platform that will be. Since my projects usually incorporate other data from different sources I don't want my UI and business objects knowing about which backend i'm using.

The more I research this and plot out different courses it seems that creating a DAO object for every business object is a good way to go. ORM would be nice but I don't have the time to code up my own Qt4 implementation.

benlau
7th October 2010, 01:55
It is a very late to reply , I hope you don't mind. I have made a Qt ORM library call DQuest released under New BSD open source license . I wish you like it.

http://code.google.com/p/d-quest/