Object providing a set of utility functions for JPA (Java Persistence API) code generation
Since : 2.0.7
Attributes and methods |
.embeddedIdAnnotations(int leftMargin, AttributeInContext attribute) : String
Returns the JPA annotations for an 'embedded id' (with a left margin)
( there's no '@Id' for an embedded id )
Parameters :
leftMargin : the left margin (number of blanks)
attribute : the attribute to be annotated
Example :
$jpa.embeddedIdAnnotations( 4, $attribute )
Since : 2.0.7
|
.entityAnnotations(int leftMargin, EntityInContext entity) : String
Returns a multiline String containing all the Java JPA annotations required for the current entity
with the given left marging before each line
Parameters :
leftMargin : the left margin (number of blanks)
entity : the entity to be annotated
Example :
$jpa.entityAnnotations(4, $entity)
Since : 2.0.7
|
.fieldAnnotations(int leftMargin, AttributeInContext field) : String
Returns the JPA annotations for the given field (with a left margin)
Parameters :
leftMargin : the left margin (number of blanks)
field : the field to be annotated
Example :
$jpa.fieldAnnotations( 4, $field )
Since : 2.0.7
|
.genColumnDefinition : boolean
Defines if 'columnDefinition' must be generated in 'Column' annotation
Can be set to 'true' or 'false' (default value is 'false')
Example :
#set( $jpa.genColumnDefinition = true )
Since : 3.4.0
|
.genTargetEntity : boolean
Defines if 'targetEntity' must be generated in @ManyToMany, @OneToMany, etc
Can be set to 'true' or 'false' (default value is 'false')
Example :
#set( $jpa.genTargetEntity = true )
Since : 3.3.0
|
.imports(EntityInContext entity) : List of 'String'
Returns a list of all the Java classes required by the current entity for JPA
( this version always returns 'javax.persistence.*' )
Parameters :
entity : the entity
Example :
#foreach( $import in $jpa.imports($entity) )
import $import;
#end
Since : 2.0.7
|
.joinColumnInsertable : String
Defines the value for 'insertable' attribute in '@JoinColumn' annotation
Can be set to 'true' or 'false' (default value is 'nothing')
Example :
#set( $jpa.joinColumnInsertable = true )
Since : 3.3.0
|
.joinColumnUpdatable : String
Defines the value for 'updatable' attribute in '@JoinColumn' annotation
Can be set to 'true' or 'false' (default value is 'nothing')
Example :
#set( $jpa.joinColumnUpdatable = true )
Since : 3.3.0
|
.linkAnnotations(int leftMargin, LinkInContext link) : String
Returns a string containing all the JPA annotations for the given link
@ManyToOne, @OneToMany, etc
@JoinColumns / @JoinColumn
Parameters :
leftMargin : the left margin (number of blanks)
link : the link from which the JPA annotations will be generated
Example :
$jpa.linkAnnotations( 4, $link )
Since : 3.3.0
|
.linkAnnotations(int leftMargin, LinkInContext link, List alreadyMappedFields) : String
Returns a string containing all the JPA annotations for the given link
The list of mapped fields is used to determine if a JoinColumn is already mapped as a field
If a JoinColumn is based on a field already mapped then 'insertable=false, updatable=false' is set
Parameters :
leftMargin : the left margin (number of blanks)
link : the link to be annotated
alreadyMappedFields : list of all the fields already mapped by JPA as 'simple fields'
Example :
$jpa.linkAnnotations( 4, $link, $listOfMappedFields )
Since : 2.0.7
|
.linkCardinalityAnnotation(int leftMargin, LinkInContext link) : String
Returns a string containing the JPA cardinality annotation for the given link
( e.g. @ManyToOne, @OneToMany, etc )
Parameters :
leftMargin : the left margin (number of blanks)
link : the link from which the JPA annotation will be generated
Example :
$jpa.linkCardinalityAnnotation( 4, $link )
Since : 3.3.0
|
.linkJoinAnnotation(int leftMargin, LinkInContext link) : String
Returns a string containing the JPA JoinColumn(s) annotations for the given link
Parameters :
leftMargin : the left margin (number of blanks)
link : the link from which the JPA annotation will be generated
Example :
$jpa.linkJoinAnnotation(4,$link)
Since : 3.3.0
|
.linkJoinAnnotation(int leftMargin, LinkInContext link, List alreadyMappedFields) : String
Returns a string containing the JPA JoinColumn(s) annotations for the given link
The list of mapped fields is used to determine if a JoinColumn is already mapped as a field
If a JoinColumn is based on a field already mapped then 'insertable=false, updatable=false' is set
Parameters :
leftMargin : the left margin (number of blanks)
link : the link from which the JPA annotation will be generated
alreadyMappedFields : list of all the fields already mapped by JPA as 'simple fields'
Example :
$jpa.linkJoinAnnotation( 4, $link, $listOfMappedFields )
Since : 3.3.0
|
.manyToManyFetchType : FetchType
Defines default FETCH-TYPE ('LAZY' or 'EAGER') for 'ManyToMany' cardinality
Example :
#set( $jpa.manyToManyFetchType = 'EAGER' )
Since : 3.3.0
|
.manyToOneFetchType : FetchType
Defines default FETCH-TYPE ('LAZY' or 'EAGER') for 'ManyToOne' cardinality
Example :
#set( $jpa.manyToOneFetchType = 'LAZY' )
Since : 3.3.0
|
.oneToManyFetchType : FetchType
Defines default FETCH-TYPE ('LAZY' or 'EAGER') for 'OneToMany' cardinality
Example :
#set( $jpa.oneToManyFetchType = 'EAGER' )
Since : 3.3.0
|
.oneToOneFetchType : FetchType
Defines default FETCH-TYPE ('LAZY' or 'EAGER') for 'OneToOne' cardinality
Example :
#set( $jpa.oneToOneFetchType = 'LAZY' )
Since : 3.3.0
|