Package javax.persistence

Examples of javax.persistence.AccessType


      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." );
View Full Code Here


  private Access getAccessType(Element tree, XMLContext.Default defaults) {
    String access = tree == null ? null : tree.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." );
View Full Code Here

          rootClassWithAllSubclasses,
          processedEntities,
          classToDirectSubClassMap
      );

      AccessType defaultAccessType = determineDefaultAccessType( rootClassWithAllSubclasses );
      InheritanceType hierarchyInheritanceType = determineInheritanceType(
          rootClassInfo,
          rootClassWithAllSubclasses
      );
View Full Code Here

   * @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 ) ) {
View Full Code Here

      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;
View Full Code Here

    }
  }

  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 );
    }
View Full Code Here

      if ( !( annotationTarget.getClass().equals( MethodInfo.class ) || annotationTarget.getClass()
          .equals( FieldInfo.class ) ) ) {
        continue;
      }

      AccessType accessType = JandexHelper.getEnumValue( accessAnnotation, "value", AccessType.class );

      if ( !isExplicitAttributeAccessAnnotationPlacedCorrectly( annotationTarget, accessType ) ) {
        continue;
      }
View Full Code Here

    Elements utils = context.getElementUtils();
    return utils.getTypeElement( fullyQualifiedClassName );
  }

  private AccessType determineEntityAccessType(EntityMappings mappings) {
    AccessType accessType = context.getPersistenceUnitDefaultAccessType();
    if ( mappings.getAccess() != null ) {
      accessType = mapXmlAccessTypeToJpaAccessType( mappings.getAccess() );
    }
    return accessType;
  }
View Full Code Here

  private void determineXmlAccessTypes() {
    for ( EntityMappings mappings : entityMappings ) {
      String fqcn;
      String packageName = mappings.getPackage();
      AccessType defaultAccessType = determineEntityAccessType( mappings );

      for ( Entity entity : mappings.getEntity() ) {
        String name = entity.getClazz();
        fqcn = StringUtil.determineFullyQualifiedClassName( packageName, name );
        AccessType explicitAccessType = null;
        org.hibernate.jpamodelgen.xml.jaxb.AccessType type = entity.getAccess();
        if ( type != null ) {
          explicitAccessType = mapXmlAccessTypeToJpaAccessType( type );
        }
        AccessTypeInformation accessInfo = new AccessTypeInformation(
            fqcn, explicitAccessType, defaultAccessType
        );
        context.addAccessTypeInformation( fqcn, accessInfo );
      }

      for ( org.hibernate.jpamodelgen.xml.jaxb.MappedSuperclass mappedSuperClass : mappings.getMappedSuperclass() ) {
        String name = mappedSuperClass.getClazz();
        fqcn = StringUtil.determineFullyQualifiedClassName( packageName, name );
        AccessType explicitAccessType = null;
        org.hibernate.jpamodelgen.xml.jaxb.AccessType type = mappedSuperClass.getAccess();
        if ( type != null ) {
          explicitAccessType = mapXmlAccessTypeToJpaAccessType( type );
        }
        AccessTypeInformation accessInfo = new AccessTypeInformation(
            fqcn, explicitAccessType, defaultAccessType
        );
        context.addAccessTypeInformation( fqcn, accessInfo );
      }

      for ( org.hibernate.jpamodelgen.xml.jaxb.Embeddable embeddable : mappings.getEmbeddable() ) {
        String name = embeddable.getClazz();
        fqcn = StringUtil.determineFullyQualifiedClassName( packageName, name );
        AccessType explicitAccessType = null;
        org.hibernate.jpamodelgen.xml.jaxb.AccessType type = embeddable.getAccess();
        if ( type != null ) {
          explicitAccessType = mapXmlAccessTypeToJpaAccessType( type );
        }
        AccessTypeInformation accessInfo = new AccessTypeInformation(
View Full Code Here

      );
      return;
    }

    // check for explicit access type
    AccessType forcedAccessType = determineAnnotationSpecifiedAccessType( searchedElement );
    if ( forcedAccessType != null ) {
      context.logMessage(
          Diagnostic.Kind.OTHER, "Explicit access type on " + searchedElement + ":" + forcedAccessType
      );
      accessTypeInfo = new AccessTypeInformation( fqcn, forcedAccessType, null );
      context.addAccessTypeInformation( fqcn, accessTypeInfo );
      updateEmbeddableAccessType( searchedElement, context, forcedAccessType );
      return;
    }

    // need to find the default access type for this class
    // let's check first if this entity is the root of the class hierarchy and defines an id. If so the
    // placement of the id annotation determines the access type
    AccessType defaultAccessType = getAccessTypeInCaseElementIsRoot( searchedElement, context );
    if ( defaultAccessType != null ) {
      accessTypeInfo = new AccessTypeInformation( fqcn, null, defaultAccessType );
      context.addAccessTypeInformation( fqcn, accessTypeInfo );
      updateEmbeddableAccessType( searchedElement, context, defaultAccessType );
      return;
View Full Code Here

TOP

Related Classes of javax.persistence.AccessType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.