Java Code Examples for javax.persistence.MappedSuperclass

The following are top voted examples for showing how to use javax.persistence.MappedSuperclass. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: crnk-framework   File: JpaResourceInformationProvider.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 2
Project: crnk-framework   File: JpaResourceInformationProvider.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 3
Project: lams   File: AbstractPropertyHolder.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 4
Project: cuba   File: CubaClientTestCase.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 5
Project: org.fastnate   File: EntityClass.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
					}
				}
			}
		}
	}

}
 
Example 6
Project: rice   File: StaticWeavingTest.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 7
Project: xcrud   File: EntityTools.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 8
Project: kuali_rice   File: OrmUtils.java   Source Code and License 6 votes vote down vote up
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();
 }
 
Example 9
Project: units4j   File: JandexAssert.java   Source Code and License 6 votes vote down vote up
/**
 * 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;

}
 
Example 10
Project: lams   File: InheritanceState.java   Source Code and License 5 votes vote down vote up
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() );
	}
}
 
Example 11
Project: lams   File: InheritanceState.java   Source Code and License 5 votes vote down vote up
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 );
	}
}
 
Example 12
Project: lams   File: JPAOverriddenAnnotationReader.java   Source Code and License 5 votes vote down vote up
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
		}
	}
}
 
Example 13
Project: oma-riista-web   File: ClassInventory.java   Source Code and License 5 votes vote down vote up
@Nonnull
@SuppressWarnings("unchecked")
public static Set<Class<?>> getManagedJpaClasses() {
    return getMainClasses(Predicates.or(
            withAnnotation(Entity.class),
            withAnnotation(Embeddable.class),
            withAnnotation(MappedSuperclass.class)));
}
 
Example 14
Project: katharsis-framework   File: AbstractEntityMetaProvider.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 15
Project: cuba   File: MetaClassRepresentation.java   Source Code and License 5 votes vote down vote up
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());
}
 
Example 16
Project: cuba   File: QueryCacheManager.java   Source Code and License 5 votes vote down vote up
protected Set<String> getDescendants(Set<String> relatedTypes) {
    if (relatedTypes == null) return null;
    Set<String> newRelatedTypes = new HashSet<>();
    relatedTypes.forEach(type -> {
        newRelatedTypes.add(type);
        MetaClass metaClass = metadata.getClassNN(type);
        if (metaClass.getDescendants() != null) {
            Set<String> descendants = metaClass.getDescendants().stream()
                    .filter(it -> it.getJavaClass() != null && !it.getJavaClass().isAnnotationPresent(MappedSuperclass.class))
                    .map(MetadataObject::getName).collect(Collectors.toSet());
            newRelatedTypes.addAll(descendants);
        }
    });
    return newRelatedTypes;
}
 
Example 17
Project: metaworks_framework   File: EntityMarkerClassTransformer.java   Source Code and License 5 votes vote down vote up
/**
 * Determines if a given annotation set contains annotations that correspond to ones that someone would expect to appear
 * in a persistence.xml
 * 
 * @param annotations
 * @return
 */
protected boolean containsTypeLevelPersistenceAnnotation(Annotation[] annotations) {
    for (Annotation annotation : annotations) {
        if (annotation.getTypeName().equals(Entity.class.getName())
                || annotation.getTypeName().equals(Embeddable.class.getName())
                || annotation.getTypeName().equals(MappedSuperclass.class.getName())) {
            return true;
        }
    }
    return false;
}
 
Example 18
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@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, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 19
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections("org.kuali.rice.krad");
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 20
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 21
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(
    		PersistableBusinessObjectBase.class.getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 22
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 23
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 24
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 25
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 26
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections("org.kuali.rice.kew", "org.kuali.rice.kim", "org.kuali.rice.kcb", "org.kuali.rice.ken");
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 27
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 28
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 29
Project: kc-rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().getPackage().getName());
    Set<Class<?>> entityTypes = reflections.getTypesAnnotatedWith(Entity.class, true);
    Set<Class<?>> superTypes = reflections.getTypesAnnotatedWith(MappedSuperclass.class, true);
    Set<Class<?>> embeddableTypes = reflections.getTypesAnnotatedWith(Embeddable.class, true);

    // next, let's assert that they have been statically weaved
    assertStaticWeaved(entityTypes, superTypes, embeddableTypes);
}
 
