javax.persistence.AssociationOverrides Java Examples

The following examples show how to use javax.persistence.AssociationOverrides. 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: AbstractPropertyHolder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static AssociationOverride[] buildAssociationOverrides(XAnnotatedElement element, String path) {
	AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class );
	AssociationOverrides pluralOverrides = element.getAnnotation( AssociationOverrides.class );

	AssociationOverride[] overrides;
	if ( singleOverride != null ) {
		overrides = new AssociationOverride[] { singleOverride };
	}
	else if ( pluralOverrides != null ) {
		overrides = pluralOverrides.value();
	}
	else {
		overrides = null;
	}
	return overrides;
}
 
Example #2
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param mergeWithAnnotations Whether to use Java annotations for this
 * element, if present and not disabled by the XMLContext defaults.
 * In some contexts (such as an element-collection mapping) merging
 * with annotations is never allowed.
 */
private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) {
	List<AssociationOverride> attributes = buildAssociationOverrides( tree, defaults );
	if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
		AssociationOverride annotation = getPhysicalAnnotation( AssociationOverride.class );
		addAssociationOverrideIfNeeded( annotation, attributes );
		AssociationOverrides annotations = getPhysicalAnnotation( AssociationOverrides.class );
		if ( annotations != null ) {
			for ( AssociationOverride current : annotations.value() ) {
				addAssociationOverrideIfNeeded( current, attributes );
			}
		}
	}
	if ( attributes.size() > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class );
		ad.setValue( "value", attributes.toArray( new AssociationOverride[attributes.size()] ) );
		return AnnotationFactory.create( ad );
	}
	else {
		return null;
	}
}