Class EntityConverter

java.lang.Object
org.fastnate.generator.converter.EntityConverter
All Implemented Interfaces:
ValueConverter<Object>

public class EntityConverter extends Object implements ValueConverter<Object>
Converts the reference to an entity to an expression that uses the sequence value of that entity.
Author:
Tobias Liefke
  • Constructor Details

    • EntityConverter

      public EntityConverter()
  • Method Details

    • getEntityReference

      public static ColumnExpression getEntityReference(Object entity, String mappedId, GeneratorContext context, boolean whereExpression)
      Creates an expression for an entity.
      Parameters:
      entity - the entity
      mappedId - the property that contains the id, only interesting if the id is an EmbeddedProperty
      context - the current database context
      whereExpression - indicates that the reference is used in a "where" statement
      Returns:
      the expression using the sequence of that entity or null if the entity was not written up to now
    • getExpression

      public ColumnExpression getExpression(Object value, GeneratorContext context)
      Description copied from interface: ValueConverter
      Builds the expression for writing the given value into an SQL clause.
      Specified by:
      getExpression in interface ValueConverter<Object>
      Parameters:
      value - the current value
      context - the current context (contains the database dialect).
      Returns:
      the expression (that is including surrounding ' for string literals)