
Steve Hutton <shutton <at> featurecomplete.com> writes: [...]
Well, back to Jeff's point about how it would be nice if the specification of the column names in the query was somehow validated against the the column names in the o/r mapping at compile time, to find any disconnects.
It's an interesting idea (might require full SQL parser to achieve?)
The way we do it is as follows: The representations of both classes and tables are explicit in code, as is the description of how data members or accessors are associated to fields. The code that performs queries is thus generic. We separated the classes that are used for data exchange from the actual application logic, so that the data exchange classes may be automatically generated. The tools we use for database design & maintenance can output the db structure in SQL DDL, which we parse to generate the data exchange classes and those part of the data exchange infrastructure that depend on the db structure. This could obviously be done by connecting to the db and querying its structure, but SQL source files are more convenient to store and handle with a version control tool. As our schema includes in excess of 250 tables this results in tens of thousands of lines of code that are automatically maintained. This obviously doesn't handle the case of the schema being altered in between builds, but as we spell out in full the involved field names in all queries in general either this isn't a problem or causes an error in the application. Cheers, Nicola Musatti