Hibernate / EclipseLink Interview questions
What is the difference between static weaving and dynamic weaving?
Both accomplish the same bytecode transformation; they differ in when it happens and what's required to make it work.
| Dynamic (load-time) weaving | Static (build-time) weaving |
| Happens when the JVM loads entity classes at runtime. | Happens as a build step, before the application ever runs. |
| Requires a Java agent or a compatible application server integration. | Requires the EclipseLink Ant task or Maven/Gradle plugin in the build. |
| Works transparently with no extra build configuration in supported environments. | Adds an explicit weaving step to the build pipeline. |
| May not be available in some restrictive deployment environments. | Works reliably regardless of runtime class-loading restrictions. |
Most Java EE/Jakarta EE application servers support dynamic weaving out of the box, so it's the common default; static weaving becomes the practical choice for standalone Java SE applications, restrictive containerized environments, or any setup where enabling a load-time Java agent isn't straightforward.
More Related questions...