Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.openjpa.jdbc.meta.strats
Class AbstractFieldStrategy

    java.lang.Object
      org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
          org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy

All Implemented Interfaces:
  FieldStrategy, Strategy

Direct Known Subclasses:
  ContainerFieldStrategy, EmbedFieldStrategy, HandlerFieldStrategy, MaxEmbeddedBlobFieldStrategy, MaxEmbeddedByteArrayFieldStrategy, MaxEmbeddedCharArrayFieldStrategy, MaxEmbeddedClobFieldStrategy, NoneFieldStrategy, PrimitiveFieldStrategy, RelationFieldStrategy, StringFieldStrategy

    public abstract class AbstractFieldStrategy

extends AbstractStrategy
implements FieldStrategy

No-op strategy for easy extension.

Author:
  Abe White

Field Summary
`protected FieldMapping` | `field` The owning field mapping.

Constructor Summary
`AbstractFieldStrategy()`

Method Summary
`void` | `appendIsEmpty(SQLBuffer sql, Select sel, Joins joins)` Append a where clause to the given statement checking if this value is empty.
`void` | `appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins)` Append a where clause to the given statement checking if this value is not empty.
`void` | `appendIsNotNull(SQLBuffer sql, Select sel, Joins joins)` Append a where clause to the given statement checking if this value is not null.
`void` | `appendIsNull(SQLBuffer sql, Select sel, Joins joins)` Append a where clause to the given statement checking if this value is null.
`void` | `appendSize(SQLBuffer sql, Select sel, Joins joins)` Append a where clause to the given statement checking the size of the value.
`protected void` | `assertNotMappedBy()` Throws an informative exception if the field declares a mapped-by value.
`boolean` | `isEagerSelectToMany()` Whether the eager joins or selects used by this field are to-many.
`boolean` | `isVersionable()` Return true if this field can be used as part of a state image for optimistic locking.
`Joins` | `join(Joins joins, boolean forceOuter)` Join this value to the class table.
`Joins` | `joinKey(Joins joins, boolean forceOuter)` Join the key value to the class table.
`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.
`void` | `load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)` Load secondary data using a connection from the store manager.
`void` | `load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)` Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.
`void` | `loadEagerJoin(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Result res)` Load the joined eager result.
`Object` | `loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res)` Load the batched eager result.
`Object` | `loadKeyProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)` Load this field's key value using the given result.
`Object` | `loadProjection(JDBCStore store, JDBCFetchConfiguration fetch, Result res, Joins joins)` Load this field value using the given result.
`int` | `select(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)` Select the virtual row columns of this mapping.
`void` | `selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)` Fill in joined select to related objects.
`void` | `selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode)` Fill in parallel eager select for related objects.
`void` | `setFieldMapping(FieldMapping owner)` Set the class mapping using this strategy.
`int` | `supportsSelect(Select sel, int type, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch)` Return whether this mapping can perform the given select type.
`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` | `where(OpenJPAStateManager sm, JDBCStore store, RowManager rm, Object prevValue)` Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value.

Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
`customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, map, update`

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.Strategy
`customDelete, customInsert, customUpdate, delete, getAlias, initialize, insert, isCustomDelete, isCustomInsert, isCustomUpdate, map, update`

Field Detail

### field

    protected FieldMapping field

  The owning field mapping.

Constructor Detail

### AbstractFieldStrategy

    public AbstractFieldStrategy()

Method Detail

### assertNotMappedBy

    protected void assertNotMappedBy()

  Throws an informative exception if the field declares a mapped-by value.

### setFieldMapping

    public void setFieldMapping(FieldMapping owner)

  Description copied from interface: `FieldStrategy`
  Set the class mapping using this strategy. This will be called before use.

  Specified by:
    `setFieldMapping` in interface `FieldStrategy`

### supportsSelect

    public int supportsSelect(Select sel,
                              int type,
                              OpenJPAStateManager sm,
                              JDBCStore store,
                              JDBCFetchConfiguration fetch)

  Description copied from interface: `FieldStrategy`
  Return whether this mapping can perform the given select type. Return 0 if the given type is not supported. If the given type is an eager parallel type, return the number of UNIONed selects necessary to fetch the data. Otherwise, return any positive number if the type is supported. The given state manager may be null if selecting multiple instances.

  Specified by:
    `supportsSelect` in interface `FieldStrategy`
  See Also:
    `Select`

### selectEagerJoin

    public void selectEagerJoin(Select sel,
                                OpenJPAStateManager sm,
                                JDBCStore store,
                                JDBCFetchConfiguration fetch,
                                int eagerMode)

  Description copied from interface: `FieldStrategy`
  Fill in joined select to related objects.

  Specified by:
    `selectEagerJoin` in interface `FieldStrategy`
  See Also:
    `FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)`

### selectEagerParallel

    public void selectEagerParallel(SelectExecutor sel,
                                    OpenJPAStateManager sm,
                                    JDBCStore store,
                                    JDBCFetchConfiguration fetch,
                                    int eagerMode)

  Description copied from interface: `FieldStrategy`
  Fill in parallel eager select for related objects.

  Specified by:
    `selectEagerParallel` in interface `FieldStrategy`
  See Also:
    `FieldStrategy.select(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int)`

### isEagerSelectToMany

    public boolean isEagerSelectToMany()

  Description copied from interface: `FieldStrategy`
  Whether the eager joins or selects used by this field are to-many.

  Specified by:
    `isEagerSelectToMany` in interface `FieldStrategy`

### select

    public int select(Select sel,
                      OpenJPAStateManager sm,
                      JDBCStore store,
                      JDBCFetchConfiguration fetch,
                      int eagerMode)

  Description copied from interface: `FieldStrategy`
  Select the virtual row columns of this mapping.

  Specified by:
    `select` in interface `FieldStrategy`
  Parameters:
    `sel` - the select to add to
    `sm` - the instance being loaded, or null if not initialized yet or selecting for multiple instances
    `store` - the current store manager
    `fetch` - fetch configuration
    `eagerMode` - the eager fetch mode to use; this may be more restrictive than the mode of the fetch configuration
  Returns:
    > 0 if this mapping requires the selected data (if any), 0 if it selected data but does not require it, or < 0 if no data was selected

### loadEagerParallel

    public Object loadEagerParallel(OpenJPAStateManager sm,
                                    JDBCStore store,
                                    JDBCFetchConfiguration fetch,
                                    Object res)
                             throws SQLException

  Description copied from interface: `FieldStrategy`
  Load the batched eager result.

  Specified by:
    `loadEagerParallel` in interface `FieldStrategy`
    `res` - originally the `Result` to load from, but this method may return a processed result form that will be passed to subsequent calls
  Throws:
    `SQLException`

### loadEagerJoin

    public void loadEagerJoin(OpenJPAStateManager sm,
                              JDBCStore store,
                              JDBCFetchConfiguration fetch,
                              Result res)
                       throws SQLException

  Description copied from interface: `FieldStrategy`
  Load the joined eager result.

  Specified by:
    `loadEagerJoin` in interface `FieldStrategy`
  Throws:
    `SQLException`

### load

    public void load(OpenJPAStateManager sm,
                     JDBCStore store,
                     JDBCFetchConfiguration fetch,
                     Result res)
              throws SQLException

  Description copied from interface: `FieldStrategy`
  Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.

  Specified by:
    `load` in interface `FieldStrategy`
  Throws:
    `SQLException`

### load

    public void load(OpenJPAStateManager sm,
                     JDBCStore store,
                     JDBCFetchConfiguration fetch)
              throws SQLException

  Description copied from interface: `FieldStrategy`
  Load secondary data using a connection from the store manager.

  Specified by:
    `load` in interface `FieldStrategy`
  Throws:
    `SQLException`

### 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`

