Class TransformerBasedValueHolder<T>

java.lang.Object
org.eclipse.persistence.internal.indirection.DatabaseValueHolder<T>
org.eclipse.persistence.internal.indirection.TransformerBasedValueHolder<T>
All Implemented Interfaces:
Serializable, Cloneable, ValueHolderInterface<T>, WeavedAttributeValueHolderInterface<T>

public class TransformerBasedValueHolder<T> extends DatabaseValueHolder<T>
Since:
release specific (what release of product did this appear in) This class is to replace the MethodBasedValueHolder for TransformationMappings Holds on to an AttributeTransformer and uses it to generate the attribute value when triggered. That Transformer may be a MethodBasedAttributeTransformer or a user defined implementation.
Version:
$Header: TransformerBasedValueHolder.java 30-aug-2006.11:32:36 gyorke Exp $
See Also:
  • Field Details

    • transformer

      protected transient AttributeTransformer transformer
      Stores the method to be executed. The method can take one (the row) or two parameters (the row and session).
    • object

      protected transient Object object
      Stores the object which owns this attribute.
  • Constructor Details

    • TransformerBasedValueHolder

      public TransformerBasedValueHolder(AttributeTransformer theTransformer, Object theObject, AbstractRecord theRow, AbstractSession theSession)
      Initialize the method-based value holder.
      Parameters:
      theTransformer - The method that returns the object when executed.
      theObject - the Object which owns this attribute.
      theRow - The row representation of the object.
      theSession - The session to the database that stores the object.
  • Method Details

    • getTransformer

      protected AttributeTransformer getTransformer()
      Return the method.
    • getObject

      protected Object getObject()
      Return the receiver.
    • instantiate

      protected T instantiate() throws DescriptorException
      Instantiate the object by executing the method on the transformer.
      Specified by:
      instantiate in class DatabaseValueHolder<T>
      Throws:
      DescriptorException
    • instantiate

      protected T instantiate(Object object, AbstractSession session) throws DescriptorException
      Throws:
      DescriptorException
    • instantiateForUnitOfWorkValueHolder

      public T instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> unitOfWorkValueHolder)
      Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).

      When in transaction and/or for pessimistic locking the UnitOfWorkValueHolder needs to be triggered directly without triggering the wrapped valueholder. However only the wrapped valueholder knows how to trigger the indirection, i.e. it may be a batchValueHolder, and it stores all the info like the row and the query. Note: This method is not thread-safe. It must be used in a synchronized manner

      Specified by:
      instantiateForUnitOfWorkValueHolder in class DatabaseValueHolder<T>
    • isPessimisticLockingValueHolder

      public boolean isPessimisticLockingValueHolder()
      INTERNAL: Answers if this valueholder is a pessimistic locking one. Such valueholders are special in that they can be triggered multiple times by different UnitsOfWork. Each time a lock query will be issued. Hence even if instantiated it may have to be instantiated again, and once instantiated all fields can not be reset. Note: This method is not thread-safe. It must be used in a synchronized manner
      Specified by:
      isPessimisticLockingValueHolder in class DatabaseValueHolder<T>
    • setTransformer

      protected void setTransformer(AttributeTransformer theTransformer)
      Set the transformer.
    • setObject

      protected void setObject(Object theObject)
      Set the receiver.