Domanda

I'm trying to configure Hibernate Search to use Infinispan as its directory provider, and also have the indexes persisted to a SQL database for clustering capabilities. I believe I have configured everything properly, however I do not see the SQL tables being created properly for Infinispan. I do not see any errors or messages in the logs indicating that the configuration is wrong, so I'm a bit stuck.

The relevant portion of my persistence.xml file looks like this:

    <!-- Hibernate Search properties - Infinispan -->
    <property name="hibernate.search.infinispan.cachemanager_jndiname"
        value="java:jboss/infinispan/container/hibernateSearch" />
    <property name="hibernate.search.default.directory_provider"
        value="infinispan" />
    <property name="hibernate.search.infinispan.chunk_size"
        value="300000000" />
    <property name="hibernate.search.reader.strategy" value="shared" />
    <property name="hibernate.search.worker.execution" value="sync" />
    <property name="hibernate.search.jmx_enabled" value="true" />

I have the following in my standalone-full.xml file on JBoss EAP 6.2:

    <cache-container name="hibernateSearch" default-cache="LuceneIndexesData" jndi-name="java:jboss/infinispan/hibernateSearch">
        <transport lock-timeout="60000"/>
        <replicated-cache name="LuceneIndexesMetadata" mode="SYNC"  >
            <binary-keyed-jdbc-store datasource="java:jboss/datasources/PicketLinkDatasource"
                      passivation="false" shared="true" purge="false">
                <property name="createTableOnStart" >true</property>
                <binary-keyed-table>
                    <id-column name="ID_COLUMN" type="VARCHAR(255)" />
                    <data-column name="DATUM" type="BLOB"/>
                </binary-keyed-table>
            </binary-keyed-jdbc-store>
        </replicated-cache>
        <replicated-cache name="LuceneIndexesData" mode="SYNC"  >
            <binary-keyed-jdbc-store datasource="java:jboss/datasources/PicketLinkDatasource"
                      passivation="false" shared="true" purge="false">
                <property name="createTableOnStart" >true</property>
                <binary-keyed-table>
                    <id-column name="ID_COLUMN" type="VARCHAR(255)" />
                    <data-column name="DATUM" type="BLOB"/>
                </binary-keyed-table>
            </binary-keyed-jdbc-store>
        </replicated-cache>
        <replicated-cache name="LuceneIndexesLocking" mode="SYNC"  >
            <binary-keyed-jdbc-store datasource="java:jboss/datasources/PicketLinkDatasource"
                      passivation="false" shared="true" purge="false">
                <property name="createTableOnStart" >true</property>
                <binary-keyed-table>
                    <id-column name="ID_COLUMN" type="VARCHAR(255)" />
                    <data-column name="DATUM" type="BLOB"/>
                </binary-keyed-table>
            </binary-keyed-jdbc-store>
        </replicated-cache>
    </cache-container>

I'm under the impression that a configuration like this would create the necessary SQL tables when the app server starts up. However, I do not see this as the case.

Am I doing something wrong here? Is there a step I am missing in my configuration?

È stato utile?

Soluzione

You're correct, the table creation would be triggered automatically on Cache start, however the Caches are started lazily by default. There is an EAGER start option:

<cache-container
    name="hibernateSearch"
    default-cache="LuceneIndexesData"
    jndi-name="java:jboss/infinispan/hibernateSearch"
    start="EAGER">

    <transport lock-timeout="60000" />

    <replicated-cache name="LuceneIndexesMetadata"
        mode="SYNC"
        start="EAGER">
        <binary-keyed-jdbc-store
            datasource="java:jboss/datasources/PicketLinkDatasource"
            shared="true"
            passivation="false"
            purge="false">
            <property name="createTableOnStart">true</property>
            <binary-keyed-table>
                <id-column name="ID_COLUMN" type="VARCHAR(255)" />
                <data-column name="DATUM" type="BLOB" />
            </binary-keyed-table>
        </binary-keyed-jdbc-store>
    </replicated-cache>

    <replicated-cache name="LuceneIndexesData"
        mode="SYNC"
        start="EAGER">
        <binary-keyed-jdbc-store
            datasource="java:jboss/datasources/PicketLinkDatasource"
            shared="true"
            passivation="false"
            purge="false">
            <property name="createTableOnStart">true</property>
            <binary-keyed-table>
                <id-column name="ID_COLUMN" type="VARCHAR(255)" />
                <data-column name="DATUM" type="BLOB" />
            </binary-keyed-table>
        </binary-keyed-jdbc-store>
    </replicated-cache>

    <replicated-cache name="LuceneIndexesLocking"
        mode="SYNC"
        start="EAGER" />

</cache-container>

I also removed the CacheStore for the LuceneIndexesLocking Cache as you shouldn't use one.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top