7.2. PersistenceManagerFactory Properties

Table of Contents

7.2.1. Connection Configuration
7.2.2. PersistenceManagerFactory and Transaction Defaults
7.2.3. PersistenceManager Pooling

The majority of the PersistenceManagerFactory interface consists of Java bean-style "getter" and "setter" methods for several properties, represented by field declarations in the diagram at the beginning of this chapter. These properties can be grouped into three functional categories: data store connection configuration, default PersistenceManager and Transaction options, and PersistenceManager pooling settings.

The lists below explain the meaning of each property. Many of these properties can be set through the Properties instance passed to the aforementioned getPersistenceManagerFactory method in JDOHelper. Where this is the case, the name of the corresponding Properties key will appear in parentheses after the property name.

7.2.1. Connection Configuration

Use the properties below to tell JDO implementations how to connect with your data store.

  • ConnectionUserName (javax.jdo.option.ConnectionUserName). The user name to specify when connecting to the data store.

  • ConnectionPassword (javax.jdo.option.ConnectionPassword). The password for the above user.

  • ConnectionURL (javax.jdo.option.ConnectionURL). The URL of the data store.

  • ConnectionDriverName (javax.jdo.option.ConnectionDriverName). The full class name of the driver to use when interacting with the data store.

  • ConnectionFactoryName (javax.jdo.option.ConnectionFactoryName). The JNDI location of a connection factory to use to obtain data store connections. This property overrides the other data store connection properties above.

  • ConnectionFactory . A connection factory to use to obtain data store connections. This property overrides all other data store connection properties above, including the ConnectionFactoryName. The exact type of the given factory is implementation-dependent. Many JDO implementations will expect a standard Java Connector Architecture (JCA) ConnectionFactory. Implementations layered on top of JDBC might expect a JDBC DataSource. Still other implementations might use other factory types.

  • ConnectionFactory2Name (javax.jdo.option.ConnectionFactory2Name). In a managed environment, connections obtained from the primary connection factory may be automatically enlisted in any global transaction in progress. To implement local transactions, the JDO implementation might require an additional connection factory that is not configured to participate in global transactions. The JNDI location of this factory can be specified through this property.

  • ConnectionFactory2 . The connection factory to use for local transactions. Overrides the ConnectionFactory2Name above.

Note

Kodo JDO uses JDBC DataSources in place of JCA ConnectionFactory objects.

7.2.2. PersistenceManagerFactory and Transaction Defaults

The settings below will become the default property values for the PersistenceManagers and associated Transactions produced by the PersistenceManagerFactory. Some implementations may not fully support all properties. If you attempt to set a property to an unsupported value, the operation will throw a JDOUnsupportedOptionException.

  • Multithreaded (javax.jdo.option.Multithreaded). Set this property to true to indicate that the persistence-capable instances managed by the PersistenceManager will be accessed concurrently by multiple threads.

  • Optimistic (javax.jdo.option.Optimistic). Set to true to use optimistic transactions by default.

  • RetainValues (javax.jdo.option.RetainValues). If this property is true, the fields of persistent objects will not be cleared on transaction commit. RetainValues automatically implies NontransactionalRead.

  • RestoreValues (javax.jdo.option.RestoreValues). Controls the behavior of persistent and transactional fields on transaction rollback. Set this property to true to restore the fields to the values they had when the transaction began.

  • NontransactionalRead (javax.jdo.option.NontransactionalRead). Specifies whether you can read persistent fields outside of a transaction. If this property is false, any attempt to read a persistent field outside of a transaction will result in a JDOUserException.

  • NontransactionalWrite (javax.jdo.option.NontransactionalWrite). Specifies whether you can write to persistent fields outside of a transaction. If this property is false, any attempt to modify a persistent field outside of a transaction will result in a JDOUserException.

  • IgnoreCache (javax.jdo.option.IgnoreCache). This property controls whether changes made to persistent instances in the current transaction are considered when evaluating queries. A value of true is a hint to the JDO runtime that changes in the current transaction can be ignored; this usually enables the implementation to run the query using the data store's native query interface. A value of false, on the other hand, may force implementations to run transactional queries in memory, which is often a slow process.

Note

Kodo JDO supports all PersistenceManager and Transaction properties. It recognizes many additional properties as well; see the Kodo JDO Reference Guide for details.

7.2.3. PersistenceManager Pooling

The following properties apply to the PersistenceManagerFactory's pooling of PersistenceManagers. Implementations are free to ignore these property settings if they do not support PersistenceManager pooling.

  • MaxPool (javax.jdo.option.MaxPool). The maximum number of PersistenceManagers to allow in the pool.

  • MinPool (javax.jdo.option.MinPool). The minimum number of PersistenceManagers to allow in the pool.

  • MsWait (javax.jdo.option.MsWait). The number of milliseconds to wait for a free PersistenceManager before giving up.

Note

Kodo JDO applies these settings to its automatic connection pooling; it does not pool PersistenceManagers.