I'm continuing a thread from the hibenate blog to the forum so more people can join in the discussion. Read the comments on this blog
http://blog.hibernate.org/cgi-bin/blosx ... #threebeta to understand the reasoning behind this post.
Currently, the configuration object takes a properties object to set up hibernate. If you want to provide a class, like a cach provider, then you specify the name of the property and the name of the class (which must contain a 0-args constructor) which hibernate will try and instantiate. The problem with this mechanism is that you cannot pass in an existing object such as a cache that you resolve from JNDI.
What I propose is using the map interface as an option instead of properties which wouldn't break backwards compatibilty is as much as you would only have to change the Configuration class to pass a map, the Environment class to add new constants for preconfigured objects and the SettingsFactory class to use the preconfigured classes from the map and cast to CacheProvider from the object, but continue to cast other objects to strings as before.
An example of the spring configuration for IoC would then look like this
<pre>
[bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"]
[property name="mappingResources"]
[value]product.hbm.xml[/value]
[/property]
[property name="hibernateProperties"]
[map]
[entry key="hibernate.dialect"]
[value]net.sf.hibernate.dialect.MySQLDialect[/value]
[/entry]
[entry key="hibernate.cacheProvider.ioc"]
[ref bean="cacheProvider" /]
[/entry]
[/map]
[/property]
[/bean]
</pre>
How do you feel about this change, would other people also benefit from such a change? Is there anything I've missed here that might make the solution more difficult than I've suggested? I've already coded an example that I'm going to test later today, I'll feedback on the results then.
Graham