A firstshot at subject is now in CVS of HibernateExt.
I've promised it for a looong time, so now it's time to
fullfill that promise (unfortunately I'm currently disappointed
about how hard it turned out to make a .vm behave just
as intelligent as the current renderer - thus the .vm file
are not at all complate)
But please try it out and report back with any problems ;)
The changes are:
* hbm2java now have an Velocity based renderer
* Renderer's can now be configured with <param> tags
* Refactored the "source model" hbm2java uses.
+ now all elements have access to their corresponding XML data. Can be used to access all the information that are not otherwise directly available.
The docs for velocity renderes are:
Velocity based renderer/generator
It is now possible to use velocity as an alternative rendering mechanism.
The follwing config.xml shows how to configure hbm2java to use its velocity renderer.
Code:
<codegen>
<generate renderer="net.sf.hibernate.tool.hbm2java.VelocityRenderer">
<param name="template">pojo.vm</param>
</generate>
</codegen>
The parameter named template is a resource path to the velocity macro file you want to use.
This file must be available via the classpath for hbm2java. Thus remember to add the directory where pojo.vm
is located to your ant task or shell script. (The default location is ./tools/src/velocity</literal>
Be aware that the current pojo.vm generates only the most basic parts of the java beans.
It is not as complete and feature rich as the default renderer - primarily a lot of the meta tags
are not supported.
Any improvements, comments, questions and contributions for improving the velocity based renderer.