when you run
Configuration cfg = new Configuration().configure();
the .configure()
reads the data from the XML, and it has a higher priority over the programmatic configuration.
However, if you remove the .configure
, all the configuration will be "read" from the settings that you will pass. For example:
Configuration configuration = new Configuration()
.setProperty( "hibernate.connection.driver_class", "org.postgresql.Driver" )
.setProperty( "hibernate.dialect","org.hibernate.dialect.PostgreSQLDialect")
[...snip...]
.addAnnotatedClass( com.myPackage.MyClass.class )
[...] ;
will set all the properties at runtime.