-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate.hbm2ddl.auto does nothing?
PostPosted: Thu Jun 08, 2006 11:19 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Using HSQLDB, I want to run hbm2ddl multiple times without it recreating the existing schema...I want it to keep whatever's there.

I understand that setting hibernate.hbm2ddl.auto to validate or update should solve this, but it changes nothing. The SQL to drop and create the schema is run against the database, with no regard for current data in the DB.

However, when I set the hbm2ddl tag's update attribute to "true", then running hbm2ddl doesn't remove currently-existing data. The problem here though is that the Hibernate 3 documentation specifies that update shouldn't be set to true!

So does hibernate.hbm2ddl.auto only get read when update="true"? I thought this might be the case, but even when update="true" and I comment out setting hibernate.hbm2ddl.auto to validate or update, it works the same...

What exactly does hibernate.hbm2ddl.auto even do!?!? And how is it different from the hbm2ddl tag's update="true"!?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 3:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
<hbm2ddl> is the ant task

hibernate.hbm2ddl.auto is a setting in hibernate that states how hbm2ddl should behave when sessionfactory is created.

the hbm2ddl update attribute has nothing to do with this setting, except it is implemented through schemaexport/schemaupdate.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 3:28 am 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
So if I understand what you're saying, a SessionFactory is created just for the hbm2ddl ant task, and the hibernate.hbm2ddl.auto tells that SessionFactory what to do when it runs just for the hbm2ddl ant task?

Again, I'm still completely confused as to what hibernate.hbm2ddl.auto even does!? At least if I KNOW then I can figure out whether it's doing what it's supposed to and I can continue diagnosing the problem.

Seriously, if the documentation doesn't even explain what it's doing, how are we ever supposed to learn!!? Somebody PLEASE explain.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 4:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh ? what docs doesn't say what it does ?

From the doc about the .auto:

"Automatically validate or 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.

eg. validate | update | create | create-drop"

sounds pretty clear to me.

hbm2ddl is something you use to do this more explicitly from e.g an ant task or eclipse plugin.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 5:03 am 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Pardon my frustrations, but as per my initial problem, when using the hbm2ddl ant task to create the schema, when I keep hbm2ddl's update="false", but set hibernate.hbm2ddl.auto to either validate or update, it doesn't seem to do anything.

The full DDL is still produced and executed against the database without regard for the fact that I set hibernate.hbm2ddl.auto to validate or update.

This is why I tried to set hbm2ddl update="true", and it worked. However, I am afraid that if hibernate.hbm2ddl.auto doesn't do what it's supposed to do when using hbm2ddl, then anytime Java code that I write to persist and load classes, the hibernate.hbm2ddl.auto setting will continue to do nothing.

Are these fears justified, or is the hibernate.hbm2ddl.auto not supposed to do anything when hbm2ddl is executing?

If you understand the source of my confusion, hopefully you can clear things up for me.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 5:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate.hbm.ddl.auto is not used when running <hbm2ddl> because it does not use the SessionFactory, it uses the Configuration.

the .auto setting is only in context of when Sessionfactory is created and closed - nothing else, nothing more.

_________________
Max
Don't forget to rate


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