Working with a Container Policy

A container policy specifies the concrete class TopLink should use when reading target objects from the database. You can specify a container policy for collection mappings (DirectCollectionMapping, OneToManyMapping, and ManyToManyMapping) and for read-all queries (ReadAllQuery).

Starting with JDK 1.2, the collection mappings can use any concrete class that implements either the java.util.Collection interface or the java.util.Map interface.

When using TopLink with JDK 1.2 (or later), you can map object attributes declared as Collection or Map, or any subinterface of these two interfaces, or as a class that implements one of these two interfaces. You must specify in the mapping the concrete container class to be used. When TopLink reads objects from the database that contain an attribute mapped with a collection mapping, the attribute is set with an instance of the concrete class specified. By default, a collection mapping's container class is java.util.Vector.

Read-all queries also require a container policy to specify how the result objects are to be returned. The default container is java.util.Vector.

Container policies cannot be used to specify a custom container class when using indirect containers.

 

Copyright © 1997, 2004, Oracle. All rights reserved.