Class SubSelectDataRouter

java.lang.Object
org.jumpmind.symmetric.route.AbstractDataRouter
org.jumpmind.symmetric.route.SubSelectDataRouter
All Implemented Interfaces:
IBuiltInExtensionPoint, IExtensionPoint, IDataRouter

public class SubSelectDataRouter extends AbstractDataRouter implements IBuiltInExtensionPoint
This data router is invoked when the router_type is 'subselect'. The router_expression is always a SQL expression that is used to find the list of nodes a row of data will be routed to. This router should never be used for high throughput tables because it makes a call back to the database for each row that is routed.

The query that is used to select the nodes is as follows:

select c.node_id from $[sym.sync.table.prefix]_node c where c.node_group_id=:NODE_GROUP_ID and c.sync_enabled=1 and ...

The SQL expression designated in the router_expression is appended to the above SQL statement. Current and old column values can be passed into the sub select expression. For example, say you had an EMPLOYEE table and a PASSWORD table. When the password changes you want to route the password to the HOME_STORE that is stored on the EMPLOYEE table. The sub select expression might look like:

c.external_id in (select home_store from employee where employee_id in (:EMPLOYEE_ID, :OLD_EMPLOYEE_ID))