Apache Camel JPA: Using the output attribute of one entity to query another entity

390 Views Asked by At

I am trying to use camel-jpa component with the hibernate provider and Named queries. It works great with a small caveat...

I have an event queue table which is logs state changes to different entity objects like incident, request, change in a normalized fashion and is populated by database triggers

The event queue table will have columns like event_id,occurance_time,entity_type,entity_id,operation, and other status flags

where entity types is like entity_type: incident, change, request etc... operation: create, update, delete, comment etc..

I initially created an event entity which performed JoinColumn on a subset of the entities like incident, request which works great since Incidents and request objects reside in the same table. However it would not work since Change and other Objects and other entities reside in other tables.

I am planning to fetch the stub record from the event_queue as is without using joins and using camel-jpa and then use a "choice" operator and subsequent jpa queries depending on the entity type and id.

Please assist on how this can be done with the camel-jpa component since the entity_id would need to be passed to the query based on the outcome of the first jpa: operation.

I have looked at a similar question asked on Stack Overflow "Apache Camel JPA: read from multiple tables" where he uses bean but I would like to use a more elegant way to solve the problem

0

There are 0 best solutions below