-->
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.  [ 6 posts ] 
Author Message
 Post subject: Can Hibernate create tables from mappings?
PostPosted: Mon Dec 25, 2006 5:26 am 
Newbie

Joined: Thu Nov 30, 2006 10:06 am
Posts: 9
Can I create table or issue CREATE TABLE commands from Hibernate or some hibernate tools?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 25, 2006 6:08 am 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
Yes, you can use Hibernate Tools.

Quote:
The tool used for schema generation is hbm2ddl; its class is org.hibernate.tool.hbm2ddl.SchemaExport, so it’s also sometimes called SchemaExport.

_________________
Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 26, 2006 5:23 pm 
Beginner
Beginner

Joined: Thu Sep 22, 2005 10:48 am
Posts: 30
Location: Rio de Janeiro, Brazil
Or use in your hibernate.cfg.xml:
Code:
<property name="hbm2ddl.auto">create</property>

_________________
Please don't forget to rateME!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 29, 2006 6:02 am 
Newbie

Joined: Fri Dec 29, 2006 5:51 am
Posts: 3
Sorry, mistake

_________________
ne patim od ludila, uzivam u njemu...


Last edited by djordje.ivanovic on Fri Dec 29, 2006 6:10 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 29, 2006 6:06 am 
Newbie

Joined: Fri Dec 29, 2006 5:51 am
Posts: 3
Can you give me some basic example how to use SchemaExport or hbm2ddl? Ok, i put <property name="hbm2ddl.auto">create</property> in hibernate.cfg.xml. What to do now? Please, this is wery urgent!!!

Thanks, Djordje

_________________
ne patim od ludila, uzivam u njemu...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 29, 2006 7:51 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It depends on what you want to do: if you just want to create the schema, then you're done. Just start your app and the schema will just be created as soon as you instantiate the sessionfactory.

If you want to get the SQL, it's very simple: read this part of the reference doc http://www.hibernate.org/hib_docs/v3/re ... etguide-s1

It will take you about three or four lines to write the code that will take your hibernate.cfg.xml file and generate all the corresponding SQL to the found mapping files.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.