$link

( documentation for Telosys generator version 4.1.0 )


This object provides all information about an entity link
Each link is retrieved from the entity class


Example :
   
   #foreach( $link in $entity.links )
    private $link.formattedFieldType(10) $link.formattedFieldName(12);
   #end

Attributes and methods
.attributes : List of '$linkAttribute' (origin-target association)

Returns a list of all attributes defining the link
Each element contains the owning side attribute and its corresponding reverse side attribute

.attributesCount : int

Returns the number of attributes used to define the link

Example :
   $link.attributesCount

Since : 2.1.0

.cardinality : String

Returns the cardinality of the link
eg : 'OneToMany', 'ManyToOne', 'OneToOne', 'ManyToMany'

.cascade : String

Returns the 'cascade type' ( 'ALL', 'MERGE', 'MERGE PERSIST', 'PERSIST REFRESH', 'REMOVE' )
A string containing all the selected cascade options

.entity : EntityInContext

Returns the entity to which the link belongs


Since : 3.3.0

.fetch : String

Returns the 'fetch type' ( 'DEFAULT' or 'EAGER' or 'LAZY' )

.fieldName : String

Returns the field name for the link (attribute name in the entity class)

.fieldType : String

Returns the type of the link
eg : Person, List, ...

.formattedFieldName(int n) : String

Returns the link's name with n trailing blanks

Parameters :
   n : the number of blanks to be added at the end of the name

.formattedFieldType(int n) : String

Returns the link's type with n trailing blanks
eg : List, List, Person, ...

Parameters :
   n : the number of blanks to be added at the end of the name

.getter : String

Returns the Java getter for the link e.g. 'getPerson' for link 'person'

.hasAttributeInPrimaryKey() : boolean

Returns TRUE if the link has one (or more) attribute in the entity Primary Key
( one of its 'origin attributes' is the Primary Key or a part of the Primary Key )

Since : 2.1.0

.hasJoinEntity() : boolean

Returns TRUE if the link has a 'join entity'

Since : 3.4.0

.hasMappedBy() : boolean

Returns TRUE if 'mappedBy' is defined

Since : 3.3.0

.hasTag(String tagName) : boolean

Returns TRUE if the link has a tag with the given name

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

Example :
   $link.hasTag('mytag')

Since : 3.4.0

.insertable : String

Returns the 'insertable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.insertableIs(boolean booleanValue) : boolean

Returns true if 'insertable flag' is defined and equals the given value
The flag can be 'undefined' then neither true nor false

Parameters :
   booleanValue : true or false

Example :
   #if ( $link.insertableIs(true) )
   #if ( $link.insertableIs(false) )

Since : 3.3.0

.isCardinalityManyToMany() : boolean

Returns TRUE if the link has a 'ManyToMany' cardinality

.isCardinalityManyToOne() : boolean

Returns TRUE if the link has a 'ManyToOne' cardinality

.isCardinalityOneToMany() : boolean

Returns TRUE if the link has a 'OneToMany' cardinality

.isCardinalityOneToOne() : boolean

Returns TRUE if the link has a 'OneToOne' cardinality

.isCardinalityToMany() : boolean

Returns TRUE if the link cardinality is 'OneToMany' or 'ManyToMany'

Since : 3.4.0

.isCardinalityToOne() : boolean

Returns TRUE if the link cardinality is 'ManyToOne' or 'OneToOne'

Since : 3.4.0

.isCascadeALL() : boolean

Returns true if the 'cascade options' is 'ALL'

.isCascadeMERGE() : boolean

Returns true if the 'cascade options' contains 'MERGE'

.isCascadePERSIST() : boolean

Returns true if the 'cascade options' contains 'PERSIST'

.isCascadeREFRESH() : boolean

Returns true if the 'cascade options' contains 'REFRESH'

.isCascadeREMOVE() : boolean

Returns true if the 'cascade options' contains 'REMOVE'

.isCollectionType() : boolean

Returns TRUE if the link is a collection
In other words, if its cardinality is 'OneToMany' or 'ManyToMany'

.isEmbedded() : boolean

Returns TRUE if the link is marked as 'embedded'

Since : 3.3.0

.isFetchDEFAULT() : boolean

Returns true if the 'fetch type' is 'DEFAULT'

.isFetchEAGER() : boolean

Returns true if the 'fetch type' is 'EAGER'

.isFetchLAZY() : boolean

Returns true if the 'fetch type' is 'LAZY'

.isOptionalFalse() : boolean

Returns true if the 'optional status' is 'FALSE'

.isOptionalTrue() : boolean

Returns true if the 'optional status' is 'TRUE'

.isOptionalUndefined() : boolean

Returns true if the 'optional status' is 'UNDEFINED'

.isOrphanRemoval() : boolean

Returns TRUE if the link is marked with 'OrphanRemoval' option.
Useful for ORM like JPA, Doctrine, etc

Example :
   #if ( $link.isOrphanRemoval() )
   ...
   #end

Since : 4.1.0

.isOwningSide() : boolean

Returns TRUE if the link is the 'Owning Side' of the relationship between 2 entities

.isSelected() : boolean

Returns TRUE if the link is selected (checkbox checked in the GUI)

.isTransient() : boolean

Returns TRUE if the link is marked as 'transient'

Since : 3.3.0

.joinEntity : EntityInContext

Returns the 'join entity' (entity object) used by the link
Throws an exception if the link doesn't have a 'join entity'
check existence before with 'hasJoinEntity()'

Since : 4.1.0

.joinEntityName : String

Returns the name of the 'join entity' used by the link
Returns an empty string if the link doesn't have a 'join entity'
check existence before with 'hasJoinEntity()'

Since : 3.4.0

.mappedBy : String

Returns the name of the link in the 'owning side'
Typically for JPA 'mappedBy'
NB : can be null if 'mappedBy' is not defined
check existence before with 'hasMappedBy()'

.optional : String

Returns the 'optional status' for the link ( 'TRUE', 'FALSE' or 'UNDEFINED' )
Typically for JPA 'optional=true/false'

.setter : String

Returns the Java setter for the link e.g. 'setPerson' for link 'person'

.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 :
   $link.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 :
   $link.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 :
   $link.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 :
   $link.tagValueAsInt('mytag', 123)

Since : 3.4.0

.targetEntity : EntityInContext

Returns the entity referenced by the link


Since : 2.1.0

.targetEntityFullType : String

Returns the type of the entity referenced by the link
eg : 'my.package.Book', 'my.package.Customer', ...

.targetEntityName : String

Returns the name of the entity referenced by the link
eg : 'Book', 'Customer', ...


Since : 3.4.0

.targetEntitySimpleType : String

Returns the type of the entity referenced by the link
eg : 'Book', 'Customer', ...

.updatable : String

Returns the 'updatable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.updatableIs(boolean booleanValue) : boolean

Returns true if 'updatable flag' is defined and equals the given value
The flag can be 'undefined' then neither true nor false

Parameters :
   booleanValue : true or false

Example :
   #if ( $link.updatableIs(true) )
   #if ( $link.updatableIs(false) )

Since : 3.3.0

.usesAttribute(AttributeInContext attribute) : boolean

Returns TRUE if the given attribute is an origin attribute in the link

Parameters :
   attribute : the attribute to be checked