I've tried to generate Hibernate mapping from a pojo class, and everything runs 
without a problem, but the hbm.xml is not generated.

Here is my Pojo class:


package com.sicflex.data;
import com.sicflex.hbm.util.HbmBase;
import java.util.Set;

/**
 * This class provides the means to create the menu template for the system.<br>
 * Each menu options will have a unique menu identification, 
 * that could be referenced later by the user profile. 
 * Options to be complete must have a valid url.
 * @author Sicflex
 * @since version 1.0
 * @hibernate.class
 *  tables="menu"
 *  dynamic-update="true"
 */
public class Menu extends HbmBase
{
  private String menuId;

  private String displayNameKey;

  private String menuType;

  private String url;

  /**
   * @return object of type String; which is a unique identifier for the menu
   * option.
   * @hibernate.id 
   *  generator-class="native"
   */
  public String getMenuId()
  {
    return menuId;
  }

  /**
   * @param menuId of type String, set a unique identifier for any menu option.
   * once set it can not be changed.
   */
  public void setMenuId(String menuId)
  {
    this.menuId = menuId;
  }


  /**
   * @param displayNameKey of type String, refers to the resources key to be 
used 
   * for display purposes. This property exists in almost every class that its
   * name could be shown to users. Using this property guarantees reliable 
localization 
   * behavior.
   */
  public void setDisplayNameKey(String displayNameKey)
  {
    this.displayNameKey = displayNameKey;
  }


  /**
   * @return object of type String, referring to the resource key used by the 
object.
   * @hibernate.property
   *  not-null="true"
   */
  public String getDisplayNameKey()
  {
    return displayNameKey;
  }


  /**
   * @param menuType should be one of constant MenuType.
   */
  public void setMenuType(String menuType)
  {
    this.menuType = menuType;
  }


  /**
   * @return String object containing a MenuType constant.
   */
  public String getMenuType()
  {
    return menuType;
  }


  /**
   * @param url points to the link to redirect to.
   */
  public void setUrl(String url)
  {
    this.url = url;
  }


  /**
   * @return a Url string.
   */
  public String getUrl()
  {
    return url;
  }

}

And a portion of Ant's build file

  <!-- XDOCLET -->
  <!-- Properties -->
  <property name="xdoclet.home" value="c:/xdoclet-1.2.2"/>
  <property name="hibernate.generated.home" 
value="c:/WebSicflex/ViewController/src/com/sicflex/hbm/util"/>
  <property name="data.home" 
value="c:/WebSicflex/ViewController/src/com/sicflex/data"/>
  <!-- Library -->
  <path id="library.XDocLet.Library">
    <fileset dir="${xdoclet.home}/lib">
      <include name="**/*.jar"/>
    </fileset>
  </path>
  <!--- Task definition -->  
  <taskdef name="hibernatexdoclet"
           classname="xdoclet.modules.hibernate.HibernateDocletTask">
        <classpath refid="library.XDocLet.Library"/>
  </taskdef>

  <!--- Target definition -->  
  <target name="generate.hibernate" depends="compile" description="Generate HBM 
files" >
    <echo>Running Hibernate XDocLet </echo>
    <echo message="Destination= ${hibernate.generated.home}"/>
    <echo message="DataDir= ${data.home}"/>
    <hibernatexdoclet
        destdir="${hibernate.generated.home}"
        excludedtags="@version,@author,@todo,@see"
        addedtags="@xdoclet-generated at ${TODAY},@copyright Sicflex,@version 
${version}"
        force="true"
        verbose="false" >
    
        <fileset dir="${data.home}">
            <include name="**/*.java" />
        </fileset>
        <hibernate version="2.1"/>
    </hibernatexdoclet>

    <!-- Upgrade grammar from Hibernate1 to Hibernate2 -->
    <replace dir="${hibernate.generated.home}">
        <include name="**/hibernate/*.hbm.xml"/>
        <replacefilter token="readonly=" value="inverse="/>
        <replacefilter token="role=" value="name="/>
        <replacefilter token="hibernate-mapping.dtd" 
value="hibernate-mapping-2.0.dtd"/>
    </replace>  
  </target>


And finally the results of running generate.hibernate task

Buildfile: C:\WebSicflex\ViewController\build.xml


init:


compile:


generate.hibernate:
     [echo] Running Hibernate XDocLet 
     [echo] Destination= c:/WebSicflex/ViewController/src/com/sicflex/hbm/util
     [echo] DataDir= c:/WebSicflex/ViewController/src/com/sicflex/data
[hibernatexdoclet] (XDocletMain.start                   47  ) Running 
<hibernate/>


BUILD SUCCESSFUL

Total time: 2 seconds


 

Reply via email to