微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.MapsId的实例源码

项目:org.fastnate    文件EntityClass.java   
/**
 * Resolves the column for the {@code id property} of this entity class.
 *
 * @param attribute
 *            the referencing attribute (for evaluating annotations)
 *
 * @return the column name
 * @throws IllegalStateException
 *             if the id property is not singular and no MapsId is given
 */
GeneratorColumn getIdColumn(final AttributeAccessor attribute) {
    if (this.idProperty instanceof SingularProperty) {
        return ((SingularProperty<?,?>) this.idProperty).getColumn();
    }
    if (this.idProperty instanceof EmbeddedProperty) {
        final MapsId mapsId = attribute.getAnnotation(MapsId.class);
        if (mapsId != null && mapsId.value().length() > 0) {
            final Property<?,?> property = ((EmbeddedProperty<E,?>) this.idProperty).getEmbeddedProperties()
                    .get(mapsId.value());
            if (property instanceof SingularProperty) {
                return ((SingularProperty<?,?>) this.idProperty).getColumn();
            }
        }
        throw new ModelException(attribute + " misses MapId for a singular property in " + this.entityClass);
    }
    if (this.idProperty == null && this.parentEntityClass != null) {
        // It seems we are still building the hierarchy
        this.idProperty = this.context.getDescription(this.parentEntityClass).getIdproperty();
        if (this.idProperty != null) {
            return getIdColumn(attribute);
        }
    }

    throw new ModelException(attribute + " does not reference an ID column in " + this.entityClass);
}
项目:lams    文件Configuration.java   
public void addPropertyAnnotatedWithMapsId(XClass entityType,PropertyData property) {
    Map<String,PropertyData> map = propertiesAnnotatedWithMapsId.get( entityType );
    if ( map == null ) {
        map = new HashMap<String,PropertyData>();
        propertiesAnnotatedWithMapsId.put( entityType,map );
    }
    map.put( property.getproperty().getAnnotation( MapsId.class ).value(),property );
}
项目:lams    文件JPAOverriddenAnnotationReader.java   
/**
 * Adds a @MapsId annotation to the specified annotationList if the specified element has the
 * maps-id attribute set. This should only be the case for many-to-one or one-to-one
 * associations.
 */
private void getMapsId(List<Annotation> annotationList,Element element) {
    String attrVal = element.attributeValue( "maps-id" );
    if ( attrVal != null ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( MapsId.class );
        ad.setValue( "value",attrVal );
        annotationList.add( AnnotationFactory.create( ad ) );
    }
}
项目:engerek    文件RAuditItem.java   
@ForeignKey(name = "none")
@MapsId("record")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
        @JoinColumn(name = COLUMN_RECORD_ID,referencedColumnName = "id")
})
public RAuditEventRecord getRecord() {
    return record;
}
项目:org.fastnate    文件EntityProperty.java   
/**
 * Creates a new instance of {@link EntityProperty}.
 *
 * @param context
 *            the generator context.
 * @param containerTable
 *            the table that contains our column
 * @param attribute
 *            the accessor of the attribute
 * @param override
 *            optional {@link AttributeOverride} configuration.
 */
public EntityProperty(final GeneratorContext context,final GeneratorTable containerTable,final AttributeAccessor attribute,@Nullable final AssociationOverride override) {
    super(attribute);
    this.context = context;

    // Initialize the target class description
    this.targetClass = context.getDescription((Class<T>) attribute.getType());

    // Initialize according to the *ToOne annotations
    final Mapping@R_324_4045@ion mapping = new Mapping@R_324_4045@ion(attribute);
    this.required = !mapping.isOptional();
    this.mappedBy = mapping.getMappedBy().length() == 0 ? null : mapping.getMappedBy();
    final MapsId mapsId = attribute.getAnnotation(MapsId.class);
    this.idField = mapsId != null ? mapsId.value() : null;

    // Initialize the column name
    if (this.mappedBy == null) {
        final JoinColumn joinColumn = override != null && override.joinColumns().length > 0
                ? override.joinColumns()[0]
                : attribute.getAnnotation(JoinColumn.class);
        if (joinColumn != null && joinColumn.name().length() > 0) {
            this.column = containerTable.resolveColumn(joinColumn.name());
        } else {
            this.column = containerTable.resolveColumn(attribute.getName() + "_"
                    + (this.targetClass == null ? "id" : this.targetClass.getIdColumn(attribute)));
        }
    } else {
        this.column = null;
    }

    // Initialize ANY Meta @R_324_4045@ion
    final String anyColumnName = mapping.getAnyMetaColumn();
    if (anyColumnName != null) {
        this.anyColumn = containerTable.resolveColumn(anyColumnName);
        fillMetaDefs(attribute,context.getDialect());
    } else {
        this.anyColumn = null;
    }
}
项目:BCDS    文件ModelratingResultsstatus.java   
@MapsId("processId")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROCESS_ID",insertable = false,updatable = false)
public ModelratingResults getModelratingResults() {
    return this.modelratingResults;
}
项目:celerio-angular-quickstart    文件UseCase3.java   
@JoinColumn(name = "ID2",nullable = false)
@ManyToOne
@MapsId(value = "id2")
public UseCase2 getId2() {
    return id2;
}
项目:org.fastnate    文件PluralProperty.java   
private static String findMappedId(final AttributeAccessor attribute) {
    final MapsId mapsId = attribute.getAnnotation(MapsId.class);
    return mapsId == null || mapsId.value().length() == 0 ? null : mapsId.value();
}
项目:jbromo    文件EntityUtil.java   
/**
 * Return true if MapsId annotation is define on a field.
 * @param field the field
 * @return true/false.
 */
public static boolean isMapsId(final Field field) {
    return field.getAnnotation(MapsId.class) != null;
}
项目:jbromo    文件EntityUtil.java   
/**
 * Get field name from MapsId annotation.
 * @param field the field
 * @return the field name.
 */
public static String getMapsIdValue(final Field field) {
    final MapsId m = field.getAnnotation(MapsId.class);
    return m == null ? null : m.value();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。