Hibernate @embeddable annotation equivalent for XML mapping file?

I have a class that I create a Hibernate mapping that contains an obsolete object that I cannot change, so it does not have the required id field to play well with Hibernate. I would like to annotate the deprecated object as the @Embedded field of my new class and write the hbm.xml file for the deprecated object and note that it is embedded. Is there any way to do this? The only documentation for embedding objects I've seen is annotating objects, not using XML.

I understand that I could expand the deprecated object and annotate it accordingly, but this case can happen often, so I would like to avoid this if possible.

+6
xml annotations hibernate
source share
1 answer

The @Embedded XML @Embedded is <component> , see 5.1.5. Built-in objects (similar components) .

However, it does not work the same as the @Embeddable / @Embedded , you need to describe all the properties of the component class in the .hbm.xml containing the class, something like this:

 <class name = "NewClass"> ... <component name = "legacyObject"> ... properties of the legacy class ... </component> </class> 
+10
source share

All Articles