|
Click the link to the forum, and post your question there. As of Hibernate 3.2.1 the workaround mentioned above does no longer work, since a call to buildSettings() is introduced in org.hibernate.cfg.Configuration.generateSchemaUpdateScript(). Since settings have already been build, Spring will throw "No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean" from its LocalDataSourceConnectionProvider. Suddenly this moves from being a "Minor" problem to a "Major", since we cannot run our tests with 3.2.1. I prepared a patch against the 3.2 branch that solves this problem for our environment, namely H2, PostgreSQL, and SQL Server 2005. Note that I could not make it work with Hypersonic/HSQL since its CREATE SCHEMA statement requires a mandatory AUTHORIZATION part that I didn't want to deal with at this point. Somebody else might know how to fix this problem in an efficient way. Anyway, H2 gave our test suite a tremendous boost, so dropping HSQL was the logical step and we're happy. See attachment create-schema.patch so you want schemaexport to automatically create and drop schemas after its done......that's dangerous! Living on the edge... Seriously, that seems to be the quick Besides, since we drop the tables, what's so funny about dropping the schemas, too? hibernate knows exactly which tables it created.......but it does not know if all tables in a schema has been removed. With a too liberal db/rights you would be nuking out things you shouldn't. Agreed. Is there a good way to lower the danger of accidentally doing this that's currently supported by Hibernate? I could consider this in the patch. If not, I'd vote for leaving that up to the developer/DBA and go with the simple solution. Modification of previous patch, so that the schema creation syntax is delegated to the dialect object. Has this patch made it into a released version? I've tried applying it (the second attachment) to Hibernate 3.2.2 with strange results. When used in conjunction with H2 1.0.79, the schemas get created, but after the attempts to create the tables. This obviously doesn't work. With so many moving parts it's kind of hard to tell what's wrong. Pointers to a Hibernate release that works with H2 would be greatly appreciated. Thanks The crux of the issue seems to be just the creation of schema, not dropping schema. Earlier comments about dropping more than is intended provide good reason for not dropping schema from Hibernate. Can a version of the patch for this bug that only creates, but never drops, schema make it into a release? This bug is a serious impediment for the common case of using an H2 in-memory database for unit testing. hbm2ddl.auto=update seems to work for me with h2 when use org.hibernate.dialect.H2Dialect rather than HSQLDialect This issue should be fixed. All that is necessary is an option to force creation of the schemas if none are present. Users should not have to update and recompile code to make this happen. Its been over three years at this point. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hi,
PostgresSQL will not create the schema.
How can i fix that ?
Cristi