Package org.hibernate.bytecode.enhance

Examples of org.hibernate.bytecode.enhance.EnhancementException


      managedCtClass.addMethod( writer );
      return writer;
    }
    catch (Exception e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance entity class [%s] to add field writer method [%s]",
              managedCtClass.getName(),
              writerName
          ),
View Full Code Here


        final StackMapTable smt = MapMaker.make( classPool, methodInfo );
        methodInfo.getCodeAttribute().setAttribute( smt );
      }
      catch (BadBytecode e) {
        throw new EnhancementException(
            "Unable to perform field access transformation in method : " + methodName,
            e
        );
      }
    }
View Full Code Here

      // "add" EntityEntry
      this.entityEntryCtClass = classPool.makeClass( EntityEntry.class.getName() );
    }
    catch (IOException e) {
      throw new EnhancementException( "Could not prepare Javassist ClassPool", e );
    }

    try {
      this.objectCtClass = classPool.getCtClass( Object.class.getName() );
    }
    catch (NotFoundException e) {
      throw new EnhancementException( "Could not prepare Javassist ClassPool", e );
    }
  }
View Full Code Here

              managedCtClass
          )
      );
    }
    catch (CannotCompileException e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance entity class [%s] to add EntityEntry getter",
              managedCtClass.getName()
          ),
          e
View Full Code Here

          generateFieldWriter( managedCtClass, persistentField, typeDescriptor ),
          typeDescriptor
      );
    }
    catch (Exception e) {
      throw new EnhancementException(
          String.format(
              "Unable to enhance persistent attribute [%s:%s]",
              managedCtClass.getName(),
              persistentField.getName()
          ),
View Full Code Here

    try {
      theField = new CtField( fieldType, fieldName, targetClass );
      targetClass.addField( theField );
    }
    catch (CannotCompileException e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance class [%s] to add field [%s]",
              targetClass.getName(),
              fieldName
          ),
View Full Code Here

  private void addGetter(CtClass targetClass, CtField theField, String getterName) {
    try {
      targetClass.addMethod( CtNewMethod.getter( getterName, theField ) );
    }
    catch (CannotCompileException e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance entity class [%s] to add getter method [%s]",
              targetClass.getName(),
              getterName
          ),
View Full Code Here

  private void addSetter(CtClass targetClass, CtField theField, String setterName) {
    try {
      targetClass.addMethod( CtNewMethod.setter( setterName, theField ) );
    }
    catch (CannotCompileException e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance entity class [%s] to add setter method [%s]",
              targetClass.getName(),
              setterName
          ),
View Full Code Here

        final CtMethod reader = CtNewMethod.getter( readerName, persistentField );
        managedCtClass.addMethod( reader );
        return reader;
      }
      catch (CannotCompileException e) {
        throw new EnhancementException(
            String.format(
                "Could not enhance entity class [%s] to add field reader method [%s]",
                managedCtClass.getName(),
                readerName
            ),
            e
        );
      }
    }

    // temporary solution...
    final String methodBody = typeDescriptor.buildReadInterceptionBodyFragment( fieldName )
        + " return this." + fieldName + ";";

    try {
      final CtMethod reader = CtNewMethod.make(
          Modifier.PRIVATE,
          persistentField.getType(),
          readerName,
          null,
          null,
          "{" + methodBody + "}",
          managedCtClass
      );
      managedCtClass.addMethod( reader );
      return reader;
    }
    catch (Exception e) {
      throw new EnhancementException(
          String.format(
              "Could not enhance entity class [%s] to add field reader method [%s]",
              managedCtClass.getName(),
              readerName
          ),
View Full Code Here

      // "add" EntityEntry
      this.entityEntryCtClass = classPool.makeClass( EntityEntry.class.getName() );
    }
    catch (IOException e) {
      throw new EnhancementException( "Could not prepare Javassist ClassPool", e );
    }

    try {
      this.objectCtClass = classPool.getCtClass( Object.class.getName() );
    }
    catch (NotFoundException e) {
      throw new EnhancementException( "Could not prepare Javassist ClassPool", e );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.bytecode.enhance.EnhancementException

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.