How can I ensure that all properties are loaded from hibernate.cfg.xml, then add additional properties programmatically? I saw the following code snippet but it looks like a
You code snippet should load hibernate.cfg.xml from the root of the classpath and then add or overwrite the configuration properties programmatically . So , please make sure that your so called the "existing one hibernate.cfg.xml " is on the root of the classpath.
If your "existing one hibernate.cfg.xml " is not on root of the classpath , but in some package , you can load it by specifying its package path in the configure() , likes
Configuration config = new Configuration();
config.configure("package1/package2/hibernate.cfg.xml");
config.setProperty("hibernate.connection.username", "update" );
config.setProperty("hibernate.connection.password", "defgh629154" );