Hibernate-enhance-maven-plugin Version 5.4.0.Final

I have been using the hibernate-enhance-maven-plugin version 5.3.6.Final without any issue for some while.
The Maven configuration in my project is:

<plugin>
                <groupId>org.hibernate.orm.tooling</groupId>
                <artifactId>hibernate-enhance-maven-plugin</artifactId>
                <version>5.3.6.Final</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <failOnError>true</failOnError>
                            <enableLazyInitialization>true</enableLazyInitialization>
                            <enableDirtyTracking>true</enableDirtyTracking>
                            <enableAssociationManagement>true</enableAssociationManagement>
                            <enableExtendedEnhancement>false</enableExtendedEnhancement>
                        </configuration>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

With the above configuration, I see a compile output like:

[INFO] --- hibernate-enhance-maven-plugin:5.3.6.Final:enhance (default) @ VatmanagerNUL ---
[INFO] Starting Hibernate enhancement for classes on D:\Repository\Jetbrains\AWS\vatmanagerNUL\target\classes
Dec 16, 2018 1:02:49 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.3.6.Final}
Dec 16, 2018 1:02:49 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
[INFO] Successfully enhanced class [D:\Repository\Jetbrains\AWS\vatmanagerNUL\target\classes\com\bolsover\aws\hibernate\visual653\Account.class]
[INFO] Successfully enhanced class [D:\Repository\Jetbrains\AWS\vatmanagerNUL\target\classes\com\bolsover\aws\hibernate\visual653\AccountAtNative.class]
 - Plus 1400 other classes mentioned..

However, on switching to Version 5.4.0.FINAL I do not see any Successfully enhanced class messages only:

[INFO] --- hibernate-enhance-maven-plugin:5.4.0.Final:enhance (default) @ VatmanagerNUL ---
[INFO] Starting Hibernate enhancement for classes on D:\Repository\Jetbrains\AWS\vatmanagerNUL\target\classes
Dec 16, 2018 1:04:01 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.4.0.Final}
Dec 16, 2018 1:04:01 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

My question is simple - is 5.4.0.Final working?

db

If you think it’s not working, create a replicating test case and open a new Jira issue.

The problem at present is that I don’t know if the enhance process is working or not - how can I confirm?

The MavenEnhancePluginTest is not failing.

Try to replicate it with that template and open a Jira issue if the issue is reproducible.

@bolsover in 5.3.x, the enhancer was displaying the class even if not enhanced e.g. it was logging all the classes of your project.

We fixed that in 5.4.x. If you don’t have any log output, it means your classes are not enhanced.

Are they properly annotated entities?

That may explain the issue - these are mapped not annotated entities.

Sorry - I should expand on that…
Under 5.3, logging from the compile phase appeared to list all mapped (with.hbm.xml) classes and some but not all other project classes.
Under 5.4, no classes are listed as enhanced. Do I understand from your reply that enhancement only takes place for annotated classes? Maybe the plugin docs need to be more explicit?
db

Do I understand from your reply that enhancement only takes place for annotated classes?

No. It should work for any mapped entity, be it annotated or using XML mappings (e.g. HBM or orm.xml). If the entities are not enhanced, it’s a bug. But you have to decompile your compiled classes and see if the enhancement has not taken place.

Hi Vlad
I’ve checked the output - it seems clear that enhancement is not taking place with either 5.3.7 or 5.4.0 (despite multiple [INFO] Successfully enhanced class… messages in the case of 5.3.7)
If you wish to check I have uploaded a small sample of the generated classes here.
The project as a whole connects to three separate database (two located in UK third in Slovkia).
The project is a swing based desktop application, fully functional, including hibernate aspects. Compile time enhancement is a ‘nice to have’ feature but not essential.
I will attempt to replicate the issue with a small test project using the same database but just a couple of mapped tables.
db

Hi Vlad
I’ve put together a minimal test to illustrate …

hibernateenhancetest

Compiling on a windows platform with jdk1.8.0_192 appears to proceed normally but I can see no evidence that the classes in package com.bolsover.aws.hibernate.visual653 are enhanced.

The test case is composed of just a couple classes from the original application. If you check the .hbm.xml, you can see that I’ve commented out all the foreign key relationships.
Each of the original database has at least 700 tables. The complete application connects to three separate database and extracts VAT related data for reporting in UK and Slovakia.

db

@vlad are you sure about enhancement supporting XML? My recollection was that it only supported annotated classes.

See DefaultEnhancementContext that tests only the annotation.

But I might be missing something.

Although annotations are more common than XML, we still need to support enhancing entity classes that are mapped via XML. I haven’t tested it with XML, but, in case it doe snot work, a new Jira issue would have to be created for this.

vlad, gsmet

Having done a few more tests it looks like enhancement is working for annotated classes but not for those mapped with hbm.xml

I’ve no idea how or where to file this as an issue - would one of you like to do it on my behalf?

db

I think this issue is caused by HHH-12004.

Yeah, it’s not really “caused” by this issue, it’s just that it has always been implemented to support annotated classes only.

IIRC, the idea at the time was to push the elements declared in XML to a Jandex index together with the annotations and then deal with everything in a totally unified way.

AFAIK, we never got this far.