16 Dec 2002 03:15
Re: map with java.
David M. Lehrian <david <at> lehrian.com>
2002-12-16 02:15:48 GMT
2002-12-16 02:15:48 GMT
Hi Nic, I too have grappled with the best way to abstract an SQL data model. The mapping concept that you outline certainly looks workable, but it seems like a lot of code needs to be written for each table you want to map. i.e. create the interface, get the connection, formulate the query and code the mapper to handle the result set (doesn't solve the first problem you mention). I am guessing that the idea is to get data from the database into HTML as quickly as possible in a manner that doesn't cause a new object to be allocated for each row in the result set (solves the second problem you mention). It just doesn't seem to do that much for you. I prefer the Object-Relational mapping method whereby each row is turned into a real java object and handed back to the programmer as an ArrayList of objects. They can then be programmed to have many different output "views". And rather than hand code each individual persistent object, I prefer to store the mapping information in an XML file and use an abstract superclass to create the actual java objects and populate their data. I wrote such an O-R mapping layer and a graphical modeling tool that generates the necessary XML mapping files, the SQL to create the database and the persistent Java objects. It is available at http://www.redshift.com/~lehrian/DMLDataAccess. It implements to-one and to-many relationships and will sort them if set up to do so in the model. As it is written in a thread safe manner I have been able to use it for all my work including servlet/JSP development. If there were ever interest, I would opensource the code. I have an example of how it i s used in a servlet on the web site. Warm Regards, Dave _______________________________________________ David M. Lehrian Software Engineer http://www.easypetidtags.com/ http://www.redshift.com/~lehrian/DMLDataAccess http://www.redshift.com/~lehrian/JDBCQueryTool http://www.redshift.com/~lehrian(Continue reading)
RSS Feed