-->
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: How to use hbm2java and cfg2hbm
PostPosted: Tue Apr 25, 2006 5:19 pm 
Newbie

Joined: Fri Apr 14, 2006 8:55 am
Posts: 6
Hi,

I am new to hibernate and need some information. I looked at several examples online and tried them too.

One thing I can't figure out is how to use hbm2java and cfg2hbm, didn't find any docs., can someone point me to some tutorial that explains how to use these.

I see following text on most of the *.hbm.xml files

Code:
<!--
Auto-generated mapping file from
the bibernate.org cfg2hbm engine
-->


and on persistent classes

Code:
/**
* generated by hbm2java
*/


Can some please tell me when are these tools being used. As don't want to create the above files manually and would rather like to use the
the above tools. Any help is appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 2:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Here is a sample Ant script for hbm2java.. This should get you started.
Code:
<target name="hbm2java" description="Generate .java from .hbm files.">
  <delete>
    <fileset dir="${hibernateDO.dir}">
      <include name="**/*.java"/>           
    </fileset>         
  </delete>
     
  <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
    <classpath refid="classpath.common"/>
  </taskdef>
     
  <hibernatetool destdir="${src.dir}">
    <configuration>
      <fileset dir="${src.dir}">
        <include name="**/hbm/*.hbm.xml"/>
      </fileset>
    </configuration>
    <hbm2java generics="false"/>
  </hibernatetool>

</target>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 10:55 am 
Newbie

Joined: Fri Apr 14, 2006 8:55 am
Posts: 6
Thanks, how does cfg2hbm works. Looks like I need some king of configuration file available to use this. Any help is appreciated?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 10:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
First step is to review the documentation
http://www.hibernate.org/hib_docs/tools/reference/en/html/ant.html#d0e645

I think you mean hbm2hbmxml as there have been a few name changes for many parts of the tools untilities over recent times.

So here is a basic snippit of Ant xml for reverse engineering the database.
Code:
<hibernatetool>
<jdbcconfiguration propertyfile="etc/hibernate.properties" />
<hbm2hbmxml destdir="${build.dir}/src" />
</hibernatetool>


Then you can use hbm2java to create the POJOs.

BTW: If this is helpful you should click the approrpiate link so others will know the information has some value.


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.