#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    68
    Rep Power
    9

    How to use hbm2java and cfg2hbm in HIBERNATE


    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 cfg2hbm and hbm2java, 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 (means I should have hbm.xml files available before I use hbm2java)
    Code:
    /** 
     * generated by hbm2java 
     */
    Can some please tell me how to use cfg2hbm and hbm2java a small example will really help. I tried posting on Hibernate forum but no answer. So posting here as most of you
    probably have used Hibernate. Any help is appreciated.

    Thanks
  2. #2
  3. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    I found the following in two hot seconds using Google:

    http://www.onjava.com/pub/a/onjava/2...-hbm2java.html

    It's an extremely important skill to learn how to search the web. Not only will it increase your research and development talents, it will also save you from asking questions that may have already been addressed before.

    If you've done the research, found nothing useful, and decide to post your question, it's a great idea to tell us that you've already searched (and what methodologies you used to do your research). That way, we don't refer you back to something you've already seen.

    Best of luck!

    ~
    Last edited by Yawmark; April 26th, 2006 at 10:32 AM.
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  4. #3
  5. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,418
    Rep Power
    1713
    What version of Hibernate are you using? The tools are a separate download in Hibernate 3 - they were packaged together in Hibernate 2. Let us know bacause the answer is a bit different between the two.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    68
    Rep Power
    9
    Originally Posted by stdunbar
    What version of Hibernate are you using? The tools are a separate download in Hibernate 3 - they were packaged together in Hibernate 2. Let us know bacause the answer is a bit different between the two.
    Thanks for the link it really helped but I searched for cfg2hbm couldn't find anything, any small example for cfg2hbm will help, also went over Hibernate In Action but they too don't describe. I am using hibernate 3. Where can I download the tools separately. Thanks
  8. #5
  9. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,418
    Rep Power
    1713
    As far as downloading the tools, what have you done? Go to hibernate.org, click on downloads, and there are the download for the tools.

    cfg2hbm doesn't exist in Hibernate 3. There are similar tools though. In your ant build file you'll have something like:

    xml Code:
     
    <hibernatetool destdir="${rev.eng.output.dir}" >
        <jdbcconfiguration 
                     configurationfile="${rev.eng.config.dir}/hibernate.cfg.xml"
                     packagename="your.package.name"
                     revengfile="${rev.eng.config.dir}/hibernate.xml" />
        <hbm2hbmxml />
    </hibernatetool>


    This is from a build file I'm using to do database reverse engineering.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    1
    Rep Power
    0

    hbm2java without ant


    hi
    i read somewhere that"hbm2java is designed to convert 1 hibernate-mapping file into a corresponding set of java classes" So can we use hbm2java without integrating with ant or maven? also i am using hibernate ver3 and want to convert only one hib-mapping file at a time.
    thanks

IMN logo majestic logo threadwatch logo seochat tools logo