Kodojdo Guide Chapter 7

xiaoxiao2021-03-06  81

Chapter VII PersistenceManagerFactory

PersistenceManagerFactory creates a PersistenceManager instance for use. It allows you to configure data connections

And specify the default settings for the PersistenceManager created. You can also learn the JDO options you support your current manufacturer through our programming.

Make you can optimize your programs using all the features of the product.

7.1. Get PersistenceManagerFactory

JDO vendors implement the public constructor when implementing the PersistenceManagerFactory, but it is recommended that you use JDOHELPER.

GetPersistenceManagerFactory method to get a PersistenceManagerFactory method. This method's property parameter

For the factory configuration information. The PersistenceManagerFactory object returned from getPersistenceManagerFactory is "

Frozen ", trying to change its attribute settings to cause JDOUSEREXCEPTION. This is because the returned factory may come from connecting pools, and other applications

The program is a shared share. JDO requires the specific PersistenceManagerFactory class to implement the serializable interface. This allows you to create and configure

PersistenceManagerFactory, then serialize to the file or store it from the JNDI tree to remove and use.

7.2. PersistenceManagerFactory properties

Most PersistenceManagerFactory interfaces contain java bean style Getter and setter methods to read and set properties

These properties can be divided into two categories according to functions: data connection configuration, default persistent managers and transaction options.

The following sections describe each property, many can be set by passing the attribute parameters to the getPersistenceManagerFactory method.

This is a situation. The configuration code of the property is listed after the method declaration.

7.2.1. Connection Configuration Use the following properties to tell JDO how to connect your database

1) Specify the username of the data connection

2) Specify the password of the data connection

3) Data connection URL

4) Data connection drive class name

5) Connecting the plant's JNDI position to obtain a data connection. This property overrides the data connection properties listed above.

The connection factory can get a connection. This property covers all other data connection properties, including the connection factory name. The exact type of the factory is the harmony

Body achievement related, many JDO implementation requires standard Java connector system connection factories (JCA). JDO requirements implemented on the JDBC layer give JDBC

Data sources, other implementations will use other factory types.

In an controlled environment, the connection obtained from the main connection plant will automatically join any global affairs. JDO will ask another

Not configured to participate in the connection factories for global transactions. For example, KODO default data storage identity generates an algorithm requires a self-tube transaction.

The plant's JNDI location can be specified in this property.

7.2.2. Default PersistenceManager and transaction

The following settings will be the default attribute value of the transaction generated by the PersistenceManagerStenceManagerFactory. One

Some implementations may not support all of these properties, if you set values ​​that do not support attributes, it will cause JDOUNSUNSUPPORTEDOPTIONEXCEPTION

1) Set this property to true. In your program, PersistenceManagers and the possible persistent classes it managed can be multi-threaded.

Access. If the property is set to False, then some JDO implementations will optimize performance by avoiding synchronization.

2) The default is true to use the optimized transaction. In the chapter of the transaction, we will discuss the optimal transaction.

3) If this attribute value is true, then after the transaction is submitted, the field value of the lasting object will not be emptied. Otherwise, the lasting field will be emptied, under

When you visit them, they will read values ​​from the database.

4) Manage the behavior of the lasting transaction field when the transaction is rolled. If set to true, then their values ​​will be set to the value when the transaction does not start.

5) Specify whether it is in the transaction out of persistent status. If the property is false, any enumeration extent, execute an inquiry or access non-main button

Behaviors will cause jdouserexception6) Specify whether it is in the transaction's proximity. If set to false, any modified persistent field behavior outside the transaction will result in

JDOUSEREXCEPTION Note The changes outside the transaction will not store the database. When the modified object is changed, change it immediately after entering the transaction.

7) This property controls whether or not to consider a lasting instance when performing a query. Set to true, it means that the current transaction can be ignored. This is usually made

Real arts can use the local interface of the database to perform a query. If set to false, the JDO saves the data before performing the query, or

Transactional inquiry. Both will affect performance.

7.3. Get PersistenceManagers

The PersistenceManagerFactory interface contains two getPersistenceManager methods. A version takes a username and password

Set the data connection of the PersistenceManager, another no-argument, depend on the connection user name and connection of PersistenceManagerFactory

Take a pass code. Both methods return a newly constructed PersistenceManager object or a PersistenceManager instance that returns the connection pool.

.

After getting the first persistenceManager from PersistenceManagerFactory, the factory configuration enters the "frozen" state.

What is changed to attributes causes JDOUSEREXCEPTION. Vendorname: JDO manufacturer

VersionNumber: Product version number

The SupportedOptions Method Returns a Collection of Strings Enumerating The JDO

Options supported by the importation. The Following Option Names Are Recognized:

In addition to supporting PersistenceManagers, PersistenceManagerFactory also supports metadata of current JDO implementation

.getproperties method Returns a property object with at least the following keyword value:

Vendorname: JDO Manufacturer VersionNumber: Product version number

The SupportedOptions method returns a string collection that enumerates the configuration options supported by the JDO implementation. The following option name is recognized:

javax.jdo.option.TransientTransactional javax.jdo.option.NontransactionalRead javax.jdo.option.NontransactionalWrite javax.jdo.option.RetainValues ​​javax.jdo.option.Optimistic javax.jdo.option.ApplicationIdentity javax.jdo.option.DatastoreIdentity javax .jdo.option.NonDurableIdentity javax.jdo.option.ArrayList javax.jdo.option.HashMap javax.jdo.option.Hashtable javax.jdo.option.LinkedList javax.jdo.option.TreeMap javax.jdo.option.TreeSet javax. JDO.Option.Vector javax.jdo.option.map javax.jdo.option.list javax.jdo.Option.Array javax.jdo.Option.NullCollection javax.jdo.Option.changeApplicationIdentity javax.jdo.Query.jdoql

KODO supports Javax.jdo.Option.changeApplicationIdentity and

转载请注明原文地址:https://www.9cbs.com/read-95055.html

New Post(0)