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


Java Converter类代码示例

本文整理汇总了Java中javax.persistence.Converter的典型用法代码示例。如果您正苦于以下问题:Java Converter类的具体用法?Java Converter怎么用?Java Converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addAttributeConverter

import javax.persistence.Converter; //导入依赖的package包/类
/**
 * Adds the AttributeConverter instance to this Configuration.  This form is mainly intended for developers
 * to programatically add their own AttributeConverter instance.  HEM, instead, uses the
 * {@link #addAttributeConverter(Class, boolean)} form
 *
 * @param attributeConverter The AttributeConverter instance.
 */
public void addAttributeConverter(AttributeConverter attributeConverter) {
	boolean autoApply = false;
	Converter converterAnnotation = attributeConverter.getClass().getAnnotation( Converter.class );
	if ( converterAnnotation != null ) {
		autoApply = converterAnnotation.autoApply();
	}

	addAttributeConverter( new AttributeConverterDefinition( attributeConverter, autoApply ) );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Configuration.java

示例2: doAutoJpa

import javax.persistence.Converter; //导入依赖的package包/类
public static void doAutoJpa(final IAnnotationFinder finder, final org.apache.openejb.jee.jpa.unit.PersistenceUnit pu) {
    final String packageName = pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN_PACKAGE);
    String[] packageNames = null;
    if (packageName != null) {
        packageNames = packageName.split(",");
    }

    // no need of meta currently since JPA providers doesn't support it
    final List<Class<?>> classes = new ArrayList<Class<?>>();
    classes.addAll(finder.findAnnotatedClasses(Entity.class));
    classes.addAll(finder.findAnnotatedClasses(Embeddable.class));
    classes.addAll(finder.findAnnotatedClasses(MappedSuperclass.class));
    classes.addAll(finder.findAnnotatedClasses(Converter.class));
    final List<String> existingClasses = pu.getClazz();
    for (final Class<?> clazz : classes) {
        final String name = clazz.getName();
        if (existingClasses.contains(name)) {
            continue;
        }

        if (packageNames == null) {
            pu.getClazz().add(name);
        } else {
            for (final String pack : packageNames) {
                if (name.startsWith(pack)) {
                    pu.getClazz().add(name);
                }
            }
        }
    }
    pu.setScanned(true);
}
 
开发者ID:apache,项目名称:tomee,代码行数:33,代码来源:AnnotationDeployer.java

示例3: createUnit

import javax.persistence.Converter; //导入依赖的package包/类
public MutablePersistenceUnitInfo createUnit(Class<? extends Annotation> qualifier, String unitName) {
    ClassLoader classLoader = holder.getCurrentReloadableClassLoader();
    MutablePersistenceUnitInfo result = new MutablePersistenceUnitInfo();
    result.setExcludeUnlistedClasses(true);
    result.setValidationMode(ValidationMode.NONE);
    result.setPersistenceUnitName(unitName);
    result.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);

    try {
        result.setPersistenceUnitRootUrl(new URL("http://foo.foo"));
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }

    result.addProperty(PersistenceUnitProperties.SESSION_CUSTOMIZER, CompositeSessionCustomizer.class.getName());

    // search for entities
    {
        Set<Class<?>> jpaAnnotations = new HashSet<>(
                Arrays.asList(Entity.class, MappedSuperclass.class, Embeddable.class));
        for (ClassNode classNode : index.getAllNodes()) {
            String className = Type.getObjectType(classNode.name).getClassName();

            if (classNode.visibleAnnotations == null)
                continue;

            boolean jpaAnnotationFound = false;
            for (AnnotationNode annotation : classNode.visibleAnnotations) {
                Class<?> annotationClass = AsmUtil.loadClass(Type.getType(annotation.desc), classLoader);

                // test if the annotation is one of the jpa annotations
                if (jpaAnnotations.contains(annotationClass))
                    jpaAnnotationFound = true;

            }

            if (jpaAnnotationFound && isPartOfPU(classNode, qualifier, classLoader)) {
                result.addManagedClassName(className);
            }
        }
    }

    // search converters
    {
        index.getAllChildren(AttributeConverter.class).stream()
                .filter(node -> isPartOfPU(node, qualifier, classLoader))
                .map(node -> AsmUtil.loadClass(Type.getObjectType(node.name), classLoader)).forEach(cls -> {
                    Converter converter = cls.getAnnotation(Converter.class);
                    if (converter != null && converter.autoApply())
                        result.addManagedClassName(cls.getName());
                });
    }
    return result;
}
 
开发者ID:ruediste,项目名称:rise,代码行数:55,代码来源:PersistenceUnitManagerHelper.java

示例4: getJpaConverterClass

import javax.persistence.Converter; //导入依赖的package包/类
public Class<? extends Converter> getJpaConverterClass() {
    return getEntityMethod().getAnnotation(Convert.class).converter();
}
 
开发者ID:eclecticlogic,项目名称:pedal-dialect,代码行数:4,代码来源:CopyAttribute.java

示例5: match

import javax.persistence.Converter; //导入依赖的package包/类
@Override
protected boolean match(Class<?> clazz) {
	return clazz.isAnnotationPresent(Converter.class);
}
 
开发者ID:minnal,项目名称:minnal,代码行数:5,代码来源:ConverterScanner.java

示例6: findEntities

import javax.persistence.Converter; //导入依赖的package包/类
private Set<String> findEntities(ScanResult scanResult)
{
    return new TreeSet<>(scanResult.getNamesOfClassesWithAnnotationsAnyOf(Entity.class, MappedSuperclass.class, Embeddable.class, Converter.class));
}
 
开发者ID:ethlo,项目名称:eclipselink-maven-plugin,代码行数:5,代码来源:EclipselinkStaticWeaveMojo.java


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