$entity

( documentation for Telosys generator version 4.0.0 )


Entity class for the current generation

Provides all information available for an entity as defined in the model :
. attributes information (class fields)
. database mapping


Since : 2.0.0

Attributes and methods
.attributes : List of 'attribute' objects

Returns all the attributes defined for this entity

Example :
   $entity.attributes

.attributesCount : int

Returns the number of attributes defined for this entity

Example :
   $entity.attributesCount

Since : 2.0.7

.attributesNamesAsString(String separator) : String

Returns all the attributes names as a string.
The attributes names are separated by the given separator

Parameters :
   separator : the separator to be put between each attribute name

Example :
   $entity.attributesNamesAsString('/')

Since : 3.0.0

.attributesNamesAsString(String separator, String prefix, String suffix) : String

Returns all the attributes names as a string.
The attributes names are separated by the given separator
with a prefix/suffix for each attribute name

Parameters :
   separator : the separator to be put between each attribute name
   prefix : the prefix to be put before each attribute name
   suffix : the prefix to be put after each attribute name

Example :
   $entity.attributesNamesAsString('/', '{{', '}}')

Since : 3.0.0

.autoincrementedKeyAttribute : 'attribute' object

Returns the attribute used as the autoincremented key
or null if none


Example :
   #if ( $entity.hasAutoIncrementedKey() )
   $entity.autoincrementedKeyAttribute
   #end

.context : String

Returns the 'context' to which the entity belongs

Example :
   $entity.context

Since : 3.4.0

.databaseCatalog : String

Returns the 'database catalog' of the table mapped with this entity

Example :
   $entity.databaseCatalog

.databaseComment : String

Returns the 'database comment' for the table mapped with this entity

Example :
   $entity.databaseComment

Since : 3.1.0

.databaseForeignKeys : List of 'foreign keys' objects

Returns all the database foreign keys defined for this entity

Example :
   $entity.databaseForeignKeys

Since : 2.0.7

.databaseForeignKeysCount : int

Returns the number of database foreign keys defined for this entity

Example :
   $entity.databaseForeignKeysCount

Since : 2.0.7

.databaseSchema : String

Returns the 'database schema' of the table mapped with this entity

Example :
   $entity.databaseSchema

.databaseTable : String

Returns the 'database table name' mapped with this entity in the model
or an empty string if no table is specified in the model

Example :
   $entity.databaseTable

.databaseTablespace : String

Returns the 'database tablespace'

Example :
   $entity.databaseTablespace

Since : 3.4.0

.databaseType : String

Returns the real database type for the table mapped with this entity
('TABLE' or 'VIEW')

Example :
   $entity.databaseType

Since : 2.0.7

.domain : String

Returns the 'domain' to which the entity belongs

Example :
   $entity.domain

Since : 3.4.0

.fullName : String

Returns the full class name for the entity (ie : "my.package.MyClass" )

Example :
   $entity.fullName

.getAttributeByColumnName(String columnName) : 'attribute' object

Returns the attribute associated with the given database column name

Parameters :
   columnName : the database column's name

Example :
   $entity.attributeByColumnName

.getAttributeByName(String ?) : AttributeInContext


Parameters :
   ? :

.getAttributeWithName(String ?) : AttributeInContext


Parameters :
   ? :

.getAttributesByCriteria(int crit1, int crit2, int crit3, int crit4) : List of 'attribute' objects

Returns all the attributes of this entity matching the given criteria
This method accepts 1 to 4 criteria
The critera are combined using the 'AND' operator
Usable criteria ( to be prefixed with '$const.' ) :
KEY, NOT_KEY, IN_LINKS, NOT_IN_LINKS, IN_SELECTED_LINKS, NOT_IN_SELECTED_LINKS, TEXT, NOT_TEXT

Parameters :
   crit1 : 1st criterion
   crit2 : 2nd criterion (optional)
   crit3 : 3rd criterion (optional)
   crit4 : 4th criterion (optional)

