Friday, April 8, 2011

useEmma=openjpa.isInUse()?false:true

OpenJPA is a JPA framework very light compared to the heavyweight Hibernate. In order to provide optimal runtime performance, flexible lazy loading, and efficient, immediate dirty tracking, OpenJPA can use an enhancer . An enhancer is a tool that automatically adds code to your persistent classes after you have written them. The enhancer post-processes the bytecode generated by your Java compiler, adding the necessary fields and methods to implement the required persistence features. This bytecode modification perfectly preserves the line numbers in stack traces and is compatible with Java debuggers.

This is my third stint with EMMA and I simply love it even over the much detailed Clover. Apart from the free factor, its pretty fast and has less memory overhead. In one of my project, our nightly CI job with clover used to crash with clover which forced us to stick with EMMA. Instrumentation is an important step to get the coverage. The instrumentor adds bytecode instrumentation to all classes found in an instrumentation path that also pass through user-provided coverage filters. Additionally, it produces the class metadata file necessary for associating runtime coverage data with the original class definitions during coverage report generation.

Unfortunately, OpenJPA enhancer and EMMA instrumentor don't jell together. Yes, there's a conflict between them. As a result, your coverage will be incomplete. So, options left out will be
1. To switch over to Cobertura(sic) or Clover.
2. To filter the Dao and JPA entity classes from the coverage (sic again).

Depending upon your flexibility and need, you can choose one of them.

No comments: