本文整理匯總了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;
}