### 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`

### appendIsEmpty

    public void appendIsEmpty(SQLBuffer sql,
                              Select sel,
                              Joins joins)

  Description copied from interface: `FieldStrategy`
  Append a where clause to the given statement checking if this value is empty. Appends impossible-to-satisfy SQL by default.

  Specified by:
    `appendIsEmpty` in interface `FieldStrategy`

### appendIsNotEmpty

    public void appendIsNotEmpty(SQLBuffer sql,
                                 Select sel,
                                 Joins joins)

  Description copied from interface: `FieldStrategy`
  Append a where clause to the given statement checking if this value is not empty. Appends always-satisfied SQL by default.

  Specified by:
    `appendIsNotEmpty` in interface `FieldStrategy`

### appendIsNull

    public void appendIsNull(SQLBuffer sql,
                             Select sel,
                             Joins joins)

  Description copied from interface: `FieldStrategy`
  Append a where clause to the given statement checking if this value is null.

  Specified by:
    `appendIsNull` in interface `FieldStrategy`

### appendIsNotNull

    public void appendIsNotNull(SQLBuffer sql,
                                Select sel,
                                Joins joins)

  Description copied from interface: `FieldStrategy`
  Append a where clause to the given statement checking if this value is not null.

  Specified by:
    `appendIsNotNull` in interface `FieldStrategy`

### appendSize

    public void appendSize(SQLBuffer sql,
                           Select sel,
                           Joins joins)

  Description copied from interface: `FieldStrategy`
  Append a where clause to the given statement checking the size of the value.

  Specified by:
    `appendSize` in interface `FieldStrategy`

### join

    public Joins join(Joins joins,
                      boolean forceOuter)

  Description copied from interface: `FieldStrategy`
  Join this value to the class table. Does nothing by default.

  Specified by:
    `join` in interface `FieldStrategy`

### joinKey

    public Joins joinKey(Joins joins,
                         boolean forceOuter)

  Description copied from interface: `FieldStrategy`
  Join the key value to the class table. Does nothing by default.

  Specified by:
    `joinKey` in interface `FieldStrategy`

### 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`
    `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`
    `traverse` - if true, throw proper exception if it is not possible for this mapping to traverse into the related type

### loadProjection

    public Object loadProjection(JDBCStore store,
                                 JDBCFetchConfiguration fetch,
                                 Result res,
                                 Joins joins)
                          throws SQLException

  Description copied from interface: `FieldStrategy`
  Load this field value using the given result. The result will contain the columns from `ValueMapping.getColumns()`.

  Specified by:
    `loadProjection` in interface `FieldStrategy`
  Throws:
    `SQLException`

### loadKeyProjection

    public Object loadKeyProjection(JDBCStore store,
                                    JDBCFetchConfiguration fetch,
                                    Result res,
                                    Joins joins)
                             throws SQLException

  Description copied from interface: `FieldStrategy`
  Load this field's key value using the given result. The result will contain the columns from `ValueMapping.getColumns()`.

  Specified by:
    `loadKeyProjection` in interface `FieldStrategy`
  Throws:
    `SQLException`

### isVersionable

    public boolean isVersionable()

  Description copied from interface: `FieldStrategy`
  Return true if this field can be used as part of a state image for optimistic locking.

  Specified by:
    `isVersionable` in interface `FieldStrategy`

### where

    public void where(OpenJPAStateManager sm,
                      JDBCStore store,
                      RowManager rm,
                      Object prevValue)
               throws SQLException

  Description copied from interface: `FieldStrategy`
  Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value. Only versionable mappings must implement this method meaningfully.

  Specified by:
    `where` in interface `FieldStrategy`
  Throws:
    `SQLException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 Apache Software Foundation. All Rights Reserved.