Class EntityProperty<E extends Persistent>

java.lang.Object
org.apache.cayenne.exp.property.BaseProperty<E>
org.apache.cayenne.exp.property.EntityProperty<E>
All Implemented Interfaces:
PathProperty<E>, Property<E>, RelationshipProperty<E>
Direct Known Subclasses:
SelfProperty

public class EntityProperty<E extends Persistent> extends BaseProperty<E> implements RelationshipProperty<E>
Property that represents to-one relationships.

Usage examples in where clause:

ObjectSelect.query(Paintings.class)
     .where(Painting.TO_ARTIST.dot(Artist.ARTIST_NAME).eq("Pablo Picasso"));

Usage examples in column select, in this case full Artist entity will be returned as the result:

ObjectSelect
     .columnQuery(Paintings.class, Painting.PAINTING_TITLE, Painting.TO_ARTIST);
Since:
4.2
See Also:
  • Constructor Details

  • Method Details

    • eqId

      public Expression eqId(Object id)
    • inId

      @Deprecated(since="5.0", forRemoval=true) public Expression inId(Collection<Object> ids)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • idsInCollection

      public Expression idsInCollection(Collection<?> ids)
      Parameters:
      ids - to use for "IN" expression
      Returns:
      IN expression comparing path represented by this property with provided ids
      Since:
      5.0
    • inId

      @Deprecated(since="5.0", forRemoval=true) public Expression inId(Object firstId, Object... moreIds)
      Deprecated, for removal: This API element is subject to removal in a future version.
      in favour of idsIn(Object...)
    • idsIn

      public Expression idsIn(Object... ids)
      Parameters:
      ids - to use for "IN" expression
      Returns:
      IN expression comparing path represented by this property with provided ids
      Since:
      5.0
    • neqId

      public Expression neqId(Object id)
    • ninId

      @Deprecated(since="5.0", forRemoval=true) public Expression ninId(Collection<Object> ids)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • idsNotInCollection

      public Expression idsNotInCollection(Collection<?> ids)
      Parameters:
      ids - collection of IDs to use for "NOT IN" expression
      Returns:
      NOT IN expression comparing path represented by this property with provided IDs
      Since:
      5.0
    • ninId

      @Deprecated(since="5.0", forRemoval=true) public Expression ninId(Object firstId, Object... moreIds)
      Deprecated, for removal: This API element is subject to removal in a future version.
      in favour of idsNotIn(Object...)
    • idsNotIn

      public Expression idsNotIn(Object... ids)
      Parameters:
      ids - to use for "NOT IN" expression
      Returns:
      NOT IN expression comparing path represented by this property with provided ids
      Since:
      5.0
    • eqIdMap

      public Expression eqIdMap(Map<String,?> id)
      Matches an object by a possibly compound id, expressed as a map of DB attribute names to values. Unlike eqId(Object) this form supports entities with a compound PK.
      Parameters:
      id - a map of the target entity PK attribute names to values
      Returns:
      an expression matching an object with the given id
      Since:
      5.0
    • neqIdMap

      public Expression neqIdMap(Map<String,?> id)
      Parameters:
      id - a map of the target entity PK attribute names to values
      Returns:
      an expression excluding an object with the given id
      Since:
      5.0
      See Also:
    • idMapsIn

      @SafeVarargs public final Expression idMapsIn(Map<String,?>... ids)
      Matches any of the objects identified by the provided ids. Unlike idsIn(Object...) this form supports entities with a compound PK, expanding to an OR of per-id matches rather than an IN, as SQL IN can't be applied to a multi-column key.
      Parameters:
      ids - maps of the target entity PK attribute names to values
      Since:
      5.0
      See Also:
    • idMapsInCollection

      public Expression idMapsInCollection(Collection<Map<String,?>> ids)
      Parameters:
      ids - maps of the target entity PK attribute names to values
      Since:
      5.0
      See Also:
    • objectIdsIn

      public Expression objectIdsIn(ObjectId... ids)
      Matches any of the objects identified by the provided ObjectIds. Unlike idsIn(Object...) this form supports entities with a compound PK.
      Since:
      5.0
      See Also:
    • objectIdsInCollection

      public Expression objectIdsInCollection(Collection<ObjectId> ids)
      Since:
      5.0
      See Also:
    • alias

      public EntityProperty<E> alias(String alias)
      Description copied from class: BaseProperty
      Creates alias with different name for this property
      Overrides:
      alias in class BaseProperty<E extends Persistent>
    • outer

      public EntityProperty<E> outer()
      Description copied from interface: RelationshipProperty
      Returns a version of this property that represents an OUTER join.
      Specified by:
      outer in interface RelationshipProperty<E extends Persistent>
    • enclosing

      public EntityProperty<E> enclosing()
      Description copied from class: BaseProperty
      This operator allows to access properties of the enclosing query from the subquery. It allows multiple nesting levels to access a corresponding query in case of multiple levels of subqueries. Example:
      ObjectSelect.query(Artist.class)
                      .where(ExpressionFactory.notExists(ObjectSelect.query(Painting.class)
                              .where(Painting.TO_ARTIST.eq(Artist.ARTIST_ID_PK_PROPERTY.enclosing()))))
      
      
      Overrides:
      enclosing in class BaseProperty<E extends Persistent>
      Returns:
      property that will be translated relative to parent query