-->
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: XML to DDL
PostPosted: Tue Mar 17, 2009 7:56 am 
Newbie

Joined: Tue Mar 17, 2009 7:49 am
Posts: 5
I am completely new to Hibernate and I'm trying to get some answers about functionality. I am under the impression, after reading some of the documentation, that Hibernate has tools that will allow me to generate DDL from an XML mapping file. Is this correct? If so, can someone please point me to where I’d find information/documentation on how to do this as this is currently the only feature we’re interested in? I’ve become totally overwhelmed by all the available documentation. Thanks in advance for your help.

- Mark


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 19, 2009 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
It's mentioned in the first chapter tutorial.

look for schema export/hbmddl.

It is also part of Hibernate Tools.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 3:53 pm 
Newbie

Joined: Tue Mar 17, 2009 7:49 am
Posts: 5
Ok, here is my .hbm.xml file, the contenst of the .cmd file I am running to generate the DDL and the output from that .cmd file. Where am I going wrong?

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="airline.hibernate.Reservation"
table="reservations"
>

<composite-id>
<key-property
name="reservationId"
column="reservation_id"
type="java.lang.Integer"
length="10"
/>
<key-property
name="personIdFk"
column="person_id_fk"
type="java.lang.Integer"
length="10"
/>
<key-property
name="flightIdFk"
column="flight_id_fk"
type="java.lang.Integer"
length="10"
/>
</composite-id>

<property
name="registrationUtc"
type="java.sql.Timestamp"
column="registration_utc"
not-null="true"
length="23"
/>
<property
name="comment"
type="java.lang.String"
column="comment"
length="2147483647"
/>

</class>
</hibernate-mapping>



@echo off

set CP="C:\hibernate-3.3.1\hibernate3.jar;C:\hibernate-3.3.1\lib\required\slf4j-1.5.6\slf4j-api-1.5.6.jar;C:\hibernate-3.3.1\lib\required\slf4j-1.5.6\slf4j-jdk14-1.5.6.jar;C:\hibernate-3.3.1\lib\required\dom4j-1.6.1.jar;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar;C:\hibernate-3.3.1\lib\required\antlr-2.7.6.jar;C:\hibernate-3.3.1\lib\required\commons-collections-3.1.jar;C:\hibernate-3.3.1\lib\required\javassist-3.4.GA.jar;C:\hibernate-3.3.1\lib\required\jta-1.1.jar"

REM Set the Java classpath
set CLASSPATH=%CP%

java -cp %CLASSPATH% org.hibernate.tool.hbm2ddl.SchemaExport --properties=hibernate.properties --text --format --create Reservation3.hbm.xml



C:\hibernate-3.3.1>h_exportdb.cmd
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.3.1.GA
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.Configuration addFile
INFO: Reading mappings from file: Reservation3.hbm.xml
Mar 20, 2009 3:49:11 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: airline.hibernate.Reservation -> reservations
Mar 20, 2009 3:49:11 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.SQLServerDialect
Mar 20, 2009 3:49:11 PM org.hibernate.tool.hbm2ddl.SchemaExport main
SEVERE: Error creating schema
org.hibernate.MappingException: component class not found: airline.hibernate.Reservation
at org.hibernate.mapping.Component.getComponentClass(Component.java:127)
at org.hibernate.tuple.component.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:156)
at org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:66)
at org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:61)
at org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.jav
a:76)
at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:73)
at org.hibernate.mapping.Component.buildType(Component.java:175)
at org.hibernate.mapping.Component.getType(Component.java:168)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:743)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:854)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
at org.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:474)
Caused by: java.lang.ClassNotFoundException: airline.hibernate.Reservation
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.mapping.Component.getComponentClass(Component.java:124)
... 13 more
org.hibernate.MappingException: component class not found: airline.hibernate.Reservation
at org.hibernate.mapping.Component.getComponentClass(Component.java:127)
at org.hibernate.tuple.component.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:156)
at org.hibernate.tuple.component.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:66)
at org.hibernate.tuple.component.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:61)
at org.hibernate.tuple.component.ComponentEntityModeToTuplizerMapping.<init>(ComponentEntityModeToTuplizerMapping.jav
a:76)
at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:73)
at org.hibernate.mapping.Component.buildType(Component.java:175)
at org.hibernate.mapping.Component.getType(Component.java:168)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:743)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:854)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
at org.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:474)
Caused by: java.lang.ClassNotFoundException: airline.hibernate.Reservation
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.mapping.Component.getComponentClass(Component.java:124)
... 13 more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 22, 2009 7:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
From your other thread, I would guess that

http://db.apache.org/ddlutils/

is more along the lines of what your looking for...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes and if you choose to use hibernate tools remember to put the classes you refer to in the mappings into your classpath.

_________________
Max
Don't forget to rate


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.