JBoss Community Archive (Read Only)

ModeShape 5

Database persistence

Stores the repository content in a relational database, via JDBC as BLOB instances.

This is the only persistence store in ModeShape 5 which supports clustering

Description

The list of tested RDBMS contains: Postgres 9.x, H2 1.4.x, MySQL 5.x and Oracle 11. When using a particular database, make you have the appropriate driver in your runtime classpath and this driver is at least JDBC 4 compliant.

If you're not using a JNDI-bound datasource, you need to make sure that the drivers you use are JDBC 4 compliant

The support is fairly generic for each RDBMS type, so versions other than the listed ones may also work. We encourage users to give it a try and if any issues come up, discuss them in our community. Also, regardless of the database vendor used, make sure the DB is configured to use READ_COMMITTED isolation be default.

Depending on the configuration (see below) ModeShape can integrate with an existing data source in order to obtain the DB connections or can manage the DB connections on its own, using the Hikari connection pool.

Configuration

Starting with 5.1.0.Final, the datasourceJNDI and datasource-jndi attributes have been renamed to dataSourceJndiName and data-source-jndi-name respectively to match the datasource attributes present in other configuration areas.

At its simplest, the configuration looks like:

JSON

JSON configuration
{
    "name" : "Test repo",
    "storage" : {
        "persistence" : {
            "type" : "db",
            "connectionUrl": "jdbc:h2:file:./target/clustered/db;AUTO_SERVER=TRUE",
            "driver" : "org.h2.Driver"
        }
    }
}

The following is the full list of attributes supported by this store in the JSON configuration:

Name

Required

Description

connectionUrl

yes (unless DS JNDI is defined)

the JDBC connection url

driver

yes (unless DS JNDI is defined)

the fully qualified name of the JDBC driver

username

no

the name of the user for the JDBC connection. Defaults to sa

password

no

the password of the user for the JDBC connection. Defaults to an empty string

datasourceJNDI

yes (unless connectionUrl and driver are defined)

the name of a datasource which is JNDI bound

tableName

no

the name of DB table where data will be store. Defaults to MODESHAPE_REPOSITORY

createOnStart

no

whether the DB table should be created on startup if it does not exist. Defaults to TRUE

dropOnExit

no

whether the DB table should be dropped when the repository terminates. Defaults to FALSE

compress

no

whether the stored BLOBs should be compressed. Defaults to FALSE

fetchSize

no

the JDBC statement fetchSize. Defaults to 1000

poolSize

no

the size of the JDBC connection pool, when this is managed by ModeShape. Defaults to 50

JBoss AS

JBoss AS configuration
  <repository name="sample">
     <db-persistence datasource-jndi="java:jboss/datasources/ModeshapeSampleDS"/>
  </repository>

When using Wildfly datasources with ModeShape, make sure to set the jta=false attribute on the datasource, because ModeShape has to be able to control the datasource transactions.

The following is the full list of attributes supported by this store in the JBoss AS configuration:

Name

Required

Description

url

yes (unless DS JNDI is defined)

the JDBC connection url

driver

yes (unless DS JNDI is defined)

the fully qualified name of the JDBC driver

username

no

the name of the user for the JDBC connection. Defaults to sa

password

no

the password of the user for the JDBC connection. Defaults to an empty string

datasource-jndi

yes (unless url and driver are defined)

the name of a datasource which is JNDI bound

table-name

no

the name of DB table where data will be store. Defaults to MODESHAPE_REPOSITORY

create-on-start

no

whether the DB table should be created on startup if it does not exist. Defaults to TRUE

drop-on-exit

no

whether the DB table should be dropped when the repository terminates. Defaults to FALSE

compress

no

whether the stored BLOBs should be compressed. Defaults to FALSE

fetch-size

no

the JDBC statement fetchSize. Defaults to 1000

pool-size

no

the size of the JDBC connection pool, when this is managed by ModeShape. Defaults to 50

Advanced Hikari configuration

When using a non-managed datasource (i.e. a datasource that is not bound in JNDI and managed by a server), you can pass any custom configuration options from your ModeShape configuration directly to Hikari:

JSON configuration
 "storage" : {
        "persistence" : {
            "type" : "db", 
            "minimumIdle" : 4,
            "leakDetectionThreshold" : 4000,
            "maximumPoolSize" : 5,
            "readOnly" : false,
            "poolName" : "testPool"
         }
 }

Any of attributes names from the HikariConfig class are valid as long as they have primitive types (including String)

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:12:42 UTC, last content change 2017-03-21 08:57:26 UTC.