Example :
   $entity.getAttributesByCriteria($const.NOT_KEY)
   $entity.getAttributesByCriteria($const.NOT_KEY, $const.NOT_IN_SELECTED_LINKS)

.hasAttribute(String ?) : boolean


Parameters :
   ? :

.hasAutoIncrementedKey() : boolean

Returns TRUE if this entity has an 'auto-incremented' key attribute
( a key based on a numeric value incremented by the database )

Example :
   #if ( $entity.hasAutoIncrementedKey() )
   ...
   #end

.hasCollections() : boolean

Returns TRUE if this entity has at least one collection

Example :
   #if ( $entity.hasCollections() )
   ...
   #end

Since : 3.4.0

.hasCompositePrimaryKey() : boolean

Returns TRUE if this entity has a composite primary key
( a primary key composed of 2 or more attributes )

Example :
   #if ( $entity.hasCompositePrimaryKey() )
   ...
   #end

.hasContext() : boolean

Returns TRUE if the entity belongs to a 'context'

Example :
   #if ( $entity.hasContext() )
   ...
   #end

Since : 3.4.0

.hasDatabaseCatalog() : boolean

Returns TRUE if the entity has a 'database catalog' explicitly defined in the model

Example :
   #if ( $entity.hasDatabaseCatalog() )
   ...
   #end

Since : 3.4.0

.hasDatabaseComment() : boolean

Returns TRUE if the entity has a 'database comment' explicitly defined in the model

Example :
   #if ( $entity.hasDatabaseComment() )
   ...
   #end

Since : 3.4.0

.hasDatabaseSchema() : boolean

Returns TRUE if the entity has a 'database schema' explicitly defined in the model

Example :
   #if ( $entity.hasDatabaseSchema() )
   ...
   #end

Since : 3.4.0

.hasDatabaseTable() : boolean

Returns TRUE if this entity has a 'database table name' explicitly defined in the model

Example :
   #if ( $entity.hasDatabaseTable() )
   ...
   #end

Since : 3.4.0

.hasDatabaseTablespace() : boolean

Returns TRUE if the entity has a 'database tablespace' explicitly defined in the model

Example :
   #if ( $entity.hasDatabaseTablespace() )
   ...
   #end

Since : 3.4.0

.hasDomain() : boolean

Returns TRUE if the entity belongs to a 'domain'

Example :
   #if ( $entity.hasDomain() )
   ...
   #end

Since : 3.4.0

.hasForeignKeys() : boolean

Returns TRUE if this entity has at least one Foreign Key

Example :
   #if ( $entity.hasForeignKeys() )
   ...
   #end

Since : 3.4.0

.hasLinks() : boolean

Returns TRUE if this entity has at least one link

Example :
   #if ( $entity.hasLinks() )
   ...
   #end

.hasPrimaryKey() : boolean

Returns TRUE if this entity has a primary key
( a primary key composed of one or more attributes )

Example :
   #if ( $entity.hasPrimaryKey() )
   ...
   #end

Since : 2.0.7

.hasSuperClass() : boolean

Returns TRUE if the entity has a 'super class' (if its class extends another class)

Example :
   #if ( $entity.hasSuperClass() )
   ...
   #end

Since : 3.4.0

.hasTag(String tagName) : boolean

Returns TRUE if a tag is defined with the given name

Parameters :
   tagName : name of the tag for which to check the existence

Example :
   $enity.hasTag('mytag')

Since : 3.4.0

.hasTextAttribute() : boolean

Returns TRUE if this entity has at least one attribute tagged as 'long text'

Example :
   #if ( $entity.hasTextAttribute() )
   ...
   #end

.isAbstract() : boolean

Returns TRUE if the entity class is abstract

Example :
   #if ( $entity.isAbstract() )
   ...
   #end

Since : 3.4.0

.isAggregateRoot() : boolean

Returns TRUE if the entity is an 'aggregate root'

Example :
   #if ( $entity.isAggregateRoot() )
   ...
   #end

Since : 3.4.0

.isDatabaseView() : boolean

Returns TRUE if the entity data comes from a 'database view'

