Object-relational mapping (JPA + Hibernate) using XML

Asked

Viewed 306 times

4

For a specific reason, I need to do object-relational mapping (JPA) of my entities with XML.
[Unfortunately,] I cannot use annotations to do this. It turns out that in certain properties, I need to use Hibernate-specific Features. For example, extra Lazy Collections, something I would easily do using Annotations with @Lazycollection(Lazycollectionoption.EXTRA).

The JPA Hibernate documentation says the following:

"If you Wish to use Hibernate specific Features in some entities, you’ll have to either use Annotations or fallback to hbm files. You can of Course mix and match annotated entities and entities describes in hbm files." (http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/xml-overriding.html)

It turns out I have no idea how to use the aforementioned "hbm files" along with my Orm.xml (if that’s what I should do).

Someone knows how to do it?

1 answer

1


Dude, hbm that I remember, they’re just specific filenames that Hibernate used for mapping... So in your case for example: Orm.hbn.xml that in the end is still your Orm.xml where you define all the mapping of entities.

Only if you look at the configuration priority, your xml file will override the settings drop through Annotations.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.