本文整理汇总了Java中org.eclipse.persistence.mappings.DatabaseMapping.isDirectToFieldMapping方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMapping.isDirectToFieldMapping方法的具体用法?Java DatabaseMapping.isDirectToFieldMapping怎么用?Java DatabaseMapping.isDirectToFieldMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.persistence.mappings.DatabaseMapping
的用法示例。
在下文中一共展示了DatabaseMapping.isDirectToFieldMapping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: camelCaseToUnderscore
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
private void camelCaseToUnderscore(Vector<DatabaseMapping> mappings) {
for (DatabaseMapping mapping : mappings) {
DatabaseField field = mapping.getField();
if (mapping.isDirectToFieldMapping() && !mapping.isPrimaryKeyMapping()) {
String attributeName = mapping.getAttributeName();
String underScoredFieldName = camelCaseToUnderscore(attributeName);
field.setName(underScoredFieldName);
}
}
}
示例2: customize
import org.eclipse.persistence.mappings.DatabaseMapping; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void customize(Session session) throws Exception {
Map<Class, ClassDescriptor> descriptors = session.getDescriptors();
// iterate all descriptors
for (ClassDescriptor classDescriptor : descriptors.values()) {
// iterate the mappings of each descriptor
for (DatabaseMapping databaseMapping : classDescriptor.getMappings()) {
// process embedded properties
if (databaseMapping.isAggregateObjectMapping()) {
AggregateObjectMapping m = (AggregateObjectMapping) databaseMapping;
Map<String, DatabaseField> fieldMapping = m.getAggregateToSourceFields();
// iterate the mappings of the embeddable class
for (DatabaseMapping refMapping : descriptors.get(m.getReferenceClass()).getMappings()) {
if (refMapping.isDirectToFieldMapping()) {
DirectToFieldMapping refDirectMapping = (DirectToFieldMapping) refMapping;
String refFieldName = refDirectMapping.getField().getName();
if (!fieldMapping.containsKey(refFieldName)) {
DatabaseField mappedField = refDirectMapping.getField().clone();
mappedField.setName(m.getAttributeName() + "_" + mappedField.getName());
fieldMapping.put(refFieldName, mappedField);
}
}
}
}
}
}
}