The main idea here is to use a custom generator that will internally switch between the identifier and the table (or any other strategies that you need) based on the metadata information.
There is no way to do this using standard JPA. Although the @GeneratedValue annotation defines a generator parameter that allows you to specify a custom generator , it does not provide any mechanisms for writing one (only allowing you to use the built-in table / sequence generators).
It depends on the particular JPA provider (not) to implement this feature. The EclipseLink wiki has an example of how a custom generator can be defined. You will need to modify it to create internal instances of TableSequence / NativeSequence and switch between them based on session.getPlatform() .
Disclaimer: I have not tried using the above using EclipseLink; However, I did something very similar in Hibernate.
source share