Java 类javax.persistence.NamedStoredProcedureQuery 实例源码

项目:lams    文件:JPAOverriddenAnnotationReader.java   
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(Element tree, XMLContext.Default defaults) {
    List<NamedStoredProcedureQuery> queries = buildNamedStoreProcedureQueries( tree, defaults );
    if ( defaults.canUseJavaAnnotations() ) {
        NamedStoredProcedureQuery annotation = getPhysicalAnnotation( NamedStoredProcedureQuery.class );
        addNamedStoredProcedureQueryIfNeeded( annotation, queries );
        NamedStoredProcedureQueries annotations = getPhysicalAnnotation( NamedStoredProcedureQueries.class );
        if ( annotations != null ) {
            for ( NamedStoredProcedureQuery current : annotations.value() ) {
                addNamedStoredProcedureQueryIfNeeded( current, queries );
            }
        }
    }
    if ( queries.size() > 0 ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( NamedStoredProcedureQueries.class );
        ad.setValue( "value", queries.toArray( new NamedStoredProcedureQuery[queries.size()] ) );
        return AnnotationFactory.create( ad );
    }
    else {
        return null;
    }
}
项目:lams    文件:NamedProcedureCallDefinition.java   
NamedProcedureCallDefinition(NamedStoredProcedureQuery annotation) {
    this.registeredName = annotation.name();
    this.procedureName = annotation.procedureName();
    this.resultClasses = annotation.resultClasses();
    this.resultSetMappings = annotation.resultSetMappings();
    this.parameterDefinitions = new ParameterDefinitions( annotation.parameters() );
    this.hints = new QueryHintDefinition( annotation.hints() ).getHintsMap();

    final boolean specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
    final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.length > 0;

    if ( specifiesResultClasses && specifiesResultSetMappings ) {
        throw new MappingException(
                String.format(
                        "NamedStoredProcedureQuery [%s] specified both resultClasses and resultSetMappings",
                        registeredName
                )
        );
    }
}
项目:lams    文件:QueryBinder.java   
public static void bindNamedStoredProcedureQuery(NamedStoredProcedureQuery annotation, Mappings mappings, boolean isDefault) {
    if ( annotation == null ) {
        return;
    }

    if ( BinderHelper.isEmptyAnnotationValue( annotation.name() ) ) {
        throw new AnnotationException( "A named query must have a name when used in class or package level" );
    }

    final NamedProcedureCallDefinition def = new NamedProcedureCallDefinition( annotation );

    if(isDefault){
        mappings.addDefaultNamedProcedureCallDefinition( def );
    } else{
        mappings.addNamedProcedureCallDefinition( def );
    }
    LOG.debugf( "Bound named stored procedure query : %s => %s", def.getRegisteredName(), def.getProcedureName() );
}
项目:lams    文件:AnnotationBinder.java   
private static void bindNamedStoredProcedureQueries(Mappings mappings, NamedStoredProcedureQueries annotation, boolean isDefault) {
    if ( annotation != null ) {
        for ( NamedStoredProcedureQuery queryAnnotation : annotation.value() ) {
            bindNamedStoredProcedureQuery( mappings, queryAnnotation, isDefault );
        }
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
private void addNamedStoredProcedureQueryIfNeeded(NamedStoredProcedureQuery annotation, List<NamedStoredProcedureQuery> queries) {
    if ( annotation != null ) {
        String queryName = annotation.name();
        boolean present = false;
        for ( NamedStoredProcedureQuery current : queries ) {
            if ( current.name().equals( queryName ) ) {
                present = true;
                break;
            }
        }
        if ( !present ) {
            queries.add( annotation );
        }
    }
}
项目:lams    文件:AnnotationBinder.java   
private static void bindNamedStoredProcedureQuery(Mappings mappings, NamedStoredProcedureQuery annotation, boolean isDefault) {
    if ( annotation != null ) {
        QueryBinder.bindNamedStoredProcedureQuery( annotation, mappings, isDefault );
    }
}