當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。