java类javax.persistence.MappedSuperclass的实例源码

EntityMarkerClassTransformer.java 文件源码 项目:blcdemo 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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;
}
DefaultProcessPropertyInfos.java 文件源码 项目:hyperjaxb3 阅读 17 收藏 0 点赞 0 评论 0
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;
    }
}
DefaultProcessPropertyInfos.java 文件源码 项目:hyperjaxb3 阅读 17 收藏 0 点赞 0 评论 0
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;
    }
}
JPAPersistenceUnitPostProcessor.java 文件源码 项目:lutece-core 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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 );
    }
}
EntityClass.java 文件源码 项目:org.fastnate 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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));
        }
    }
}
StaticWeavingTest.java 文件源码 项目:rice 阅读 33 收藏 0 点赞 0 评论 0
@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);
}
StaticWeavingTest.java 文件源码 项目:rice 阅读 20 收藏 0 点赞 0 评论 0
@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);
}
StaticWeavingTest.java 文件源码 项目:rice 阅读 35 收藏 0 点赞 0 评论 0
@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);
}
StaticWeavingTest.java 文件源码 项目:rice 阅读 22 收藏 0 点赞 0 评论 0
@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);
}
StaticWeavingTest.java 文件源码 项目:rice 阅读 32 收藏 0 点赞 0 评论 0
@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);
}


问题


面经


文章

微信
公众号

扫码关注公众号