Example :
   #if ( $entity.isDatabaseView() )
   ...
   #end

Since : 3.4.0

.isInMemoryRepository() : boolean

Returns TRUE if entity occurrences are stored in memory ( in a 'in-memory repository' )

Example :
   #if ( $entity.isInMemoryRepository() )
   ...
   #end

Since : 3.4.0

.isJoinEntity() : boolean

Returns TRUE if the entity is a 'join entity'
( typically if the entity is a 'join table' in the database )
An entity is considered as a 'join entity' if :
- the entity has 2 Foreign Keys
- all attributes are part of the Primary Key
- all attributes are part of a Foreign Key

Example :
   #if ( $entity.isJoinEntity() )
   ...
   #end

Since : 3.3.0

.isReadOnly() : boolean

Returns TRUE if the entity occurrences are 'read only'

Example :
   #if ( $entity.isReadOnly() )
   ...
   #end

Since : 3.4.0

.isTableType() : boolean

Returns TRUE if the database type of the entity is 'TABLE'
(it can be a TABLE or a VIEW, see also 'isViewType')

Example :
   #if ( $entity.isTableType() )
   ...
   #end

Since : 2.0.7

.isViewType() : boolean

Returns TRUE if the database type of the entity is 'VIEW'
(it can be a TABLE or a VIEW, see also 'isTableType')

Example :
   #if ( $entity.isViewType() )
   ...
   #end

Since : 2.0.7

.keyAttribute : Instance of 'attribute'

Returns the unique attribute used as the Primary Key for this entity.
Throws an exception if the entity does not have a Primary Key
or if it has a composite Primary Key (2 or more attributes)

Example :
   $entity.keyAttribute

Since : 3.0.0

.keyAttributes : List of 'attribute' objects

Returns the attributes used in the Primary Key for this entity

Example :
   #foreach( $attribute in $entity.keyAttributes )
   ...
   #end

.keyAttributesCount : int

Returns the number of attributes used in the Primary Key for this entity

Example :
   $entity.keyAttributesCount

Since : 2.0.7

.keyAttributesNamesAsString(String separator) : String

Returns the key attributes names as a string.
The attributes names are separated by the given separator
with a prefix/suffix for each attribute name

Parameters :
   separator : the separator to be put between each attribute name

Example :
   $entity.keyAttributesNamesAsString('/')

Since : 2.1.0

.keyAttributesNamesAsString(String separator, String prefix, String suffix) : String

Returns the key attributes names as a string.
The attributes names are separated by the given separator
with a prefix/suffix for each attribute name

Parameters :
   separator : the separator to be put between each attribute name
   prefix : the prefix to be put before each attribute name
   suffix : the prefix to be put after each attribute name

Example :
   $entity.keyAttributesNamesAsString('/', '{{', '}}')

Since : 2.1.0

.links : List of 'link' objects

Returns a list of all the links defined for the current entity

Example :
   #foreach( $link in $entity.links )
   ...
   #end

.linksCount : int

Returns the number of links defined in the entity

Example :
   $entity.linksCount

Since : 3.3.0

.name : String

Returns the entity class name without the package ( ie : "MyClass" )

Example :
   $entity.name

.nonKeyAttributes : List of 'attribute' objects

Returns the attributes NOT used in the Primary Key for this entity

Example :
   #foreach( $attribute in $entity.nonKeyAttributes )
   ...
   #end

.nonKeyAttributesCount : int

Returns the number of attributes NOT used in the Primary Key for this entity

Example :
   $entity.nonKeyAttributesCount

Since : 2.0.7

.nonKeyAttributesNamesAsString(String separator) : String

Returns the 'non key' attributes names as a string.
The attributes names are separated by the given separator

Parameters :
   separator : the separator to be put between each attribute name

Example :
   $entity.nonKeyAttributesNamesAsString('/')

Since : 3.0.0

.nonKeyAttributesNamesAsString(String separator, String prefix, String suffix) : String

Returns the 'non key' attributes names as a string.
The attributes names are separated by the given separator
with a prefix/suffix for each attribute name

Parameters :
   separator : the separator to be put between each attribute name
   prefix : the prefix to be put before each attribute name
   suffix : the prefix to be put after each attribute name

Example :
   $entity.nonKeyAttributesNamesAsString('/', '{{', '}}')

Since : 3.0.0

.nonTextAttributes : List of 'attribute' objects

Returns the attributes NOT tagged as 'long text' for this entity
( 'standard attributes' )

Example :
   #foreach( $attribute in $entity.nonTextAttributes )
   ...
   #end

.package : String

Returns the package name (or void) for the entity ( ie : "my.package" or "" )

Example :
   $entity.package

.referencedEntities : List of 'entity' objects

Returns a list containing all entities referenced by the current entity
(only for the first level of dependency)

Example :
   #foreach( $refEntity in $entity.referencedEntities )
   ...
   #end

Since : 3.4.0

.referencedEntitiesForAllLevels : List of 'entity' objects

Returns a list containing all entities referenced by the current entity
at all levels of dependencies tree (including all sub levels)

Example :
   #foreach( $refEntity in $entity.referencedEntitiesForAllLevels )
   ...
   #end

Since : 3.4.0

.referencedEntityTypes() : List

Returns a list of 'simple type' for all the entities referenced by the current entity
(based on the 'owning side' links)

Example :
   #set( $referencedEntities = $entity.referencedEntityTypes() )

Since : 2.1.0

.referencedEntityTypes(List attributes) : List

Returns a list of 'simple type' for each entity referenced by the given attributes


Parameters :
   attributes : list of attributes to be used to search the referenced entities

Example :
   #set( $referencedEntities = $entity.referencedEntityTypes( $entity.nonKeyAttributes ) )

Since : 2.1.0

.references : List of 'reference' objects

Returns a list containing all references hold by the current entity
(only for the first level of dependency)

Example :
   #foreach( $reference in $entity.references )
   ...
   #end

Since : 3.4.0

.referencesInDepth : List of 'reference' objects

Returns a list containing all references hold by the current entity
in all levels of dependencies tree (including all sub levels)

Example :
   #foreach( $reference in $entity.referencesInDepth )
   ...
   #end

Since : 3.4.0

.selectedLinks : List of 'link' objects

Returns a list of all the links selected in the model for the current entity

Example :
   #foreach( $link in $entity.selectedLinks )
   ...
   #end

.sqlPrimaryKeyColumns : List of strings

Returns a list of SQL column names for all the attributes making up the Primary Key
(returns a void list if no Primary Key)

Example :
   #foreach( $col in $entity.sqlPrimaryKeyColumns )
   ...
   #end

.sqlPrimaryKeyColumnsAsString : String

Returns a string containing SQL column names for all the attributes making up the Primary Key
the column names are separated by a comma
(returns a void string if no Primary Key)

.sqlTableName : String

Returns the database table name for the given entity
If the table name is defined in the model it is used in priority
if no table name is defined then the entity name is converted to table name
by applying the target database conventions
(for example 'student_projects' for an entity named 'StudentProjects')


Since : 3.4.0

.superClass : String

Returns the 'super class' extended by the entity class

Example :
   $entity.superClass

Since : 3.4.0

.tagValue(String tagName) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the returned value is an empty string

Parameters :
   tagName : name of the tag for which to get the value

Example :
   $enity.tagValue('mytag')

Since : 3.4.0

.tagValue(String tagName, String defaultValue) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $enity.tagValue('mytag', 'abc')

Since : 3.4.0

.tagValueAsBoolean(String tagName, boolean defaultValue) : boolean

Returns the boolean value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $enity.tagValueAsBoolean('mytag', false)

Since : 3.4.0

.tagValueAsInt(String tagName, int defaultValue) : int

Returns the integer value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $enity.tagValueAsInt('mytag', 123)

Since : 3.4.0

.textAttributes : List of 'attribute' objects

Returns the attributes tagged as 'long text' for this entity
( specific attributes used to store long text )

Example :
   #foreach( $attribute in $entity.textAttributes )
   ...
   #end