javadatabasehibernatedatasourcebonecp

BoneCP and Hibernate


I'm currently in a process to integrate BoneCP into an existing project that has Hibernate, and as I was reading BoneCP's manual, I found this:

If you are using this library directly in Hibernate (i.e. without a DataSource, not recommended)

and I started wondering why is this? Can someone please explain to me why is it bad to use BoneCP directly in Hibernate?


Solution

  • It is a strange recommendation.

    The "not recommended" advice implies not using com.jolbox:bonecp-provider which only contains one class BoneCPConnectionProvider.
    If you want to use BoneCP with Hibernate, you will need the bonecp-provider because it is a required configuration property in hibernate.cfg.xml:
    <property name="connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</property>
    (copied from here, but also shown in this SO question).

    If you do not use the bonecp-provider, you must use the "default" datasource implementation jcom.jolbox.bonecp.BoneCPDataSource (shown in this SO question). But then you cannot use Hibernate.