How to separate class declaration from its database relation definition

Viewed 36

Context

I have a case in a kotlin project, where I generate classes using protocol buffers.
I'd like to create for those classes mapping definitions, so I could store them in db.
However, because protobuf classes are generated,
I cannot add Entity annotations to them.

Therefore I am looking a way to annotate those classes outside of their definitions.

What I tried

I was reading documentation for hibernate,
as I remembered it could create mapping definitions separated from class declarations:

Hibernate in 3.3 had an option to create xml mapping definitions: https://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html

However, it seems missing from newer documentation and in 5.6 the closest I saw was: https://docs.jboss.org/hibernate/orm/5.6/userguide/html_single/Hibernate_User_Guide.html#dynamic-model

Questions

  • Is it possible to still use XML mapping definitions in hibernate?
  • Why XML approach was removed from the Hibernate documentation?

OR

  • Are there any other solutions that would allow me to store protobuf objects in database without using hibernate?
0 Answers
Related