configuration.setProperty("connection.url", newJdbcUrl) fails

Description

It appears that, after

Configuration configuration = new Configuration().configure(cfgFileName);

but before

new SchemaExport(configuration).create(false,true);
sessionFactory = configuration.buildSessionFactory()

the JDBC Connection URL can't be changed with

configuration.setProperty("connection.url", newJdbcUrl)

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.

Environment

WinXP, Tomcat 5.5, MySQL 5, Hibernate 3.1.2

Activity

Show:
PerP
May 9, 2006, 2:29 PM

By the way: in the attached example, the calls to

boolean dbExisted = Utils.ensureDb(dbUrl, userName, password); // local method
if (!dbExisted)
new SchemaExport(configuration).create(false,true);

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.

PerP
May 9, 2006, 4:11 PM

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).

Brett Meyer
April 7, 2014, 5:46 PM

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.

Thank you!

Brett Meyer
July 8, 2014, 3:10 PM

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!

Rejected

Assignee

Unassigned

Reporter

PerP

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure