简体   繁体   English

Hibernate - 字节码检测和字节码增强之间的区别?

[英]Hibernate - Difference between bytecode instrumentation and bytecode enhancement?

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 ) 我正在使用Hibernate 4.2和构建时间字节码检测来解决@OneToOne关系和@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字节码检测: 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 Hibernate字节码增强: http//docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch20.html#bytecode-enhancement

Because on the hibernate documentation, it is written : 因为在hibernate文档中,它写成:

The EnhancementTask is intended as a total replacement for InstrumentTask. EnhancementTask旨在作为InstrumentTask的完全替代品。 Further, it is also incompatible with InstrumentTask, so any existing instrumented classes will need to be built from source again. 此外,它也与InstrumentTask不兼容,因此需要再次从源构建任何现有的检测类。

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. 字节码检测:在“运行时”期间向Java类添加字节码。它不是在运行时,而是在Java类的“加载”时间内更多。 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. 如果您的Hibernate字节码增强是这种情况,那么更改代码的明显选择是字节代码检测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM