@Override
    protected void generateCreateInsns(MethodVisitor mv) {
      if (this.getObjectModelMetadata().getMode() == ObjectModelMode.REFERENCE) {
        Label defaultImplLabel = new Label();
        Class<?> objectModelProxyClass =
            HibernateObjectModelFactoryProvider.this.generateObjectModelProxy(
                this.getObjectModelMetadata().getObjectModelClass());

        mv.visitVarInsn(Opcodes.ALOAD, 1);
        mv.visitTypeInsn(Opcodes.INSTANCEOF, HIBERNATE_PROXY_INTERNAL_NAME);
        mv.visitJumpInsn(Opcodes.IFEQ, defaultImplLabel);

        mv.visitTypeInsn(Opcodes.NEW, objectModelProxyClass.getName().replace('.', '/'));
        mv.visitInsn(Opcodes.DUP);
        mv.visitVarInsn(Opcodes.ALOAD, 0);
        mv.visitVarInsn(Opcodes.ALOAD, 1);
        mv.visitTypeInsn(Opcodes.CHECKCAST, HIBERNATE_PROXY_INTERNAL_NAME);

        mv.visitMethodInsn(
            Opcodes.INVOKESPECIAL,
            objectModelProxyClass.getName().replace('.', '/'),
            "<init>",
            '(' + ASM.getDescriptor(ObjectModelFactory.class) + HIBERNATE_PROXY_DESC + ")V",
            false);
        mv.visitInsn(Opcodes.ARETURN);

        mv.visitLabel(defaultImplLabel);
      }
      super.generateCreateInsns(mv);
    }
 @Override
 protected void generateGetInsns(MethodVisitor mv) {
   Label defaultImplLabel = new Label();
   mv.visitVarInsn(Opcodes.ALOAD, 1);
   mv.visitTypeInsn(Opcodes.INSTANCEOF, HIBERNATE_PROXY_INTERNAL_NAME);
   mv.visitJumpInsn(Opcodes.IFEQ, defaultImplLabel);
   mv.visitVarInsn(Opcodes.ALOAD, 1);
   mv.visitTypeInsn(Opcodes.CHECKCAST, HIBERNATE_PROXY_INTERNAL_NAME);
   mv.visitMethodInsn(
       Opcodes.INVOKESTATIC,
       ASM.getInternalName(FrozenLazyInitializerImpl.class),
       "getFrozenLazyInitializer",
       '('
           + ASM.getDescriptor(HibernateProxy.class)
           + ')'
           + ASM.getDescriptor(FrozenLazyInitializer.class),
       false);
   mv.visitInsn(Opcodes.POP);
   mv.visitLabel(defaultImplLabel);
   super.generateGetInsns(mv);
 }