当前位置: 首页>>代码示例>>Java>>正文


Java EmbeddedId类代码示例

本文整理汇总了Java中javax.persistence.EmbeddedId的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedId类的具体用法?Java EmbeddedId怎么用?Java EmbeddedId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EmbeddedId类属于javax.persistence包,在下文中一共展示了EmbeddedId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFieldType

import javax.persistence.EmbeddedId; //导入依赖的package包/类
@Override
public Optional<ResourceFieldType> getFieldType(BeanAttributeInformation attributeDesc) {
	Optional<OneToOne> oneToOne = attributeDesc.getAnnotation(OneToOne.class);
	Optional<OneToMany> oneToMany = attributeDesc.getAnnotation(OneToMany.class);
	Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
	Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
	if (oneToOne.isPresent() || oneToMany.isPresent() || manyToOne.isPresent() || manyToMany.isPresent()) {
		return Optional.of(ResourceFieldType.RELATIONSHIP);
	}

	Optional<Id> id = attributeDesc.getAnnotation(Id.class);
	Optional<EmbeddedId> embeddedId = attributeDesc.getAnnotation(EmbeddedId.class);
	if (id.isPresent() || embeddedId.isPresent()) {
		return Optional.of(ResourceFieldType.ID);
	}
	return Optional.empty();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:18,代码来源:JpaResourceFieldInformationProvider.java

示例2: hasIdClassOrEmbeddedId

import javax.persistence.EmbeddedId; //导入依赖的package包/类
public Boolean hasIdClassOrEmbeddedId() {
	if ( hasIdClassOrEmbeddedId == null ) {
		hasIdClassOrEmbeddedId = false;
		if ( getClassWithIdClass( true ) != null ) {
			hasIdClassOrEmbeddedId = true;
		}
		else {
			final ElementsToProcess process = getElementsToProcess();
			for ( PropertyData property : process.getElements() ) {
				if ( property.getProperty().isAnnotationPresent( EmbeddedId.class ) ) {
					hasIdClassOrEmbeddedId = true;
					break;
				}
			}
		}
	}
	return hasIdClassOrEmbeddedId;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:InheritanceState.java

示例3: ComponentPropertyHolder

import javax.persistence.EmbeddedId; //导入依赖的package包/类
public ComponentPropertyHolder(
		Component component,
		String path,
		PropertyData inferredData,
		PropertyHolder parent,
		Mappings mappings) {
	super( path, parent, inferredData.getPropertyClass(), mappings );
	final XProperty embeddedXProperty = inferredData.getProperty();
	setCurrentProperty( embeddedXProperty );
	this.component = component;
	this.isOrWithinEmbeddedId =
			parent.isOrWithinEmbeddedId()
					|| ( embeddedXProperty != null &&
					( embeddedXProperty.isAnnotationPresent( Id.class )
							|| embeddedXProperty.isAnnotationPresent( EmbeddedId.class ) ) );

	this.virtual = embeddedXProperty == null;
	if ( !virtual ) {
		this.embeddedAttributeName = embeddedXProperty.getName();
		this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );
	}
	else {
		embeddedAttributeName = "";
		this.attributeConversionInfoMap = Collections.emptyMap();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ComponentPropertyHolder.java

示例4: isProcessingId

import javax.persistence.EmbeddedId; //导入依赖的package包/类
private boolean isProcessingId(XMLContext.Default defaults) {
	boolean isExplicit = defaults.getAccess() != null;
	boolean correctAccess =
			( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
					|| ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD
					.equals( defaults.getAccess() ) );
	boolean hasId = defaults.canUseJavaAnnotations()
			&& ( isPhysicalAnnotationPresent( Id.class ) || isPhysicalAnnotationPresent( EmbeddedId.class ) );
	//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
	boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() &&
			( mirroredAttribute != null &&
					( mirroredAttribute.isAnnotationPresent( Id.class )
							|| mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) );
	boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType )
			&& !mirrorAttributeIsId;
	return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JPAOverriddenAnnotationReader.java

示例5: buildSelectByIdSql

import javax.persistence.EmbeddedId; //导入依赖的package包/类
@DB()
protected String buildSelectByIdSql(final StringBuilder sql) {
    if (_idField == null) {
        return null;
    }

    if (_idField.getAnnotation(EmbeddedId.class) == null) {
        sql.append(_table).append(".").append(DbUtil.getColumnName(_idField, null)).append(" = ? ");
    } else {
        final Class<?> clazz = _idField.getClass();
        final AttributeOverride[] overrides = DbUtil.getAttributeOverrides(_idField);
        for (final Field field : clazz.getDeclaredFields()) {
            sql.append(_table).append(".").append(DbUtil.getColumnName(field, overrides)).append(" = ? AND ");
        }
        sql.delete(sql.length() - 4, sql.length());
    }

    return sql.toString();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:GenericDaoBase.java

示例6: findById

import javax.persistence.EmbeddedId; //导入依赖的package包/类
protected T findById(final ID id, final boolean removed, final Boolean lock) {
    final StringBuilder sql = new StringBuilder(_selectByIdSql);
    if (!removed && _removed != null) {
        sql.append(" AND ").append(_removed.first());
    }
    if (lock != null) {
        sql.append(lock ? FOR_UPDATE_CLAUSE : SHARE_MODE_CLAUSE);
    }
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    PreparedStatement pstmt = null;
    try {
        pstmt = txn.prepareAutoCloseStatement(sql.toString());

        if (_idField.getAnnotation(EmbeddedId.class) == null) {
            prepareAttribute(1, pstmt, _idAttributes.get(_table)[0], id);
        }

        final ResultSet rs = pstmt.executeQuery();
        return rs.next() ? toEntityBean(rs, true) : null;
    } catch (final SQLException e) {
        throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:24,代码来源:GenericDaoBase.java

示例7: validateClassAnnotations

import javax.persistence.EmbeddedId; //导入依赖的package包/类
/**
 * Validates the provided class' annotations.
 * Currently the only validation performed is for @Id & @SpaceId annotations
 * that must be declared on the same getter.  
 */
private void validateClassAnnotations(Class<?> type) {
    // Validation is only relevant for Entities
    if (type.getAnnotation(Entity.class) == null)
        return;
    
    for (Method getter : type.getMethods()) {
        
        if (!getter.getName().startsWith("get"))
            continue;
        
        SpaceId spaceId = getter.getAnnotation(SpaceId.class);
        boolean hasJpaId = getter.getAnnotation(Id.class) != null || getter.getAnnotation(EmbeddedId.class) != null; 
        if (spaceId != null || hasJpaId) {                
            if (!hasJpaId || spaceId == null)
                throw new IllegalArgumentException("SpaceId and Id annotations must both be declared on the same property in JPA entities in type: " + type.getName());
            if (spaceId.autoGenerate()) {
                GeneratedValue generatedValue = getter.getAnnotation(GeneratedValue.class);
                if (generatedValue == null || generatedValue.strategy() != GenerationType.IDENTITY)
                    throw new IllegalArgumentException(
                            "SpaceId with autoGenerate=true annotated property should also have a JPA GeneratedValue annotation with strategy = GenerationType.IDENTITY.");
            }
            break;
        }
    }        
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:31,代码来源:StoreManager.java

示例8: getId

import javax.persistence.EmbeddedId; //导入依赖的package包/类
@EmbeddedId
@AttributeOverrides({
		@AttributeOverride(name = "RTableCatalog", column = @Column(name = "r_table_catalog")),
		@AttributeOverride(name = "RTableSchema", column = @Column(name = "r_table_schema")),
		@AttributeOverride(name = "RTableName", column = @Column(name = "r_table_name")),
		@AttributeOverride(name = "RRasterColumn", column = @Column(name = "r_raster_column")),
		@AttributeOverride(name = "srid", column = @Column(name = "srid")),
		@AttributeOverride(name = "scaleX", column = @Column(name = "scale_x", precision = 17, scale = 17)),
		@AttributeOverride(name = "scaleY", column = @Column(name = "scale_y", precision = 17, scale = 17)),
		@AttributeOverride(name = "blocksizeX", column = @Column(name = "blocksize_x")),
		@AttributeOverride(name = "blocksizeY", column = @Column(name = "blocksize_y")),
		@AttributeOverride(name = "sameAlignment", column = @Column(name = "same_alignment")),
		@AttributeOverride(name = "regularBlocking", column = @Column(name = "regular_blocking")),
		@AttributeOverride(name = "numBands", column = @Column(name = "num_bands")),
		@AttributeOverride(name = "pixelTypes", column = @Column(name = "pixel_types")),
		@AttributeOverride(name = "nodataValues", column = @Column(name = "nodata_values")),
		@AttributeOverride(name = "outDb", column = @Column(name = "out_db")),
		@AttributeOverride(name = "extent", column = @Column(name = "extent")) })
public RasterColumnsId getId() {
	return this.id;
}
 
开发者ID:AuScope,项目名称:IGSN,代码行数:22,代码来源:RasterColumns.java

示例9: getIdProp

import javax.persistence.EmbeddedId; //导入依赖的package包/类
public static String getIdProp(Class c){
	for(Method m : c.getMethods()){
		boolean isGetter = m.getName().startsWith("get");
		boolean noParameters = (m.getParameterTypes().length == 0);
		boolean notGetClass = !m.getName().equals("getClass");
		if (isGetter && noParameters && notGetClass) {
			boolean hasIdMethod = m.isAnnotationPresent(Id.class) || m.isAnnotationPresent(EmbeddedId.class);
			String fieldName = acessorToProperty(m.getName());
			boolean hasIdField = isIdField(c, fieldName);
			if(hasIdMethod || hasIdField){
				return fieldName;
			}
		}
	}
	return null;
}
 
开发者ID:EsfingeFramework,项目名称:comparison,代码行数:17,代码来源:BeanUtils.java

示例10: getId

import javax.persistence.EmbeddedId; //导入依赖的package包/类
@EmbeddedId
@AttributeOverrides({
		@AttributeOverride(name = "skuItem", column = @Column(name = "SKU_Item", length = 13)),
		@AttributeOverride(name = "upc", column = @Column(name = "UPC", length = 12)),
		@AttributeOverride(name = "sku", column = @Column(name = "SKU", length = 6)),
		@AttributeOverride(name = "itemNumber", column = @Column(name = "Item_Number", length = 6)),
		@AttributeOverride(name = "brand", column = @Column(name = "Brand", nullable = false, length = 45)),
		@AttributeOverride(name = "style", column = @Column(name = "Style", nullable = false, length = 45)),
		@AttributeOverride(name = "colorMap", column = @Column(name = "Color_Map", length = 45)),
		@AttributeOverride(name = "color", column = @Column(name = "Color", length = 45)),
		@AttributeOverride(name = "sizeMap", column = @Column(name = "Size_Map", length = 45)),
		@AttributeOverride(name = "size", column = @Column(name = "Size", length = 45)),
		@AttributeOverride(name = "sortSize", column = @Column(name = "Sort_Size", nullable = false)),
		@AttributeOverride(name = "inStock", column = @Column(name = "In_Stock", precision = 23, scale = 0)),
		@AttributeOverride(name = "material", column = @Column(name = "Material", nullable = false, length = 45)),
		@AttributeOverride(name = "shoeType", column = @Column(name = "Shoe_Type", nullable = false, length = 4)),
		@AttributeOverride(name = "description", column = @Column(name = "Description", nullable = false, length = 11)) })
public SkuShoeViewId getId() {
	return this.id;
}
 
开发者ID:VDuda,项目名称:SyncRunner-Pub,代码行数:21,代码来源:SkuShoeView.java

示例11: buildProperties

import javax.persistence.EmbeddedId; //导入依赖的package包/类
/**
 * Fills the {@link #properties}.
 *
 * @param c
 *            the currently inspected class
 * @param stopClass
 *            the class in the hierarchy to stop inspecting
 */
private void buildProperties(final Class<? super E> c, final Class<? super E> stopClass) {
	// Fill properties of super classes (at least until we find the joined parent class)
	if (c.getSuperclass() != null && c.getSuperclass() != stopClass) {
		buildProperties(c.getSuperclass(), stopClass);
	}

	// And now fill the properties of this class
	if (c.isAnnotationPresent(MappedSuperclass.class) || c.isAnnotationPresent(Entity.class)) {
		for (final AttributeAccessor field : this.accessStyle.getDeclaredAttributes(c, this.entityClass)) {
			if (!field.isAnnotationPresent(EmbeddedId.class) && !field.isAnnotationPresent(Id.class)) {
				final Property<E, ?> property = buildProperty(field, getColumnAnnotation(field),
						this.associationOverrides.get(field.getName()));
				if (property != null) {
					this.properties.put(field.getName(), property);
					this.allProperties.add(property);
					if (property instanceof SingularProperty) {
						buildUniqueProperty((SingularProperty<E, ?>) property);
					}
				}
			}
		}
	}

}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:33,代码来源:EntityClass.java

示例12: findIdProperty

import javax.persistence.EmbeddedId; //导入依赖的package包/类
private boolean findIdProperty(final Iterable<AttributeAccessor> declaredAttributes) {
	for (final AttributeAccessor attribute : declaredAttributes) {
		if (attribute.isAnnotationPresent(EmbeddedId.class)) {
			this.idProperty = new EmbeddedProperty<>(this, attribute);
			return true;
		} else if (attribute.isAnnotationPresent(Id.class)) {
			if (attribute.isAnnotationPresent(GeneratedValue.class)) {
				this.context.registerGenerators(attribute, this.table);
				this.idProperty = new GeneratedIdProperty<>(this, attribute, getColumnAnnotation(attribute));
			} else {
				this.idProperty = buildProperty(attribute, getColumnAnnotation(attribute),
						this.associationOverrides.get(attribute.getName()));
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:19,代码来源:EntityClass.java

示例13: findById

import javax.persistence.EmbeddedId; //导入依赖的package包/类
protected T findById(ID id, boolean removed, Boolean lock) {
    StringBuilder sql = new StringBuilder(_selectByIdSql);
    if (!removed && _removed != null) {
        sql.append(" AND ").append(_removed.first());
    }
    if (lock != null) {
        sql.append(lock ? FOR_UPDATE_CLAUSE : SHARE_MODE_CLAUSE);
    }
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    PreparedStatement pstmt = null;
    try {
        pstmt = txn.prepareAutoCloseStatement(sql.toString());

        if (_idField.getAnnotation(EmbeddedId.class) == null) {
            prepareAttribute(1, pstmt, _idAttributes.get(_table)[0], id);
        }

        ResultSet rs = pstmt.executeQuery();
        return rs.next() ? toEntityBean(rs, true) : null;
    } catch (SQLException e) {
        throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:24,代码来源:GenericDaoBase.java

示例14: getIdField

import javax.persistence.EmbeddedId; //导入依赖的package包/类
private <T> Field getIdField(Class<T> entityClass){
	Field idField = ID_FIELD.get(entityClass);
	if(idField != null){
		return idField;
	}

	List<Field> fields = new ArrayList<Field>();
	Beans.getDeclaredFields(fields, entityClass);
	for(Field f : fields){
		if(f.getAnnotation(Id.class) != null || f.getAnnotation(EmbeddedId.class) != null){
			idField = f;
		}
	}

	ID_FIELD.put(entityClass, idField);
	Asserts.notNull(idField, String.format("%s实体中没有ID字段", entityClass));

	return idField;
}
 
开发者ID:howsun,项目名称:howsun-javaee-framework,代码行数:20,代码来源:HibernateGenericDao.java

示例15: getId

import javax.persistence.EmbeddedId; //导入依赖的package包/类
@EmbeddedId
@AttributeOverrides({
                @AttributeOverride(name = "customerNumber", column = @Column(name = "customerNumber", nullable = false)),
                @AttributeOverride(name = "checkNumber", column = @Column(name = "checkNumber", nullable = false, length = 50)) })
public PaymentId getId() {
        return this.id;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Payment.java


注:本文中的javax.persistence.EmbeddedId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。