- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping
类的一些代码示例,展示了XMLObjectReferenceMapping
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLObjectReferenceMapping
类的具体详情如下:
包路径:org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping
类名称:XMLObjectReferenceMapping
[英]TopLink OXM version of a 1-1 mapping. A list of source-target key field associations is used to link the source xpaths to their related target xpaths, and hence their primary key (unique identifier) values used when (un)marshalling. This mapping has a Vector of XMLFields as opposed to a single XMLField. It is important to note that each target xpath is assumed to be set as a primary key field on the target (reference) class descriptor - this is necessary in order to locate the correct target object instance in the session cache when resolving mapping references.
[中]TopLink OXM版本的1-1映射。源-目标密钥字段关联列表用于将源XPath链接到它们的相关目标XPath,从而在(取消)编组时使用它们的主键(唯一标识符)值。这种映射有一个XMLFields向量,而不是一个XMLField向量。需要注意的是,假设每个目标xpath都被设置为目标(引用)类描述符上的主键字段——这对于在解析映射引用时在会话缓存中找到正确的目标对象实例是必要的。
代码示例来源:origin: stackoverflow.com
import org.eclipse.persistence.config.DescriptorCustomizer;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping;
public class PhoneNumberCustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor descriptor) throws Exception {
descriptor.removeMappingForAttributeName("contact");
XMLObjectReferenceMapping contactMapping = new XMLObjectReferenceMapping();
contactMapping.setAttributeName("contact");
contactMapping.setReferenceClass(Employee.class);
contactMapping.addSourceToTargetKeyFieldAssociation("contact/@eID", "eId/text()");
contactMapping.addSourceToTargetKeyFieldAssociation("contact/@country", "country/text()");
descriptor.addMapping(contactMapping);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public void writeSingleValue(Object value, Object parent, XMLRecord row, AbstractSession session) {
for (Iterator fieldIt = getFields().iterator(); fieldIt.hasNext();) {
XMLField xmlField = (XMLField) fieldIt.next();
Object fieldValue = buildFieldValue(value, xmlField, session);
if (fieldValue != null) {
QName schemaType = getSchemaType(xmlField, fieldValue, session);
String stringValue = getValueToWrite(schemaType, fieldValue, session);
row.put(xmlField, stringValue);
}
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public void preInitialize(AbstractSession session) throws DescriptorException {
getAttributeAccessor().setIsWriteOnly(this.isWriteOnly());
getAttributeAccessor().setIsReadOnly(this.isReadOnly());
super.preInitialize(session);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Write the attribute value from the object to the row.
*/
@Override
public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) {
// for each xmlField on this mapping
Object targetObject = getAttributeValueFromObject(object);
writeSingleValue(targetObject, object, (XMLRecord) row, session);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
private void addChoiceElementMapping(XMLField sourceField, String className, XMLField targetField) {
XMLObjectReferenceMapping mapping = new XMLObjectReferenceMapping();
mapping.setReferenceClassName(className);
mapping.setAttributeAccessor(temporaryAccessor);
mapping.addSourceToTargetKeyFieldAssociation(sourceField, targetField);
this.choiceElementMappings.put(sourceField, mapping);
this.choiceElementMappingsByClassName.put(className, mapping);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
private void addChoiceElementMapping(XMLField sourceField, Class theClass, XMLField targetField) {
XMLObjectReferenceMapping mapping = new XMLObjectReferenceMapping();
mapping.setReferenceClass(theClass);
mapping.setAttributeAccessor(temporaryAccessor);
mapping.addSourceToTargetKeyFieldAssociation(sourceField, targetField);
this.choiceElementMappings.put(sourceField, mapping);
this.choiceElementMappingsByClass.put(theClass, mapping);
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
if (getReferenceClass() == null) {
setReferenceClass(session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(getReferenceClassName()));
XMLDescriptor descriptor = (XMLDescriptor) this.getDescriptor();
XMLDescriptor targetDescriptor = (XMLDescriptor) getReferenceDescriptor();
for (int index = 0; index < sourceToTargetKeys.size(); index++) {
XMLField sourceField = (XMLField) sourceToTargetKeys.get(index);
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
if (null == referenceClass) {
if(referenceClassName != null){
setReferenceClass(session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(referenceClassName));
XMLDescriptor descriptor = (XMLDescriptor) this.getDescriptor();
XMLDescriptor targetDescriptor = (XMLDescriptor) getReferenceDescriptor();
for (int index = 0; index < sourceToTargetKeys.size(); index++) {
XMLField sourceField = (XMLField) sourceToTargetKeys.get(index);
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Cascade registerNew for Create through mappings that require the cascade
*/
public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) {
// Aggregate objects are not registered but their mappings should be.
Object objectReferenced = getRealAttributeValueFromObject(object, uow);
if (objectReferenced == null) {
return;
}
if (!visitedObjects.containsKey(objectReferenced)) {
visitedObjects.put(objectReferenced, objectReferenced);
ObjectBuilder builder = getReferenceDescriptor(objectReferenced.getClass(), uow).getObjectBuilder();
builder.cascadeRegisterNewForCreate(objectReferenced, uow, visitedObjects);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Retrieve the target object's primary key value that is mapped to a given
* source xpath (in the source-target key field association list).
*
* @param sourceObject
* @param xmlFld
* @param session
* @return null if the target object is null, the reference class is null, or
* a primary key field name does not exist on the reference descriptor that
* matches the target field name - otherwise, return the associated primary
* key value
*/
public Object buildFieldValue(Object targetObject, XMLField xmlFld, AbstractSession session) {
if (targetObject == null || getReferenceClass() == null) {
return null;
}
ClassDescriptor descriptor = getReferenceDescriptor();
ObjectBuilder objectBuilder = descriptor.getObjectBuilder();
Vector pks = objectBuilder.extractPrimaryKeyFromObject(targetObject, session);
int idx = descriptor.getPrimaryKeyFields().indexOf(getSourceToTargetKeyFieldAssociations().get(xmlFld));
if (idx == -1) {
return null;
}
return pks.get(idx);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
if (targetObject == null || getReferenceClass() == null) {
return null;
Object primaryKey = objectBuilder.extractPrimaryKeyFromObject(targetObject, session);
int idx = 0;
if(!(null == referenceClass || ClassConstants.OBJECT == getReferenceClass())) {
idx = descriptor.getPrimaryKeyFields().indexOf(getSourceToTargetKeyFieldAssociations().get(xmlFld));
if (idx == -1) {
return null;
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
private Setting convertToSetting(DatabaseMapping mapping, Object value) {
XMLDescriptor xmlDescriptor = (XMLDescriptor) mapping.getDescriptor();
NamespaceResolver nsResolver = xmlDescriptor.getNamespaceResolver();
Setting rootSetting = new Setting();
XMLField xmlField = (XMLField) mapping.getField();
if (xmlField == null) {
if (mapping instanceof XMLObjectReferenceMapping) {
xmlField = (XMLField) ((XMLObjectReferenceMapping) mapping).getFields().get(0);
} else if (mapping instanceof XMLCollectionReferenceMapping) {
xmlField = (XMLField) ((XMLCollectionReferenceMapping) mapping).getFields().get(0);
}
}
Setting setting = rootSetting;
if (xmlField != null) {
XPathFragment xPathFragment = xmlField.getXPathFragment();
rootSetting = convertToSetting(xPathFragment, nsResolver);
setting = rootSetting;
while (xPathFragment.getNextFragment() != null) {
xPathFragment = xPathFragment.getNextFragment();
Setting childSetting = convertToSetting(xPathFragment, nsResolver);
setting.addChild(childSetting);
setting = childSetting;
}
}
setting.setObject(dataObject);
setting.setMapping(mapping);
setting.setValue(value, false);
return rootSetting;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
oppositeMapping.setInverseReferenceMapping(this);
if(refMapping.getReferenceClass() == this.getDescriptor().getJavaClass()) {
refMapping.setInverseReferenceMapping(this);
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.moxy
ObjectReferenceMapping mapping = new XMLObjectReferenceMapping();
initializeXMLMapping((XMLMapping)mapping, property);
mapping.setReferenceClassName(referenceClass.getQualifiedName());
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object targetObject, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
Object fieldValue = xmlObjectReferenceMapping.buildFieldValue(targetObject, xmlField, session);
if (fieldValue == null) {
if(null != targetObject) {
XMLField fkField = (XMLField) xmlObjectReferenceMapping.getSourceToTargetKeyFieldAssociations().get(xmlField);
fieldValue = marshalRecord.getMarshaller().getXMLContext().getValueByXPath(targetObject, fkField.getXPath(), fkField.getNamespaceResolver(), Object.class);
}
if(null == fieldValue) {
return false;
}
}
QName schemaType = getSchemaType(xmlField, fieldValue, session);
String stringValue = getValueToWrite(schemaType, fieldValue, (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(),namespaceResolver);
XPathFragment groupingFragment = marshalRecord.openStartGroupingElements(namespaceResolver);
if (xPathFragment.isAttribute()) {
marshalRecord.attribute(xPathFragment, namespaceResolver, stringValue);
marshalRecord.closeStartGroupingElements(groupingFragment);
} else {
marshalRecord.closeStartGroupingElements(groupingFragment);
marshalRecord.characters(stringValue);
}
return true;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
if(nextMapping instanceof XMLObjectReferenceMapping) {
XMLObjectReferenceMapping refMapping = (XMLObjectReferenceMapping)nextMapping;
if(refMapping.getInverseReferenceMapping().getAttributeAccessor() != null && refMapping.getInverseReferenceMapping().getContainerPolicy() != null) {
ClassDescriptor refDescriptor = ormSession.getClassDescriptor(refMapping.getReferenceClass());
if(refDescriptor != null) {
DatabaseMapping backpointerMapping =refDescriptor.getMappingForAttributeName(refMapping.getInverseReferenceMapping().getAttributeName());
if(backpointerMapping != null && backpointerMapping.isCollectionMapping()) {
refMapping.getInverseReferenceMapping().getContainerPolicy().setContainerClass(((CollectionMapping)backpointerMapping).getContainerPolicy().getContainerClass());
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
private void addChoiceElementMapping(XMLField sourceField, Class theClass, XMLField targetField) {
XMLObjectReferenceMapping mapping = new XMLObjectReferenceMapping();
mapping.setReferenceClass(theClass);
mapping.setAttributeAccessor(temporaryAccessor);
mapping.addSourceToTargetKeyFieldAssociation(sourceField, targetField);
this.choiceElementMappings.put(sourceField, mapping);
this.choiceElementMappingsByClass.put(theClass, mapping);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
private void addChoiceElementMapping(XMLField sourceField, String className, XMLField targetField) {
XMLObjectReferenceMapping mapping = new XMLObjectReferenceMapping();
mapping.setReferenceClassName(className);
mapping.setAttributeAccessor(temporaryAccessor);
mapping.addSourceToTargetKeyFieldAssociation(sourceField, targetField);
this.choiceElementMappings.put(sourceField, mapping);
this.choiceElementMappingsByClassName.put(className, mapping);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
if (null == referenceClass) {
if(referenceClassName != null){
setReferenceClass(session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(referenceClassName));
XMLDescriptor descriptor = (XMLDescriptor) this.getDescriptor();
XMLDescriptor targetDescriptor = (XMLDescriptor) getReferenceDescriptor();
for (int index = 0; index < sourceToTargetKeys.size(); index++) {
XMLField sourceField = (XMLField) sourceToTargetKeys.get(index);
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Cascade perform delete through mappings that require the cascade
*/
public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects) {
// objects referenced by this mapping are not registered as they have
// no identity, however mappings from the referenced object may need cascading.
Object objectReferenced = getRealAttributeValueFromObject(object, uow);
if (objectReferenced == null) {
return;
}
if (!visitedObjects.containsKey(objectReferenced)) {
visitedObjects.put(objectReferenced, objectReferenced);
ObjectBuilder builder = getReferenceDescriptor(objectReferenced.getClass(), uow).getObjectBuilder();
builder.cascadePerformRemove(objectReferenced, uow, visitedObjects);
}
}
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setAttributeName()方法的一些代码示例
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getSchemaType()方法的一些代码示例,展示
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setIsWriteOnly()方法的一些代码示例,展
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getValueToWrite()方法的一些代码示例,
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.isReadOnly()方法的一些代码示例,展示了XM
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getAttributeValueFromObject
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getSingleValueToWriteForUni
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getFields()方法的一些代码示例,展示了XML
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.writeSingleValue()方法的一些代码示例
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getReferenceClass()方法的一些代码示
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getRealAttributeValueFromOb
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getDescriptor()方法的一些代码示例,展示
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setInverseReferenceMapping(
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setAttributeAccessor()方法的一些
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.initialize()方法的一些代码示例,展示了XM
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getAttributeAccessor()方法的一些
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setReferenceClassName()方法的一
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.setReferenceClass()方法的一些代码示
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.addSourceToTargetKeyFieldAs
本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping.getSourceToTargetKeyFieldAs
我是一名优秀的程序员,十分优秀!