Search code examples
javaloggingjpaeclipselinkmonitoring

Monitoring EclipseLink JPA progress


I'm back at my first EclipseLink JPA project and noticed some issues regarding the performance. Here's the situation:

The application runs with a local Apache Derby DB. During the creation of the EntityManager the console logs a few infos and warnings, which takes a few seconds but is fine so far. However, if I package the whole code into an executable jar and run it outside Eclipse, the whole process takes a lot more time.

Now while it would be wise to find the reason for this issues in the first place, I at least wanted to add a ProgressBar in order keep rough track of the progress.

I looked up the EclipseLink wiki and found out that it already features a PerformanceMonitor and some logging utilities. I am now stuck at the seemingly simple task of putting 1 and 1 together.

How can I hook up my ProgressBar with EclipseLink? Or another approach: How can I log ongoing activities of EclipseLink in the first place?

Any help is much appreciated.

Cheers


Solution

  • You should enable the eclipselink logging by adding this in your persistent unit's properties in the persistence.xml file:

    <property name="eclipselink.logging.level" value="DEBUG"/>
    

    to enable a most detailed logging, or even 'ALL' instead of 'DEBUG' if not enough. But remove it when going to production or that line itself will make it slower.

    Two common things that could make eclipse link slower are:

    having this in in the persistence.xml when not needed:

    <property name="eclipselink.ddl-generation" value="create-tables"/>
    

    and NOT having this (if you declare de classes in the persistence.xml file. Set it to false if you do not!!):

    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    

    as of the progress bar, I would say it will be very hard, and not precise since even eclipselink don't know the whole amount of classes it will process in he beginning, so I don't think it's worth the effort, but good luck if you find out a way to do it.