-->
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.  [ 2 posts ] 
Author Message
 Post subject: Reverse Eng from Oracle database
PostPosted: Fri Mar 14, 2008 10:01 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.5

Ant script:

Code:
<?xml version="1.0" encoding="utf-8"?>

<!--
  Generic Ant to generete hbm and pojo EasyWeb compliants
-->
<project name="Reverse Engineering" default="compile" basedir=".">

    <!-- Name of project and version -->
    <property name="proj.name"      value="Nebogiazione del budget"/>
    <property name="proj.shortname" value="ob"/>
    <property name="version"        value="1.0"/>

    <!-- Global properties for this build -->
    <property name="src.dir"   value="src"/>
    <property name="dest.dir"       value="generated" />
   <property name="dest.dir.xml"   value="${dest.dir}/xml" />
    <property name="lib.dir"        value="C:/Programmi/eclipse/plugins/org.hibernate.eclipse_3.2.0.GA/lib"/>
   <property name="jdbc.jar"       value="D:/Sviluppo/Driver/ojdbc14.jar" />
   <property name="package"        value="it.infracom.${proj.shortname}.persistent" />

    <!-- Classpath declaration -->
   <path id="library.classpath">
      <path location="${jdbc.jar}"/>
      <path location="${lib.dir}/tools/hibernate-tools.jar"/>
      <path location="${lib.dir}/hibernate/hibernate3.jar"/>
      <path location="${lib.dir}/tools/freemarker.jar"/>
          <fileset dir="${lib.dir}/hibernate">
            <include name="**/*.jar"/>
          </fileset>
   </path>       

    <!-- Enable the HibernateToolTask -->
    <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="library.classpath"/>
   <taskdef name="javaformatter" classname="org.hibernate.tool.ant.JavaFormatterTask" classpathref="library.classpath"/>
   
    <!-- Clean up -->
    <target name="clean" description="Clean the source directory">
        <delete dir="${dest.dir}"/>
        <mkdir dir="${dest.dir}"/>
    </target>

    <!-- Generate XML metadata mappig files from database schema -->
    <target name="reveng.hbmxml"  description="Read database, generate XML mapping files">
        <hibernatetool destdir="${dest.dir}">
            <jdbcconfiguration
               configurationfile="${src.dir}/hibernate.cfg.xml"
                revengfile="hibernate.reveng.xml"
               packagename="${package}"
            />
            <hbm2hbmxml destdir="${dest.dir.xml}"/>
              <!-- Generate cfg file -->
              <hbm2cfgxml/>
        </hibernatetool>
    </target>

    <!-- Generate Java persistent classes from XML mapping files -->
    <target name="reveng.pojos" description="Read XML mapping files, generate POJOs">
        <hibernatetool destdir="${dest.dir}">
            <configuration>
                <fileset dir="${dest.dir}">
                    <include name="**/*.hbm.xml"/>
                </fileset>
            </configuration>
           <!-- Generate POJO source -->
            <hbm2java jdk5="true"/> 
        </hibernatetool>
    </target>
   
   <!-- Format by eclipse settings -->
   <javaformatter configurationfile="optional-eclipse-formatting-settings">
       <fileset dir="${dest.dir}">
           <include name="**/*.java"/>
       </fileset>
   </javaformatter>    
   
   <target name="compile" depends="clean, reveng.hbmxml, reveng.pojos" />


</project>



Hibernate.cgf.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>
      <!-- JDBC connection pool  -->
      <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@217.172.30.53:1512:bhorax12</property>
      <property name="hibernate.connection.username">syuob00</property>
      <property name="hibernate.connection.password">syuob00</property>
     <property name="hibernate.default_schema">syuob00</property>     
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
     <!-- Dialect  -->   
     <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
     <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      <property name="current_session_context_class">thread</property>     
     <!-- Varie -->
       <property name="hibernate.cglib.use_reflection_optimizer">true</property>
       <property name="hibernate.cache.use_query_cache">true</property>      
     <!-- Cache -->         
       <property name="cache.use_second_level_cache">true</property>      
       <property name="cache.use_structured_entries">true</property>             
       <property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
       <property name="cache.provider_configuration_file_resource_path">ehcache.xml</property>      
       <!-- jdbc -->
     <property name="show_sql">true</property>
     <property name="use_outer_join">true</property>
     <property name="max_fetch_depth">2</property>
     <property name="jdbc.batch_size">1</property>
     <property name="c3p0.acquire_increment">1</property>
     <property name="c3p0.idle_test_period">100</property>
     <property name="c3p0.max_size">100</property>
     <property name="c3p0.max_statements">50</property>
     <property name="c3p0.min_size">10</property>
     <property name="c3p0.timeout">100</property>
    
     <!--  Mapping files   -->
    
    
  </session-factory>
 
</hibernate-configuration>


hibernate.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>
    <type-mapping>
      <sql-type jdbc-type="VARCHAR" hibernate-type="string" />
      <sql-type jdbc-type="NUMERIC" hibernate-type="java.util.Long" />
    </type-mapping>
     
   <table-filter match-name="OBTD_ACL_RUOLI"/>
   <table-filter match-name="OBTD_ACL_RUOLI_UTENTI"/>
   <table-filter match-name="OBTD_DPL_AMBIENTI"/>

   <!-- table allows you to override/define how reverse engineering are done for a specific table -->
   <table name="OBTD_ACL_RUOLI">
        <primary-key>
            <!-- setting up a specific id generator for a table -->
          <generator class="sequence">
               <param name="table">seq_table</param>
          </generator>
          <key-column name="CAFRUL"/>
        </primary-key>
   </table>
</hibernate-reverse-engineering>



When i try to execute ant script i get this error:

Error:

[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.exception.GenericJDBCException: Could not get list of tables from database. Probably a JDBC driver problem.
[hibernatetool] Configured schema:syuob00
[hibernatetool] Configured catalog:null
[hibernatetool] <SQLException while getting schemas>
[hibernatetool] <SQLException while getting catalogs>
[hibernatetool] java.sql.SQLException: Non vi sono altri dati da leggere nel socket


Could Anyone help me? Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 14, 2008 10:02 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
opss sorry.. for multi post maybe same connection problem! SORRY!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.