Example 30
Project: SparkCommerce   File: EntityMarkerClassTransformer.java   Source Code and License 5 votes vote down vote up
/**
 * Determines if a given annotation set contains annotations that correspond to ones that someone would expect to appear
 * in a persistence.xml
 * 
 * @param annotations
 * @return
 */
protected boolean containsTypeLevelPersistenceAnnotation(Annotation[] annotations) {
    for (Annotation annotation : annotations) {
        if (annotation.getTypeName().equals(Entity.class.getName())
                || annotation.getTypeName().equals(Embeddable.class.getName())
                || annotation.getTypeName().equals(MappedSuperclass.class.getName())) {
            return true;
        }
    }
    return false;
}
 
Example 31
Project: blcdemo   File: EntityMarkerClassTransformer.java   Source Code and License 5 votes vote down vote up
/**
 * Determines if a given annotation set contains annotations that correspond to ones that someone would expect to appear
 * in a persistence.xml
 * 
 * @param annotations
 * @return
 */
protected boolean containsTypeLevelPersistenceAnnotation(Annotation[] annotations) {
    for (Annotation annotation : annotations) {
        if (annotation.getTypeName().equals(Entity.class.getName())
                || annotation.getTypeName().equals(Embeddable.class.getName())
                || annotation.getTypeName().equals(MappedSuperclass.class.getName())) {
            return true;
        }
    }
    return false;
}
 
Example 32
Project: hyperjaxb3   File: DefaultProcessPropertyInfos.java   Source Code and License 5 votes vote down vote up
public boolean isRootClass(Class<?> theClass) {
	final boolean notMappedSuperclassAndNotEmbeddable = theClass
			.getAnnotation(MappedSuperclass.class) == null
			&& theClass.getAnnotation(Embeddable.class) == null;
	if (theClass.getSuperclass() != null) {
		return notMappedSuperclassAndNotEmbeddable
				&& !isSelfOrAncestorRootClass(theClass.getSuperclass());
	} else {
		return notMappedSuperclassAndNotEmbeddable;
	}
}
 
Example 33
Project: hyperjaxb3   File: DefaultProcessPropertyInfos.java   Source Code and License 5 votes vote down vote up
public boolean isSelfOrAncestorRootClass(Class<?> theClass) {
	if (isRootClass(theClass)) {
		return true;
	} else if (theClass.getSuperclass() != null) {
		return isSelfOrAncestorRootClass(theClass.getSuperclass());
	} else {
		return theClass.getAnnotation(MappedSuperclass.class) == null
				&& theClass.getAnnotation(Embeddable.class) == null;
	}
}
 
Example 34
Project: lutece-core   File: JPAPersistenceUnitPostProcessor.java   Source Code and License 5 votes vote down vote up
/**
 * Scans for *.orm.xml and adds Entites from classpath.
 *
 * @param pui
 *            the pui
 */
@Override
public void postProcessPersistenceUnitInfo( MutablePersistenceUnitInfo pui )
{
    _Log.info( "Scanning for JPA orm.xml files" );

    for ( File ormFile : getListORMFiles( ) )
    {
        String ormAbsolutePath = ormFile.getAbsolutePath( );
        _Log.info( "Found ORM file : " + ormAbsolutePath );
        pui.addMappingFileName( ormAbsolutePath.substring( ormAbsolutePath.indexOf( CLASSPATH_PATH_IDENTIFIER ) ) );
    }

    _Log.info( "Scanning for JPA entities..." );

    Set<String> entityClasses = AnnotationUtil.find( Entity.class.getName( ) );
    entityClasses.addAll( AnnotationUtil.find( Embeddable.class.getName( ) ) );
    entityClasses.addAll( AnnotationUtil.find( MappedSuperclass.class.getName( ) ) );

    for ( String strClass : entityClasses )
    {
        _Log.info( "Found entity class : " + strClass );

        if ( !pui.getManagedClassNames( ).contains( strClass ) )
        {
            pui.addManagedClassName( strClass );
        }
    }

    if ( _Log.isDebugEnabled( ) )
    {
        dumpPersistenceUnitInfo( pui );
    }
}
 
Example 35
Project: org.fastnate   File: EntityClass.java   Source Code and License 5 votes vote down vote up
/**
 * Fills the {@link #idProperty}.
 *
 * @param c
 *            the currently inspected class
 */
