Configuration Reference - Tirasa/OpenJPA-Azure GitHub Wiki

This page shows all configuration parameters supported, in addition to the standard OpenJPA configuration.

General parameters

These mandatory parameters must be specified in order to trigger Azure-specific components in OpenJPA.

openjpa.BrokerFactory

Enables all Azure-specific OpenJPA components and additional configuration parameters.

openjpa.azure.Federations

List of federation names - as created in Azure - separated by comma.

This is the set of federations that will be involved in OpenJPA operations.

openjpa.azure.PerformUseFederation

Boolean flag to specify if "USE FEDERATION" statement is needed to connect to federations.

Default value is "false".

In this case "USE FEDERATION" statement should be performed by the datasource for each new created connection.

Usually this would be possible by specifying an connection initialization statement.

For example, tomcat's datasource factory (org.apache.tomcat.jdbc.pool.DataSourceFactory) permits to specify a connection initialization statement by providing the "initSQL" parameter.

Example:

<Resource name="jdbc/userfed0" auth="Container"
            type="javax.sql.DataSource"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            initSQL="USE FEDERATION UsersFed (range_id=0) WITH FILTERING=OFF, RESET"
            ....
/>

Slice parameters

A slice configuration must be provided.

Global Slice configuration

slice ref. guide

openjpa.slice.DistributionPolicy

Specify org.apache.openjpa.azure.AzureDistributionPolicy

openjpa.slice.QueryTargetPolicy

Specify org.apache.openjpa.azure.AzureQueryTargetPolicy

openjpa.slice.FinderTargetPolicy

Specify org.apache.openjpa.azure.AzureFinderTargetPolicy

openjpa.slice.ReplicationPolicy

Specify org.apache.openjpa.azure.AzureReplicationPolicy

Configure a slice per federation member plus the 'ROOT' slice

slice ref. guide

Configure each slice to link the root database.

Parameters to be specified for each declared federation

In the following:

  • [federation] is a placeholder for one of Azure federations declared in openjpa.azure.Federations
  • [table] is a placeholder for a SQL table

openjpa.azure.[federation].Tables

List of tables that will be managed in the given federation.

When not provided, OpenJPA will assume that all tables belong to the root database.

openjpa.azure.[federation].DistributionName

Distribution name used when the given federation was created; when not specified, defaults to range_id.

openjpa.azure.[federation].RangeMappingType

Range mapping type used when the given federation was created; accepted values:

  • BIGINT
  • INT
  • UNIQUEIDENTIFIER
  • VARBINAR

openjpa.azure.[federation].[table].RangeMappingName

If no value is provided for this parameter, [table] will be managed as reference table (see this for more information) and then replicated over each member of the given [federation].

If column name used for range mapping of the given [table] is specified here, [table] will be managed as federated table.

This parameter requires anyway that openjpa.azure.[federation].Tables value contains [table].


Working Example

      <property name="openjpa.BrokerFactory" value="azure"/>

      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true,SchemaAction='add')"/>
      
      <property name="openjpa.ConnectionURL" value="jdbc:sqlserver://XXXXXX"/>
      <property name="openjpa.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <property name="openjpa.ConnectionUserName" value="${jpa.username}"/>
      <property name="openjpa.ConnectionPassword" value="${jpa.password}"/>
      
      <property name="openjpa.jdbc.MappingDefaults" 
                value="ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict"/>
                  
      <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=TRACE, Tool=TRACE, SQL=TRACE"/>

      <!-- Federations -->
      <entry key="openjpa.azure.PerformUseFederation" value="true"/>

      <property name="openjpa.azure.Federations" value="FED_1, FED_2, FED_3, FED_4, FED_5" />
        
      <property name="openjpa.azure.FED_1.RangeMappingType" value="BIGINT" />
      <property name="openjpa.azure.FED_1.Tables" value="PersonBINT,BusinessRole,PObject" />
      <property name="openjpa.azure.FED_1.PersonBINT.RangeMappingName" value="id" />
      <property name="openjpa.azure.FED_1.BusinessRole.RangeMappingName" value="id" />
      <property name="openjpa.azure.FED_1.PObject.RangeMappingName" value="id" />
        
      <property name="openjpa.azure.FED_2.RangeMappingType" value="UNIQUEIDENTIFIER" />
      <property name="openjpa.azure.FED_2.Tables" value="PersonUID" />
      <property name="openjpa.azure.FED_2.PersonUID.RangeMappingName" value="code" />
        
      <property name="openjpa.azure.FED_3.RangeMappingType" value="INT" />
      <property name="openjpa.azure.FED_3.Tables" value="PersonINT" />
      <property name="openjpa.azure.FED_3.PersonINT.RangeMappingName" value="code" />
        
      <property name="openjpa.azure.FED_4.RangeMappingType" value="VERBINARY" />
      <property name="openjpa.azure.FED_4.Tables" value="PersonBIN" />
      <property name="openjpa.azure.FED_4.PersonBIN.RangeMappingName" value="code" />
      
      <property name="openjpa.azure.FED_5.RangeMappingType" value="BIGINT" />
      <property name="openjpa.azure.FED_5.Tables" value="PObject" />
      <property name="openjpa.azure.FED_5.PObject.RangeMappingName" value="id" />

      <property name="openjpa.slice.Master"  value="ROOT"/>
      <property name="openjpa.slice.Lenient" value="true"/>
      <property name="openjpa.slice.ReplicatedTypes" value="org.apache.openjpa.azure.beans.PObject"/>

      <property name="openjpa.slice.DistributionPolicy" value="org.apache.openjpa.azure.AzureDistributionPolicy"/>
      <property name="openjpa.slice.QueryTargetPolicy" value="org.apache.openjpa.azure.AzureQueryTargetPolicy"/>
      <property name="openjpa.slice.FinderTargetPolicy" value="org.apache.openjpa.azure.AzureFinderTargetPolicy"/>
      <property name="openjpa.slice.ReplicationPolicy" value="org.apache.openjpa.azure.AzureReplicationPolicy"/>

      <property name="openjpa.slice.ROOT.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.ROOT.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_1.0.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_1.0.ConnectionDriverName"  value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_1.1.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_1.1.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_2.0.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_2.0.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_2.1.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_2.1.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_3.0.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_3.0.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_3.1.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_3.1.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_4.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_4.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

      <property name="openjpa.slice.FED_5.ConnectionURL" value="jdbc:sqlserver://XXXXXX ... always the same"/>
      <property name="openjpa.slice.FED_5.ConnectionDriverName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>