当前位置: 首页>>代码示例>>Java>>正文


Java ClassDescriptor.getMappingForAttributeName方法代码示例

本文整理汇总了Java中org.eclipse.persistence.descriptors.ClassDescriptor.getMappingForAttributeName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassDescriptor.getMappingForAttributeName方法的具体用法?Java ClassDescriptor.getMappingForAttributeName怎么用?Java ClassDescriptor.getMappingForAttributeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.persistence.descriptors.ClassDescriptor的用法示例。


在下文中一共展示了ClassDescriptor.getMappingForAttributeName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConvertersEstabished_directAssignment

import org.eclipse.persistence.descriptors.ClassDescriptor; //导入方法依赖的package包/类
@Test
public void testConvertersEstabished_directAssignment() throws Exception {
	ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
	DatabaseMapping attribute = classDescriptor.getMappingForAttributeName("nonStandardDataType");
	assertEquals("attribute data type mismatch", DirectToFieldMapping.class, attribute.getClass());
	Converter converter = ((org.eclipse.persistence.mappings.DirectToFieldMapping) attribute).getConverter();
	assertNotNull("converter not assigned", converter);
	assertEquals("Mismatch - converter should have been the EclipseLink JPA wrapper class", ConverterClass.class,
               converter.getClass());
	Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
	f.setAccessible(true);
	String attributeConverterClassName = (String) f.get(converter);
	assertNotNull("attributeConverterClassName missing", attributeConverterClassName);
	assertEquals("Converter class incorrect", "org.kuali.rice.krad.data.jpa.testbo.NonStandardDataTypeConverter",
               attributeConverterClassName);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:EclipseLinkAnnotationMetadataProviderImplTest.java

示例2: testConvertersEstabished_autoApply

import org.eclipse.persistence.descriptors.ClassDescriptor; //导入方法依赖的package包/类
@Test
public void testConvertersEstabished_autoApply() throws Exception {
	ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
	DatabaseMapping attribute = classDescriptor.getMappingForAttributeName("currencyProperty");
	assertEquals("attribute data type mismatch", DirectToFieldMapping.class, attribute.getClass());
	Converter converter = ((org.eclipse.persistence.mappings.DirectToFieldMapping) attribute).getConverter();
	assertNotNull("converter not assigned", converter);
	assertEquals("Mismatch - converter should have been the EclipseLink JPA wrapper class", ConverterClass.class,
               converter.getClass());
	Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
	f.setAccessible(true);
	String attributeConverterClassName = (String) f.get(converter);
	assertNotNull("attributeConverterClassName missing", attributeConverterClassName);
	assertEquals("Converter class incorrect", "org.kuali.rice.krad.data.jpa.converters.KualiDecimalConverter",
               attributeConverterClassName);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:EclipseLinkAnnotationMetadataProviderImplTest.java

示例3: testConvertersEstabished_autoApply_Boolean

import org.eclipse.persistence.descriptors.ClassDescriptor; //导入方法依赖的package包/类
@Test
public void testConvertersEstabished_autoApply_Boolean() throws Exception {
	ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
	DatabaseMapping attribute = classDescriptor.getMappingForAttributeName("booleanProperty");
	assertEquals("attribute data type mismatch", DirectToFieldMapping.class, attribute.getClass());
	Converter converter = ((org.eclipse.persistence.mappings.DirectToFieldMapping) attribute).getConverter();
	assertNotNull("converter not assigned", converter);
	assertEquals("Mismatch - converter should have been the EclipseLink JPA wrapper class", ConverterClass.class,
               converter.getClass());
	Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
	f.setAccessible(true);
	String attributeConverterClassName = (String) f.get(converter);
	assertNotNull("attributeConverterClassName missing", attributeConverterClassName);
	assertEquals("Converter class incorrect", "org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter",
               attributeConverterClassName);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:EclipseLinkAnnotationMetadataProviderImplTest.java

示例4: handleRemoveMapping

import org.eclipse.persistence.descriptors.ClassDescriptor; //导入方法依赖的package包/类
/**
 * Checks class descriptors for {@link @RemoveMapping} and {@link RemoveMappings} annotations at the class level
 * and removes any specified mappings from the ClassDescriptor.
 *
 * @param session the current session.
 */
protected void handleRemoveMapping(Session session) {
    Map<Class, ClassDescriptor> descriptors = session.getDescriptors();

    if (descriptors == null || descriptors.isEmpty()) {
        return;
    }

    for (ClassDescriptor classDescriptor : descriptors.values()) {
        List<DatabaseMapping> mappingsToRemove = new ArrayList<DatabaseMapping>();
        List<RemoveMapping> removeMappings = scanForRemoveMappings(classDescriptor);

        for (RemoveMapping removeMapping : removeMappings) {
            if (StringUtils.isBlank(removeMapping.name())) {
                throw DescriptorException.attributeNameNotSpecified();
            }

            DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName(removeMapping.name());

            if (databaseMapping == null) {
                throw DescriptorException.mappingForAttributeIsMissing(removeMapping.name(), classDescriptor);
            }

            mappingsToRemove.add(databaseMapping);
        }

        for (DatabaseMapping mappingToRemove : mappingsToRemove) {
            classDescriptor.removeMappingForAttributeName(mappingToRemove.getAttributeName());
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:37,代码来源:KradEclipseLinkCustomizer.java

示例5: testExtensionAttribute_eclipselink_data

import org.eclipse.persistence.descriptors.ClassDescriptor; //导入方法依赖的package包/类
@Test
public void testExtensionAttribute_eclipselink_data() {
	ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
	ClassDescriptor referenceDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObjectExtension.class);
	assertNotNull("A classDescriptor should have been retrieved from JPA for TestDataObject", classDescriptor);
	assertNotNull("A classDescriptor should have been retrieved from JPA for TestDataObjectExtension",
               referenceDescriptor);
	DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName("extension");
       assertNotNull("extension mapping missing from metamodel", databaseMapping);
       assertTrue("Should be a OneToOne mapping", databaseMapping instanceof OneToOneMapping);
       OneToOneMapping mapping = (OneToOneMapping)databaseMapping;

       assertEquals("Should be mapped by primaryKeyProperty", "primaryKeyProperty", mapping.getMappedBy());
       Map<DatabaseField, DatabaseField> databaseFields = mapping.getSourceToTargetKeyFields();
       assertEquals(1, databaseFields.size());
       for (DatabaseField sourceField : databaseFields.keySet()) {
           DatabaseField targetField = databaseFields.get(sourceField);
           assertEquals("PK_PROP", sourceField.getName());
           assertEquals("PK_PROP", targetField.getName());
       }

	assertNotNull("Reference descriptor missing from relationship", mapping.getReferenceDescriptor());
	assertEquals("Reference descriptor should be the one for TestDataObjectExtension", referenceDescriptor,
               mapping.getReferenceDescriptor());

	assertNotNull("selection query relationship missing", mapping.getSelectionQuery());
	assertNotNull("selection query missing name", mapping.getSelectionQuery().getName());
	assertEquals("selection query name incorrect", "extension", mapping.getSelectionQuery().getName());
	assertNotNull("selection query reference class", mapping.getSelectionQuery().getReferenceClass());
	assertEquals("selection query reference class incorrect", TestDataObjectExtension.class,
               mapping.getSelectionQuery().getReferenceClass());
	assertNotNull("selection query reference class name", mapping.getSelectionQuery().getReferenceClassName());
	assertNotNull("selection query source mapping missing", mapping.getSelectionQuery().getSourceMapping());
	assertEquals("selection query source mapping incorrect", mapping,
               mapping.getSelectionQuery().getSourceMapping());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:37,代码来源:EclipseLinkAnnotationMetadataProviderImplTest.java


注:本文中的org.eclipse.persistence.descriptors.ClassDescriptor.getMappingForAttributeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。