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.  [ 4 posts ] 
Author Message
 Post subject: Tools, hbm2hbmxml, reveng.xml, <table> element usage
PostPosted: Mon Sep 11, 2006 11:44 am 
Newbie

Joined: Mon Sep 11, 2006 11:13 am
Posts: 3
Location: Germany
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: Hibernate Tools 3.2.0.beta7

Mapping documents: Generated

Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs: N/A

Name and version of the database you are using: Oracle 9.2.0.7.0

The generated SQL (show_sql=true): N/A

Debug level Hibernate log excerpt: N/A


Problems with Session and transaction handling? N/A

Read this: http://hibernate.org/42.html


Hi,

Implementation Description: Using Hibernate Tools to generate *.hbm.xml files from Oracle database tables with ant task (not eclipse). Modules provided are ant build.xml, hibernate.cfg.xml, reveng.xml (please see below).

Problem Description: If the schema name is ommitted, the <table> declaration is ignored in the reveng.xml file, when generating *.hbm.xml files. The schema can be defined in the hibernate.cfg.xml (default_schema), or the reveng.xml <table> element (schema attribute). No warning or error is reported when the <table> element is not used. If the schema name is required, a warning message when the <table> element is encountered would be very helpful.

Related Information: Tools forum issue "Hibernate Reverse Engineering Tool ignores reveng.xml file" (rahulpilani, 24/04/06) reports that if the schema is defined as a default, and also in the <table> element, this also causes an issue.

best regards,
Aidan Russell

Munich, Germany

------------------------ hibernate.cfg.xml ---------------------------
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
       <property name="connection.url">jdbc:oracle:thin:@soriqsv10.qsu.fm.hypovereinsbank.de:1521:HVGDT2</property>
        <property name="connection.username">tugd002</property>
        <property name="connection.password">tugd002</property>
       
        <!-- <property name="default_schema">TUGD001</property> -->

        <!-- JDBC connection pool (use built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
       <property name="dialect">org.hibernate.dialect.OracleDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">false</property>

        <!-- Drop and re-create the database schema on startup -->
      <!-- <property name="hbm2ddl.auto">create</property> -->

    </session-factory>

</hibernate-configuration>



-------------------------------------- reveng.xml -------------------------------
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="T_INDEX_HEADER" exclude="false" package="com.ted.HBMTools1.db"/>

    <table name="T_INDEX_HEADER" schema="TUGD001">
       <primary-key>
          <key-column name="RIC" type="string"></key-column>
       </primary-key>
       <column name="ISIN" type="string"/>
       <column name="INDEXNAME" type="string"/>
       <column name="INDEXTYPE" type="string"/>
    </table>
   
</hibernate-reverse-engineering>



------------------------------------ ANT build.xml -----------------------------
Code:
<project name="HBMTools1" default="clean">

    <property file="build.properties"/>
    <property name="targetdir" value="${basedir}/generated"/>
    <property name="librarydir" value="${basedir}/lib"/>
    <property name="hbmtoolslibrarydir" value="${basedir}/../hbmtools_master_lib"/>

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

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

   <taskdef name="hibernatetool"
      classname="org.hibernate.tool.ant.HibernateToolTask"
      classpathref="libraries"/>

   <hibernatetool destdir="${targetdir}">
      <jdbcconfiguration
         packagename="com.ted.HBMTools1.db"
         revengfile="reveng.xml"
         configurationfile="hibernate.cfg.xml"/>
      <hbm2hbmxml/>
   </hibernatetool>

    <target name="hibernatetool">
    </target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 11, 2006 2:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so your question is just to get a warning if a table is not matched ever when reverse engineered ?

note, I can't throw an error automatically since in some cases (E.g. if you use the same reveng.xml for different db's) a non-match is expected.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 2:08 am 
Newbie

Joined: Mon Sep 11, 2006 11:13 am
Posts: 3
Location: Germany
Hi,

Maybe a documentation enhancement would suffice to indicate that the schema is required to match the <table> element (either as a default or in the <table> declaration).

Since the <table-filter> does match, even when the <table> does not match, it's a bit confusing. The schema attribute is optional, but seems to be mandatory to obtain a match (if not configured as a default).

- Aidan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 2:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
russeaid wrote:
Maybe a documentation enhancement would suffice to indicate that the schema is required to match the <table> element (either as a default or in the <table> declaration).


I've added: "Has to be specified if you are reverse engineering multiple schemas or if it is not equal to hiberante.default_schema" to the docs.

Quote:
Since the <table-filter> does match, even when the <table> does not match, it's a bit confusing. The schema attribute is optional, but seems to be mandatory to obtain a match (if not configured as a default).


For me this makes perfect sense ;)

The table-filter matches because a *match* is performed and the default match-schema is .* (e.g. all schemas)

The table is not used because well, the schema's are *not* the same. e.g. you can have multiple schemas with the same table name.

in any case, i know people don't think about the fact that they are pointing to a multi schema'ed database so i am trying to make the defaults behavior more "narrow"/"intelligent" so if you only find tables from one schema then that one schema is the default.

_________________
Max
Don't forget to rate


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

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.