Question


I am in a rather nasty situation. We use compass for Hibernate search integration with Lucene and have implemented database directory search (using JdbcDirectory) instead of FSDirectoryProvider, RAMDirectoryProvider etc.

The problem is that the directory provider is passed as a property inside the META-INF/persistence.xml like the one below:

<property name="hibernate.search.default.directory_provider" value="uk.company.package.JdbcDirectoryProvider" />

We need to pass the database details to the the JdbcDirectoryProvider as JdbcDirectory requires a datasource to be passed.

We are constructing the datasource (for the directory provider) in an unconventional way using a property file (in the class path) with the database and index details.

If we have uk.company.JdbcDirectoryProvider configured as a spring bean, we can inject the datasource. This works well with Tomcat but not with OAS or Weblogic as still as we are passing the directory_provider in the persistence.xml. Probably becasue the datasource is initialized by the spring (becasue of the way classloaders work in these app servers).

My question is how can we configure the hibernate.search.default.directory_provider directly inside aSpring bean instead of the persistence.xml?

The closest place is:

<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

But it only takes three properties:

<property name="showSql" value="true" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />

Solution

You could pass the hibernate properties in spring bean as jpaProperties

<property name="jpaProperties">
    <props>
       <prop key="hibernate.search.default.directory_provider">
       uk.company.package.JdbcDirectoryProvider
     </prop>
    </props>
</property>
Was it helpful?

Solution

I found the solution.

You could pass the hibernate properties in spring bean as jpaProperties

<property name="jpaProperties">
    <props>
       <prop key="hibernate.search.default.directory_provider">
       uk.company.package.JdbcDirectoryProvider
     </prop>
    </props>
</property>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top