Package org.hibernate.bytecode.enhance

Examples of org.hibernate.bytecode.enhance.EnhancementException


  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

      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

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.