Hello. I have a rather annoying problem. I have the following classes: AbstractEntity, which contains the id, and n classes which extend it. The mapping of the hierarchy is table per class. Now, I want the id to be generated automatically, but independent for each table.
Example:
Code:
dao.insertEntityA(entityA1);
dao.insertEntityB(entityB1);
dao.insertEntityB(entityA2);
dao.insertEntityA(entityB2);
Now, I expect that the ids of the elements in the DB have the values: 1, 2 for both tables. I tried all sorts of annotations :) but still, the best thing I got (that actually worked) was a generic sequence, which is not very helpful.
If anyone knows how to solve this, please let me know. Thank you very much. By the way, I can only use annotations, so an XML mapping will not work for me. I'm using JPA (Hibernate impl).