-->
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.  [ 13 posts ] 
Author Message
 Post subject: How to run Hibernate 3 hbm2java Ant task?
PostPosted: Sun May 01, 2005 3:51 pm 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
I checked out the Hibernate3 and HibernateExt sources from CVS and built the parts of the Hibernate 3 tools that are buildable under JDK 1.4.2 (i.e. left out metadata and ejb).

So far, I have been unable to figure out how to invoke the new Ant tasks by running Ant in Eclipse 3.0.1 on JDK 1.4.2. I can't find any docs for the Ant tasks. I am also inexperienced with Ant. Do newbie documentation and sample build.xml files exist?

(I am assuming the hbm2java CLI tool has been discontinued. I'd use it if it was available for Hibernate 3.)


Top
 Profile  
 
 Post subject: Sample build.xml
PostPosted: Fri May 06, 2005 10:12 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
This is what I have come up with so far:

<project name="foo" default="codegen" basedir=".">
<target name="codegen" description="Run hbm2java">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"/>
<hibernatetool destdir="src/">
<configuration propertyfile="hibernate.properties">
<fileset dir=".">
<include name="hibernate-mapping.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
<hbm2ddl drop="true" create="true" export="true" outputfilename="schema.sql"/>
</hibernatetool>
</target>
</project>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 12:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
its in the docs of the latest version from jboss ide downloads.

http://cvs.sourceforge.net/viewcvs.py/* ... ml?rev=1.8

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Doc discoverability
PostPosted: Sat May 07, 2005 7:17 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
max wrote:
its in the docs of the latest version from jboss ide downloads.


It would certainly help if the Ant task documentatian wasn't hidden among the Eclipse stuff and if the docs were visible to Google.

The DDL file doesn't have semicolons. How can I make the exporter add those? Also, it looks like the task is not attempting to connect to the database. (If the database is down, the Ant task succeeds.) How do I make the exporter connect to the db?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 7:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the ant tasks have not yet been properly released so thats why its not on the site yet.

I've added the delimiter support just now so its in cvs.
The ant task seem to connect fine at my end...it should only NOT connect if export="false" since export defaults to true.

-max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 10:21 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
max wrote:
I've added the delimiter support just now so its in cvs.
The ant task seem to connect fine at my end...it should only NOT connect if export="false" since export defaults to true.


DB connection now works at my end, too. However, I said cvs up in HibernateExt and rebuilt but didn't see anything new pertaining to the semicolons.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 11:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
anoncvs is some hours behind

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: schemaexport connects but does not work
PostPosted: Sun May 08, 2005 9:54 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
I see hbm2ddl connects to the database, but the order of operations is unsuccessful. Is this a known problem? (I am using Postgres 8.) Had to fall back to 2.x schemaexport.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 10:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
AFAIK they should be identical regarding sequencing ... need more concrete informaiton.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 12:21 pm 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
Sorry. It was not a sequencing problem but a bad inverse reference in my hbm. Somehow it didn't cause bad sql in the old tools.


Top
 Profile  
 
 Post subject: no id's generated?!
PostPosted: Wed May 11, 2005 4:48 am 
Newbie

Joined: Fri Mar 11, 2005 7:03 am
Posts: 2
Hi everyone!

I've been able to use the hbm2java ant task bundled in the hibernate tools 3.0 alpha. I was able to successfully run the ant task...however I encountered a small, annoying problem. The <id> tags are not generated in the POJO.

here is one of my mapping files. I've removed the other properties for brevity:

Code:
<hibernate-mapping package="com.ssi.hibernate.playground">
   <class name="PersonalInfo" table="personalinfo">
      <id name="id" type="string" length="32">
         <generator class="uuid.hex">
            <!--
            <param name="property">employee</param>
            -->
         </generator>
      </id>

      <property name="firstname" type="string" length="30" />
      <property name="middlename" type="string" length="30" />
      <property name="lastname" type="string" length="30" />
      <property name="birthdate" type="date" />
      <property name="gender" type="char" />

   </class>
</hibernate-mapping>


Currently, everytime I generate a POJO, I have to manually add the id. It's time consuming especially if you have a lot of mapping files at hand.

How do you go about this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 4:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes there is a bug around this which is fixed in cvs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 4:59 am 
Newbie

Joined: Fri Mar 11, 2005 7:03 am
Posts: 2
max wrote:
yes there is a bug around this which is fixed in cvs.


Thanks for the quick reply.

Now I have to find out how to get the files from cvs from my office....our sysad blocked almost all ports...

OT: anybody know how to tunnel CVS via http port 80? ;)


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