-->
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.  [ 5 posts ] 
Author Message
 Post subject: no hbm/java genereated but no error thrown (ant)
PostPosted: Fri Jun 30, 2006 5:15 am 
Newbie

Joined: Thu Jun 29, 2006 10:25 am
Posts: 4
Hi,

Im new to hibernate and am setting it up in my application. Im trying to reverse engineer an existing database schema. Ive tried using hibernate tool 3.1 beta5 and eclipse 3.1.2 but as other have encountered, I am also missing the Hibernate Code Generation link. I swtiched to Ant (1.6.5) but I still cant make it run properly. Im not getting any error even with ant -verbose but Im not also getting any generated files. The thing is, I played around with my hibernate.cfg.xml changing the DB/user/url with wrong values and its still giving me Build succesful message(why are they not throwing exceptions? but when i placed a malformed xml it did gave error). They are valid hibernate.cfg.xml and hibernate.reveng.xml since they were generated when I was using eclipse and I was able to see my DB schema from there. Perhaps there is something wrong in my build.xml (Tho I its just straight forward)?


I have my config files below.... appreciate any help from you. Thanks.

ANT result

Build sequence for target(s) `hibernatetool' is [hibernatetool]
Complete build sequence is [hibernatetool, ]

hibernatetool:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java 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] 2. task: hbm2hbmxml (Generates a set of hbm.xml files)

BUILD SUCCESSFUL


hibernate.cfg.xml

<?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>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">pwd</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.33.16.123:1525:DEV1</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.default_catalog">DEV1</property>
<property name="hibernate.default_schema">user</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

</session-factory>
</hibernate-configuration>



hibernate.reveng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<table-filter match-catalog="DEV1" match-schema="user" match-name="BM"/>
<table-filter match-catalog="DEV1" match-schema="user" match-name="COMPONENT"/>
<table-filter match-catalog="DEV1" match-schema="user" match-name="RATE"/>
</hibernate-reverse-engineering>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 5:24 am 
Newbie

Joined: Thu Jun 29, 2006 10:25 am
Posts: 4
below is the build.xml Im using


<project name="test" default="hibernatetool" basedir=".">

<target name="hibernatetool">
<path id="toolslib">
<path location="lib/hibernate-tools.jar" />
<path location="lib/hibernate3.jar" />
<path location="lib/freemarker.jar" />
<path location="lib/ojdbc14.zip" />
<path location="lib/hibernate/antlr-2.7.6rc1.jar" />
<path location="lib/hibernate/commons-logging-1.0.4.jar" />
<path location="lib/hibernate/asm.jar" />
<path location="lib/hibernate/asm-attrs.jar" />
<path location="lib/hibernate/c3p0-0.9.0.jar" />
<path location="lib/hibernate/cglib-2.1.3.jar" />
<path location="lib/hibernate/commons-collections-2.1.1.jar" />
<path location="lib/hibernate/concurrent-1.3.2.jar" />
<path location="lib/hibernate/connector.jar" />
<path location="lib/hibernate/dom4j-1.6.1.jar" />
<path location="lib/hibernate/ehcache-1.1.jar" />
<path location="lib/hibernate/jaas.jar" />
<path location="lib/hibernate/jdbc2_0-stdext.jar" />
<path location="lib/hibernate/jgroups-2.2.8.jar" />
<path location="lib/hibernate/jta.jar" />
<path location="lib/hibernate/log4j-1.2.11.jar" />
<path location="lib/hibernate/oscache-2.1.jar" />
<path location="lib/hibernate/proxool-0.8.3.jar" />
<path location="lib/hibernate/swarmcache-1.0rc2.jar" />
<path location="." />
</path>

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

<hibernatetool destdir="./generated">
<jdbcconfiguration propertyfile="./src/hibernate.properties"
packagename="com.sony"
revengfile="./src/hibernate.reveng.xml"
/>


<!--<configuration configurationfile="./src/hibernate.cfg.xml"/> -->

<hbm2java />
<hbm2hbmxml/>
</hibernatetool>

</target>
</project>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 7:17 am 
Newbie

Joined: Wed Jun 28, 2006 11:04 am
Posts: 4
I'm not sure if the order of the tasks does have an impact, but

<hbm2java />
<hbm2hbmxml/>

seem to be the wrong way arround -> first u generate the hbm's and then the code.

Also I'm using seperate steps:
like:

....
Code:
<target   name="ddl2hbm" depends="init"   >
   <hibernatetool destdir="${build.dir}/generated">
      
      <jdbcconfiguration
         configurationfile="hibernate.cfg.xml"
         packagename="xx.xxx.xxx.db"
         revengfile="hibernate.reveng.xml"
      >

      </jdbcconfiguration>
      <hbm2hbmxml/>
   </hibernatetool>   
</target>

.... then this to generate the hibernate config holding the correct hbm references:
Code:
   <target   name="hbm2config">
   <hibernatetool destdir="${build.dir}/generated">
      <configuration configurationfile="hibernate.cfg.xml">
       <fileset   dir="${build.dir}/generated">
          <include   name="**/MASTER_*.hbm.xml"/>
          <exclude   name="**/*Test*"/>
       </fileset>
      </configuration>
      <hbm2cfgxml   destdir="${build.dir}"/>
   </hibernatetool>   
</target>

.... and the code generation

Code:
<target   name="hbm2java"   depends="hbm2config">
   <hibernatetool destdir="${build.dir}/src"   >
      <configuration configurationfile="${build.dir}/hibernate.cfg.xml">
<!-- use the generated one !!! -->
      </configuration>
      <hbm2java   jdk5="true" ejb3="false"/>   
   </hibernatetool>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 9:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the order inside *one* hibernatetool does not (normally) matter.

the seperation into two hibernatetool runs does though since then the templates will be running against different configurations (the input is different)

...i would look into if the casing of catalog and schema is correct since no output and no errors hints to me that no tables were found.

putting a log4j.properties/log4j.xml into your classpath would definitly also help you see what is going on.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 8:21 am 
Newbie

Joined: Thu Jun 29, 2006 10:25 am
Posts: 4
I was able to make it work using JbossEclipse IDE (tho i had to recofigure everything and start from scratch again).

Thanks for the help!


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