Bug #1307 export field and table names into xml or MySQLConstants.java
Submitted: 16 Sep 2003 13:00 Modified: 11 Nov 2009 2:34
Reporter: Ralf Hauser Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / J Severity:S4 (Feature request)
Version:any OS:Any (any)
Assigned to: CPU Architecture:Any

[16 Sep 2003 13:00] Ralf Hauser
Description:
The field and table names (or typos therewith) are a frequent source of errors when using connector/j:

First, the need to be correct in the prepared-statements and then, when getting values out of the Resultset into the business (or e.g. Struts ActionForm) Objects, all needs to be in sink again.
Unfortunately, this is a lot of typing and IDEs/compilers appear to have a hard time to help ==> often an error only gets noticed at run-time, i.e. after compilation, deployment (e.g. of a web application) and then possibly only in the course of a lengthy test.

Therefore, it would be great to have a scriptable mechanism (that can be triggered for example out of ant's build.xml) that produces a set of string constants to be used when creating queries. This way,
- the compiler will catch quite some typos
- maintainability is largely increased when a field name needs to be changed/dropped for whatever reason.

Therefore my suggestion:
Document in http://www.mysql.com/documentation/connector-j/index.html how one can generate a structured (xml or java directly) field and table list:
- are there tools working on the basis of the mysql-client or server
- are there parsers of loadDbScheme.sql files (since I use a tool to generate this [ChilliSource DDS-Lite], I guess this tool is the ultimate origin of the field names to take)?
- ...

P.S.: I am using xml files and the http://sourceforge.net/projects/fmpp pre-processsor to create similar constant files to keep the string-variables used in the various parts of the struts MVC in synch - i.e. the variables used in the view (jsp files, content.properties) as well as in the controller (Struts*Actions.java) are both generated from one single source.

How to repeat:
all the time

Suggested fix:
having such a tool would make implementation much more efficient, i.e. a lot less error searching
[13 Jan 2004 23:13] Ralf Hauser
as soon as mysqldumpfields is fixed as per http://bugs.mysql.com/bug.php?id=1530, I am confident, I will easily be able to do this together with sf.net/projects/fmpp.

in analogy - to extract field/variable names out of struts business objects, I was successful using objectweb's asm as per http://sourceforge.net/mailarchive/message.php?msg_id=6152001
[25 Jan 2004 1:06] Ralf Hauser
see also http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26411 for alignment with the struts validator