cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a solution to store heavy variable's id not serialized bytes

quaff
Champ in-the-making
Champ in-the-making
I have found many serialized entity in act_ge_bytearray, actually I'm using FormType for converting between id and entity,why not just store formType and id instead of serialized bytes?
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
Sure. Take a look at the VariableType interface. This allows you to plug in any conversion from POJO of type X to the DB-representation (ValueFields) of a variable and the other way around, depending on the "type_" in the DB:


public interface VariableType {

  /**
   * name of variable type (limited to 100 characters length)
   */
  String getTypeName();
 
  /**
   * <p>Indicates if this variable type supports caching.</p>
   * <p>If caching is supported, the result of {@link #getValue(ValueFields)} is saved for the
   *    duration of the session and used for subsequent reads of the variable's value.</p>
   * <p>If caching is not supported, all reads of a variable's value require a
   *    fresh call to {@link #getValue(ValueFields)}.</p>
   * @return whether variables of this type are cacheable.
   */
  boolean isCachable();
 
  /**
   * @return whether this variable type can store the specified value.
   */
  boolean isAbleToStore(Object value);
 
  /**
   * Stores the specified value in the supplied {@link ValueFields}.
   */
  void setValue(Object value, ValueFields valueFields);
 
  /**
   * @return the value of a variable based on the specified {@link ValueFields}.
   */
  Object getValue(ValueFields valueFields);

}

An example of such an implementation is the JpaEntityVariableType, which only stores the ID and the classname in the DB. When the variable is needed, the type will be called and a correct JPA entity instance is fetched based on that ID and classname to be used in the engine.

Just plug in your custom variable type in the processEngineConfiguration and you're good to go…

quaff
Champ in-the-making
Champ in-the-making
thanks,It's very useful. I think BigDecimal should be supported by activiti officially.
maybe enum type should be supported too,use textValue store name and textValue2 store enum type.

quaff
Champ in-the-making
Champ in-the-making

jbarrez
Star Contributor
Star Contributor
Thanks, we'll look at it shortly.