Java 类javax.persistence.NamedEntityGraph 实例源码

项目:lams    文件:JPAOverriddenAnnotationReader.java   
public static List<NamedEntityGraph> buildNamedEntityGraph(Element element, XMLContext.Default defaults) {
    if ( element == null ) {
        return new ArrayList<NamedEntityGraph>();
    }
    List<NamedEntityGraph> namedEntityGraphList = new ArrayList<NamedEntityGraph>();
    List<Element> namedEntityGraphElements = element.elements( "named-entity-graph" );
    for ( Element subElement : namedEntityGraphElements ) {
        AnnotationDescriptor ann = new AnnotationDescriptor( NamedEntityGraph.class );
        copyStringAttribute( ann, subElement, "name", false );
        copyBooleanAttribute( ann, subElement, "include-all-attributes" );
        bindNamedAttributeNodes( subElement, ann );

        List<Element> subgraphNodes = subElement.elements( "subgraph" );
        bindNamedSubgraph( defaults, ann, subgraphNodes );
        List<Element> subclassSubgraphNodes = subElement.elements( "subclass-subgraph" );
        bindNamedSubgraph( defaults, ann, subclassSubgraphNodes );
        namedEntityGraphList.add( (NamedEntityGraph) AnnotationFactory.create( ann ) );
    }
    //TODO
    return namedEntityGraphList;
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private NamedEntityGraphs getNamedEntityGraphs(Element tree, XMLContext.Default defaults) {
    List<NamedEntityGraph> queries = buildNamedEntityGraph( tree, defaults );
    if ( defaults.canUseJavaAnnotations() ) {
        NamedEntityGraph annotation = getPhysicalAnnotation( NamedEntityGraph.class );
        addNamedEntityGraphIfNeeded( annotation, queries );
        NamedEntityGraphs annotations = getPhysicalAnnotation( NamedEntityGraphs.class );
        if ( annotations != null ) {
            for ( NamedEntityGraph current : annotations.value() ) {
                addNamedEntityGraphIfNeeded( current, queries );
            }
        }
    }
    if ( queries.size() > 0 ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( NamedEntityGraphs.class );
        ad.setValue( "value", queries.toArray( new NamedEntityGraph[queries.size()] ) );
        return AnnotationFactory.create( ad );
    }
    else {
        return null;
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void addNamedEntityGraphIfNeeded(NamedEntityGraph annotation, List<NamedEntityGraph> queries) {
    if ( annotation != null ) {
        String queryName = annotation.name();
        boolean present = false;
        for ( NamedEntityGraph current : queries ) {
            if ( current.name().equals( queryName ) ) {
                present = true;
                break;
            }
        }
        if ( !present ) {
            queries.add( annotation );
        }
    }

}
项目:lams    文件:NamedEntityGraphDefinition.java   
public NamedEntityGraphDefinition(NamedEntityGraph annotation, String jpaEntityName, String entityName) {
    this.annotation = annotation;
    this.jpaEntityName = jpaEntityName;
    this.entityName = entityName;
    this.name = StringHelper.isNotEmpty( annotation.name() )
            ? annotation.name()
            : jpaEntityName;
    if ( name == null ) {
        throw new IllegalArgumentException( "Named entity graph name cannot be null" );
    }
}
项目:lams    文件:EntityBinder.java   
private void processNamedEntityGraphs() {
    processNamedEntityGraph( annotatedClass.getAnnotation( NamedEntityGraph.class ) );
    final NamedEntityGraphs graphs = annotatedClass.getAnnotation( NamedEntityGraphs.class );
    if ( graphs != null ) {
        for ( NamedEntityGraph graph : graphs.value() ) {
            processNamedEntityGraph( graph );
        }
    }
}
项目:lams    文件:NamedEntityGraphDefinition.java   
public NamedEntityGraph getAnnotation() {
    return annotation;
}
项目:lams    文件:EntityBinder.java   
private void processNamedEntityGraph(NamedEntityGraph annotation) {
    if ( annotation == null ) {
        return;
    }
    mappings.addNamedEntityGraphDefintion( new NamedEntityGraphDefinition( annotation, name, persistentClass.getEntityName() ) );
}