Skip Headers

# Configuring Container Policy

Previous

Next

Collection mapping container policy specifies the concrete class TopLink should use when reading target objects from the database.

Collection mappings can use any concrete class that implements the `java.util.List`, `java.util.Set`, `java.util.Collection`, or `java.util.Map` interface. You can map object attributes declared as `List`, `Set`, `Collection`, `Map`, or any subinterface of these interfaces, or as a class that implements one of these interfaces.

By default, the TopLink runtime uses the following concrete classes from the `oracle.toplink.indirection` package for each of these container types:

- `List`–`IndirectList` or `EJBIndirectList`

- `Set`–`IndirectSet` or `EJBIndirectSet`

- `Collection`–`IndirectList` or `EJBIndirectList`

- `Map`–`IndirectMap` or `EJBIndirectMap`

Alternatively, you can 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. For example, TopLink does not sort in memory. If you want to sort in memory, override the default `Set` type (`IndirectList`) with `java.util.TreeSet` as the concrete collection type. By default, a collection mapping's container class is `java.util.Vector`.

Note: If you are using TopLink Workbench and you override the default `Collection` class with a custom `Collection` class of your own, you must put your custom `Collection` class on the TopLink Workbench classpath (see "Configuring the TopLink Workbench Environment").

Table: Mapping Support for Container Policy summarizes which mappings support this option.

Mapping Support for Container Policy

Mapping | List | Set | Collection | Map | Using TopLink Workbench | Using Java
--- | --- | --- | --- | --- | --- | ---
Relational Mappings |  |  |  |  |  |
One-to-Many Mapping |  |  |  |  |  |
Many-to-Many Mapping |  |  |  |  |  |
Aggregate Collection Mapping |  |  |  |  |  |
Direct Collection Mapping |  |  |  |  |  |
Direct Map Mapping |  |  |  |  |  |
Object-Relational Mappings |  |  |  |  |  |
Object-Relational Array Mapping |  |  |  |  |  |
Object-Relational Object Array Mapping |  |  |  |  |  |
Object-Relational Nested Table Mapping |  |  |  |  |  |
EIS Mappings |  |  |  |  |  |
EIS Composite Direct Collection Mapping |  |  |  |  |  |
EIS Composite Collection Mapping |  |  |  |  |  |
EIS One-to-Many Mapping |  |  |  |  |  |
XML Mappings |  |  |  |  |  |
XML Composite Direct Collection Mapping |  |  |  |  |  |
XML Composite Collection Mapping |  |  |  |  |  |
XML Any Collection Mapping |  |  |  |  |  |