AssociationOverride (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.persistence Annotation Type AssociationOverride


@Target(value={TYPE,METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface AssociationOverride

This annotation is used to override a many-to-one or one-to-one mapping of property or field for an entity relationship.

The AssociationOverride annotation may be applied to an entity that extends a mapped superclass to override a many-to-one or one-to-one mapping defined by the mapped superclass. If the AssociationOverride annotation is not specified, the join column is mapped the same as in the original mapping.

    Example:
    @MappedSuperclass
    public class Employee {
        ...
        @ManyToOne
        protected Address address;
        ...
    }
    
    @Entity 
    @AssociationOverride(name="address", 
        joinColumns=@JoinColumn(name="ADDR_ID"))
    // address field mapping overridden to ADDR_ID fk
    public class PartTimeEmployee extends Employee {
        ...
    }
 

从以下版本开始:
Java Persistence 1.0
另请参见:
OneToOne, ManyToOne, MappedSuperclass

Required Element Summary
 JoinColumn[] joinColumns
          The join column that is being mapped to the persistent attribute.
 String name
          The name of the relationship property whose mapping is being overridden if property-based access is being used, or the name of the relationship field if field-based access is used.
 

元素详细信息

name

public abstract String name
The name of the relationship property whose mapping is being overridden if property-based access is being used, or the name of the relationship field if field-based access is used.


joinColumns

public abstract JoinColumn[] joinColumns
The join column that is being mapped to the persistent attribute. The mapping type will remain the same as is defined in the mapped superclass.


Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.