I am in the process of defining the mapping of an object via an hbm.xml file because inheritance is not working correctly and is preventing the use of standard annotations.
I have almost managed to do everything, but I am unable to provide the definition for the @EntityListeners.
I have the impression that CallbackDefinition on the PersistentClass is only populated with annotations. I even tried adding it by default, but it doesn’t work for HBM entities.
Basically, I have the impression that for HBM, there is nothing to transmit the listeners, but that seems strange to me. Am I missing something?
You can alter some static variable i.e. static boolean called; in your listener and check that the flag was set in an assertion to verify that a listener was called.
Note that for configuration via XML file, it would be possible to specify default listeners for all entities (which I will test), and it’s not possible to define a specific one for a particular entity.
With hbm.xml it’s not possible, but with pure orm.xml you can define a listener per entity/mapped-superclass. Who knows, maybe it even works in combination with hbm.xml. I haven’t tried though.
I just noticed that the use of <hibernate-mapping> is deprecated (hbm.xml).
It suggests using orm.xml or mapping.xml or enable hibernate.transform_hbm_xml.
Which do you think is better to use?
10:58:33,447|WARN |{}|orm.deprecation|main|HHH90000028: Support for <hibernate-mappings/> is deprecated [INPUT_STREAM : D:\java\workspaces\developpement_dev\efluid\app\target\classes\com\hermes\ref\acteur\businessobject\ActeurInterne.hbm.xml]; migrate to orm.xml or mapping.xml, or enable hibernate.transform_hbm_xml.enabled for on the fly transformation
The best way IMO is to use annotations, but if you must use XML, you should use orm.xml since hbm.xml will probably be removed in ORM 7, which will be released later this year.
hbm.xml is a separate complete definition from the mapping but it will disappear
orm.xml is simply the completion of annotations by text file
In my case, the issue is that I want to avoid keeping an inheritance from a problematic parent class, so I am forced to use hbm.xml.
It’s worth noting that this is temporary, just while we make the necessary changes to the incorrect model. This will resolve the situation for the next 6 to 8 months.