I want to use a custom sequence generator in my application, but the entity is located in a domain model jar that is shared with other applications. Apparently entity annotations can be overridden in orm.xml but I can’t figure out the proper XML incantation to get this to work.
I can modify the annotation in the entity like this this:
@GenericGenerator(name = "MYGEN", strategy = "MyCustomGenerator")
@GeneratedValue(generator = "MYGEN")
But I need to somehow map this to orm.xml in order to override the original annotation. Looking at the orm.xml schema here it appears that I can’t even specify a generation type besides “sequence” and “table”.
I should mention that I am using JPA with Hibernate, if that matters.
Did you look at the hibernate annotations documentation?
https://docs.jboss.org/hibernate/stable/annotations/reference/en/html/xml-overriding.html
It explains quite well how to override the annotation configurations in the orm xmls,
For exmaple, consider this entity:
To override the ID field with a sequence generator I used: