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; }
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) { inFlightPropertyDataList.add( 0, propertyAnnotatedElement ); if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { if ( !prop.isAnnotationPresent( MapsId.class ) ) { if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) { context.getMetadataCollector().addToOneAndIdProperty( entity, propertyAnnotatedElement ); inFlightPropertyDataList.add( propertyAnnotatedElement ); if ( element.isAnnotationPresent( MapsId.class ) ) { context.getMetadataCollector().addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) { annElts.add( 0, propertyAnnotatedElement ); if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) { mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement ); annElts.add( propertyAnnotatedElement ); if ( element.isAnnotationPresent( MapsId.class ) ) { mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
<A extends Annotation> Stream<A> getAnnotationsByType(XAnnotatedElement xAnnotated, Class<A> annotationType) { return Arrays.stream( xAnnotated.getAnnotations() ) .flatMap( annotationHelper::expandRepeatableContainingAnnotation ) .filter( annotation -> annotationType.isAssignableFrom( annotation.annotationType() ) ) .map( annotationType::cast ); }
public void testKnowsWhetherAnAnnotationIsPresent() { assertTrue( getConcreteInstance().isAnnotationPresent( TestAnnotation.class ) ); assertFalse( getConcreteInstance().isAnnotationPresent( Override.class ) ); }
Stream<? extends Annotation> getAnnotationsByMetaAnnotationType( XAnnotatedElement xAnnotated, Class<? extends Annotation> metaAnnotationType) { return Arrays.stream( xAnnotated.getAnnotations() ) .flatMap( annotationHelper::expandRepeatableContainingAnnotation ) .filter( annotation -> annotationHelper.isMetaAnnotated( annotation, metaAnnotationType ) ); }
private static void bindFilters(XAnnotatedElement annotatedElement, EntityBinder entityBinder) { Filters filtersAnn = annotatedElement.getAnnotation( Filters.class ); if ( filtersAnn != null ) { for ( Filter filter : filtersAnn.value() ) { entityBinder.addFilter(filter); } } Filter filterAnn = annotatedElement.getAnnotation( Filter.class ); if ( filterAnn != null ) { entityBinder.addFilter(filterAnn); } }
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) { annElts.add( 0, propertyAnnotatedElement ); if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { if ( prop.isAnnotationPresent( JoinColumn.class ) if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) { mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement ); annElts.add( propertyAnnotatedElement ); if ( element.isAnnotationPresent( MapsId.class ) ) { mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
private static void bindTypeDefs(XAnnotatedElement annotatedElement, MetadataBuildingContext context) { TypeDef defAnn = annotatedElement.getAnnotation( TypeDef.class ); TypeDefs defsAnn = annotatedElement.getAnnotation( TypeDefs.class ); if ( defAnn != null ) { bindTypeDef( defAnn, context ); } if ( defsAnn != null ) { for ( TypeDef def : defsAnn.value() ) { bindTypeDef( def, context ); } } }
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) { annElts.add( 0, propertyAnnotatedElement ); if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { if ( prop.isAnnotationPresent( JoinColumn.class ) if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) { mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement ); annElts.add( propertyAnnotatedElement ); if ( element.isAnnotationPresent( MapsId.class ) ) { mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, MetadataBuildingContext context) { FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class ); FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class ); if ( fetchProfileAnnotation != null ) { bindFetchProfile( fetchProfileAnnotation, context ); } if ( fetchProfileAnnotations != null ) { for ( FetchProfile profile : fetchProfileAnnotations.value() ) { bindFetchProfile( profile, context ); } } }
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) { inFlightPropertyDataList.add( 0, propertyAnnotatedElement ); if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) { String columnName = element.getAnnotation( Column.class ).name(); for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { if ( !prop.isAnnotationPresent( MapsId.class ) ) { if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) { context.getMetadataCollector().addToOneAndIdProperty( entity, propertyAnnotatedElement ); inFlightPropertyDataList.add( propertyAnnotatedElement ); if ( element.isAnnotationPresent( MapsId.class ) ) { context.getMetadataCollector().addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
private static void bindGenericGenerators(XAnnotatedElement annotatedElement, MetadataBuildingContext context) { GenericGenerator defAnn = annotatedElement.getAnnotation( GenericGenerator.class ); GenericGenerators defsAnn = annotatedElement.getAnnotation( GenericGenerators.class ); if ( defAnn != null ) { bindGenericGenerator( defAnn, context ); } if ( defsAnn != null ) { for ( GenericGenerator def : defsAnn.value() ) { bindGenericGenerator( def, context ); } } }
private static void bindFilterDefs(XAnnotatedElement annotatedElement, MetadataBuildingContext context) { FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class ); FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class ); if ( defAnn != null ) { bindFilterDef( defAnn, context ); } if ( defsAnn != null ) { for ( FilterDef def : defsAnn.value() ) { bindFilterDef( def, context ); } } }
public static void bindAnyMetaDefs(XAnnotatedElement annotatedElement, MetadataBuildingContext context) { AnyMetaDef defAnn = annotatedElement.getAnnotation( AnyMetaDef.class ); AnyMetaDefs defsAnn = annotatedElement.getAnnotation( AnyMetaDefs.class ); boolean mustHaveName = XClass.class.isAssignableFrom( annotatedElement.getClass() ) || XPackage.class.isAssignableFrom( annotatedElement.getClass() ); if ( defAnn != null ) { checkAnyMetaDefValidity( mustHaveName, defAnn, annotatedElement ); bindAnyMetaDef( defAnn, context ); } if ( defsAnn != null ) { for (AnyMetaDef def : defsAnn.value()) { checkAnyMetaDefValidity( mustHaveName, def, annotatedElement ); bindAnyMetaDef( def, context ); } } }
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 ) {
SqlResultSetMapping ann = annotatedElement.getAnnotation( SqlResultSetMapping.class ); QueryBinder.bindSqlResultSetMapping( ann, context, false ); SqlResultSetMappings ann = annotatedElement.getAnnotation( SqlResultSetMappings.class ); if ( ann != null ) { for ( SqlResultSetMapping current : ann.value() ) { NamedQuery ann = annotatedElement.getAnnotation( NamedQuery.class ); QueryBinder.bindQuery( ann, context, false ); org.hibernate.annotations.NamedQuery ann = annotatedElement.getAnnotation( org.hibernate.annotations.NamedQuery.class ); NamedQueries ann = annotatedElement.getAnnotation( NamedQueries.class ); QueryBinder.bindQueries( ann, context, false ); org.hibernate.annotations.NamedQueries ann = annotatedElement.getAnnotation( org.hibernate.annotations.NamedQueries.class ); NamedNativeQuery ann = annotatedElement.getAnnotation( NamedNativeQuery.class ); QueryBinder.bindNativeQuery( ann, context, false ); org.hibernate.annotations.NamedNativeQuery ann = annotatedElement.getAnnotation( org.hibernate.annotations.NamedNativeQuery.class ); NamedNativeQueries ann = annotatedElement.getAnnotation( NamedNativeQueries.class );
private void extractInheritanceType() { XAnnotatedElement element = getClazz(); Inheritance inhAnn = element.getAnnotation( Inheritance.class ); MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class ); if ( mappedSuperClass != null ) { setEmbeddableSuperclass( true ); setType( inhAnn == null ? null : inhAnn.strategy() ); } else { setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() ); } }
AccessType jpaAccessType = null; org.hibernate.annotations.AccessType accessTypeAnnotation = element.getAnnotation( org.hibernate.annotations.AccessType.class ); if ( accessTypeAnnotation != null ) { hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() ); Access access = element.getAnnotation( Access.class ); if ( access != null ) { jpaAccessType = AccessType.getAccessStrategy( access.value() );
HashMap<String, IdentifierGeneratorDefinition> generators = new HashMap<>(); TableGenerators tableGenerators = annElt.getAnnotation( TableGenerators.class ); if ( tableGenerators != null ) { for ( TableGenerator tableGenerator : tableGenerators.value() ) { SequenceGenerators sequenceGenerators = annElt.getAnnotation( SequenceGenerators.class ); if ( sequenceGenerators != null ) { for ( SequenceGenerator sequenceGenerator : sequenceGenerators.value() ) { TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class ); SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class ); GenericGenerator genGen = annElt.getAnnotation( GenericGenerator.class ); if ( tabGen != null ) { IdentifierGeneratorDefinition idGen = buildIdGenerator( tabGen, context );