-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate Reengineering chapter2
PostPosted: Fri Dec 04, 2009 1:31 am 
Beginner
Beginner

Joined: Thu Nov 12, 2009 1:57 am
Posts: 22
Hi,
I am trying to run hibernate reengineering project. The helloworld.reveng.xml has the following code entry

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering
        SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">

<hibernate-reverse-engineering>

    <table-filter match-name=".*" package="hello"/>
    <table name="MESSAGES" schema="PUBLIC" class="Message">

        <primary-key>
            <generator class="increment"/>
            <key-column name="MESSAGE_ID" property="id" type="long"/>
        </primary-key>

        <column name="MESSAGE_TEXT" property="text"/>

        <!-- This _requires_ the foreign key constraint name in the database -->
        <foreign-key constraint-name="FK_NEXT_MESSAGE">
            <many-to-one property="nextMessage"/>
            <set exclude="true"/>
        </foreign-key>

    </table>

</hibernate-reverse-engineering>


and build.xml has following code

Code:
<project name="Hello World Reverse" default="clean" basedir=".">

    <!-- Name of project and version -->
    <property name="proj.name"      value="Hello World Reverse"/>
    <property name="proj.shortname" value="helloworld-reverse"/>
    <property name="version"        value="1.0"/>

    <!-- Global properties for this build -->
    <property name="database.dir"           value="database"/>
    <property name="src.java.dir"           value="src"/>
    <property name="lib.dir"                value="lib"/>

    <!-- Classpath declaration -->
    <path id="project.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
            <include name="**/*.zip"/>
        </fileset>
    </path>

    <!-- Useful shortcuts -->
    <patternset id="meta.files">
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
    </patternset>

    <!-- Clean up -->
    <target name="clean" description="Clean the source directory">
        <delete dir="${src.java.dir}"/>
        <mkdir dir="${src.java.dir}"/>
    </target>

    <!-- Start the HSQL DB browser tool -->
    <target name="dbmanager" description="Start HSQL DB manager">
        <java
            classname="org.hsqldb.util.DatabaseManagerSwing"
            fork="yes"
            classpathref="project.classpath"
            failonerror="true">
            <arg value="-url"/>
            <arg value="jdbc:hsqldb:hsql://localhost/"/>
            <arg value="-driver"/>
            <arg value="org.hsqldb.jdbcDriver"/>
        </java>
    </target>

    <!-- Enable the HibernateToolTask -->
    <taskdef name="hibernatetool"
             classname="org.hibernate.tool.ant.HibernateToolTask"
             classpathref="project.classpath"/>

    <!-- Generate XML metadata mappig files from database schema -->
    <target name="reveng.hbmxml"
            description="Read database, generate XML mapping files">

        <hibernatetool destdir="${src.java.dir}">
            <jdbcconfiguration
                propertyfile="${basedir}/helloworld.db.properties"
                revengfile="${basedir}/helloworld.reveng.xml"/>
            <hbm2hbmxml/>
            <hbm2cfgxml/>
        </hibernatetool>

    </target>

    <!-- Generate Java persistent classes from XML mapping files -->
    <target name="reveng.pojos"
            description="Read XML mapping files, generate POJOs">

        <hibernatetool destdir="${src.java.dir}">
            <configuration>
                <fileset dir="${src.java.dir}">
                    <include name="**/*.hbm.xml"/>
                </fileset>
            </configuration>
            <hbm2java/> <!-- Generate POJO source -->
        </hibernatetool>

    </target>

    <!-- Generate annotated Java entity beans from database schema -->
    <target name="reveng.entities"
            description="Read database, generate Java entity beans">

        <hibernatetool destdir="${src.java.dir}">
            <jdbcconfiguration
                propertyfile="${basedir}/helloworld.db.properties"
                revengfile="${basedir}/helloworld.reveng.xml"/>
            <hbm2java jdk5="true" ejb3="true"/>
            <hbm2cfgxml ejb3="true"/>
        </hibernatetool>

    </target>

</project>

When i run the reveng.hbmxml using ant build, all the tables in my schema are being read/displayed in console. Is there a way where i can specify that only message table be read and corresponding xml files are generated.

Thnx.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.