Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the property "hibernate.hbm2ddl.auto"

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In Hibernate the property hibernate.hbm2ddl.auto




Automatically export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.



Can anybody please tell me actually what does export schema DDL to the database

Thanks in advance .
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It drops all of the existing tables, and then recreates them, giving you a fresh new database.

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you cameron , that was helpful .

So using create - drop affects performace know as it need to recreate all the Tables again .

So can you please tell me what should be used actually from performace point of View ad what is the default value if one doesn't specify anything.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's really just a development time thing. I mean, why would you want to delete all of your data every time your application restarts?

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not at Applicatiaon startup but this will be happenig after every server start up know.
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran Varre wrote:Not at Applicatiaon startup but this will be happenig after every server start up know.

I think Cameron is right, at every deployment (applications start) this will happen.

When you are in production of course you should use valide at most.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get you Aurelian . Can you please elobrate your answer
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you configure your SessionFactory this will process the hibernate.hbm2ddl.auto property and do what it is documented to do. So if it is set to create, it will drop all tables you have mapped and recreate them. It's normal to initialise the SessionFactory at start up, so when you deploy your web application this will happen.

What Aurelian is pointing out I think is that you would not want this behaviour in a production environment.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice explanation Paul .Thank you.
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I wanted to say. Thank you too, Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic