# How to see if Bytecode Enhancement works or not

**URL:** https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044
**Category:** Hibernate ORM
**Created:** [July 11, 2018, 10:28am UTC](https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044 "2018-07-11T10:28:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![UptownErik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/uptownerik/32/47_2.png) [@UptownErik](https://discourse.hibernate.org/u/UptownErik)
#### Post date: [July 11, 2018, 10:28am UTC](https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044/1 "2018-07-11T10:28:05Z")

</div>

Hi!

I’m using bytecode enhancement in my project to ensure that all associations are lazily loaded. I added the maven plugin to my pom-file. However, it seems like it does not affect my testing, some associations are still eagerly loaded even though I have the flag “enableLazyInitialization” is set to true. Is there something more I need to do in order to activate the bytecode enhancement with my entities in the code to make the associations be lazy loaded? I have tried setting all the entities manually to lazy aswell, but the same problem as when not using the tool occurs, OneToOne-associations are eagerly loaded. The documentation does not mention anything more than adding the plugin to the pom-file. Is there some way I can ensure that the tool is up and running?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)
#### Post date: [July 11, 2018, 1:06pm UTC](https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044/2 "2018-07-11T13:06:09Z")

</div>

Are your classes instrumented properly. Just decompile them to make sure they were enhanced.

It might be that IDEA steps in a recompiles them without using Maven, hence bypassing the plugin.

---

<div class="post-metadata">

### Author: ![UptownErik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/uptownerik/32/47_2.png) [@UptownErik](https://discourse.hibernate.org/u/UptownErik)
#### Post date: [July 11, 2018, 2:01pm UTC](https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044/3 "2018-07-11T14:01:15Z")

</div>

I have decompiled them, they are identical to the original source code so I guess that they are not being enhanced. I’ve tried recompiling with Maven, but it does not make a difference. I’ve checked the console for any printouts, but there doesn’t seem to be anything about the bytecode tool. Any ideas? Should it just be enough to include the tool in the pom-file and then compile using maven? Also I’m running unit tests to test my application.

---

<div class="post-metadata">

### Author: ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)
#### Post date: [July 11, 2018, 2:17pm UTC](https://discourse.hibernate.org/t/how-to-see-if-bytecode-enhancement-works-or-not/1044/4 "2018-07-11T14:17:57Z")

</div>

Check out my [GitHub repository](https://github.com/vladmihalcea/high-performance-java-persistence/blob/master/core/pom.xml#L35).

If you enable `enableLazyInitialization` and run:

```
mvn clean test-compile

```

and go to `core/target/classes`, you’ll see the entity classes are enhanced.

Also, Maven tells you that it enhances classes when running `test-compile`.