private void buildIdProperty(final Class<? super E> c) {
	// TODO (Issue #2) Support @IdClass

	// Find ID properties of super classes
	if (c.getSuperclass() != null) {
		buildIdProperty(c.getSuperclass());
	}

	// Find the Entity / MappedSuperclass annotation
	if (c.isAnnotationPresent(Entity.class) || c.isAnnotationPresent(MappedSuperclass.class)) {
		// Determine the access type
		if (this.accessStyle == null) {
			final Access accessType = c.getAnnotation(Access.class);
			if (accessType != null) {
				this.accessStyle = AccessStyle.getStyle(accessType.value());
			}
		}

		// And now find the id property of this class
		if (this.accessStyle == null) {
			if (findIdProperty(AccessStyle.FIELD.getDeclaredAttributes(c, this.entityClass))) {
				this.accessStyle = AccessStyle.FIELD;
			} else if (findIdProperty(AccessStyle.METHOD.getDeclaredAttributes(c, this.entityClass))) {
				this.accessStyle = AccessStyle.METHOD;
			}
		} else {
			findIdProperty(this.accessStyle.getDeclaredAttributes(c, this.entityClass));
		}
	}
}
 
Example 36
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections("org.kuali.rice.krad");
    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);
}
 
Example 37
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 38
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(
    		PersistableBusinessObjectBase.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);
}
 
Example 39
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 40
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 41
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 42
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections("org.kuali.rice.kew", "org.kuali.rice.kim", "org.kuali.rice.kcb", "org.kuali.rice.ken");
    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);
}
 
Example 43
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 44
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 45
Project: rice   File: StaticWeavingTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testStaticWeaving() {
    // first, scan for all files on the classpath with an @Entity or @MappedSuperClass annotation
    Reflections reflections = new Reflections(getClass().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);
}
 
Example 46
Project: tomee   File: AnnotationDeployer.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 47
Project: kie-wb-common   File: PersistableClassValidator.java   Source Code and License 5 votes vote down vote up
/**
 * Validates if a class can be considered persistable.
 * @param className a class name to validate.
 * @param classLoader a classloader from where the class className and the referenced types by the className can be loaded.
 * @return a list of validation messages.
 */
public List<ValidationMessage> validate( String className, ClassLoader classLoader ) {
    List<ValidationMessage> result = new ArrayList<>( );
    Class< ? > clazz;
    try {
        if ( className == null || className.trim( ).isEmpty( ) ) {
            result.add( newErrorMessage( PersistenceDescriptorValidationMessages.PERSISTABLE_CLASS_NAME_EMPTY_ID,
                    PersistenceDescriptorValidationMessages.PERSISTABLE_CLASS_NAME_EMPTY ) );
            return result;
        }
        clazz = classLoader.loadClass( className );
        Annotation[] annotations = clazz.getAnnotations( );
        Optional< Annotation > persistable = Arrays.stream( annotations )
                .filter( annotation ->
                        Entity.class.equals( annotation.annotationType( ) ) ||
                                Embeddable.class.equals( annotation.annotationType( ) ) ||
                                MappedSuperclass.class.equals( annotation.annotationType( ) ) )
                .findFirst( );
        if ( !persistable.isPresent( ) ) {
            result.add( newErrorMessage( PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE_ID,
                    MessageFormat.format( PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE, className ), className ) );
        }
    } catch ( ClassNotFoundException e ) {
        result.add( newErrorMessage( PersistenceDescriptorValidationMessages.CLASS_NOT_FOUND_ID,
                MessageFormat.format( PersistenceDescriptorValidationMessages.CLASS_NOT_FOUND, className ), className ) );
    }
    return result;
}
 
Example 48
Project: crnk-framework   File: MappedSuperclassMetaFactory.java   Source Code and License 4 votes vote down vote up
@Override
public boolean accept(Type type) {
	return ClassUtils.getRawType(type).getAnnotation(MappedSuperclass.class) != null;
}
 
Example 49
Project: crnk-framework   File: JpaMetaUtils.java   Source Code and License 4 votes vote down vote up
public static boolean isJpaType(Class<?> type) {
	return type.getAnnotation(Embeddable.class) != null
			|| type.getAnnotation(Entity.class) != null
			|| type.getAnnotation(MappedSuperclass.class) != null;
}
 
