We're trying to find a way to do something (in the latest and greatest version of Hibernate), but have no idea if it is possible. Here is the situation:
AModel is:
Log that has a LogValue (an abstract class) that can be an IntLogValue, StringLogValue, etc., all mapped using joined inheritance.
BD therefore has the following tables:
Log
LogValue
IntLogValue
StringLogValue
etc...
All the IDs of these things are mapped using @Id @GeneratedValue
B-We want to archive logs to a secondary DB, then remove them from the primary one.
The basics work fine. We load the entities from DB 1, we reset the IDs, then save them to DB 2.
C-Problematic: we want for the IDs to be identical on DB 1 and DB 2.
D-The question: can we override the mapping on ID, to tell hibernate, in the second case, to use the values we have?
E-What we tried: create a subclass, that overrides ID field with no @GeneratedValue, but hibernate threw an exception telling us the mapping could not be overridden on the ID field.
|