Package org.castor.cpa.jpa.natures
Class JPAFieldNature
- java.lang.Object
-
- org.castor.core.nature.BaseNature
-
- org.castor.cpa.jpa.natures.JPAFieldNature
-
- All Implemented Interfaces:
Nature
public class JPAFieldNature extends BaseNature
ABaseNatureextension, that gives access to information derived from field bound JPA annotations.- Since:
- 1.3
- Author:
- Peter Schmidt, Martin Kandler
- See Also:
PropertyHolder
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCASCADE_TYPESProperty Key forCascadeTypearray of a relation.static java.lang.StringLOBProperty Key forLobstatic java.lang.StringSTRING_ENUM_TYPEProperty Key forEnumeratedstatic java.lang.StringTEMPORAL_TYPEProperty Key forTemporal
-
Constructor Summary
Constructors Constructor Description JPAFieldNature(PropertyHolder holder)Instantiate aJPAFieldNatureto access the givenPropertyHolder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.persistence.FetchTypegetBasicFetch()javax.persistence.CascadeType[]getCascadeTypes()java.lang.StringgetColumnDefinition()Returns the 'columnDefinition' value of the @Column annotation.java.lang.BooleangetColumnInsertable()java.lang.IntegergetColumnLength()java.lang.StringgetColumnName()Returns the name of the @Column annotation.java.lang.BooleangetColumnNullable()java.lang.IntegergetColumnPrecision()java.lang.IntegergetColumnScale()java.lang.StringgetColumnTable()java.lang.BooleangetColumnUnique()java.lang.BooleangetColumnUpdatable()FieldInfogetFieldInfo()Get the underlyingFieldInfo(thePropertyHolder).java.lang.StringgetGeneratedValueGenerator()Get theGeneratedValue.generator()javax.persistence.GenerationTypegetGeneratedValueStrategy()Get theGeneratedValue.strategy()java.lang.StringgetId()Returns the fully qualified name of the Nature.java.lang.StringgetJoinColumnColumnDefinition()java.lang.BooleangetJoinColumnInsertable()java.lang.StringgetJoinColumnName()java.lang.BooleangetJoinColumnNullable()java.lang.StringgetJoinColumnReferencedColumnName()java.lang.StringgetJoinColumnTable()java.lang.BooleangetJoinColumnUnique()java.lang.BooleangetJoinColumnUpdatable()java.lang.StringgetJoinTableCatalog()javax.persistence.JoinColumn[]getJoinTableInverseJoinColumns()javax.persistence.JoinColumn[]getJoinTableJoinColumns()java.lang.StringgetJoinTableName()java.lang.StringgetJoinTableSchema()java.lang.Class<?>getRelationCollectionType()java.lang.StringgetRelationMappedBy()java.lang.Class<?>getRelationTargetEntity()javax.persistence.TemporalTypegetTemporalType()booleanisBasicOptional()booleanisId()booleanisLob()booleanisManyToMany()booleanisManyToManyInverseCopy()booleanisManyToOne()booleanisOneToMany()booleanisOneToOne()booleanisRelationLazyFetch()booleanisRelationOptional()booleanisStringEnumType()booleanisTransient()voidsetBasicFetch(javax.persistence.FetchType fetch)voidsetBasicOptional(boolean optional)voidsetCascadeTypes(javax.persistence.CascadeType[] cascadeTypes)voidsetColumnDefinition(java.lang.String columnDefinition)Sets the 'columnDefinition' value of the @Column annotation.voidsetColumnInsertable(boolean insertable)voidsetColumnLength(int length)voidsetColumnName(java.lang.String name)Set the name value of the @Column annotation.voidsetColumnNullable(boolean nullable)voidsetColumnPrecision(int precision)voidsetColumnScale(int scale)voidsetColumnTable(java.lang.String table)voidsetColumnUnique(boolean unique)voidsetColumnUpdatable(boolean updatable)voidsetGeneratedValueGenerator(java.lang.String generator)Set theGeneratedValue.generator()voidsetGeneratedValueStrategy(javax.persistence.GenerationType strategy)Set theGeneratedValue.strategy()voidsetId(boolean isId)voidsetJoinColumnColumnDefinition(java.lang.String columnDefinition)voidsetJoinColumnInsertable(boolean insertable)voidsetJoinColumnName(java.lang.String name)voidsetJoinColumnNullable(boolean nullable)voidsetJoinColumnReferencedColumnName(java.lang.String referencedColumnName)voidsetJoinColumnTable(java.lang.String table)voidsetJoinColumnUnique(boolean unique)voidsetJoinColumnUpdatable(boolean updatable)voidsetJoinTableCatalog(java.lang.String catalog)voidsetJoinTableInverseJoinColumns(javax.persistence.JoinColumn[] inverseJoinColumns)voidsetJoinTableJoinColumns(javax.persistence.JoinColumn[] joinColumns)voidsetJoinTableName(java.lang.String tablename)voidsetJoinTableSchema(java.lang.String schema)voidsetLob(boolean isLob)voidsetManyToMany(boolean hasManyToMany)voidsetManyToManyInverseCopy(boolean copySettingsInverse)voidsetManyToOne(boolean hasManyToOne)voidsetOneToMany(boolean hasOneToMany)voidsetOneToOne(boolean hasOneToOne)voidsetRelationCollectionType(java.lang.Class<?> collectionType)voidsetRelationLazyFetch(boolean lazyFetch)voidsetRelationMappedBy(java.lang.String mappedBy)voidsetRelationOptional(boolean optional)voidsetRelationTargetEntity(java.lang.Class<?> targetEntity)voidsetStringEnumType(boolean isStringEnumType)voidsetTemporalType(javax.persistence.TemporalType temporalType)voidsetTransient(boolean isTransient)-
Methods inherited from class org.castor.core.nature.BaseNature
getBooleanPropertyDefaultFalse, getHolder, getProperty, getPropertyAsList, getPropertyAsMap, setProperty
-
-
-
-
Field Detail
-
TEMPORAL_TYPE
public static final java.lang.String TEMPORAL_TYPE
Property Key forTemporal- See Also:
- Constant Field Values
-
LOB
public static final java.lang.String LOB
Property Key forLob- See Also:
- Constant Field Values
-
STRING_ENUM_TYPE
public static final java.lang.String STRING_ENUM_TYPE
Property Key forEnumerated- See Also:
- Constant Field Values
-
CASCADE_TYPES
public static final java.lang.String CASCADE_TYPES
Property Key forCascadeTypearray of a relation.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JPAFieldNature
public JPAFieldNature(PropertyHolder holder)
Instantiate aJPAFieldNatureto access the givenPropertyHolder.- Parameters:
holder- The underlyingPropertyHolder(obviously aFieldInfo).- See Also:
PropertyHolder
-
-
Method Detail
-
getId
public final java.lang.String getId()
Returns the fully qualified name of the Nature.- Returns:
- qualified name of the nature.
- See Also:
Nature.getId()
-
getFieldInfo
public FieldInfo getFieldInfo()
Get the underlyingFieldInfo(thePropertyHolder).- Returns:
- the underlying
FieldInfo. If thePropertyHolderwas not of typeFieldInfo, null is returned.
-
setBasicFetch
public final void setBasicFetch(javax.persistence.FetchType fetch)
- Parameters:
fetch- The value ofBasic.fetch()- See Also:
BASIC_FETCH
-
getBasicFetch
public final javax.persistence.FetchType getBasicFetch()
- Returns:
- The value of
Basic.fetch() - See Also:
BASIC_FETCH
-
setBasicOptional
public final void setBasicOptional(boolean optional)
- Parameters:
optional- The value ofBasic.optional()- See Also:
BASIC_OPTIONAL
-
isBasicOptional
public final boolean isBasicOptional()
- Returns:
- True if
Basic.optional()was set to true on the field. - See Also:
BASIC_OPTIONAL
-
setColumnName
public final void setColumnName(java.lang.String name)
Set the name value of the @Column annotation.- Parameters:
name- The value ofColumn.name()- See Also:
COLUMN_NAME
-
getColumnName
public final java.lang.String getColumnName()
Returns the name of the @Column annotation.- Returns:
- The value of
Column.name() - See Also:
COLUMN_NAME
-
setColumnDefinition
public final void setColumnDefinition(java.lang.String columnDefinition)
Sets the 'columnDefinition' value of the @Column annotation.- Parameters:
columnDefinition- The value ofColumn.columnDefinition()- See Also:
COLUMN_DEFINITION
-
getColumnDefinition
public final java.lang.String getColumnDefinition()
Returns the 'columnDefinition' value of the @Column annotation.- Returns:
- The value of
Column.columnDefinition() - See Also:
COLUMN_DEFINITION
-
setColumnLength
public final void setColumnLength(int length)
- Parameters:
length- The value ofColumn.length()- See Also:
COLUMN_LENGTH
-
getColumnLength
public final java.lang.Integer getColumnLength()
- Returns:
- The value of
Column.length() - See Also:
COLUMN_LENGTH
-
setColumnInsertable
public final void setColumnInsertable(boolean insertable)
- Parameters:
insertable- The value ofColumn.insertable()- See Also:
COLUMN_INSERTABLE
-
getColumnInsertable
public final java.lang.Boolean getColumnInsertable()
- Returns:
- The value of
Column.insertable() - See Also:
COLUMN_INSERTABLE
-
setColumnNullable
public final void setColumnNullable(boolean nullable)
- Parameters:
nullable- The value ofColumn.nullable()- See Also:
COLUMN_NULLABLE
-
getColumnNullable
public final java.lang.Boolean getColumnNullable()
- Returns:
- The value of
Column.nullable() - See Also:
COLUMN_NULLABLE
-
setColumnPrecision
public final void setColumnPrecision(int precision)
- Parameters:
precision- The value ofColumn.precision()- See Also:
COLUMN_PRECISION
-
getColumnPrecision
public final java.lang.Integer getColumnPrecision()
- Returns:
- The value of
Column.precision() - See Also:
COLUMN_PRECISION
-
setColumnScale
public final void setColumnScale(int scale)
- Parameters:
scale- The value ofColumn.scale()- See Also:
COLUMN_SCALE
-
getColumnScale
public final java.lang.Integer getColumnScale()
- Returns:
- The value of
Column.scale() - See Also:
COLUMN_SCALE
-
setColumnTable
public final void setColumnTable(java.lang.String table)
- Parameters:
table- The value ofColumn.table()- See Also:
COLUMN_TABLE
-
getColumnTable
public final java.lang.String getColumnTable()
- Returns:
- The value of
Column.table() - See Also:
COLUMN_TABLE
-
setColumnUnique
public final void setColumnUnique(boolean unique)
- Parameters:
unique- The value ofColumn.unique()- See Also:
COLUMN_UNIQUE
-
getColumnUnique
public final java.lang.Boolean getColumnUnique()
- Returns:
- The value of
Column.unique() - See Also:
COLUMN_UNIQUE
-
setColumnUpdatable
public final void setColumnUpdatable(boolean updatable)
- Parameters:
updatable- The value ofColumn.updatable()- See Also:
COLUMN_UPDATABLE
-
getColumnUpdatable
public final java.lang.Boolean getColumnUpdatable()
- Returns:
- The value of
Column.updatable() - See Also:
COLUMN_UPDATABLE
-
setId
public final void setId(boolean isId)
- Parameters:
isId- IfIdwas found on that property.- See Also:
ID
-
isId
public final boolean isId()
- Returns:
- true if
Idwas set on the property, else false. - See Also:
ID
-
setTransient
public final void setTransient(boolean isTransient)
- Parameters:
isTransient- ifTransientwas found on that property.- See Also:
TRANSIENT
-
isTransient
public final boolean isTransient()
- Returns:
- true if
Transientwas set on the property, else false - See Also:
TRANSIENT
-
setJoinTableName
public void setJoinTableName(java.lang.String tablename)
- Parameters:
tablename- The value ofJoinTable.name()- See Also:
JOINTABLE_NAME
-
getJoinTableName
public java.lang.String getJoinTableName()
- Returns:
- The value of
JoinTable.name() - See Also:
JOINTABLE_NAME
-
setJoinTableCatalog
public void setJoinTableCatalog(java.lang.String catalog)
- Parameters:
catalog- The value ofJoinTable.catalog()- See Also:
JOINTABLE_CATALOG
-
getJoinTableCatalog
public java.lang.String getJoinTableCatalog()
- Returns:
- The value of
JoinTable.catalog() - See Also:
JOINTABLE_CATALOG
-
setJoinTableSchema
public void setJoinTableSchema(java.lang.String schema)
- Parameters:
schema- The value ofJoinTable.schema()- See Also:
JOINTABLE_SCHEMA
-
getJoinTableSchema
public java.lang.String getJoinTableSchema()
- Returns:
- The value of
JoinTable.schema() - See Also:
#TABLE_SCHEMA
-
setJoinTableJoinColumns
public void setJoinTableJoinColumns(javax.persistence.JoinColumn[] joinColumns)
- Parameters:
joinColumns- The value ofJoinTable.joinColumns()- See Also:
JOINTABLE_JOINCOLUMNS
-
getJoinTableJoinColumns
public javax.persistence.JoinColumn[] getJoinTableJoinColumns()
- Returns:
- The value of
JoinTable.joinColumns() - See Also:
JOINTABLE_JOINCOLUMNS
-
setJoinTableInverseJoinColumns
public void setJoinTableInverseJoinColumns(javax.persistence.JoinColumn[] inverseJoinColumns)
- Parameters:
inverseJoinColumns- The value ofJoinTable.inverseJoinColumns()- See Also:
JOINTABLE_INVERSE_JOINCOLUMNS
-
getJoinTableInverseJoinColumns
public javax.persistence.JoinColumn[] getJoinTableInverseJoinColumns()
- Returns:
- The value of
JoinTable.inverseJoinColumns() - See Also:
JOINTABLE_INVERSE_JOINCOLUMNS
-
setJoinColumnName
public final void setJoinColumnName(java.lang.String name)
- Parameters:
name- The value ofJoinColumn.name().- See Also:
JOINCOLUMN_NAME
-
getJoinColumnName
public final java.lang.String getJoinColumnName()
- Returns:
- The value of
JoinColumn.name(). - See Also:
JOINCOLUMN_NAME
-
setJoinColumnReferencedColumnName
public final void setJoinColumnReferencedColumnName(java.lang.String referencedColumnName)
- Parameters:
referencedColumnName- The value ofJoinColumn.referencedColumnName().- See Also:
JOINCOLUMN_REFERENCEDCOLUMNNAME
-
getJoinColumnReferencedColumnName
public final java.lang.String getJoinColumnReferencedColumnName()
- Returns:
- The value of
JoinColumn.referencedColumnName(). - See Also:
JOINCOLUMN_REFERENCEDCOLUMNNAME
-
setJoinColumnUnique
public final void setJoinColumnUnique(boolean unique)
- Parameters:
unique- The value ofJoinColumn.unique().- See Also:
JOINCOLUMN_UNIQUE
-
getJoinColumnUnique
public final java.lang.Boolean getJoinColumnUnique()
- Returns:
- The value of
JoinColumn.unique(). - See Also:
JOINCOLUMN_UNIQUE
-
setJoinColumnNullable
public final void setJoinColumnNullable(boolean nullable)
- Parameters:
nullable- The value ofJoinColumn.nullable().- See Also:
JOINCOLUMN_NULLABLE
-
getJoinColumnNullable
public final java.lang.Boolean getJoinColumnNullable()
- Returns:
- The value of
JoinColumn.nullable(). - See Also:
JOINCOLUMN_NULLABLE
-
setJoinColumnInsertable
public final void setJoinColumnInsertable(boolean insertable)
- Parameters:
insertable- The value ofJoinColumn.insertable().- See Also:
JOINCOLUMN_INSERTABLE
-
getJoinColumnInsertable
public final java.lang.Boolean getJoinColumnInsertable()
- Returns:
- The value of
JoinColumn.insertable(). - See Also:
JOINCOLUMN_INSERTABLE
-
setJoinColumnUpdatable
public final void setJoinColumnUpdatable(boolean updatable)
- Parameters:
updatable- The value ofJoinColumn.updatable().- See Also:
JOINCOLUMN_UPDATABLE
-
getJoinColumnUpdatable
public final java.lang.Boolean getJoinColumnUpdatable()
- Returns:
- The value of
JoinColumn.updatable(). - See Also:
JOINCOLUMN_UPDATABLE
-
setJoinColumnColumnDefinition
public final void setJoinColumnColumnDefinition(java.lang.String columnDefinition)
- Parameters:
columnDefinition- The value ofJoinColumn.columnDefinition().- See Also:
JOINCOLUMN_COLUMNDEFINITION
-
getJoinColumnColumnDefinition
public final java.lang.String getJoinColumnColumnDefinition()
- Returns:
- The value of
JoinColumn.columnDefinition(). - See Also:
JOINCOLUMN_COLUMNDEFINITION
-
setJoinColumnTable
public final void setJoinColumnTable(java.lang.String table)
- Parameters:
table- The value ofJoinColumn.table().- See Also:
JOINCOLUMN_TABLE
-
getJoinColumnTable
public final java.lang.String getJoinColumnTable()
- Returns:
- The value of
JoinColumn.table(). - See Also:
JOINCOLUMN_TABLE
-
setOneToOne
public void setOneToOne(boolean hasOneToOne)
- Parameters:
hasOneToOne- ifOneToOnewas found on that property.- See Also:
ONETOONE
-
isOneToOne
public boolean isOneToOne()
- Returns:
- if
OneToOnewas set on the property, else false. - See Also:
ONETOONE
-
setManyToOne
public void setManyToOne(boolean hasManyToOne)
- Parameters:
hasManyToOne- ifManyToOnewas found on that property.- See Also:
MANYTOONE
-
isManyToOne
public boolean isManyToOne()
- Returns:
- if
ManyToOnewas set on the property, else false. - See Also:
MANYTOONE
-
setOneToMany
public void setOneToMany(boolean hasOneToMany)
- Parameters:
hasOneToMany- ifOneToManywas found on that property.- See Also:
ONETOMANY
-
isOneToMany
public boolean isOneToMany()
- Returns:
- if
OneToManywas set on the property, else false. - See Also:
ONETOMANY
-
setManyToMany
public void setManyToMany(boolean hasManyToMany)
- Parameters:
hasManyToMany- ifManyToManywas found on that property.- See Also:
MANYTOMANY
-
isManyToMany
public boolean isManyToMany()
- Returns:
- if
ManyToOnewas set on the property, else false. - See Also:
MANYTOMANY
-
setManyToManyInverseCopy
public void setManyToManyInverseCopy(boolean copySettingsInverse)
- Parameters:
copySettingsInverse- set this to true if a ManyToMany related field shall copy allJoinTablerelevant information from the other side of the relation (inverting theJoinColumnsettings).- See Also:
MANYTOMANY_INVERSECOPY
-
isManyToManyInverseCopy
public boolean isManyToManyInverseCopy()
- Returns:
- if this is true a ManyToMany related field shall copy all
JoinTablerelevant information from the other side of the relation (inverting theJoinColumnsettings). - See Also:
MANYTOMANY_INVERSECOPY
-
setRelationTargetEntity
public void setRelationTargetEntity(java.lang.Class<?> targetEntity)
- Parameters:
targetEntity- The value ofOneToOne.targetEntity(),OneToMany.targetEntity(),ManyToOne.targetEntity(),ManyToMany.targetEntity(), depending to the relation type.- See Also:
RELATION_TARGETENTITY
-
getRelationTargetEntity
public java.lang.Class<?> getRelationTargetEntity()
- Returns:
- The value of
OneToOne.targetEntity(),OneToMany.targetEntity(),ManyToOne.targetEntity(),ManyToMany.targetEntity(), depending on the relation type. Returns null iff no relational annotation was set on the field. - See Also:
RELATION_TARGETENTITY
-
setRelationLazyFetch
public void setRelationLazyFetch(boolean lazyFetch)
- Parameters:
lazyFetch- true ifOneToOne.fetch(),OneToMany.fetch(),ManyToOne.fetch(),ManyToMany.fetch()is set toFetchType.LAZY, depending on the relation type.- See Also:
RELATION_LAZYFETCH
-
isRelationLazyFetch
public boolean isRelationLazyFetch()
- Returns:
- true if
OneToOne.fetch(),OneToMany.fetch(),ManyToOne.fetch(),ManyToMany.fetch()is set toFetchType.LAZY, depending on the relation type. - See Also:
RELATION_LAZYFETCH
-
setRelationMappedBy
public void setRelationMappedBy(java.lang.String mappedBy)
- Parameters:
mappedBy- The content ofOneToMany.mappedBy(),ManyToMany.mappedBy(), depending on the relation type.- See Also:
RELATION_MAPPEDBY
-
getRelationMappedBy
public java.lang.String getRelationMappedBy()
- Returns:
- The content of
OneToMany.mappedBy(),ManyToMany.mappedBy(), depending on the relation type. If no (or an empty) String was set, null is returned! - See Also:
RELATION_MAPPEDBY
-
getRelationCollectionType
public java.lang.Class<?> getRelationCollectionType()
- Returns:
- The type of Collection being used by
OneToMany,ManyToMany, depending on the relation type. Returns null iff none of the above relational annotations was set on the field. - See Also:
RELATION_COLLECTIONTYPE
-
setRelationCollectionType
public void setRelationCollectionType(java.lang.Class<?> collectionType)
- Parameters:
collectionType- Set the type of Collection being used byOneToMany,ManyToMany, depending on the relation type.- See Also:
RELATION_COLLECTIONTYPE
-
setRelationOptional
public void setRelationOptional(boolean optional)
- Parameters:
optional- Set the value ofOneToOne.optional(),ManyToOne.optional(), depending on the relation type.- See Also:
RELATION_OPTIONAL
-
isRelationOptional
public boolean isRelationOptional()
- Returns:
- true if
OneToOne.optional(),ManyToOne.optional()was set to true, depending on the relation type. - See Also:
RELATION_OPTIONAL
-
setGeneratedValueStrategy
public void setGeneratedValueStrategy(javax.persistence.GenerationType strategy)
Set theGeneratedValue.strategy()- Parameters:
strategy-- See Also:
GENERATEDVALUE_STRATEGY
-
getGeneratedValueStrategy
public javax.persistence.GenerationType getGeneratedValueStrategy()
Get theGeneratedValue.strategy()- Returns:
- strategy
- See Also:
GENERATEDVALUE_STRATEGY
-
setGeneratedValueGenerator
public void setGeneratedValueGenerator(java.lang.String generator)
Set theGeneratedValue.generator()- Parameters:
strategy-- See Also:
GENERATEDVALUE_STRATEGY
-
getGeneratedValueGenerator
public java.lang.String getGeneratedValueGenerator()
Get theGeneratedValue.generator()- Returns:
- strategy
- See Also:
GENERATEDVALUE_STRATEGY
-
getTemporalType
public javax.persistence.TemporalType getTemporalType()
- Returns:
- The
TemporalTypeof field. - See Also:
TEMPORAL_TYPE
-
setTemporalType
public void setTemporalType(javax.persistence.TemporalType temporalType)
- Parameters:
temporalType- set theTemporalTypeof field.- See Also:
TEMPORAL_TYPE
-
isLob
public boolean isLob()
- Returns:
- true if
Lobwas set on the property, else false - See Also:
LOB
-
setLob
public void setLob(boolean isLob)
- Parameters:
isLob- ifLobwas found on that property.- See Also:
LOB
-
isStringEnumType
public boolean isStringEnumType()
- Returns:
- true if
Enumeratedwith valueEnumTypeSTRING was set on the property, else false - See Also:
STRING_ENUM_TYPE
-
setStringEnumType
public void setStringEnumType(boolean isStringEnumType)
- Parameters:
isStringEnumType- ifEnumeratedwith valueEnumTypeSTRING was found on that property.- See Also:
STRING_ENUM_TYPE
-
getCascadeTypes
public javax.persistence.CascadeType[] getCascadeTypes()
- Returns:
- The
CascadeTypearray of relation. - See Also:
CASCADE_TYPES
-
setCascadeTypes
public void setCascadeTypes(javax.persistence.CascadeType[] cascadeTypes)
- Parameters:
cascadeTypes- set theCascadeTypearray of relation.- See Also:
CASCADE_TYPES
-
-