When should I use hibernate.connection.provider_class
? I am a little confused between it and 'hibernate.connection.diver_class'.
provider_class might be useful for connection pool
开发者_运维百科is there any other purpose where we can use provider_class?
Another use for connection provider is to uphold sessions over time, this is especially true with the combination of mysql + hibernate. If you don't have a properly configured connection provider that handles timeouts from mysql, you're likely to loose your connection to the database sooner or later if you have periods of inactivity.
The driver class is what it sais it is, what driver do you use to connect to your db. The connection provider class is class that can manage your connections for you and provide it to the session.
Have a look at: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html
The connection provider class is usually used if you want to use connection pooling. eg: hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider.
ConnectionProvider is what you use to customize your strategy for obtaining connections. As well as connection pooling, it can be used to implement multi-tenancy databases.
A brief run-thru:
http://literatejava.com/hibernate/multi-tenancy-architecture-with-hibernate/
精彩评论