7.5.1.4. Configuration example
Below is an example of a JDBC CacheLoader using Oracle as database. The CacheLoaderConfiguration XML element contains an arbitrary set of properties which define the database-related configuration.
<attribute name="CacheLoaderConfiguration">
<config>
<passivation>false</passivation>
<preload>/some/stuff</preload>
<cacheloader>
<class>org.jboss.cache.loader.JDBCCacheLoader</class>
<!-- same as the old CacheLoaderConfig attribute -->
<properties>
cache.jdbc.table.name=jbosscache
cache.jdbc.table.create=true
cache.jdbc.table.drop=true
cache.jdbc.table.primarykey=jbosscache_pk
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=varchar(255)
cache.jdbc.node.column=node
cache.jdbc.node.type=blob
cache.jdbc.parent.column=parent
cache.jdbc.driver=oracle.jdbc.OracleDriver
cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
cache.jdbc.user=SCOTT
cache.jdbc.password=TIGER
</properties>
<!-- whether the cache loader writes are asynchronous -->
<async>false</async>
<!-- only one cache loader in the chain may set fetchPersistentState to true.
An exception is thrown if more than one cache loader sets this to true.
-->
<fetchPersistentState>true</fetchPersistentState>
<!-- determines whether this cache loader ignores writes - defaults to false.
-->
<ignoreModifications>false</ignoreModifications>
<!-- if set to true, purges the contents of this cache loader when the cache
starts up. Defaults to false. -->
<purgeOnStartup>false</purgeOnStartup>
</cacheloader>
</config>
</attribute>
As an alternative to configuring the entire JDBC connection, the name of an existing data source can be given:
<attribute name="CacheLoaderConfiguration">
<config>
<passivation>false</passivation>
<preload>/some/stuff</preload>
<cacheloader>
<class>org.jboss.cache.loader.JDBCCacheLoader</class>
<!-- same as the old CacheLoaderConfig attribute -->
<properties>
cache.jdbc.datasource=java:/DefaultDS
</properties>
<!-- whether the cache loader writes are asynchronous -->
<async>false</async>
<!-- only one cache loader in the chain may set fetchPersistentState to true.
An exception is thrown if more than one cache loader sets this to true.
-->
<fetchPersistentState>true</fetchPersistentState>
<!-- determines whether this cache loader ignores writes - defaults to false.
-->
<ignoreModifications>false</ignoreModifications>
<!-- if set to true, purges the contents of this cache loader when the cache
starts up. Defaults to false. -->
<purgeOnStartup>false</purgeOnStartup>
</cacheloader>
</config>
</attribute>