Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:21:48+00:00 2026-05-14T03:21:48+00:00

My current setup using hibernate uses the hibernate.reveng.xml file to generate the various hbm.xml

  • 0

My current setup using hibernate uses the hibernate.reveng.xml file to generate the various hbm.xml files. Which are then turned into POJOs using hbm2java. We spent some time while designing our schema, to place some pretty decent descriptions on the Tables and there columns. I am able to pull these descriptions into the hbm.xml files when generating them using hbm2jhbmxml.

So I get something similar to this:

<class name="test.Person" table="PERSONS">
  <comment>The comment about the PERSONS table.</comment>
  <property name="firstName" type="string">
      <column name="FIRST_NAME" length="100" not-null="true">
          <comment>The first name of this person.</comment>
      </column>
  </property>
  <property name="middleInitial" type="string">
      <column name="MIDDLE_INITIAL" length="1">
          <comment>The middle initial of this person.</comment>
      </column>
  </property>
  <property name="lastName" type="string">
      <column name="LAST_NAME" length="100">
          <comment>The last name of this person.</comment>
      </column>
  </property>
</class>

So how do I tell hbm2java to pull and place these comments in the created Java files?

I have read over this about editing the freemarker templates to change the way code is generated. I under stand the concept, but it was not to detailed about what else you could do with it beyond there example of pre and post conditions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:21:48+00:00Added an answer on May 14, 2026 at 3:21 am

    The usual way to add javadoc in generated POJOs is to use meta tags, like in this sample:

    <!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 the comments of your tables and columns, my understanding of the Javadoc Comments in POJOs thread is that you’d have to modify the templates used to generate hbm files.

    To do so, look at the freemarker templates of 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 of:

    <#if clazz.table.comment?exists  && clazz.table.comment?trim?length!=0>
     <comment>${clazz.table.comment}</comment>
    </#if>
    

    I guess that 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>
    

    And so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so this is my current setup for a makefile. There are files which
I've recently started using prettyphoto to display a video. This is my current setup
The Current Setup: So, I can use the following code to save a file
I need a method of stopping concurrent logins using PHP/MySQL. The current setup Currently
I started using JRebel just moment ago. In my current setup launch JBoss instance
I'm using Eclipse and Maven. My current setup is - client (separate Eclipse and
My current setup consists of: a parentPom in a plugin a customPlugin version 2.0
My current setup : I have an entity object with some properties, among them
Here is my current setup. I have two pages running on the jquery mobile
In my current setup, I have a typedef std::function<void (MyClass&, std::vector<std::string>) MyFunction; std::map<std::string, MyFunction>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.