Example 50
Project: spring-data-ebean   File: EbeanRepositoryConfigExtension.java   Source Code and License 4 votes vote down vote up
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
  return Arrays.asList(Entity.class, MappedSuperclass.class);
}
 
Example 51
Project: finances   File: MappedClassFilter.java   Source Code and License 4 votes vote down vote up
public boolean test(Class<?> clazz) {
    return clazz.isAnnotationPresent(Entity.class)
        || clazz.isAnnotationPresent(MappedSuperclass.class);
}
 
Example 52
Project: katharsis-framework   File: MappedSuperclassMetaProvider.java   Source Code and License 4 votes vote down vote up
@Override
public boolean accept(Type type, Class<? extends MetaElement> metaClass) {
	boolean hasAnnotation = ClassUtils.getRawType(type).getAnnotation(MappedSuperclass.class) != null;
	boolean hasType = metaClass == MetaElement.class || metaClass == MetaMappedSuperclass.class || metaClass == MetaJpaDataObject.class;
	return hasAnnotation && hasType;
}
 
Example 53
Project: geoxygene   File: DatasetGeoxGUIComponent.java   Source Code and License 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent arg0) {
  if (CartAGenDoc.getInstance().getPostGisSession() == null) {
    // open a connection with the current PostGISDB
    Configuration hibConfig = new Configuration();
    hibConfig = hibConfig.configure(
        PostgisDB.class.getResource(PostgisDB.getDefaultConfigPath()));
    hibConfig.setProperty("hibernate.connection.url", PostgisDB.getUrl());

    // get the persistent classes
    for (Class<?> classObj : CartAGenDoc.getInstance().getCurrentDataset()
        .getCartAGenDB().getPersistentClasses()) {
      // add the persistent class to the hibernate configuration
      hibConfig.addAnnotatedClass(classObj);
      // get the annotated interfaces or superclasses of the persistent
      // class
      Set<Class<?>> superclasses = ReflectionUtil
          .getSuperClassesAndInterfaces(classObj);

      // add the annotated interfaces to the hibernate configuration
      for (Class<?> c : superclasses) {
        if (c.isAnnotationPresent(Entity.class)
            || c.isAnnotationPresent(MappedSuperclass.class)) {
          hibConfig.addAnnotatedClass(c);
        }
      }
    }

    // start the transaction
    Session session = hibConfig.buildSessionFactory().openSession();
    // => openSession seems to require to argument
    // Session session = hibConfig.buildSessionFactory()
    // .openSession(PostgisDB.getConnection());

    CartAGenDoc.getInstance().setPostGisSession(session);
    session.beginTransaction();
  } else {
    CartAGenDoc.getInstance().getPostGisSession().beginTransaction();
  }

}
 
Example 54
Project: dachs   File: IdentityUtil.java   Source Code and License 4 votes vote down vote up
private boolean isEntity(Class<?> type)
{
    return type.getAnnotation(Entity.class) != null 
       || type.getAnnotation(MappedSuperclass.class) != null;
}
 
