When I used Hibernate
itself, I could've done something like Main.getSession().get(User.class, 1);
where getSession()
would call openSession()
from the session factory. but how can I do the same with HikariDataSource
? Wiki mentioned something about HikariConnectionProvider
but no example was given.
@Bean
public DataSource dataSource() throws SQLException {
if (dbUrl == null || dbUrl.isEmpty()) {
return new HikariDataSource();
} else {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(dbUrl);
return new HikariDataSource(config);
}
}