jpa/hibernate-transformer/src/main/java/org/jboss/as/hibernate/MethodAdapter.java
@Override
    public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
        if (rewriteSessionImplementor &&
                hasSessionImplementor(desc) &&
                (opcode == Opcodes.INVOKESPECIAL || opcode == Opcodes.INVOKEVIRTUAL)) {
            // if we have a user type calling a method from org.hibernate, we rewrite it to use SharedSessionContractImplementor
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s' is calling method %s.%s, which must be changed to use SharedSessionContractImplementor as parameter.",
                    moduleName, className, owner, name);
            mv.visitMethodInsn(opcode, owner, name, replaceSessionImplementor(desc), itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                (owner.equals("org/hibernate/Session") || owner.equals("org/hibernate/BasicQueryContract"))
                && name.equals("getFlushMode") && desc.equals("()Lorg/hibernate/FlushMode;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s' is calling %s.getFlushMode, which must be changed to call getHibernateFlushMode().",
                    moduleName, className, owner);
            name = "getHibernateFlushMode";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("getFirstResult") &&
                desc.equals("()Ljava/lang/Integer;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.getFirstResult, which must be changed to call getHibernateFirstResult() " +
                            "so null can be returned when the value is uninitialized. Please note that if a negative value was set using " +
                            "org.hibernate.Query.setFirstResult, then getHibernateFirstResult() will return 0.",
                    moduleName, className);
            name = "getHibernateFirstResult";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("getMaxResults") &&
                desc.equals("()Ljava/lang/Integer;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.getMaxResults, which must be changed to call getHibernateMaxResults() " +
                            "so that null will be returned when the value is uninitialized or ORM 5.1 org.hibernate.Query#setMaxResults was " +
                            "used to set a value <= 0"
                    , moduleName, className);
            name = "getHibernateMaxResults";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (!disableAmbiguousChanges && opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("setFirstResult") &&
                desc.equals("(I)Lorg/hibernate/Query;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.setFirstResult, which must be changed to call setHibernateFirstResult() " +
                            "so setting a value < 0 results in pagination starting with the 0th row as was done in Hibernate ORM 5.1 " +
                            "(instead of throwing IllegalArgumentException as specified by JPA)."
                    , moduleName, className);
            name = "setHibernateFirstResult";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (!disableAmbiguousChanges && opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("setMaxResults") &&
                desc.equals("(I)Lorg/hibernate/Query;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.setMaxResults, which must be changed to call setHibernateMaxResults() " +
                            "so that values <= 0 are treated the same as uninitialized.  Review Hibernate ORM migration doc "
                    , moduleName, className);
            name = "setHibernateMaxResults";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else {
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
        }

    }
@Override
    public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
        if (rewriteSessionImplementor &&
                hasSessionImplementor(desc) &&
                (opcode == Opcodes.INVOKESPECIAL || opcode == Opcodes.INVOKEVIRTUAL)) {
            // if we have a user type calling a method from org.hibernate, we rewrite it to use SharedSessionContractImplementor
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s' is calling method %s.%s, which must be changed to use SharedSessionContractImplementor as parameter.",
                    moduleName, className, owner, name);
            mv.visitMethodInsn(opcode, owner, name, replaceSessionImplementor(desc), itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                (owner.equals("org/hibernate/Session") || owner.equals("org/hibernate/BasicQueryContract"))
                && name.equals("getFlushMode") && desc.equals("()Lorg/hibernate/FlushMode;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s' is calling %s.getFlushMode, which must be changed to call getHibernateFlushMode().",
                    moduleName, className, owner);
            name = "getHibernateFlushMode";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("getFirstResult") &&
                desc.equals("()Ljava/lang/Integer;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.getFirstResult, which must be changed to call getHibernateFirstResult() " +
                            "so null can be returned when the value is uninitialized. Please note that if a negative value was set using " +
                            "org.hibernate.Query.setFirstResult, then getHibernateFirstResult() will return 0.",
                    moduleName, className);
            name = "getHibernateFirstResult";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("getMaxResults") &&
                desc.equals("()Ljava/lang/Integer;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.getMaxResults, which must be changed to call getHibernateMaxResults() " +
                            "so that null will be returned when the value is uninitialized or ORM 5.1 org.hibernate.Query#setMaxResults was " +
                            "used to set a value <= 0"
                    , moduleName, className);
            name = "getHibernateMaxResults";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (!disableAmbiguousChanges && opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("setFirstResult") &&
                desc.equals("(I)Lorg/hibernate/Query;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.setFirstResult, which must be changed to call setHibernateFirstResult() " +
                            "so setting a value < 0 results in pagination starting with the 0th row as was done in Hibernate ORM 5.1 " +
                            "(instead of throwing IllegalArgumentException as specified by JPA)."
                    , moduleName, className);
            name = "setHibernateFirstResult";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else if (!disableAmbiguousChanges && opcode == Opcodes.INVOKEINTERFACE &&
                owner.equals("org/hibernate/Query") &&
                name.equals("setMaxResults") &&
                desc.equals("(I)Lorg/hibernate/Query;")) {
            logger.debugf("Deprecated Hibernate51CompatibilityTransformer transformed application classes in '%s', " +
                            "class '%s', is calling org.hibernate.Query.setMaxResults, which must be changed to call setHibernateMaxResults() " +
                            "so that values <= 0 are treated the same as uninitialized.  Review Hibernate ORM migration doc "
                    , moduleName, className);
            name = "setHibernateMaxResults";
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
            transformedState.setClassTransformed(true);
        } else {
            mv.visitMethodInsn(opcode, owner, name, desc, itf);
        }

    }
Calls to Hibernate ORM 5.3 getFlushMode(), will not be changed as the desc will not match (desc == "()Ljavax.persistence.FlushModeType;")