Example 55
Project: cuba   File: PermissionConfig.java   Source Code and License 4 votes vote down vote up
private void compileEntitiesAndAttributes() {
    entities = new ArrayList<>();
    entityAttributes = new ArrayList<>();

    Session session = metadata.getSession();
    List<MetaModel> modelList = new ArrayList<>(session.getModels());
    modelList.sort(new MetadataObjectAlphabetComparator());

    for (MetaModel model : modelList) {

        List<MetaClass> classList = new ArrayList<>(model.getClasses());
        classList.sort(new MetadataObjectAlphabetComparator());

        for (MetaClass metaClass : classList) {
            String name = metaClass.getName();
            // Filter base classes
            if (!metaClass.getJavaClass().isAnnotationPresent(MappedSuperclass.class)) {
                // Skip classes that have extensions
                if (metadata.getExtendedEntities().getExtendedClass(metaClass) != null) {
                    continue;
                }

                // For extended entities use original metaclass name
                MetaClass originalMetaClass = metadata.getExtendedEntities().getOriginalMetaClass(metaClass);
                String entityName = originalMetaClass == null ? name : originalMetaClass.getName();

                String caption = messages.getTools().getDetailedEntityCaption(metaClass, locale);

                // Entity target
                entities.add(new OperationPermissionTarget(metaClass.getJavaClass(),
                        "entity:" + entityName, caption, entityName));

                // Target with entity attributes
                MultiplePermissionTarget attrs = new MultiplePermissionTarget(metaClass.getJavaClass(),
                        "entity:" + entityName, caption, entityName);

                List<MetaProperty> propertyList = new ArrayList<>(metaClass.getProperties());
                Collection<CategoryAttribute> dynamicAttributes =
                        PermissionConfig.this.dynamicAttributes.getAttributesForMetaClass(metaClass);

                for (CategoryAttribute dynamicAttribute : dynamicAttributes) {
                    MetaPropertyPath metaPropertyPath =
                            metadataTools.resolveMetaPropertyPathNN(metaClass,
                                    DynamicAttributesUtils.encodeAttributeCode(dynamicAttribute.getCode()));
                    propertyList.add(metaPropertyPath.getMetaProperty());
                }
                propertyList.sort(new MetadataObjectAlphabetComparator());

                for (MetaProperty metaProperty : propertyList) {
                    String metaPropertyName = metaProperty.getName();
                    attrs.getPermissions().add(new AttributeTarget(metaPropertyName));
                }
                entityAttributes.add(attrs);
            }
        }
    }
}
 
Example 56
Project: act-ebean   File: ModelBaseEnhancer.java   Source Code and License 4 votes vote down vote up
private void addAnnotation() {
    AnnotationVisitor av = visitAnnotation(Type.getType(MappedSuperclass.class).getDescriptor(), true);
    av.visitEnd();
}
 
Example 57
Project: rise   File: PersistenceUnitManagerHelper.java   Source Code and License 4 votes vote down vote up
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;
}
 
Example 58
Project: querybean-generator   File: ProcessingContext.java   Source Code and License 4 votes vote down vote up
private boolean isMappedSuper(Element mappedSuper) {
  return mappedSuper.getAnnotation(MappedSuperclass.class) != null;
}
 
Example 59
Project: ef-orm   File: GqRepositoryConfigExtension.java   Source Code and License 4 votes vote down vote up
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
	return Arrays.asList(Entity.class, MappedSuperclass.class);
}
 
Example 60
Project: guzz   File: JPA2AnnotationsBuilder.java   Source Code and License 4 votes vote down vote up
/**
 * Build the {@link Business} and the {@link Table} information of the domain class.
 * <p/>
 * We have to seperate this operation from the {@link #parseClassForAttributes(GuzzContextImpl, POJOBasedObjectMapping, Business, DBGroup, SimpleTable, Class)}
 *  to get the final "dbGroup" after the inherited tree.
 */
protected static void parseClassForEntityTable(DomainInfo info, Class domainClass){
	//逐层分析,先分析分类。
	Class parentCls = domainClass.getSuperclass() ;
	if(parentCls != null && parentCls.isAnnotationPresent(MappedSuperclass.class)){
		parseClassForEntityTable(info, parentCls) ;
	}
	
	//分析本层类
	org.guzz.annotations.Entity ge = (org.guzz.annotations.Entity) domainClass.getAnnotation(org.guzz.annotations.Entity.class) ;
	org.guzz.annotations.Table gt = (org.guzz.annotations.Table) domainClass.getAnnotation(org.guzz.annotations.Table.class) ;
	javax.persistence.Table pt = (javax.persistence.Table) domainClass.getAnnotation(javax.persistence.Table.class) ;
	
	if(ge != null){
		info.businessName = ge.businessName() ;
		
		Class m_interpreter = ge.interpreter() ;
		if(m_interpreter != null && !NullValue.class.isAssignableFrom(m_interpreter)){
			info.interpreter = m_interpreter ;
		}
	}
	
	if(pt != null){
		if(StringUtil.notEmpty(pt.name())){
			info.tableName = pt.name() ;
		}
	}
	
	if(gt != null){
		if(StringUtil.notEmpty(gt.dbGroup())){
			info.dbGroup = gt.dbGroup() ;
		}
		if(StringUtil.notEmpty(gt.name())){
			info.tableName = gt.name() ;
		}
		if(gt.shadow() != null){
			info.shadow = gt.shadow() ;
		}
		
		info.dynamicUpdate = gt.dynamicUpdate() ;
	}
	
}