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


Java MappedSuperclass类代码示例

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


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

示例1: build

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public ResourceInformation build(final Class<?> resourceClass) {
	String resourceType = getResourceType(resourceClass);


	MetaDataObject meta = metaProvider.discoverMeta(resourceClass).asDataObject();
	DefaultResourceInstanceBuilder instanceBuilder = new DefaultResourceInstanceBuilder(resourceClass);

	List<ResourceField> fields = getResourceFields(resourceClass);

	Class<?> superclass = resourceClass.getSuperclass();
	String superResourceType = superclass != Object.class
			&& superclass.getAnnotation(MappedSuperclass.class) == null ? context.getResourceType(superclass)
			: null;

	TypeParser typeParser = context.getTypeParser();
	return new JpaResourceInformation(typeParser, meta, resourceClass, resourceType, superResourceType,
			instanceBuilder, fields);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:21,代码来源:JpaResourceInformationProvider.java

示例2: getResourceType

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
@Override
public String getResourceType(Class<?> entityClass) {
	JpaResource annotation = entityClass.getAnnotation(JpaResource.class);
	if (annotation != null) {
		return annotation.type();
	}
	if (entityClass.getAnnotation(MappedSuperclass.class) != null) {
		return null; // super classes do not have a document type
	}

	String name = entityClass.getSimpleName();
	if (name.endsWith(ENTITY_NAME_SUFFIX)) {
		name = name.substring(0, name.length() - ENTITY_NAME_SUFFIX.length());
	}
	return Character.toLowerCase(name.charAt(0)) + name.substring(1);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:17,代码来源:JpaResourceInformationProvider.java

示例3: buildHierarchyColumnOverride

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
private void buildHierarchyColumnOverride(XClass element) {
	XClass current = element;
	Map<String, Column[]> columnOverride = new HashMap<String, Column[]>();
	Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>();
	Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>();
	while ( current != null && !mappings.getReflectionManager().toXClass( Object.class ).equals( current ) ) {
		if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class )
				|| current.isAnnotationPresent( Embeddable.class ) ) {
			//FIXME is embeddable override?
			Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() );
			Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() );
			Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath() );
			currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
			currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
			currentJoinTableOverride.putAll( joinTableOverride ); //subclasses have precedence over superclasses
			columnOverride = currentOverride;
			joinColumnOverride = currentJoinOverride;
			joinTableOverride = currentJoinTableOverride;
		}
		current = current.getSuperclass();
	}

	holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null;
	holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null;
	holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:AbstractPropertyHolder.java

