The subject may be misleading. Essentially, I have 3 "entities" with relationships between them. only one of the entities needs to be persistent (between server restarts). I still want DB functionality across the non-persistent entities … for example queries.
What’s the right pattern to handle this?
I thought about an in-memory DB, but as one of my entities does need to be persistent, i don’t think this is an option as the non-persistent entities would be in a different persistence unit.
another thought was just keep everything persistent, but wipe the non-persistent tables when the system restarts.
You could have two persistence units. One two a disk database, and one to an in-memory database.
The relationship would need to be transient, or possibly storing the foreign key to A and B. Or just don’t have the relationship between the two, just perform a query to find A or B when required, as a relationship in a persistent entity that is not persisted seems odd.