Class DbEntity

    • Field Detail

      • catalog

        protected String catalog
      • schema

        protected String schema
      • qualifier

        protected Expression qualifier
        Qualifier, that will be applied to all select queries and joins with this DbEntity
    • Constructor Detail

      • DbEntity

        public DbEntity()
        Creates an unnamed DbEntity.
      • DbEntity

        public DbEntity​(String name)
        Creates a named DbEntity.
    • Method Detail

      • getRelationship

        public DbRelationship getRelationship​(String relName)
        Description copied from class: Entity
        Returns relationship with name relName. Will return null if no relationship with this name exists in the entity.
        getRelationship in class Entity
      • getAttribute

        public DbAttribute getAttribute​(String attributeName)
        Description copied from class: Entity
        Returns attribute with name attributeName or null if no attribute with this name exists.
        getAttribute in class Entity
      • getFullyQualifiedName

        public String getFullyQualifiedName()
        Returns table name including catalog and schema, if any of those are present.
      • getSchema

        public String getSchema()
        Returns database schema of this table.
        table's schema, null if not set.
      • setSchema

        public void setSchema​(String schema)
        Sets the database schema name of the table described by this DbEntity.
      • getCatalog

        public String getCatalog()
        Returns the catalog name of the table described by this DbEntity.
      • setCatalog

        public void setCatalog​(String catalog)
        Sets the catalog name of the table described by this DbEntity.
      • getPrimaryKeys

        public List<DbAttribute> getPrimaryKeys()
        Returns an unmodifiable collection of DbAttributes representing the primary key of the table described by this DbEntity.
      • getGeneratedAttributes

        public Collection<DbAttribute> getGeneratedAttributes()
        Returns an unmodifiable collection of DbAttributes that are generated by the database.
      • addAttribute

        public void addAttribute​(DbAttribute attr)
        Adds a new attribute to this entity.
        IllegalArgumentException - if Attribute has no name or there is an existing attribute with the same name
        IllegalArgumentException - if a relationship has the same name as this attribute
      • removeAttribute

        public void removeAttribute​(String attrName)
        Removes attribute from the entity, removes any relationship joins containing this attribute. Does nothing if the attribute name is not found.
        removeAttribute in class Entity
        See Also:
      • resolvePathComponents

        public Iterator<CayenneMapEntry> resolvePathComponents​(Expression pathExp)
                                                        throws ExpressionException
        Description copied from class: Entity
        Processes expression pathExp and returns an Iterator of path components that contains a sequence of Attributes and Relationships. Note that if path is invalid and can not be resolved from this entity, this method will still return an Iterator, but an attempt to read the first invalid path component will result in ExpressionException.
        Specified by:
        resolvePathComponents in class Entity
      • setPrimaryKeyGenerator

        public void setPrimaryKeyGenerator​(DbKeyGenerator primaryKeyGenerator)
        Set the primary key generator for this entity. If null is passed, nothing is changed.
      • getPrimaryKeyGenerator

        public DbKeyGenerator getPrimaryKeyGenerator()
        Return the primary key generator for this entity.
      • dbEntityChanged

        public void dbEntityChanged​(EntityEvent e)
        DbEntity property changed event. May be name, attribute or relationship added or removed, etc. Attribute and relationship property changes are handled in respective listeners.
        Specified by:
        dbEntityChanged in interface DbEntityListener
      • getQualifier

        public Expression getQualifier()
        qualifier that will be ANDed to all select queries with this entity
      • setQualifier

        public void setQualifier​(Expression qualifier)
        Sets qualifier for this entity
      • isFullReplacementIdAttached

        public boolean isFullReplacementIdAttached​(ObjectId id)
        Returns true if there is full replacement id is attached to an ObjectId. "Full" means that all PK columns are present and only PK columns are present.
      • translateToRelatedEntity

        public Expression translateToRelatedEntity​(Expression expression,
                                                   String relationshipPath)
        Transforms Expression rooted in this entity to an analogous expression rooted in related entity.
        Specified by:
        translateToRelatedEntity in class Entity