aspose file tools*
The moose likes Object Relational Mapping and the fly likes the property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "the property "hibernate.hbm2ddl.auto"" Watch "the property "hibernate.hbm2ddl.auto"" New topic
Author

the property "hibernate.hbm2ddl.auto"

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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 .


Save India From Corruption - Anna Hazare.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

It drops all of the existing tables, and then recreates them, giving you a fresh new database.

-Cameron McKenzie
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Apr 18, 2009
Posts: 2234

Not at Applicatiaon startup but this will be happenig after every server start up know.
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
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.


http://javasign.blogspot.com/
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

I didn't get you Aurelian . Can you please elobrate your answer
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Nice explanation Paul .Thank you.
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
That's what I wanted to say. Thank you too, Paul.
 
Consider Paul's rocket mass heater.
 
subject: the property "hibernate.hbm2ddl.auto"