The usual way to add javadoc to generated POJOs is to use meta tags, as in this example:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <class name="Person"> <meta attribute="class-description"> Javadoc for the Person class @author Frodo </meta> <id name="id" type="long"> <meta attribute="scope-set">protected</meta> <generator class="increment"/> </id> <property name="name" type="string"> <meta attribute="field-description">The name of the person</meta> </property> </class>
So, to get something similar, but including comments on your tables and columns, my understanding of Javadoc Comments in POJOs is that you have to change the templates used to generate hbm files.
To do this, check out the freemarker templates hibernate-tools.jar , hbm/persistentclass.hbm.ftl , hbm/property.hbm.ftl , etc. (this is not an exhaustive list) and modify them.
For example, in hbm/persistentclass.hbm.ftl instead:
<#if clazz.table.comment?exists && clazz.table.comment?trim?length!=0> <comment>${clazz.table.comment}</comment> </#if>
I assume you could do:
<#if clazz.table.comment?exists && clazz.table.comment?trim?length!=0> <meta attribute="class-description"> ${clazz.table.comment} </meta> <comment>${clazz.table.comment}</comment> </#if>
Etc.
source share