Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring Instantiation Policy

The TopLink runtime instantiates new instances of a class according to the instantiation policy you configure on the class's descriptor.

Table 28-31 summarizes which descriptors support an instantiation policy.

Table 28-31 Descriptor Support for Instantiation Policy

Descriptor Using TopLink Workbench
Using Java

Relational Descriptors

Supported.


Supported.


Object-Relational Descriptors

Unsupported.


Supported.


EIS Descriptors

Supported.


Supported.


XML Descriptors

Supported.


Supported.



You can specify one of the following types of instantiation policy:

Using TopLink Workbench

To set the instantiation policy for a descriptor, use this procedure:

  1. In the Navigator, select a descriptor.

    If the Instantiation advanced property is not visible for the descriptor, right-click the descriptor and choose Select Advanced Properties > Instantiation from the context menu or from the Selected menu.

  2. Click the Instantiation tab.

    Figure 28-40 Instantiation Tab

    Sample Instantiation tab

Use the following information to enter data in each field on the tab:

Field Description
Use Default Constructor Specify if the default constructor of the class instantiates a new instance.
Use Method Specify a method to execute to create objects from the database.
    Method
Select the name of a method to be executed to create objects from the database. The method must be a public, static method on the descriptor's class and must return a new instance of the object.
Use Factory Specify an object factory method.
    Factory Class Select the class of the factory object that creates the new instances.
    Factory Method Select the method to be used to obtain a factory object. Choose <nothing> to use the default constructor.
    Instantiation Method Select the method to be called on the factory object to obtain a new instance that will be populated with data from the data source.

Using Java

Use one of the following ClassDescriptor methods to set the appropriate type of instantiation policy:

  • useDefaultConstructorInstantiationPolicy

  • useMethodInstantiationPolicy

  • useFactoryInstantiationPolicy