我正在尝试将Hibernate Search配置为使用Infinispan作为其目录提供程序,并且还将索引持久保存到SQL数据库以用于群集功能。我相信我已经正确配置了所有内容,但是我没有看到为Infinispan正确创建的SQL表。我没有在日志中看到任何错误或消息,表明配置错误,所以我有点卡住了。
我的persistence.xml文件的相关部分如下所示:
<!-- 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" />
我在JBoss EAP 6.2上的standalone-full.xml文件中有以下内容:
<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>
我认为这样的配置会在应用服务器启动时创建必要的SQL表。但是,我不认为这种情况。
我在这里做错了吗?我的配置中是否缺少一个步骤?
答案 0 :(得分:2)
你是对的,表创建将在Cache启动时自动触发,但默认情况下缓存启动缓存。有一个EAGER启动选项:
<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>
我还删除了 LuceneIndexesLocking 缓存的CacheStore,因为你不应该使用它。