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