Hi,
For the first issue, I found away:
1) I changed the persistentclass.hbm.vm and add in "use-in-tostring" to it.
<meta attribute="use-in-tostring"> true </meta> you can add other code generator parameters here take a look at
http://www.hibernate.org/hib_docs/tools ... degen.html
2) I made ddl to java in a two phases task. First from ddl to hbmxml with jdbcconfiguration configuration, second from hbm to java with configuration. It is as below (hope other find it use full):
Code:
<project name="Hibernate-Tool" default="ddl2hbmxml">
<property name="sourcedir" value="${basedir}/src"/>
<property name="targetdir" value="${basedir}/bin"/>
<property name="librarydir" value="${basedir}/exploded/WEB-INF/lib"/>
<property name="docdir" value="${basedir}/doc"/>
<property name="sqlfile" value="${docdir}/dal/Schema.sql"/>
<property name="hibernate.cfg" value="${basedir}/src/Maps/hibernate.cfg.xml"/>
<property name="destdir" value="${basedir}/src"/>
<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>
</fileset>
<pathelement location="${sourcedir}"/>
<pathelement location="${sourcedir}/Maps/"/>
<pathelement location="${targetdir}"/>
</path>
<target name="ddl2hbmxml" description="db>>cfg">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="libraries"/>
<hibernatetool destdir="${destdir}">
<jdbcconfiguration
packagename="com.bonakdar.dal.entities"
configurationfile="${hibernate.cfg}"
/>
<hbm2hbmxml/>
<hbm2cfgxml destdir="${destdir}/Maps"/>
<!--<hbm2doc destdir="${docdir}/dal"/>-->
</hibernatetool>
</target>
<target name="hbm2java" description="cf>>java" depends="ddl2hbmxml">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="libraries"/>
<hibernatetool destdir="${destdir}">
<configuration
configurationfile="${hibernate.cfg}"
/>
<hbm2java jdk5="true"/>
<hbm2ddl destdir="${docdir}/dal" />
</hibernatetool>
</target>
</project>
Regards,
Alireza Fattahi