This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Create database schema from Hibernate?

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
Do Re Mi Fa So La Tiny Ad
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!