javax.persistence.NamedSubgraph Java Examples

The following examples show how to use javax.persistence.NamedSubgraph. 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 static void bindNamedSubgraph(
		XMLContext.Default defaults,
		AnnotationDescriptor ann,
		List<Element> subgraphNodes,
		ClassLoaderAccess classLoaderAccess) {
	List<NamedSubgraph> annSubgraphNodes = new ArrayList<>(  );
	for(Element subgraphNode : subgraphNodes){
		AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
		copyStringAttribute( annSubgraphNode, subgraphNode, "name", true );
		String clazzName = subgraphNode.attributeValue( "class" );
		Class clazz;
		try {
			clazz = classLoaderAccess.classForName(
					XMLContext.buildSafeClassName( clazzName, defaults )
			);
		}
		catch ( ClassLoadingException e ) {
			throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
		}
		annSubgraphNode.setValue( "type", clazz );
		bindNamedAttributeNodes(subgraphNode, annSubgraphNode);
		annSubgraphNodes.add( AnnotationFactory.create( annSubgraphNode ) );
	}

	ann.setValue( "subgraphs", annSubgraphNodes.toArray( new NamedSubgraph[annSubgraphNodes.size()] ) );
}
 
Example #2
Source File: MetamodelImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void applyNamedSubgraphs(NamedEntityGraph namedEntityGraph, String subgraphName, SubgraphImpl subgraph) {
	for ( NamedSubgraph namedSubgraph : namedEntityGraph.subgraphs() ) {
		if ( subgraphName.equals( namedSubgraph.name() ) ) {
			applyNamedAttributeNodes(
					namedSubgraph.attributeNodes(),
					namedEntityGraph,
					subgraph
			);
		}
	}
}