-->
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: How to Convert a .java to .hbm.xml file
PostPosted: Thu Oct 07, 2004 8:19 am 
Newbie

Joined: Fri Mar 26, 2004 7:23 am
Posts: 19
Dear all,

I was able to generate the .java file from the .hbm.xml.

using the hiernate-extensions tools .... ( hbm2java)

But how to get the reverse done...that is


.hbm.xml to .java file .....

Can u please let me the know the utlity and snippet of sample code ....

I know that Xdoclet does provide help but i want to know the hibernate provided way for this...


Thanks in advance :) :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 9:06 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Hibernate generates hbm from java files thru xdoclet. If you generate your hbm files from your db you can also generate xdoclet comments as meta data in the hbm file thus when you generate your java files it also generates the xdoclet comments


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2004 9:29 am 
Newbie

Joined: Fri Mar 26, 2004 7:23 am
Posts: 19
hai,

But you havent mentioned how to generate the hbm files from the db...

Can u please ....do so..


Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2004 10:10 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
You can generate hbm files from db with middlegen. You can download middlegen for hibernate on the hibernate download section. Thus you'll have an ant buildfile that you have to configure to work with your database (in fact you have to configure properties files).
In the middlegen ant task you have an hibernate subtask where you can set genXDocletTags to true. Then middlegen will generate hbm.xml files from your db with meta xdoclet information in your hbm files.
Code:
  <target name="middlegen">
    <taskdef name="middlegen" classname="middlegen.MiddlegenTask" classpathref="project.classpath"/>
    <middlegen
         appname="${name}"
         prefsdir="${conf.dir}"
         gui="false"
         databaseurl="${database.url}"
         driver="${database.driver}"
         username="${database.userid}"
         password="${database.password}"
         schema="${database.schema}"
         catalog="${database.catalog}"
    >
      <hibernate
          destination="${src}"
          package="com.mycompany"
          genXDocletTags="true"
          genIntergratedCompositeKeys="true">
      </hibernate>
    </middlegen>
  </target>

After that you can use hbm2java to generate java classes with xdoclet tags. Then you can regenerat hbm files from these java files with xdoclet


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2004 10:56 am 
Newbie

Joined: Fri Mar 26, 2004 7:23 am
Posts: 19
Thank you one & all.

I will try the method u mentioned...


Cheers!!!!!!!


Bye


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.