public String getPropertyName() throws MappingException { return property.getName(); }
@Override protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) { final String propertyName = property.getName(); // conversions on parent would have precedence AttributeConversionInfo conversion = locateAttributeConversionInfo( propertyName ); if ( conversion != null ) { return conversion; } return null; }
@Override protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) { return locateAttributeConversionInfo( property.getName() ); }
/** * @param clazz Source class. * @param propertyName Property name. * @param accessType Expected access type. Legal values are <i>field</i> and <i>property</i>. * * @return Property object or {@code null} if none with expected name and access type has been found. */ public static XProperty getProperty(XClass clazz, String propertyName, String accessType) { for ( XProperty property : clazz.getDeclaredProperties( accessType ) ) { if ( propertyName.equals( property.getName() ) ) { return property; } } return null; }
Ejb3Column[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) { Ejb3Column[] result = columns; final PropertyData overridingProperty = BinderHelper.getPropertyOverriddenByMapperOrMapsId( isId, propertyHolder, property.getName(), buildingContext ); if ( overridingProperty != null ) { result = buildExcplicitOrDefaultJoinColumn( overridingProperty ); } return result; }
Audited allClassAudited) { for ( XProperty property : properties ) { final String accessType = accessTypeProvider.apply( property.getName() ); if ( persistentProperties.contains( property.getName() ) && !auditedPropertiesHolder.contains( property.getName() ) ) { final Value propertyValue = persistentPropertiesSource.getProperty( property.getName() ).getValue(); if ( propertyValue instanceof Component ) { this.addFromComponentProperty( property, accessType, (Component) propertyValue, allClassAudited ); else if ( propertiesGroupMapping.containsKey( property.getName() ) ) { final String embeddedName = propertiesGroupMapping.get( property.getName() ); if ( !auditedPropertiesHolder.contains( embeddedName ) ) {
final String path = embeddedAttributeName + '.' + property.getName(); if ( attributeConversionInfoMap.containsKey( path ) ) { return; if ( convertAnnotation != null ) { final AttributeConversionInfo info = new AttributeConversionInfo( convertAnnotation, property ); attributeConversionInfoMap.put( property.getName(), info ); for ( Convert convertAnnotation : convertsAnnotation.value() ) { final AttributeConversionInfo info = new AttributeConversionInfo( convertAnnotation, property ); attributeConversionInfoMap.put( property.getName(), info );
private void addFromNotComponentProperty(XProperty property, String accessType, Audited allClassAudited) { final PropertyAuditingData propertyData = new PropertyAuditingData(); final boolean isAudited = fillPropertyData( property, propertyData, accessType, allClassAudited ); if ( isAudited ) { // Now we know that the property is audited auditedPropertiesHolder.addPropertyAuditingData( property.getName(), propertyData ); } }
LOG.debugf( "Starting applyAttributeConverter [%s:%s]", persistentClassName, property.getName() ); LOG.debugf( "Skipping AttributeConverter checks for Id attribute [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for version attribute [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyTemporal [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyEnumerated [%s]", property.getName() ); return; LOG.debugf( "Skipping AttributeConverter checks for association attribute [%s]", property.getName() ); return;
private void assertTypesAreResolvable() { for ( XProperty xProperty : persistentAttributeMap.values() ) { if ( !xProperty.isTypeResolved() && !discoverTypeWithoutReflection( xProperty ) ) { String msg = "Property " + StringHelper.qualify( xClass.getName(), xProperty.getName() ) + " has an unbound type and no explicit target entity. Resolve this Generic usage issue" + " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"; throw new AnnotationException( msg ); } } } //
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. */ @Override public JoinTable getJoinTable(XProperty property) { final String propertyName = StringHelper.qualify( getPath(), property.getName() ); JoinTable result = getOverriddenJoinTable( propertyName ); if (result == null) { result = property.getAnnotation( JoinTable.class ); } return result; }
private static Class<?> getTargetEntityClass(XProperty property) { final ManyToOne mTo = property.getAnnotation( ManyToOne.class ); if (mTo != null) { return mTo.targetEntity(); } final OneToOne oTo = property.getAnnotation( OneToOne.class ); if (oTo != null) { return oTo.targetEntity(); } throw new AssertionFailure("Unexpected discovery of a targetEntity: " + property.getName() ); } }
private void validateLobMappingSupport(XProperty property) { // HHH-9834 - Sanity check try { if ( property.isAnnotationPresent( ElementCollection.class ) ) { if ( property.isAnnotationPresent( Lob.class ) ) { if ( !property.getCollectionClass().isAssignableFrom( Map.class ) ) { throw new MappingException( "@ElementCollection combined with @Lob is only supported for Map collection types." ); } } } } catch ( MappingException e ) { throw new HibernateException( String.format( "Invalid mapping in [%s] for property [%s]", property.getDeclaringClass().getName(), property.getName() ), e ); } }
final String propertyName = property.getName(); if ( attributeConversionInfoMap.containsKey( propertyName ) ) { return;
/** * Process the {@link AuditOverride} annotations for this property. * * @param property the property for which the {@link AuditOverride} * annotations are being processed * @param propertyData the Envers auditing data for this property * * @return {@code false} if isAudited() of the override annotation was set to */ private boolean processPropertyAuditingOverrides(XProperty property, PropertyAuditingData propertyData) { // if this property is part of a component, process all override annotations if ( this.auditedPropertiesHolder instanceof ComponentAuditingData ) { final List<AuditOverride> overrides = ( (ComponentAuditingData) this.auditedPropertiesHolder ).getAuditingOverrides(); for ( AuditOverride override : overrides ) { if ( property.getName().equals( override.name() ) ) { // the override applies to this property if ( !override.isAudited() ) { return false; } else { if ( override.auditJoinTable() != null ) { propertyData.setJoinTable( override.auditJoinTable() ); } } } } } return true; }
private void addFromComponentProperty( XProperty property, String accessType, Component propertyValue, Audited allClassAudited) { final ComponentAuditingData componentData = new ComponentAuditingData(); final boolean isAudited = fillPropertyData( property, componentData, accessType, allClassAudited ); final PersistentPropertiesSource componentPropertiesSource; if ( propertyValue.isDynamic() ) { componentPropertiesSource = new DynamicComponentSource( reflectionManager, propertyValue, property ); } else { componentPropertiesSource = new ComponentPropertiesSource( reflectionManager, propertyValue ); } final ComponentAuditedPropertiesReader audPropReader = new ComponentAuditedPropertiesReader( ModificationStore.FULL, componentPropertiesSource, componentData, globalCfg, reflectionManager, propertyNamePrefix + MappingTools.createComponentPrefix( property.getName() ) ); audPropReader.read(); if ( isAudited ) { // Now we know that the property is audited auditedPropertiesHolder.addPropertyAuditingData( property.getName(), componentData ); } }
@Override public ConverterDescriptor resolveAttributeConverterDescriptor(XProperty property) { AttributeConversionInfo info = locateAttributeConversionInfo( property ); if ( info != null ) { if ( info.isConversionDisabled() ) { return null; } else { try { return makeAttributeConverterDescriptor( info ); } catch (Exception e) { throw buildExceptionFromInstantiationError( info, e ); } } } log.debugf( "Attempting to locate auto-apply AttributeConverter for property [%s:%s]", path, property.getName() ); return context.getMetadataCollector() .getAttributeConverterAutoApplyHandler() .findAutoApplyConverterForAttribute( property, context ); }
throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
private static void bindCollectionSecondPass( Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled, XProperty property, PropertyHolder propertyHolder, MetadataBuildingContext buildingContext) { try { BinderHelper.createSyntheticPropertyReference( joinColumns, collValue.getOwner(), collectionEntity, collValue, false, buildingContext ); } catch (AnnotationException ex) { throw new AnnotationException( "Unable to map collection " + collValue.getOwner().getClassName() + "." + property.getName(), ex ); } SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext ); if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) { joinColumns[0].setJPA2ElementCollection( true ); } TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, buildingContext ); }
this.embeddedAttributeName = embeddedXProperty.getName(); this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );