NPersistence Reference Guide
Used to override the mapping of a Basic (whether explicit or default) property or field or Id property or field.

May be applied to an entity that extends a mapped superclass or to an embedded field or property to override a basic mapping or id mapping defined by the mapped superclass or embeddable class (or embeddable class of one of its attributes).

May be applied to an element collection containing instances of an embeddable class or to a map collection whose key and/or value is an embeddable class. When AttributeOverride is applied to a map, "key." or "value." must be used to prefix the name of the attribute that is being overridden in order to specify it as part of the map key or map value.

To override mappings at multiple levels of embedding, a dot (".") notation form must be used in the name element to indicate an attribute within an embedded attribute. The value of each identifier used with the dot notation is the name of the respective embedded field or property.

If AttributeOverride is not specified, the column is mapped the same as in the original mapping.

Examples

CopyC#
 Example 1:

 [MappedSuperclass]
 public class Employee {
     [Id] protected Integer id;
     [Version] protected Integer version;
     protected String address;
     public Integer getId() { ... }
     public void setId(Integer id) { ... }
     public String getAddress() { ... }
     public void setAddress(String address) { ... }
 }

 [Entity]
 [AttributeOverride(PropertyName="address", Name="ADDR"))]
 public class PartTimeEmployee extends Employee {
     // address field mapping overridden to ADDR
     protected Float wage();
     public Float getHourlyWage() { ... }
     public void setHourlyWage(Float wage) { ... }
 }


 Example 2:

 [Embeddable] public class Address {
     protected String street;
     protected String city;
     protected String state;
     [Embedded] protected Zipcode zipcode;
 }

 [Embeddable] public class Zipcode {
     protected String zip;
     protected String plusFour;
 }

 [Entity] public class Customer {
     [Id] protected Integer id;
     protected String name;
     [AttributeOverride(PropertyName="state", Name="ADDR_STATE")]
     [AttributeOverride(PropertyName="zipcode.zip", Name="ADDR_ZIP")]
     })
     [Embedded] protected Address address;
     ...
 }


 Example 3:

 [Entity] public class PropertyRecord {
     [Embedded]Id PropertyOwner owner;
     [AttributeOverride(PropertyName="key.street", Name="STREET_NAME")]
     [AttributeOverride(PropertyName="value.size", Name="SQUARE_FEET")]
     [AttributeOverride(PropertyName="value.tax", Name="ASSESSMENT")]

    [ElementCollection]
    Dictionary<Address, PropertyInfo> parcels;
 }

[Embeddable] public class PropertyInfo {
    Integer parcelNumber;
    Integer size;
    BigDecimal tax;
}

Namespace: NPersistence
Assembly: NPersistence (in NPersistence.dll) Version: 2.0.0.0 (2.0.0.0)

Syntax

   
 C# 
public sealed class AttributeOverride : Column

Members

         
 All Members  Constructors   Fields  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
AttributeOverride()()()()
Initializes a new instance of the AttributeOverride class
ColumnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the column. Defaults to the generated SQL to create a column of the inferred type.
(Inherited from Column.)
Insertable
(Optional) Whether the column is included in SQL INSERT statements generated by the persistence provider.
(Inherited from Column.)
Length
(Optional) The column length. (Applies only if a string-valued column is used.)
(Inherited from Column.)
Name
(Optional) The name of the column. Defaults to the property or field name.
(Inherited from Column.)
Nullable
(Optional) Whether the database column is nullable.
(Inherited from Column.)
Precision
(Optional) The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.) Value must be set by developer if used when generating the DDL for the column.
(Inherited from Column.)
PropertyName
(Required) The name of the property whose mapping is being overridden if property-based access is being used, or the name of the field if field-based access is used.
Scale
(Optional) The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
(Inherited from Column.)
Table
(Optional) The name of the table that contains the column. If absent the column is assumed to be in the primary table.
(Inherited from Column.)
Unique
(Optional) Whether the column 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 corresponds to only a single column. This constraint applies in addition to any constraint entailed by primary key mapping and to constraints specified at the table level.
(Inherited from Column.)
Updatable
(Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider.
(Inherited from Column.)

Inheritance Hierarchy

System..::..Object
  System..::..Attribute
    NPersistence..::..Column
      NPersistence..::..AttributeOverride

See Also