本文整理汇总了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();
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}