Hello,
Is is possible to make getVendorProperties() public?
Because if you do something like in https://docs.spring.io/spring-data/jpa/reference/repositories/create-instances.html#jpa.java-config it is not possible to access these vendorProperties like it is done in JpaBaseConfiguration#entityManagerFactory()
Comment From: wilkinsona
I'm not sure that I see the connection between your question and the Spring Data JPA documentation to which you've linked. JpaBaseConfiguration
is a base class for auto-configuration of JPA infrastructure. There are no public concrete sub-classes of JpaBaseConfiguration
so you'll have to sub-class it anyway. At that point, you could make your implementation of getVendorProperties()
public if you wish.
Comment From: bmaehr
Subclassing of HibernateJpaConfuguration is only possible in that package because it is protected. That is what I have done until now.
My suggestion would allow this:
@Bean("authEntityManagerFactory")
@Primary
public LocalContainerEntityManagerFactoryBean authEntityManagerFactory(
@Qualifier("authDataSource") final DataSource dataSource,
final EntityManagerFactoryBuilder builder,
final JpaBaseConfiguration jpaConfiguration) {
final Map<String, Object> properties = new HashMap<>();
final Map<? extends String, ? extends Object> vendorProperties = jpaConfiguration.getVendorProperties();
properties.putAll(vendorProperties);
final LocalContainerEntityManagerFactoryBean result = builder //
.dataSource(dataSource) //
.properties(properties) //
.packages(...) //
.persistenceUnit("auth") //
.build();
return result;
}
Comment From: philwebb
We don't consider auto-configuration classes as public API and as such I don't think injecting and using them directly is a good idea. I think once you’re at the point of declaring your own LocalContainerEntityManagerFactoryBean
, you should set the properties you need directly.