It appears that, after
Configuration configuration = new Configuration().configure(cfgFileName);
sessionFactory = configuration.buildSessionFactory()
the JDBC Connection URL can't be changed with
Trying to do so causes configuration.getProperty to return the new value,
but the SessionFactory gets confused and appears to use the old value.
I have the impression that configure(cfgFileName) sets the properties
of the Configuration in some "hard" way, so that later calls to setProperty
are mostly ignored (except that getProperty returns the new value).
The attached file attempts to do this, and fails.
WinXP, Tomcat 5.5, MySQL 5, Hibernate 3.1.2
By the way: in the attached example, the calls to
boolean dbExisted = Utils.ensureDb(dbUrl, userName, password); // local method
does create a new database with the new url (with Utils.ensureDb),
but does not export a schema to it.
This strengthens my suspicions that the configuration has been
carved in stone by .configure and really can't be changed with .setProperty.
The basic problem appears to be that the property names
specfied in the file read by .configure(cfgFilename) may be
abbreviated (e.g. "connection.url" for "hibernate.connection.url")
but NOT in the parameter to .setProperty!
This should IMHO be fixed either by adding the same ability
to expand an abbreviated property name to .setProperty
(in the same way as .configure), or documenting the difference
of behaviour in the JavaDoc. (It wouldn't hurt to make the JavaDoc
more complete on this issue in any case).
In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.
If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.
Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!