本文介绍了休眠 - 字节码检测和字节码增强之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用Hibernate 4.2并构建时间字节码工具来解决出现在 @OneToOne 关系和 @Lob ()

你知道什么是区别:

Hibernate字节码工具:

a href =http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch20.html#performance-fetching-lazyproperties =noreferrer> http:// docs。 jboss.org/hibernate/orm/4.3/manual/en-US/html/ch20.html#performance-fetching-lazyproperties

Hibernate字节码增强:

因为在休眠它是这样写的:

我可以解决我的问题通过使用字节码检测问题,但它不能通过使用字节码增强工作。你知道为什么吗 ?

也许,这个新功能还没有完全开发?



感谢您的帮助。 b $ b

解决方案

答案是字节码增强的方式。让我们来看看在这两种情况下会发生什么


  1. 字节码工具:在运行时期间将字节码添加到Java类中。 ,但更多的是在Java类的加载时间。此外,您可以详细阅读。




  1. 字节码增强:字节码增强可以在运行时或构建时(离线)执行。在运行时执行增强功能时,持久化类会在加载时得到增强。当离线执行增强时,类文件在后编译步骤中得到增强;

    在大多数字节码增强的情况下,它们都是在编译后进行的。如果您的Hibernate字节码增强功能出现这种情况,那么是的,更改代码的明显选择是字节码检测。



I am using Hibernate 4.2 and build time bytecode instrumentation for solve the lazy issue that appears on a @OneToOne relation and @Lob (https://developer.jboss.org/wiki/SomeExplanationsOnLazyLoadingone-to-one)

Do you know what is the difference between :

Hibernate bytecode instrumentation : http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch20.html#performance-fetching-lazyproperties

Hibernate bytecode enhancement : http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch20.html#bytecode-enhancement

Because on the hibernate documentation, it is written :

I can solve my issue by using bytecode instrumentation but it doesn't works by using bytecode enhancement. Do you know why ?

Maybe, this new feature is not fully developped ?

Thanks for your helps.

解决方案

The answer is the way byte code enhancement is done. Let's see what happen in both cases

  1. Bytecode instrumentation: Adding bytecode to a Java class during "run time." It's not really during run time, but more during "load" time of the Java class. Further you can read this post in detail.

And

  1. Bytecode enhancement: Bytecode enhancement may be performed either at runtime or at build time (offline). When enhancement is performed at runtime, persistent classes are enhanced as they are loaded. When enhancement is performed offline, class files are enhanced during a post-compilation step;

    In most case of bytecode enhancement, they are done at post compilation. If this is the case with your Hibernate bytecode enhancement, then yes the obvious choice to change the code is the byte code instrumentation.

这篇关于休眠 - 字节码检测和字节码增强之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 15:23