Java Code Examples for javax.persistence.AttributeOverrides#value()
The following examples show how to use
javax.persistence.AttributeOverrides#value() .
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 |
/** * @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 association mapping) merging with * annotations is never allowed. */ private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults, List<AttributeOverride> attributes, boolean mergeWithAnnotations) { if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) { AttributeOverride annotation = getPhysicalAnnotation( AttributeOverride.class ); addAttributeOverrideIfNeeded( annotation, attributes ); AttributeOverrides annotations = getPhysicalAnnotation( AttributeOverrides.class ); if ( annotations != null ) { for ( AttributeOverride current : annotations.value() ) { addAttributeOverrideIfNeeded( current, attributes ); } } } if ( attributes.size() > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class ); ad.setValue( "value", attributes.toArray( new AttributeOverride[attributes.size()] ) ); return AnnotationFactory.create( ad ); } else { return null; } }
Example 2
Source File: MapBinder.java From lams with GNU General Public License v2.0 | 6 votes |
private boolean mappingDefinedAttributeOverrideOnMapKey(XProperty property) { if ( property.isAnnotationPresent( AttributeOverride.class ) ) { return namedMapKey( property.getAnnotation( AttributeOverride.class ) ); } if ( property.isAnnotationPresent( AttributeOverrides.class ) ) { final AttributeOverrides annotations = property.getAnnotation( AttributeOverrides.class ); for ( AttributeOverride attributeOverride : annotations.value() ) { if ( namedMapKey( attributeOverride ) ) { return true; } } } return false; }
Example 3
Source File: DbUtil.java From cosmic with Apache License 2.0 | 6 votes |
public static final AttributeOverride[] getAttributeOverrides(final AnnotatedElement ae) { AttributeOverride[] overrides = null; final AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class); if (aos != null) { overrides = aos.value(); } if (overrides == null || overrides.length == 0) { final AttributeOverride override = ae.getAnnotation(AttributeOverride.class); if (override != null) { overrides = new AttributeOverride[1]; overrides[0] = override; } else { overrides = new AttributeOverride[0]; } } return overrides; }
Example 4
Source File: DbUtil.java From cloudstack with Apache License 2.0 | 6 votes |
public static final AttributeOverride[] getAttributeOverrides(AnnotatedElement ae) { AttributeOverride[] overrides = null; AttributeOverrides aos = ae.getAnnotation(AttributeOverrides.class); if (aos != null) { overrides = aos.value(); } if (overrides == null || overrides.length == 0) { AttributeOverride override = ae.getAnnotation(AttributeOverride.class); if (override != null) { overrides = new AttributeOverride[1]; overrides[0] = override; } else { overrides = new AttributeOverride[0]; } } return overrides; }
Example 5
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 4 votes |
private static Map<String, Column[]> buildColumnOverride(XAnnotatedElement element, String path) { Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); if ( element != null ) { AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class ); AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class ); AttributeOverride[] overrides; if ( singleOverride != null ) { overrides = new AttributeOverride[]{ singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } if ( overrides != null ) { Map<String, List<Column>> columnOverrideList = new HashMap<>(); for ( AttributeOverride depAttr : overrides ) { String qualifiedName = StringHelper.qualify( path, depAttr.name() ); if ( columnOverrideList.containsKey( qualifiedName ) ) { columnOverrideList.get( qualifiedName ).add( depAttr.column() ); } else { columnOverrideList.put( qualifiedName, new ArrayList<>( Arrays.asList( depAttr.column() ) ) ); } } for (Map.Entry<String, List<Column>> entry : columnOverrideList.entrySet()) { columnOverride.put( entry.getKey(), entry.getValue().toArray( new Column[entry.getValue().size()] ) ); } } } return columnOverride; }