javaspringhibernatec3p0

Hibernate 6.0.0.Alpha9 cannot resolve c3p0 DriverManagerDataSource


I have been experimenting with updating Hibernate to 6.0.0 Alpha9 version from Hibernate 5 when I got the message that both hibernate-core and hibernate-c3p0 are being relocated from org.hibernate to org.hibernate.orm. But as I do that in my Spring MVC configuration class import com.mchange.v2.c3p0.DriverManagerDataSource; becomes unresolved. Was it removed from the new version or do I need to use something else instead?

I currently use it as a DataSource for Spring Security and Liquibase:

    @Bean(name = "dataSource")
    public DriverManagerDataSource dataSource() {
        DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
        driverManagerDataSource.setDriverClass( dataSourceDriverClass );
        driverManagerDataSource.setJdbcUrl( dataSourceUrl );
        driverManagerDataSource.setUser( dataSourceUsername );
        driverManagerDataSource.setPassword( dataSourcePassword );
        return driverManagerDataSource;
    }

Solution

  • The dependency structure seems to have changed i.e. the dependency is not exposed transitively anymore. You will have to add an explicit dependency api 'com.mchange:c3p0:0.9.5.5' or

    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.5</version>
    </dependency>