javax.persistence.NamedStoredProcedureQuery Java Examples

The following examples show how to use javax.persistence.NamedStoredProcedureQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private NamedStoredProcedureQueries getNamedStoredProcedureQueries(Element tree, XMLContext.Default defaults) {
	List<NamedStoredProcedureQuery> queries = buildNamedStoreProcedureQueries( tree, defaults, classLoaderAccess );
	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;
	}
}
 
Example #2
Source File: NamedProcedureCallDefinition.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
NamedProcedureCallDefinition(NamedStoredProcedureQuery annotation) {
	this.registeredName = annotation.name();
	this.procedureName = annotation.procedureName();
	this.hints = new QueryHintDefinition( annotation.hints() ).getHintsMap();
	this.resultClasses = annotation.resultClasses();
	this.resultSetMappings = annotation.resultSetMappings();

	this.parameterDefinitions = new ParameterDefinitions( annotation.parameters(), hints );

	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
				)
		);
	}
}
 
Example #3
Source File: QueryBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static void bindNamedStoredProcedureQuery(
		NamedStoredProcedureQuery annotation,
		MetadataBuildingContext context,
		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) {
		context.getMetadataCollector().addDefaultNamedProcedureCallDefinition( def );
	}
	else {
		context.getMetadataCollector().addNamedProcedureCallDefinition( def );
	}
	LOG.debugf( "Bound named stored procedure query : %s => %s", def.getRegisteredName(), def.getProcedureName() );
}
 
Example #4
Source File: AnnotationBinder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static void bindNamedStoredProcedureQueries(NamedStoredProcedureQueries annotation, MetadataBuildingContext context, boolean isDefault) {
	if ( annotation != null ) {
		for ( NamedStoredProcedureQuery queryAnnotation : annotation.value() ) {
			bindNamedStoredProcedureQuery( queryAnnotation, context, isDefault );
		}
	}
}
 
Example #5
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 );
		}
	}
}
 
Example #6
Source File: AnnotationBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static void bindNamedStoredProcedureQuery(NamedStoredProcedureQuery annotation, MetadataBuildingContext context, boolean isDefault) {
	if ( annotation != null ) {
		QueryBinder.bindNamedStoredProcedureQuery( annotation, context, isDefault );
	}
}