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


Java Embedded类代码示例

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


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

示例1: determineDeleteInBatchSupported

import javax.persistence.Embedded; //导入依赖的package包/类
private boolean determineDeleteInBatchSupported(final Class<?> genericType) {
    final MutableBoolean deleteInBatchSupported = new MutableBoolean(true);
    Reflections.doWithFields(genericType, new FieldCallback() {
        @Override
        public void doWith(final Field field) {
            if (!deleteInBatchSupported.getValue()) {
                return;
            } else if (Reflections.getAnnotation(field, ElementCollection.class) != null) {
                //element collections are mapped as separate tables, thus the values would cause a foreign key constraint violation
                deleteInBatchSupported.setValue(false);
            } else if (Reflections.getAnnotation(field, Embedded.class) != null) {
                //check embedded types for the same constraints
                if (!determineDeleteInBatchSupported(field.getType())) {
                    deleteInBatchSupported.setValue(false);
                }
            }
        }
    });
    return deleteInBatchSupported.getValue();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:21,代码来源:ACustomIdDao.java

示例2: setAuditCreatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), "auditable");
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new AdminAuditable());
                auditable = field.get(entity);
            }
            Field temporalCreatedField = auditable.getClass().getDeclaredField("dateCreated");
            Field temporalUpdatedField = auditable.getClass().getDeclaredField("dateUpdated");
            Field agentField = auditable.getClass().getDeclaredField("createdBy");
            setAuditValueTemporal(temporalCreatedField, auditable);
            setAuditValueTemporal(temporalUpdatedField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:21,代码来源:AdminAuditableListener.java

示例3: setAuditUpdatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), "auditable");
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new AdminAuditable());
                auditable = field.get(entity);
            }
            Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
            Field agentField = auditable.getClass().getDeclaredField("updatedBy");
            setAuditValueTemporal(temporalField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:19,代码来源:AdminAuditableListener.java

示例4: setAuditCreatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), "auditable");
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new Auditable());
                auditable = field.get(entity);
            }
            Field temporalField = auditable.getClass().getDeclaredField("dateCreated");
            Field agentField = auditable.getClass().getDeclaredField("createdBy");
            setAuditValueTemporal(temporalField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:19,代码来源:AuditableListener.java

示例5: setAuditUpdatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), "auditable");
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new Auditable());
                auditable = field.get(entity);
            }
            Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
            Field agentField = auditable.getClass().getDeclaredField("updatedBy");
            setAuditValueTemporal(temporalField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:19,代码来源:AuditableListener.java

示例6: setAuditCreatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), getAuditableFieldName());
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new AdminAuditable());
                auditable = field.get(entity);
            }
            Field temporalCreatedField = auditable.getClass().getDeclaredField("dateCreated");
            Field temporalUpdatedField = auditable.getClass().getDeclaredField("dateUpdated");
            Field agentField = auditable.getClass().getDeclaredField("createdBy");
            setAuditValueTemporal(temporalCreatedField, auditable);
            setAuditValueTemporal(temporalUpdatedField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:21,代码来源:AdminAuditableListener.java

示例7: setAuditUpdatedBy

import javax.persistence.Embedded; //导入依赖的package包/类
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        Field field = getSingleField(entity.getClass(), getAuditableFieldName());
        field.setAccessible(true);
        if (field.isAnnotationPresent(Embedded.class)) {
            Object auditable = field.get(entity);
            if (auditable == null) {
                field.set(entity, new AdminAuditable());
                auditable = field.get(entity);
            }
            Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
            Field agentField = auditable.getClass().getDeclaredField("updatedBy");
            setAuditValueTemporal(temporalField, auditable);
            setAuditValueAgent(agentField, auditable);
        }
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:19,代码来源:AdminAuditableListener.java

示例8: buildProperty

import javax.persistence.Embedded; //导入依赖的package包/类
/**
 * Builds the property for the given attribute.
 *
 * @param attribute
 *            the attribute to inspect
 * @param columnMetadata
 *            the attached (or overriden) column metadata
 * @param override
 *            the AssociationOverride found for this attribute
 * @return the property that represents the attribute or {@code null} if not persistent
 */
<X> Property<X, ?> buildProperty(final AttributeAccessor attribute, final Column columnMetadata,
		final AssociationOverride override) {
	if (attribute.isPersistent()) {
		if (CollectionProperty.isCollectionProperty(attribute)) {
			return new CollectionProperty<>(this, attribute, override);
		} else if (MapProperty.isMapProperty(attribute)) {
			return new MapProperty<>(this, attribute, override);
		} else if (EntityProperty.isEntityProperty(attribute)) {
			return new EntityProperty<>(this.context, getTable(), attribute, override);
		} else if (attribute.isAnnotationPresent(Embedded.class)) {
			return new EmbeddedProperty<>(this, attribute);
		} else if (attribute.isAnnotationPresent(Version.class)) {
			return new VersionProperty<>(this.context, this.table, attribute, columnMetadata);
		} else {
			return new PrimitiveProperty<>(this.context, this.table, attribute, columnMetadata);
		}
	}
	return null;
}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:31,代码来源:EntityClass.java

示例9: resovleEmbed

import javax.persistence.Embedded; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void resovleEmbed(List<Map> fields, List<Map> complexFields,
		Field field) {
	if (field.isAnnotationPresent(Embedded.class)) {
		for (Field f : field.getType().getDeclaredFields()) {
			if ((field.getName().equals("status"))
					|| field.getName().equals("serialVersionUID")) {
				continue;
			}
			if (resovleGenerAnno(field)) {
				continue;
			}
			if (isSimpleType(f.getType())) {
				fields.add(parseField(f));
			}
		}
		complexFields.remove(complexFields.size() - 1);
	}
}
 
开发者ID:easyjf,项目名称:easyjweb,代码行数:20,代码来源:AllProcessor.java

示例10: findField

import javax.persistence.Embedded; //导入依赖的package包/类
public static Field findField(final Class<?> clazz, final String columnName) {
    for (final Field field : clazz.getDeclaredFields()) {
        if (field.getAnnotation(Embedded.class) != null || field.getAnnotation(EmbeddedId.class) != null) {
            findField(field.getClass(), columnName);
        } else {
            if (columnName.equals(DbUtil.getColumnName(field))) {
                return field;
            }
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:13,代码来源:DbUtil.java

示例11: setTimestamps

import javax.persistence.Embedded; //导入依赖的package包/类
private void setTimestamps(Field[] fields, Object entity) throws Exception {
    Calendar cal = null;
    for (Field field : fields) {
        Class<?> type = field.getType();
        Temporal temporalAnnotation = field.getAnnotation(Temporal.class);

        if (temporalAnnotation != null) {
            if (field.isAnnotationPresent(Column.class)) {
                field.setAccessible(true);
                try {
                    if (TemporalType.TIMESTAMP.equals(temporalAnnotation.value()) && (field.isAnnotationPresent(AutoPopulate.class))) {
                        if (field.get(entity) == null || field.getAnnotation(AutoPopulate.class).autoUpdateValue()) {
                            if (type.isAssignableFrom(Date.class)) {
                                if (cal == null) {
                                    cal = SystemTime.asCalendar();
                                }
                                field.set(entity, cal.getTime());
                            } else if (type.isAssignableFrom(Calendar.class)) {
                                if (cal == null) {
                                    cal = SystemTime.asCalendar();
                                }
                                field.set(entity, cal);
                            }
                        }
                    }
                } finally {
                    field.setAccessible(false);
                }
            }
        } else if (field.isAnnotationPresent(Embedded.class)) {
            field.setAccessible(true);
            try {
                // Call recursively
                setTimestamps(field.getType().getDeclaredFields(), field.get(entity));
            } finally {
                field.setAccessible(false);
            }
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:41,代码来源:TemporalTimestampListener.java

示例12: getDuration

import javax.persistence.Embedded; //导入依赖的package包/类
@Embedded
@AttributeOverrides({
        @AttributeOverride(name = "learner", column = @Column(name = "duration_learner")),
        @AttributeOverride(name = "eqOracle", column = @Column(name = "duration_eqOracle"))
})
public DetailedStatistics getDuration() {
    return duration;
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:9,代码来源:Statistics.java

示例13: getMqsUsed

import javax.persistence.Embedded; //导入依赖的package包/类
@Embedded
@AttributeOverrides({
        @AttributeOverride(name = "learner", column = @Column(name = "mqs_learner")),
        @AttributeOverride(name = "eqOracle", column = @Column(name = "mqs_eqOracle"))
})
public DetailedStatistics getMqsUsed() {
    return mqsUsed;
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:9,代码来源:Statistics.java

示例14: getSymbolsUsed

import javax.persistence.Embedded; //导入依赖的package包/类
@Embedded
@AttributeOverrides({
        @AttributeOverride(name = "learner", column = @Column(name = "symbolsUsed_learner")),
        @AttributeOverride(name = "eqOracle", column = @Column(name = "symbolsUsed_eqOracle"))
})
public DetailedStatistics getSymbolsUsed() {
    return symbolsUsed;
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:9,代码来源:Statistics.java

示例15: getPostalCode

import javax.persistence.Embedded; //导入依赖的package包/类
/**
 * @return Postal code of the address
 */
@Embedded
@AttributeOverrides(value={
	       @AttributeOverride(name="code", [email protected](name="address_postal_code", length = 10, nullable = true))
	   })
public PostalCode getPostalCode() {
	return this.postalCode;
}
 
开发者ID:MobileManAG,项目名称:Project-H-Backend,代码行数:11,代码来源:Address.java


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