NPersistence Reference Guide

The JoinColumn type exposes the following fields.

Fields

 Public

 Protected
 Instance

 Static
 Declared

 Inherited
 XNA Framework Only

 .NET Compact Framework Only

 MemberDescription
AttributeRef
(Optional) Points to the JoinTable, CollectionTable or AssociationOverride attribute which this JoinColumn belongs to. If this JoinColumn is not part of a JoinTable, CollectionTable or AssociationOverride, this field should stay empty. If this field is populated and references a JoinTable, this JoinColumn represents a foreign key column of the join table which reference the primary table of the entity owning the association. (I.e. the owning side of the association). If this field is populated and references a collection table, this JoinColumn references the primary table of the entity. The default only applies if a single join column is used. The default is the same as for JoinColumn (i.e., the concatenation of the following: the name of the entity; "_"; the name of the referenced primary key column.) However, if there is more than one join column, a JoinColumn annotation must be specified for each join column . In this case, both the name and the referencedColumnName elements must be specified in each such JoinColumn annotation. If this field is populated and references an AssociationOverride, this JoinColumn represents a join column being mapped to a persistent attribute. The joinColumn elements must be specified if a foreign key mapping is used in the overriding of the mapping of the relationship. The joinColumn element must not be specified if a join table is used in the overriding of the mapping of the relationship.
ColumnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the column. Defaults to the generated SQL for the column.
Insertable
(Optional) Whether the column is included in SQL INSERT statements generated by the persistence provider.
Inverse
(Optional) Only relevant when this JoinColumn is part of a JoinTable. This field indicates that this JoinColumn represents the foreign key of the join table which references the primary table of the entity that does not own the association. (I.e. the inverse side of the association).
Name
(Optional) The name of the foreign key column. The table in which it is found depends upon the context.
  • If the join is for a OneToOne or ManyToOne mapping using a foreign key mapping strategy, the foreign key column is in the table of the source entity or embeddable.
  • If the join is for a unidirectional OneToMany mapping using a foreign key mapping strategy, the foreign key is in the table of the target entity.
  • If the join is for a ManyToMany mapping or for a OneToOne or bidirectional ManyToOne/OneToMany mapping using a join table, the foreign key is in a join table.
  • If the join is for an element collection, the foreign key is in a collection table.
Default (only applies if a single join column is used): The concatenation of the following: the name of the referencing relationship property or field of the referencing entity or embeddable class; "_"; the name of the referenced primary key column. If there is no such referencing relationship property or field in the entity, or if the join is for an element collection, the join column name is formed as the concatenation of the following: the name of the entity; "_"; the name of the referenced primary key column.
Nullable
(Optional) Whether the foreign key column is nullable.
ReferencedColumnName
(Optional) The name of the column referenced by this foreign key column.
  • When used with entity relationship mappings other than the cases described here, the referenced column is in the table of the target entity.
  • When used with a unidirectional OneToMany foreign key mapping, the referenced column is in the table of the source entity.
  • When used inside a JoinTable annotation, the referenced key column is in the entity table of the owning entity, or inverse entity if the join is part of the inverse join definition.
  • When used in a CollectionTable mapping, the referenced column is in the table of the entity containing the collection.
Default (only applies if single join column is being used): The same name as the primary key column of the referenced table.
Table
(Optional) The name of the table that contains the column. If a table is not specified, the column is assumed to be in the primary table of the applicable entity. Default:
  • If the join is for a OneToOne or ManyToOne mapping using a foreign key mapping strategy, the name of the table of the source entity or embeddable.
  • If the join is for a unidirectional OneToMany mapping using a foreign key mapping strategy, the name of the table of the target entity.
  • If the join is for a ManyToMany mapping or for a OneToOne or bidirectional ManyToOne/OneToMany mapping using a join table, the name of the join table.
  • If the join is for an element collection, the name of the collection table.
Unique
(Optional) Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the table level and is useful for when the unique key constraint is only a single field. It is not necessary to explicitly specify this for a join column that corresponds to a primary key that is part of a foreign key.
Updatable
(Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider.

See Also