private boolean isProcessingId(XMLContext.Default defaults) { boolean isExplicit = defaults.getAccess() != null; boolean correctAccess = ( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) ) || ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD .equals( defaults.getAccess() ) ); boolean hasId = defaults.canUseJavaAnnotations() && ( isPhysicalAnnotationPresent( Id.class ) || isPhysicalAnnotationPresent( EmbeddedId.class ) ); //if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) { boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() && ( mirroredAttribute != null && ( mirroredAttribute.isAnnotationPresent( Id.class ) || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) ); boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType ) && !mirrorAttributeIsId; return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault ); }
private void getAccessType(List<Annotation> annotationList, Element element) { if ( element == null ) { return; } String access = element.attributeValue( "access" ); if ( access != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( Access.class ); AccessType type; try { type = AccessType.valueOf( access ); } catch ( IllegalArgumentException e ) { throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." ); } if ( ( AccessType.PROPERTY.equals( type ) && this.element instanceof Method ) || ( AccessType.FIELD.equals( type ) && this.element instanceof Field ) ) { return; } ad.setValue( "value", type ); annotationList.add( AnnotationFactory.create( ad ) ); } }
@SuppressWarnings("unchecked") private EmbeddableHierarchy( List<ClassInfo> classInfoList, String propertyName, AnnotationBindingContext context, AccessType defaultAccessType) { this.defaultAccessType = defaultAccessType; // the resolved type for the top level class in the hierarchy context.resolveAllTypes( classInfoList.get( classInfoList.size() - 1 ).name().toString() ); embeddables = new ArrayList<EmbeddableClass>(); ConfiguredClass parent = null; EmbeddableClass embeddable; for ( ClassInfo info : classInfoList ) { embeddable = new EmbeddableClass( info, propertyName, parent, defaultAccessType, context ); embeddables.add( embeddable ); parent = embeddable; } }
public ConfiguredClass( ClassInfo classInfo, AccessType defaultAccessType, ConfiguredClass parent, AnnotationBindingContext context) { this.parent = parent; this.classInfo = classInfo; this.clazz = context.locateClassByName( classInfo.toString() ); this.configuredClassType = determineType(); this.classAccessType = determineClassAccessType( defaultAccessType ); this.customTuplizer = determineCustomTuplizer(); this.simpleAttributeMap = new TreeMap<String, BasicAttribute>(); this.idAttributeMap = new TreeMap<String, BasicAttribute>(); this.associationAttributeMap = new TreeMap<String, AssociationAttribute>(); this.localBindingContext = new EntityBindingContext( context, this ); collectAttributes(); attributeOverrideMap = Collections.unmodifiableMap( findAttributeOverrides() ); }
/** * @param classes the classes in the hierarchy * * @return Returns the default access type for the configured class hierarchy independent of explicit * {@code AccessType} annotations. The default access type is determined by the placement of the * annotations. */ private static AccessType determineDefaultAccessType(List<ClassInfo> classes) { AccessType accessTypeByEmbeddedIdPlacement = null; AccessType accessTypeByIdPlacement = null; for ( ClassInfo info : classes ) { List<AnnotationInstance> idAnnotations = info.annotations().get( JPADotNames.ID ); List<AnnotationInstance> embeddedIdAnnotations = info.annotations().get( JPADotNames.EMBEDDED_ID ); if ( CollectionHelper.isNotEmpty( embeddedIdAnnotations ) ) { accessTypeByEmbeddedIdPlacement = determineAccessTypeByIdPlacement( embeddedIdAnnotations ); } if ( CollectionHelper.isNotEmpty( idAnnotations ) ) { accessTypeByIdPlacement = determineAccessTypeByIdPlacement( idAnnotations ); } } if ( accessTypeByEmbeddedIdPlacement != null ) { return accessTypeByEmbeddedIdPlacement; } else if ( accessTypeByIdPlacement != null ) { return accessTypeByIdPlacement; } else { return throwIdNotFoundAnnotationException( classes ); } }
private static AccessType determineAccessTypeByIdPlacement(List<AnnotationInstance> idAnnotations) { AccessType accessType = null; for ( AnnotationInstance annotation : idAnnotations ) { AccessType tmpAccessType; if ( annotation.target() instanceof FieldInfo ) { tmpAccessType = AccessType.FIELD; } else if ( annotation.target() instanceof MethodInfo ) { tmpAccessType = AccessType.PROPERTY; } else { throw new AnnotationException( "Invalid placement of @Id annotation" ); } if ( accessType == null ) { accessType = tmpAccessType; } else { if ( !accessType.equals( tmpAccessType ) ) { throw new AnnotationException( "Inconsistent placement of @Id annotation within hierarchy " ); } } } return accessType; }
protected AccessType getAccessFromIndex(DotName className) { Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className ); List<AnnotationInstance> accessAnnotationInstances = indexedAnnotations.get( ACCESS ); if ( MockHelper.isNotEmpty( accessAnnotationInstances ) ) { for ( AnnotationInstance annotationInstance : accessAnnotationInstances ) { if ( annotationInstance.target() != null && annotationInstance.target() instanceof ClassInfo ) { ClassInfo ci = (ClassInfo) ( annotationInstance.target() ); if ( className.equals( ci.name() ) ) { //todo does ci need to have @Entity or @MappedSuperClass ?? return AccessType.valueOf( annotationInstance.value().asEnum() ); } } } } return null; }
@Override @Id @Size(min = 16, max = 255) @Access(value = AccessType.PROPERTY) @Column(name = "token_data", nullable = false, length = 255) public String getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "srva_event_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
private void setAccess( String access, Default defaultType) { AccessType type; if ( access != null ) { try { type = AccessType.valueOf( access ); } catch ( IllegalArgumentException e ) { throw new AnnotationException( "Invalid access type " + access + " (check your xml configuration)" ); } defaultType.setAccess( type ); } }
public EntityClass( ClassInfo classInfo, EntityClass parent, AccessType hierarchyAccessType, InheritanceType inheritanceType, AnnotationBindingContext context) { super( classInfo, hierarchyAccessType, parent, context ); this.inheritanceType = inheritanceType; this.idType = determineIdType(); boolean hasOwnTable = definesItsOwnTable(); this.explicitEntityName = determineExplicitEntityName(); this.constraintSources = new HashSet<ConstraintSource>(); if ( hasOwnTable ) { AnnotationInstance tableAnnotation = JandexHelper.getSingleAnnotation( getClassInfo(), JPADotNames.TABLE ); this.primaryTableSource = createTableSource( tableAnnotation ); } else { this.primaryTableSource = null; } this.secondaryTableSources = createSecondaryTableSources(); this.customLoaderQueryName = determineCustomLoader(); this.synchronizedTableNames = determineSynchronizedTableNames(); this.batchSize = determineBatchSize(); this.jpaCallbacks = determineEntityListeners(); processHibernateEntitySpecificAnnotations(); processCustomSqlAnnotations(); processProxyGeneration(); processDiscriminator(); }
private AccessType determineClassAccessType(AccessType defaultAccessType) { // default to the hierarchy access type to start with AccessType accessType = defaultAccessType; AnnotationInstance accessAnnotation = JandexHelper.getSingleAnnotation( classInfo, JPADotNames.ACCESS ); if ( accessAnnotation != null && accessAnnotation.target().getClass().equals( ClassInfo.class ) ) { accessType = JandexHelper.getEnumValue( accessAnnotation, "value", AccessType.class ); } return accessType; }
public EmbeddableClass( ClassInfo classInfo, String embeddedAttributeName, ConfiguredClass parent, AccessType defaultAccessType, AnnotationBindingContext context) { super( classInfo, defaultAccessType, parent, context ); this.embeddedAttributeName = embeddedAttributeName; this.parentReferencingAttributeName = checkParentAnnotation(); }
private static void addSubclassEntitySources(AnnotationBindingContext bindingContext, Map<DotName, List<ClassInfo>> classToDirectSubClassMap, AccessType defaultAccessType, InheritanceType hierarchyInheritanceType, EntityClass entityClass, EntitySource entitySource) { List<ClassInfo> subClassInfoList = classToDirectSubClassMap.get( DotName.createSimple( entitySource.getClassName() ) ); if ( subClassInfoList == null ) { return; } for ( ClassInfo subClassInfo : subClassInfoList ) { EntityClass subclassEntityClass = new EntityClass( subClassInfo, entityClass, defaultAccessType, hierarchyInheritanceType, bindingContext ); SubclassEntitySource subclassEntitySource = new SubclassEntitySourceImpl( subclassEntityClass ); entitySource.add( subclassEntitySource ); addSubclassEntitySources( bindingContext, classToDirectSubClassMap, defaultAccessType, hierarchyInheritanceType, subclassEntityClass, subclassEntitySource ); } }
protected AccessType getDefaultAccess() { if ( entity.getAccess() != null ) { return AccessType.valueOf( entity.getAccess().value() ); } return null; }
@Override @Id @Access(value = AccessType.PROPERTY) @Column(name = "integration_id", nullable = false) @Size(max = 255) public String getId() { return this.id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "announcement_subscriber_id", nullable = false) public Long getId() { return id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "announcement_id", nullable = false) public Long getId() { return id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = ID_COLUMN_NAME, nullable = false) public Long getId() { return this.id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "moose_data_card_import_id", nullable = false) public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "group_hunting_day_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "group_observation_rejection_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "group_harvest_rejection_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "hunting_club_member_invitation_id", nullable = false) public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "hunting_summary_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "moose_hunting_summary_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "moose_harvest_report_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Override @Id @Access(value = AccessType.PROPERTY) @Column(name = "gid", nullable = false) public Integer getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = ID_COLUMN_NAME, nullable = false) @Override public Long getId() { return this.id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = ID_COLUMN_NAME, nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "harvest_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "harvest_specimen_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "game_observation_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "observation_specimen_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "game_diary_image_id", nullable = false) @Access(value = AccessType.PROPERTY) @Override public Long getId() { return id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "message_id", nullable = false) public Long getId() { return id; }
@Override @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Access(value = AccessType.PROPERTY) @Column(name = "user_id", nullable = false) public Long getId() { return id; }