Random-JPA provides a way to load tables generated by triggers. Although it only supports fetching of tables generated by trigger and does load entities if only column values are modified.
Note: If entity is declared as Trigger tables, random values will not be generated for this entity.
Let us say that we have trigger which logs history of all the bank transaction taking place. “Transaction” has two foreign keys, one maps to personId and other to accountId.
final JPAContextFactory jpaContextFactory = JPAContextFactory .newInstance(Database.MY_SQL, entityManager); jpaContextFactory.withTriggers(Trigger.of(Transaction.class) .withLink(Transaction_.personId, Person_.id) .withLink(Transaction_.accountId, Account_.accountId));
So when you load trigger table “Transaction” it will query the table to fetch row with mapped personId & accountId