示例4: getClasses

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
protected List<String> getClasses(Resource[] resources) {
    List<String> classNames = new ArrayList<>();

    for (Resource resource : resources) {
        if (resource.isReadable()) {
            MetadataReader metadataReader;
            try {
                metadataReader = metadataReaderFactory.getMetadataReader(resource);
            } catch (IOException e) {
                throw new RuntimeException("Unable to read metadata resource", e);
            }

            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (annotationMetadata.isAnnotated(com.haulmont.chile.core.annotations.MetaClass.class.getName())
                    || annotationMetadata.isAnnotated(MappedSuperclass.class.getName())
                    || annotationMetadata.isAnnotated(Entity.class.getName())) {
                ClassMetadata classMetadata = metadataReader.getClassMetadata();
                classNames.add(classMetadata.getClassName());
            }
        }
    }
    return classNames;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:CubaClientTestCase.java

示例5: buildProperties

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
/**
 * Fills the {@link #properties}.
 *
 * @param c
 *            the currently inspected class
 * @param stopClass
 *            the class in the hierarchy to stop inspecting
 */
private void buildProperties(final Class<? super E> c, final Class<? super E> stopClass) {
	// Fill properties of super classes (at least until we find the joined parent class)
	if (c.getSuperclass() != null && c.getSuperclass() != stopClass) {
		buildProperties(c.getSuperclass(), stopClass);
	}

	// And now fill the properties of this class
	if (c.isAnnotationPresent(MappedSuperclass.class) || c.isAnnotationPresent(Entity.class)) {
		for (final AttributeAccessor field : this.accessStyle.getDeclaredAttributes(c, this.entityClass)) {
			if (!field.isAnnotationPresent(EmbeddedId.class) && !field.isAnnotationPresent(Id.class)) {
				final Property<E, ?> property = buildProperty(field, getColumnAnnotation(field),
						this.associationOverrides.get(field.getName()));
				if (property != null) {
					this.properties.put(field.getName(), property);
					this.allProperties.add(property);
					if (property instanceof SingularProperty) {
						buildUniqueProperty((SingularProperty<E, ?>) property);
					}
				}
			}
		}
	}

}
 
开发者ID:liefke,项目名称:org.fastnate,代码行数:33,代码来源:EntityClass.java

示例6: testStaticWeaving

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(
            DocumentAttachment.class.getPackage().getName(),
            DocumentBase.class.getPackage().getName(),
            MaintenanceLock.class.getPackage().getName(),
            Message.class.getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
开发者ID:kuali,项目名称:rice,代码行数:16,代码来源:StaticWeavingTest.java

示例7: getField

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
/**
 * A partir du nom du fieldname, retorune le field
 * @param cl
 * @param fieldName
 * @return
 * @throws FieldNotFound 
 */
private static Field getField(final Class cl, final String fieldName) throws FieldNotFound {
	Class tClass = cl;
	boolean found = false;
	while (!found && (tClass.isAnnotationPresent(Entity.class) || tClass.isAnnotationPresent(MappedSuperclass.class))) {
		try {
			Field field = tClass.getDeclaredField(fieldName);
			if (field.isAnnotationPresent(Lob.class)) {
				throw new FieldNotFound();
			}
			return field;
		} catch (NoSuchFieldException ex) { // on verifie dans la hierarchie aussi
			tClass = tClass.getSuperclass();
		}
	}
	throw new FieldNotFound();
}
 
开发者ID:hhdevelopment,项目名称:xcrud,代码行数:24,代码来源:EntityTools.java

示例8: isJpaAnnotated

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
public static boolean isJpaAnnotated(Class<?> clazz) {
 	if (clazz == null) {
 		return false;
 	}
 	if (!cache.containsKey(clazz.getName())) {
 		if (clazz.getName().contains("EnhancerByCGLIB")) {
 			try {
 				// Strip a proxy if found
 				clazz = Class.forName(clazz.getName().substring(0, clazz.getName().indexOf("$$EnhancerByCGLIB")));
 			} catch (Exception e) {
 				LOG.error(e.getMessage(), e);
 			}
 		}
 		synchronized (cache) {
     		cache.put(clazz.getName(), new Boolean(clazz.isAnnotationPresent(Entity.class) || clazz.isAnnotationPresent(MappedSuperclass.class)));
}
 	}
 	return cache.get(clazz.getName()).booleanValue();
 }
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:20,代码来源:OrmUtils.java

示例9: hasOnlyValidJpaEntities

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
/**
 * Verifies that all class that are annotated with {@link Entity} observe the rules for JPA entities.
 * 
 * <ul>
 * <li>The class must have a public or protected, no-argument constructor. The class may have other
 * constructors.</li>
 * <li>The class must not be declared final.</li>
 * <li>No methods or persistent instance variables must be declared final.</li>
 * <li>Persistent instance variables must be declared private, protected, or package-private.</li>
 * </ul>
 * 
 * @return Self.
 */
public JandexAssert hasOnlyValidJpaEntities() {
    // Precondition
    isNotNull();

    final List<AnnotationInstance> annotations = new ArrayList<>();
    annotations.addAll(actual.getAnnotations(DotName.createSimple(Entity.class.getName())));
    annotations.addAll(actual.getAnnotations(DotName.createSimple(MappedSuperclass.class.getName())));
    for (final AnnotationInstance ai : annotations) {
        final AnnotationTarget target = ai.target();
        final ClassInfo info = target.asClass();
        final AssertionRules<ClassInfo> rules = new AssertionRules<ClassInfo>(
                new RulePublicOrProtectedNoArgConstructor(), new RuleClassNotFinal(),
                new RuleClassHasNoFinalMethods(), new RulePersistentInstanceFieldVisibility());
        final AssertionResult result = rules.verify(info);
        if (!result.isValid()) {
            failWithMessage(result.getErrorMessage());
        }
    }

    return this;

}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:36,代码来源:JandexAssert.java

示例10: extractInheritanceType

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
private void extractInheritanceType() {
	XAnnotatedElement element = getClazz();
	Inheritance inhAnn = element.getAnnotation( Inheritance.class );
	MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
	if ( mappedSuperClass != null ) {
		setEmbeddableSuperclass( true );
		setType( inhAnn == null ? null : inhAnn.strategy() );
	}
	else {
		setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:InheritanceState.java

示例11: addMappedSuperClassInMetadata

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
private void addMappedSuperClassInMetadata(PersistentClass persistentClass) {
	//add @MappedSuperclass in the metadata
	// classes from 0 to n-1 are @MappedSuperclass and should be linked
	org.hibernate.mapping.MappedSuperclass mappedSuperclass = null;
	final InheritanceState superEntityState =
			InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass );
	PersistentClass superEntity =
			superEntityState != null ?
					mappings.getClass( superEntityState.getClazz().getName() ) :
					null;
	final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1;
	for ( int index = 0; index < lastMappedSuperclass; index++ ) {
		org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass;
		final Class<?> type = mappings.getReflectionManager()
				.toClass( classesToProcessForMappedSuperclass.get( index ) );
		//add MAppedSuperclass if not already there
		mappedSuperclass = mappings.getMappedSuperclass( type );
		if ( mappedSuperclass == null ) {
			mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity );
			mappedSuperclass.setMappedClass( type );
			mappings.addMappedSuperclass( type, mappedSuperclass );
		}
	}
	if ( mappedSuperclass != null ) {
		persistentClass.setSuperMappedSuperclass( mappedSuperclass );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:InheritanceState.java

示例12: getMappedSuperclass

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
private MappedSuperclass getMappedSuperclass(Element tree, XMLContext.Default defaults) {
	if ( tree == null ) {
		return defaults.canUseJavaAnnotations() ? getPhysicalAnnotation( MappedSuperclass.class ) : null;
	}
	else {
		if ( "mapped-superclass".equals( tree.getName() ) ) {
			AnnotationDescriptor entity = new AnnotationDescriptor( MappedSuperclass.class );
			return AnnotationFactory.create( entity );
		}
		else {
			return null; //this is not an entity
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:JPAOverriddenAnnotationReader.java

示例13: getManagedJpaClasses

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
@Nonnull
@SuppressWarnings("unchecked")
public static Set<Class<?>> getManagedJpaClasses() {
    return getMainClasses(Predicates.or(
            withAnnotation(Entity.class),
            withAnnotation(Embeddable.class),
            withAnnotation(MappedSuperclass.class)));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:ClassInventory.java

示例14: getJpaSuperclass

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
private Class<?> getJpaSuperclass(Class<?> resourceClass) {
	Class<?> superclass = resourceClass.getSuperclass();
	while(superclass != Object.class){
		if(superclass.getAnnotation(Entity.class) != null || superclass.getAnnotation(MappedSuperclass.class) != null){
			return superclass;
		}
		superclass = superclass.getSuperclass();
	}
	return null;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:11,代码来源:AbstractEntityMetaProvider.java

示例15: getParent

import javax.persistence.MappedSuperclass; //导入依赖的package包/类
public String getParent() {
    MetaClass ancestor = meta.getAncestor();

    if (ancestor == null || !ancestor.getName().contains("$") ||
            ancestor.getJavaClass().isAnnotationPresent(MappedSuperclass.class))
        return "";

    if (!readPermitted(ancestor)) {
        return null;
    }

    return "Parent is " + asHref(ancestor.getName());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:MetaClassRepresentation.java


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