org.apache.openjpa.jdbc.meta.strats
Class HandlerHandlerMapTableFieldStrategy

java.lang.Object
  extended by org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
      extended by org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
          extended by org.apache.openjpa.jdbc.meta.strats.ContainerFieldStrategy
              extended by org.apache.openjpa.jdbc.meta.strats.MapTableFieldStrategy
                  extended by org.apache.openjpa.jdbc.meta.strats.HandlerHandlerMapTableFieldStrategy
All Implemented Interfaces:
Serializable, FieldStrategy, Strategy, LRSMapFieldStrategy

public class HandlerHandlerMapTableFieldStrategy
extends MapTableFieldStrategy

Mapping for a map of keys and values both controlled by ValueHandlers.

Since:
0.4.0, 1.1.0
Author:
Abe White
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
field
 
Constructor Summary
HandlerHandlerMapTableFieldStrategy()
           
 
Method Summary
 Column[] getKeyColumns(ClassMapping cls)
          Return the columns holding data for a map key for the given key mapping from LRSMapFieldStrategy.getIndependentKeyMappings(boolean) or LRSMapFieldStrategy.getIndependentValueMappings(boolean) (or null).
 Result[] getResults(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, Joins[] joins, boolean lrs)
          Return results containing all keys and values for this map.
 Column[] getValueColumns(ClassMapping cls)
          Return the columns holding data for a map value for the given value mapping from LRSMapFieldStrategy.getIndependentKeyMappings(boolean) or LRSMapFieldStrategy.getIndependentValueMappings(boolean) (or null).
 void initialize()
          Perform caching and other initialization operations.
 void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set values for the mapping into the proper rows.
 Joins joinKeyRelation(Joins joins, boolean forceOuter, boolean traverse)
          Join this value's table to the table for the related first class object key type, if any.
 Joins joinRelation(Joins joins, boolean forceOuter, boolean traverse)
          Join this value's table to the table for the related first class object type, if any.
 Object loadKey(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
          Load a key from the given result.
 Object loadValue(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)
          Load a value from the given result.
 void map(boolean adapt)
          Map the owning mapping using this strategy.
 void selectKey(Select sel, ClassMapping cls, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins)
          Implement this method to select the keys of this field.
 void selectValue(Select sel, ClassMapping cls, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins)
          Implement this method to select the values of this field.
 Object toDataStoreValue(Object val, JDBCStore store)
          Translate the given external field value to its datastore equivalent.
 Object toKeyDataStoreValue(Object val, JDBCStore store)
          Translate the given key value to its datastore equivalent.
 void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
          Set values for the mapping into the proper rows.
 
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.MapTableFieldStrategy
delete, deriveKey, deriveValue, getFieldMapping, getIndependentElementMappings, getIndependentKeyMappings, getIndependentValueMappings, getJoinForeignKey, getJoinForeignKey, handleMappedByForeignKey, isTypeUnjoinedSubclass, join, joinKey, joinKeyRelation, joinValueRelation, load, loadKeyProjection, loadProjection, populateKey, supportsSelect
 
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.ContainerFieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendJoinCount, appendSize, appendUnaliasedJoin
 
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy
appendType, assertNotMappedBy, isEagerSelectToMany, isVersionable, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, where
 
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, getAlias, isCustomDelete, isCustomInsert, isCustomUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.jdbc.meta.FieldStrategy
appendIndex, appendIsEmpty, appendIsNotEmpty, appendIsNotNull, appendIsNull, appendSize, appendType, isEagerSelectToMany, isVersionable, load, loadEagerJoin, loadEagerParallel, select, selectEagerJoin, selectEagerParallel, setFieldMapping, where
 
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, getAlias, isCustomDelete, isCustomInsert, isCustomUpdate
 

Constructor Detail

HandlerHandlerMapTableFieldStrategy

public HandlerHandlerMapTableFieldStrategy()
Method Detail

getKeyColumns

public Column[] getKeyColumns(ClassMapping cls)
Description copied from interface: LRSMapFieldStrategy
Return the columns holding data for a map key for the given key mapping from LRSMapFieldStrategy.getIndependentKeyMappings(boolean) or LRSMapFieldStrategy.getIndependentValueMappings(boolean) (or null).


getValueColumns

public Column[] getValueColumns(ClassMapping cls)
Description copied from interface: LRSMapFieldStrategy
Return the columns holding data for a map value for the given value mapping from LRSMapFieldStrategy.getIndependentKeyMappings(boolean) or LRSMapFieldStrategy.getIndependentValueMappings(boolean) (or null).


selectKey

public void selectKey(Select sel,
                      ClassMapping cls,
                      OpenJPAStateManager sm,
                      JDBCStore store,
                      JDBCFetchConfiguration fetch,
                      Joins joins)
Description copied from interface: LRSMapFieldStrategy
Implement this method to select the keys of this field. Elements of the result will be loaded with LRSMapFieldStrategy.loadKey(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins). This method is only used if the key is not derived from the value.


selectValue

public void selectValue(Select sel,
                        ClassMapping cls,
                        OpenJPAStateManager sm,
                        JDBCStore store,
                        JDBCFetchConfiguration fetch,
                        Joins joins)
Description copied from interface: LRSMapFieldStrategy
Implement this method to select the values of this field. Elements of the result will be loaded with LRSMapFieldStrategy.loadValue(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins).


getResults

public Result[] getResults(OpenJPAStateManager sm,
                           JDBCStore store,
                           JDBCFetchConfiguration fetch,
                           int eagerMode,
                           Joins[] joins,
                           boolean lrs)
                    throws SQLException
Description copied from interface: LRSMapFieldStrategy
Return results containing all keys and values for this map. If only one result is needed, set both array indexes to the same result instance. Also fill in the key and value joins in the given array. The results will be loaded with the LRSMapFieldStrategy.loadKey(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins) or LRSMapFieldStrategy.deriveKey(org.apache.openjpa.jdbc.kernel.JDBCStore, java.lang.Object) and LRSMapFieldStrategy.loadValue(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, org.apache.openjpa.jdbc.sql.Result, org.apache.openjpa.jdbc.sql.Joins) methods.

Throws:
SQLException

loadKey

public Object loadKey(OpenJPAStateManager sm,
                      JDBCStore store,
                      JDBCFetchConfiguration fetch,
                      Result res,
                      Joins joins)
               throws SQLException
Description copied from interface: LRSMapFieldStrategy
Load a key from the given result. This method is only used if the key is not derived from the value.

Throws:
SQLException

loadValue

public Object loadValue(OpenJPAStateManager sm,
                        JDBCStore store,
                        JDBCFetchConfiguration fetch,
                        Result res,
                        Joins joins)
                 throws SQLException
Description copied from interface: LRSMapFieldStrategy
Load a value from the given result.

Throws:
SQLException

map

public void map(boolean adapt)
Description copied from interface: Strategy
Map the owning mapping using this strategy.

Specified by:
map in interface Strategy
Overrides:
map in class MapTableFieldStrategy
Parameters:
adapt - if true, use the owning mapping's raw mapping info to set its ORM data; if false, ORM data will already be set

initialize

public void initialize()
Description copied from interface: Strategy
Perform caching and other initialization operations. This method is called after Strategy.map(boolean), and after all related components have been mapped as well.

Specified by:
initialize in interface Strategy
Overrides:
initialize in class AbstractStrategy

insert

public void insert(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set values for the mapping into the proper rows. For class mappings, this method will be called only after the corresponding method has been called for all fields of this mapping.

Specified by:
insert in interface Strategy
Overrides:
insert in class AbstractStrategy
Throws:
SQLException

update

public void update(OpenJPAStateManager sm,
                   JDBCStore store,
                   RowManager rm)
            throws SQLException
Description copied from interface: Strategy
Set values for the mapping into the proper rows.

Specified by:
update in interface Strategy
Overrides:
update in class AbstractStrategy
Throws:
SQLException
See Also:
Strategy.insert(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.sql.RowManager)

toDataStoreValue

public Object toDataStoreValue(Object val,
                               JDBCStore store)
Description copied from interface: FieldStrategy
Translate the given external field value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

Specified by:
toDataStoreValue in interface FieldStrategy
Overrides:
toDataStoreValue in class AbstractFieldStrategy

toKeyDataStoreValue

public Object toKeyDataStoreValue(Object val,
                                  JDBCStore store)
Description copied from interface: FieldStrategy
Translate the given key value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

Specified by:
toKeyDataStoreValue in interface FieldStrategy
Overrides:
toKeyDataStoreValue in class AbstractFieldStrategy

joinRelation

public Joins joinRelation(Joins joins,
                          boolean forceOuter,
                          boolean traverse)
Description copied from interface: FieldStrategy
Join this value's table to the table for the related first class object type, if any. Does nothing by default.

Specified by:
joinRelation in interface FieldStrategy
Overrides:
joinRelation in class AbstractFieldStrategy
traverse - if true, throw proper exception if it is not possible for this mapping to traverse into the related type

joinKeyRelation

public Joins joinKeyRelation(Joins joins,
                             boolean forceOuter,
                             boolean traverse)
Description copied from interface: FieldStrategy
Join this value's table to the table for the related first class object key type, if any. Does nothing by default.

Specified by:
joinKeyRelation in interface FieldStrategy
Overrides:
joinKeyRelation in class AbstractFieldStrategy
traverse - if true, throw proper exception if it is not possible for this mapping to traverse into the related type


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.