-
Notifications
You must be signed in to change notification settings - Fork 4
Tutorial 4: (Configuration) Managing Trigger Tables
Kumar Rohit edited this page Oct 3, 2015
·
1 revision
Handling triggers is a difficult job when you are dealing with data generation. 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