I have two tables: Ta
and Tb
. They have exactly the same table structure but different table names.
I try to create one entity class to map
You can also do this without using subclasses if you use two different persistence units.
Each persistence unit can specify a unique set of mappings (including table name). One way to achieve this is to create two orm.xml files. In persistence.xml you'll need something like this :
. . .
orm-1.xml
. . .
. . .
orm-2.xml
. . .
Then within orm-1.xml :
mypackage
And within orm-2.xml :
mypackage
You'll need to create a separate EntityManagerFactory for each PersistenceUnit (probably not what you want), but if you wanted to use the same class on different databases (with different table names) this would be a way to go.