-->
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.  [ 2 posts ] 
Author Message
 Post subject: Programmatic re-creating the database schema
PostPosted: Sun Dec 30, 2007 8:23 am 
Newbie

Joined: Sun Dec 30, 2007 8:17 am
Posts: 1
I have a problem here, I need to recreate the database schema from my code. Which means hbm2ddl.auto=create functionality, but triggered from the code. Is there a way to achieve it? Thank you...


Top
 Profile  
 
 Post subject: solution
PostPosted: Mon Dec 31, 2007 8:10 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Code:
      Configuration cfg=new Configuration();
      cfg.addResource("test2/mapping.hbm.xml");
      cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.MckoiDialect");
                ... (the rest of the configuration properties)
      String[] schema=cfg.generateSchemaCreationScript(new org.hibernate.dialect.MckoiDialect());
      SchemaExport se=new SchemaExport(cfg);
      se.create(true, true);


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