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

    EntityMappings mappings = parseXml( resource, EntityMappings.class, ORM_XSD );
    if ( mappings == null ) {
      return;
    }

    AccessType accessType = determineGlobalAccessType( mappings );

    parseEntities( mappings, accessType );
    parseEmbeddable( mappings, accessType );
    parseMappedSuperClass( mappings, accessType );
  }
View Full Code Here

    return utils.getTypeElement( fullyQualifiedClassName );
  }


  private AccessType determineGlobalAccessType(EntityMappings mappings) {
    AccessType accessType = DEFAULT_XML_ACCESS_TYPE;

    if ( mappings.getAccess() != null ) {
      accessType = mapXmlAccessTypeToJpaAccessType( mappings.getAccess() );
      return accessType; // no need to check persistence unit default
    }
View Full Code Here

    return context.getProcessingEnvironment().getElementUtils().getName( packageOf.getQualifiedName() ).toString();
  }

  public List<MetaAttribute> getMembers() {
    List<MetaAttribute> membersFound = new ArrayList<MetaAttribute>();
    final AccessType elementAccessType = getAccessTypeForElement();

    List<? extends Element> fieldsOfClass = ElementFilter.fieldsIn( element.getEnclosedElements() );
    addPersistentMembers( membersFound, elementAccessType, fieldsOfClass, AccessType.FIELD );

    List<? extends Element> methodsOfClass = ElementFilter.methodsIn( element.getEnclosedElements() );
View Full Code Here

  private void addPersistentMembers(
      List<MetaAttribute> membersFound,
      AccessType elementAccessType,
      List<? extends Element> membersOfClass,
      AccessType membersKind) {
    AccessType explicitAccessType;
    if ( elementAccessType == membersKind ) {
      //all membersKind considered
      explicitAccessType = null;
    }
    else {
View Full Code Here

  }

  private AccessType getAccessTypeForElement() {

    //get local strategy
    AccessType accessType = getAccessTypeForClass( element );
    if ( accessType == null ) {
      accessType = this.defaultAccessTypeForHierarchy;
    }
    if ( accessType == null ) {
      //we don't know if an entity go up
      //
      //superclasses are always treated after their entities
      //and their access type are discovered
      //FIXME is it really true if only the superclass is changed
      TypeElement superClass = element;
      do {
        superClass = TypeUtils.getSuperclassTypeElement( superClass );
        if ( superClass != null ) {
          if ( TypeUtils.containsAnnotation( superClass, Entity.class, MappedSuperclass.class ) ) {
            //FIXME make it work for XML
            AccessType superClassAccessType = getAccessTypeForClass( superClass );
            //we've reach the root entity and resolved Ids
            if ( superClassAccessType != null && defaultAccessTypeForHierarchy != null ) {
              break; //we've found it
            }
          }
View Full Code Here

    return accessType;
  }

  private AccessType getAccessTypeForClass(TypeElement searchedElement) {
    context.logMessage( Diagnostic.Kind.OTHER, "check class " + searchedElement );
    AccessType accessType = context.getAccessType( searchedElement );

    if ( defaultAccessTypeForHierarchy == null ) {
      this.defaultAccessTypeForHierarchy = context.getDefaultAccessTypeForHerarchy( searchedElement );
    }
    if ( accessType != null ) {
      context.logMessage( Diagnostic.Kind.OTHER, "Found in cache" + searchedElement + ":" + accessType );
      return accessType;
    }

    /**
     * when forcing access type, we can only override the defaultAccessTypeForHierarchy
     * if we are the entity root (identified by having @Id or @EmbeddedId
     */
    AccessType forcedAccessType = determineAnnotationSpecifiedAccessType( searchedElement );
    if ( forcedAccessType != null ) {
      context.logMessage( Diagnostic.Kind.OTHER, "access type " + searchedElement + ":" + forcedAccessType );
      context.addAccessType( searchedElement, forcedAccessType );
    }

View Full Code Here

    return forcedAccessType;
  }

  private AccessType determineAnnotationSpecifiedAccessType(Element element) {
    final AnnotationMirror accessAnnotationMirror = TypeUtils.getAnnotationMirror( element, Access.class );
    AccessType forcedAccessType = null;
    if ( accessAnnotationMirror != null ) {
      Element accessElement = ( Element ) TypeUtils.getAnnotationValue(
          accessAnnotationMirror,
          DEFAULT_ANNOTATION_PARAMETER_NAME
      );
View Full Code Here

      boolean correctAccessType = false;
      if ( this.explicitAccessType == null ) {
        correctAccessType = true;
      }
      else {
        AccessType annotationAccessType = determineAnnotationSpecifiedAccessType( element );
        if ( explicitAccessType.equals( annotationAccessType ) ) {
          correctAccessType = true;
        }
      }
      return correctAccessType
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.