Class EntityWhereString

java.lang.Object
org.apache.ofbiz.entity.condition.EntityWhereString
All Implemented Interfaces:
Serializable, IsEmpty, EntityCondition

public final class EntityWhereString extends Object implements EntityCondition
Represents a raw SQL string condition expression.

Encapsulates SQL expressions used for where clause snippets. NOTE: This is UNSAFE and BREAKS the idea behind the Entity Engine where you avoid directly specifying SQL. So, KEEP IT MINIMAL and preferably replace it when the feature you are getting at is implemented in a more automatic way for you.

By minimal I mean use this in conjunction with other EntityConditions like the EntityExpr, EntityConditionList and EntityFieldMap objects which more cleanly encapsulate where conditions and don't require you to directly write SQL.

See Also:
  • Constructor Details

    • EntityWhereString

      public EntityWhereString(String sqlString)
      Constructs a raw SQL string condition expression.
      Parameters:
      sqlString - the raw SQL to embed in a condition expression
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IsEmpty
    • makeWhereString

      public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo)
      Description copied from interface: EntityCondition
      Dumps the corresponding SQL string.
      Specified by:
      makeWhereString in interface EntityCondition
      Parameters:
      modelEntity - the model of the entity
      entityConditionParams - the effective parameters used to substitute '?' parameters
      datasourceInfo - the model of the data source interpreting the SQL
      Returns:
      the corresponding SQL string
    • checkCondition

      public void checkCondition(ModelEntity modelEntity) throws GenericModelException
      Description copied from interface: EntityCondition
      Verifies that this condition expression is valid.
      Specified by:
      checkCondition in interface EntityCondition
      Parameters:
      modelEntity - the model of the entity
      Throws:
      GenericModelException - when this condition expression is not valid
    • entityMatches

      public boolean entityMatches(GenericEntity entity)
      Description copied from interface: EntityCondition
      Checks that this condition expression matches a particular entity.
      Specified by:
      entityMatches in interface EntityCondition
      Parameters:
      entity - the entity to match
      Returns:
      true if this condition expression matches entity
    • mapMatches

      public boolean mapMatches(Delegator delegator, Map<String,? extends Object> map)
      Description copied from interface: EntityCondition
      Checks that this condition expression matches a particular entity.
      Specified by:
      mapMatches in interface EntityCondition
      Parameters:
      delegator - the delegator used to match
      map - the entity definition to match
      Returns:
      true if this condition expression matches map when using delegator
    • getWhereString

      public String getWhereString()
      Provides access to the embedded raw SQL string.
      Returns:
      the corresponding SQL string
    • freeze

      public EntityCondition freeze()
      Description copied from interface: EntityCondition
      Create a Frozen condition expression corresponding to this condition expression.
      Specified by:
      freeze in interface EntityCondition
      Returns:
      the frozen condition expression
    • accept

      public void accept(EntityConditionVisitor visitor)
      Description copied from interface: EntityCondition
      Applies a visitor to this condition.
      Specified by:
      accept in interface EntityCondition
      Parameters:
      visitor - the visitor to be applied
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object