private TemporalType getTemporalType(XProperty property) { if ( key ) { MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class ); return ann.value(); } else { Temporal ann = property.getAnnotation( Temporal.class ); return ann.value(); } }
private javax.persistence.ForeignKey getMapKeyForeignKey(XProperty property) { final MapKeyJoinColumns mapKeyJoinColumns = property.getAnnotation( MapKeyJoinColumns.class ); if ( mapKeyJoinColumns != null ) { return mapKeyJoinColumns.foreignKey(); } else { final MapKeyJoinColumn mapKeyJoinColumn = property.getAnnotation( MapKeyJoinColumn.class ); if ( mapKeyJoinColumn != null ) { return mapKeyJoinColumn.foreignKey(); } } return null; }
/** * Add the {@link AuditOverride} annotations. * * @param property the property being processed * @param propertyData the Envers auditing data for this property */ private void addPropertyAuditingOverrides(XProperty property, PropertyAuditingData propertyData) { final AuditOverride annotationOverride = property.getAnnotation( AuditOverride.class ); if ( annotationOverride != null ) { propertyData.addAuditingOverride( annotationOverride ); } final AuditOverrides annotationOverrides = property.getAnnotation( AuditOverrides.class ); if ( annotationOverrides != null ) { propertyData.addAuditingOverrides( annotationOverrides ); } }
@Override public void addPropertyAnnotatedWithMapsId(XClass entityType, PropertyData property) { if ( propertiesAnnotatedWithMapsId == null ) { propertiesAnnotatedWithMapsId = new HashMap<>(); } Map<String, PropertyData> map = propertiesAnnotatedWithMapsId.get( entityType ); if ( map == null ) { map = new HashMap<>(); propertiesAnnotatedWithMapsId.put( entityType, map ); } map.put( property.getProperty().getAnnotation( MapsId.class ).value(), property ); }
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 addPropertyMapKey(XProperty property, PropertyAuditingData propertyData) { final MapKey mapKey = property.getAnnotation( MapKey.class ); if ( mapKey != null ) { propertyData.setMapKey( mapKey.name() ); } }
private void extractDataFromPropertyData(PropertyData inferredData) { if ( inferredData != null ) { XProperty property = inferredData.getProperty(); if ( property != null ) { processExpression( property.getAnnotation( ColumnTransformer.class ) ); ColumnTransformers annotations = property.getAnnotation( ColumnTransformers.class ); if (annotations != null) { for ( ColumnTransformer annotation : annotations.value() ) { processExpression( annotation ); } } } } }
private void setPropertyRelationMappedBy(XProperty property, PropertyAuditingData propertyData) { final OneToMany oneToMany = property.getAnnotation( OneToMany.class ); if ( oneToMany != null && !"".equals( oneToMany.mappedBy() ) ) { propertyData.setRelationMappedBy( oneToMany.mappedBy() ); } }
private void buildAttributeConversionInfoMaps( XProperty collectionProperty, Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap, Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap) { if ( collectionProperty == null ) { // not sure this is valid condition return; } { final Convert convertAnnotation = collectionProperty.getAnnotation( Convert.class ); if ( convertAnnotation != null ) { applyLocalConvert( convertAnnotation, collectionProperty, elementAttributeConversionInfoMap, keyAttributeConversionInfoMap ); } } { final Converts convertsAnnotation = collectionProperty.getAnnotation( Converts.class ); if ( convertsAnnotation != null ) { for ( Convert convertAnnotation : convertsAnnotation.value() ) { applyLocalConvert( convertAnnotation, collectionProperty, elementAttributeConversionInfoMap, keyAttributeConversionInfoMap ); } } } }
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; }
public AccessType getDefaultAccess() throws MappingException { AccessType accessType = defaultAccess; AccessType hibernateAccessType = AccessType.DEFAULT; AccessType jpaAccessType = AccessType.DEFAULT; org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class ); if ( accessTypeAnnotation != null ) { hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() ); } Access access = property.getAnnotation( Access.class ); if ( access != null ) { jpaAccessType = AccessType.getAccessStrategy( access.value() ); } if ( hibernateAccessType != AccessType.DEFAULT && jpaAccessType != AccessType.DEFAULT && hibernateAccessType != jpaAccessType ) { StringBuilder builder = new StringBuilder(); builder.append( property.toString() ); builder.append( " defines @AccessType and @Access with contradicting values. Use of @Access only is recommended." ); throw new MappingException( builder.toString() ); } if ( hibernateAccessType != AccessType.DEFAULT ) { accessType = hibernateAccessType; } else if ( jpaAccessType != AccessType.DEFAULT ) { accessType = jpaAccessType; } return accessType; }
private void addPropertyJoinTables(XProperty property, PropertyAuditingData propertyData) { // The AuditJoinTable annotation source will follow the following priority rules // 1. Use the override if one is specified // 2. Use the site annotation if one is specified // 3. Use the default if neither are specified // // The prime directive for (1) is so that when users in a subclass use @AuditOverride(s) // the join-table specified there should have a higher priority in the event the // super-class defines an equivalent @AuditJoinTable at the site/property level. final AuditJoinTable overrideJoinTable = overriddenAuditedPropertiesJoinTables.get( property ); if ( overrideJoinTable != null ) { propertyData.setJoinTable( overrideJoinTable ); } else { final AuditJoinTable propertyJoinTable = property.getAnnotation( AuditJoinTable.class ); if ( propertyJoinTable != null ) { propertyData.setJoinTable( propertyJoinTable ); } else { propertyData.setJoinTable( DEFAULT_AUDIT_JOIN_TABLE ); } } }
private void setPropertyAuditMappedBy(XProperty property, PropertyAuditingData propertyData) { final AuditMappedBy auditMappedBy = property.getAnnotation( AuditMappedBy.class ); if ( auditMappedBy != null ) { propertyData.setAuditMappedBy( auditMappedBy.mappedBy() ); if ( !"".equals( auditMappedBy.positionMappedBy() ) ) { propertyData.setPositionMappedBy( auditMappedBy.positionMappedBy() ); } } }
public XClass getPropertyClass() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getType(); } }
public XClass getClassOrElement() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getClassOrElementClass(); } }
private static void applyColumnDefault(Ejb3Column column, PropertyData inferredData) { final XProperty xProperty = inferredData.getProperty(); if ( xProperty != null ) { ColumnDefault columnDefaultAnn = xProperty.getAnnotation( ColumnDefault.class ); if ( columnDefaultAnn != null ) { column.setDefaultValue( columnDefaultAnn.value() ); } } else { LOG.trace( "Could not perform @ColumnDefault lookup as 'PropertyData' did not give access to XProperty" ); } }
/** * 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 void setupComponentTuplizer(XProperty property, Component component) { if ( property == null ) { return; } if ( property.isAnnotationPresent( Tuplizers.class ) ) { for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) { EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); //todo tuplizer.entityModeType component.addTuplizer( mode, tuplizer.impl().getName() ); } } if ( property.isAnnotationPresent( Tuplizer.class ) ) { Tuplizer tuplizer = property.getAnnotation( Tuplizer.class ); EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); //todo tuplizer.entityModeType component.addTuplizer( mode, tuplizer.impl().getName() ); } }
private static void setVersionInformation(XProperty property, PropertyBinder propertyBinder) { propertyBinder.getSimpleValueBinder().setVersion( true ); if(property.isAnnotationPresent( Source.class )) { Source source = property.getAnnotation( Source.class ); propertyBinder.getSimpleValueBinder().setTimestampVersionType( source.value().typeName() ); } }
@Override protected boolean checkAudited( XProperty property, PropertyAuditingData propertyData, String propertyName, Audited allClassAudited, String modifiedFlagSuffix) { // Checking if this property is explicitly audited or if all properties are. final Audited aud = property.getAnnotation( Audited.class ); if ( aud != null ) { propertyData.setStore( aud.modStore() ); propertyData.setRelationTargetAuditMode( aud.targetAuditMode() ); propertyData.setUsingModifiedFlag( checkUsingModifiedFlag( aud ) ); if( aud.modifiedColumnName() != null && !"".equals( aud.modifiedColumnName() ) ) { propertyData.setModifiedFlagName( aud.modifiedColumnName() ); } else { propertyData.setModifiedFlagName( MetadataTools.getModifiedFlagPropertyName( propertyName, modifiedFlagSuffix ) ); } } else { propertyData.setStore( ModificationStore.FULL ); } return true; }