I sent an email to the project a couple weeks ago, but I haven't heard anything back. Anyhow, I've recently begun working on modifying SQL2Java for my company's internal use. For what I needed to do, I ended up having to drastically modify the CodeWriter class. At this point I've basically supplanted CodeWriter and it's inheritance breaking most sub-classes. What I've added,however, is Velocity (jakarta.apache.org) template based code generation. I've also generalized most of the functionallity of CodeWriter,so via a configuration file, the class can spit out any number of template-based classes per table. (all the sql helper classes remain unmodified, however) So, basically, my version replicates the current functionality [diff identical output] _without_ subclassing CodeWriter. Pretty much all code generation can be done by modifying the templates and/or using different templates; this makes SQL2Java viable as a stand alone precompiled tool that is vastly more flexible. Since the templates can be edited easily, adding custom code to the generator is cake as well. Templates also look much closer to standard java than the CodeWriter subclasses' writeXXXX() methods. At some point I'd like to submit my code back to the project, though as it is not compatible with the available subclasses it'd probably have to be a major branch.
The project seems kind of sleepy. I hope somebody gets back to me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, lets get this in. I am interested in fixing some of the generated code, and this will make that sooo much more maintainable.
The issue I've run into it sql2java's support for complex keys -- it works for primary keys, but doesnt seem to work for so well for the ManyToMany routines. for instance:
I sent an email to the project a couple weeks ago, but I haven't heard anything back. Anyhow, I've recently begun working on modifying SQL2Java for my company's internal use. For what I needed to do, I ended up having to drastically modify the CodeWriter class. At this point I've basically supplanted CodeWriter and it's inheritance breaking most sub-classes. What I've added,however, is Velocity (jakarta.apache.org) template based code generation. I've also generalized most of the functionallity of CodeWriter,so via a configuration file, the class can spit out any number of template-based classes per table. (all the sql helper classes remain unmodified, however) So, basically, my version replicates the current functionality [diff identical output] _without_ subclassing CodeWriter. Pretty much all code generation can be done by modifying the templates and/or using different templates; this makes SQL2Java viable as a stand alone precompiled tool that is vastly more flexible. Since the templates can be edited easily, adding custom code to the generator is cake as well. Templates also look much closer to standard java than the CodeWriter subclasses' writeXXXX() methods. At some point I'd like to submit my code back to the project, though as it is not compatible with the available subclasses it'd probably have to be a major branch.
The project seems kind of sleepy. I hope somebody gets back to me.
Hello,
What you describe seems great. We are very interested in your contribution. And yes you could commit in a dedicated branch...
The projet is not so sleepy thanks to person like you ;-)
regards,
Nicolas.
Yes, lets get this in. I am interested in fixing some of the generated code, and this will make that sooo much more maintainable.
The issue I've run into it sql2java's support for complex keys -- it works for primary keys, but doesnt seem to work for so well for the ManyToMany routines. for instance:
TableA ( id1, id2, otherfileds ) primary key ( id1, id2 )
TableB( id1, id3, otherfields ) primary key ( id1, id3 )
TableATableB( id1, id2, id3 ) primary key ( id1, id2, id3 ),
foreign key ( id1, id2 ) references TableA( id1, id2 ),
foreign key ( id1, id3 ) references TableB( id1, id3 ).
The generated code for TableaManager get a method called loadTablebViaTableatableb () which jons TableATableB to TableB only by id3