Generate Hibernate Config File: Set Your Own Driver Class : Config Generation « Hibernate « Java






Generate Hibernate Config File: Set Your Own Driver Class

/////////////////////////////////////////////////////////////////////////

<project name="hibernate-tutorial" default="compile">

    <property name="sourcedir" value="${basedir}/src"/>
    <property name="targetdir" value="${basedir}/build"/>
    <property name="librarydir" value="${basedir}/lib"/>

    <path id="libraries">
        <fileset dir="${librarydir}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="clean">
        <delete dir="${targetdir}"/>
        <mkdir dir="${targetdir}"/>
    </target>

    <target name="compile" depends="clean, copy-resources">
      <javac srcdir="${sourcedir}"
             destdir="${targetdir}"
             classpathref="libraries"
             debug="on"/>
    </target>

    <target name="copy-resources">
        <copy todir="${targetdir}">
            <fileset dir="${sourcedir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="driver">
        <property name="hibernate.connection.driver_class" value="yourDriverClass"/>
        <antcall target="hbm"/>
    </target>


    <target name="hbm" depends="compile">
        <taskdef
            name="hibernatedoclet"
            classname="xdoclet.modules.hibernate.HibernateDocletTask"
            classpathref="libraries"
            />
        <hibernatedoclet
            destdir="${targetdir}"
            verbose="true">
            <fileset dir="${sourcedir}">
                <include name="**/*.java"/>
            </fileset>
            <hibernate version="3.0"/>
            <hibernatecfg
                dialect="${hibernate.dialect}"
                jdbcUrl="${hibernate.connection.url}"
                driver="${hibernate.connection.driver_class}"
                userName="${hibernate.connection.username}"
                password="${hibernate.connection.password}"
                showSql="false"
                version="3.0"
                />
        </hibernatedoclet>
    </target>

</project>


           
       








HibernateGenerateHibernateConfigFileSetYourOwnDriverClass.zip( 5,039 k)

Related examples in the same category

1.Generate Mapping File And Hibernate Config File Automatically
2.Generate Hibernate Config File: Set Dialect In Ant
3.Generate Hibernate Config File: Set URL in ANT
4.Generate Hibernate Config File: Set User Name And Password
5.Generate Hibernate Mapping File: Set Generator Class In Ant