• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Create database schema from Hibernate?

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that there's a command that you can insert in the hibernate configuration file that will automatically create your database schema in the database for you when you run your program. But is there a way to get Hibernate to create a schema file for you? I forget the type of file. I just know that you can have a file which you import into a database and it creates your tables, etc.

This way when setting up a new installation of your program, you can just run the schema file instead of having to change the Hibernate config file and then change it back.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shcema file? This is not something I'm familiar with. Different databases have ways of restoring the schema only, but these are database specific and Hibernate is not going to support these.

Also, some databases will generate DDL from a schema. Again this is database specific and not something you can get Hibernate to do.

However, are you aware that the property hibernate.hbm2ddl.auto can take the value "update"? This will create the schema if its not already there, or apply changes if any have been made. If there are no changes it will change nothing. This might be what you are looking for?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never heard of as such thing, if you get to know anything about it, then do inform us But for opposite yes, i have used some plugins in eclipse WTP version to automatically generate the hibernate cfg files, In that case, there is separate option in "open perspective" called hibernate perspective which can be used further for automatic code generation.
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
Shcema file? This is not something I'm familiar with. Different databases have ways of restoring the schema only, but these are database specific and Hibernate is not going to support these.

Also, some databases will generate DDL from a schema. Again this is database specific and not something you can get Hibernate to do.

However, are you aware that the property hibernate.hbm2ddl.auto can take the value "update"? This will create the schema if its not already there, or apply changes if any have been made. If there are no changes it will change nothing. This might be what you are looking for?



No, I didn't know about the update setting.

And a DDL may be what I'm thinking of. I'm not a DB guy, so I'm not sure what the correct terms are.
 
My cellmate was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic