Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

creating .hbm.xml file

Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i able to create .hbm.xml file automaticaly using the existing table in the database. through hibernate?

is it possible?
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have a look at middlegen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There was previous responce about it already.
Have a look at middlegen for Hibernate
[ September 29, 2004: Message edited by: Peter Laurinec ]
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating .hbm.xml file automatically

Steps you need to do

1. Get Middlegen
2. Change the build.xml according to the database you chose
3. You can mention which tables you want to generate using the option table in the build.xml file(just closely look at the different ant taks in it)
4. run the ant script using ant middlegen, this will open up a gui in which click hibernate tab, and select the tables you want to generate.
5. Finally click generate, the files will be loaded into the hibernate directory
Let me know if you have questions
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi this is how i have done the Creation of HBM file and JavaSource file
and if exist i had even created the tables in database.plesae seee the code

<project name="Domain" default="all" basedir=".">
<property name="Domain" value="Domain" />
<property file="config\"/>

<property name="ddl.file" value="ddl.sql"/>
<property name="" value ="D:\kazi\Domain\com"/>
<property name="class.root" value="classes"/>
<!-- installation configuration -->
<property name="hibernate_path"
<property name="project.dir"
value="D:\kazi\Domain" />
<property name="database.script.file" value="schema.sql" />
<!-- JDBC connectivity information -->
<property name="database.driver.file"
<property name="database.driver.classpath"
<property name="database.driver"
<property name="database.url"
<property name="database.userid" value="root"/>
<property name="database.password" value="root123"/>
<property name="database.schema" value="test"/>
<property name="database.dialect" value="net.sf.hibernate.dialect.MySQLDialect"/>

<path id="lib.class.path">
<pathelement path="${basedir}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<target name="all"
depends="build_tables,schema,hbm2ddl-schema,sql-run-ddl,codegen,compile" />

<target name="schema" description="Generate DB schema from the O/R mapping files" >
<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
<schemaexport properties="${project.dir}/config/"
quiet="no" text="no" drop="no" delimiter=";">
<fileset dir="${project.dir}">
<include name="**/*.hbm.xml">
<target name="hbm2ddl-schema" description="Generate DDL from Hibernate mapping" >
<java classname="net.sf.hibernate.tool.hbm2ddl.SchemaExport" fork="true">
<jvmarg value="-Dhibernate.dialect=${database.dialect}"/>
<arg value="mapping/AgencyActivity.hbm.xml"/>
<arg value="mapping/Incident.hbm.xml"/>
<arg value="mapping/HouseholdMemberVehicle.hbm.xml"/>
<arg value="mapping/HouseholdMember.hbm.xml"/>
<arg value="mapping/WarrantyQuestionDetails.hbm.xml"/>
<arg value="mapping/WarrantyQuestions.hbm.xml"/>
<arg value="mapping/CreditHistory.hbm.xml"/>
<arg value="mapping/Discount.hbm.xml"/>
<arg value="mapping/Fee.hbm.xml"/>
<arg value="mapping/UnderwriterActivityLog.hbm.xml"/>
<arg value="mapping/MemberRating.hbm.xml"/>
<arg value="mapping/Payment.hbm.xml"/>
<arg value="mapping/VehicleDiscount.hbm.xml"/>
<arg value="mapping/Claim.hbm.xml"/>
<arg value="mapping/AgencyUser.hbm.xml"/>
<arg value="mapping/Vehicle.hbm.xml"/>
<arg value="mapping/ClaimCoverage.hbm.xml"/>
<arg value="mapping/AdditonalEquipment.hbm.xml"/>
<arg value="mapping/VehicleRating.hbm.xml"/>
<arg value="mapping/AdditionalEquipmentDisclaimer.hbm.xml"/>
<arg value="mapping/Address.hbm.xml"/>
<arg value="mapping/Agency.hbm.xml"/>
<arg value="mapping/InsuranceTransaction.hbm.xml"/>
<arg value="mapping/AgentNotepad.hbm.xml"/>
<arg value="mapping/Alert.hbm.xml"/>
<arg value="mapping/BatchQuote.hbm.xml"/>
<arg value="mapping/Coverage.hbm.xml"/>
<arg value="mapping/InsuredDocument.hbm.xml"/>
<arg value="mapping/Lienholder.hbm.xml"/>
<arg value="mapping/Memo.hbm.xml"/>
<arg value="mapping/RequestHeader.hbm.xml"/>
<arg value="mapping/PriorCarrier.hbm.xml"/>
<arg value="mapping/PolicyEndorsement.hbm.xml"/>
<arg value="mapping/Phone.hbm.xml"/>
<arg value="mapping/MemoMessage.hbm.xml"/>
<arg value="mapping/MemoAssignmentRule.hbm.xml"/>
<arg value="mapping/MemoAttachment.hbm.xml"/>
<arg value="mapping/Status.hbm.xml"/>
<arg value="mapping/UnderwriterDocument.hbm.xml"/>
<arg value="mapping/ValidValue.hbm.xml"/>
<arg value="mapping/SubProducer.hbm.xml"/>
<arg value="mapping/RuleType.hbm.xml"/>
<arg value="mapping/Role.hbm.xml"/>
<arg value="mapping/UserCategory.hbm.xml"/>
<arg value="mapping/RoleAttribute.hbm.xml"/>
<arg value="mapping/Attribute.hbm.xml"/>
<arg value="mapping/RoleElementConfig.hbm.xml"/>
<arg value="mapping/PageElementConfig.hbm.xml"/>
<arg value="mapping/Page.hbm.xml"/>
<classpath refid="lib.class.path"/>

it has created every thing jst we have to select which target we want....i had only hbm filesl

Feel free to ask and say.

Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do this very easily (and using GUI) using Hibernate Tools.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic