$entity

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

.databaseCatalog : String

Returns the database catalog of the table mapped with this entity

Example :
   $entity.databaseCatalog

.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 mapped with this entity

Example :
   $entity.databaseTable

.databaseType : String

Returns the database type of the table mapped with this entity

Type returned by the database meta-data ( 'TABLE', 'VIEW', ... )

Example :
   $entity.databaseType

Since : 2.0.7

.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

.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)

.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

.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

.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

.hasTextAttribute() : boolean

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

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

.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

.name : String

Returns the class name for the entity 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

.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

.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

.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