1 Attachment(s)
AbstractRoutingDataSource not routing when used with Hibernate (sample attached)
I'm trying to do some simple physical sharding using AbstractRoutingDataSource along with Hibernate. I don't want to use Hibernate Shards, since we want to be able to change ORMs and still shard (I'll be adding other ORMs in a future version of this test).
I've attached a maven test project that attempts to shard with two empty localhost MySql databases named "bob" & "jack" (make sure jdbc:mysql://localhost:3306/bob & jdbc:mysql://localhost:3306/jack are available via username "root" & password "password" or change dataSource-context.xml to use the right valuesAttachment 4322). I thought it was working, but I realized that AbstractRoutingDataSource#determineCurrentLookupKe y() is not getting called (see the project's ShardedDataSource class), and therefore "jack" is never getting touched, only "bob".
Right now, I've got database schema generation turned on, but realize it probably wouldn't work across shards & should be off anyway. I've also set AbstractRoutingDataSource's lenientFallback property to true where I'd prefer false, and defaultTargetDataSource to "bob" where I'd prefer there to be no default data source at all, but application context initialization fails when there's no key. I tried a no-op data source class for defaultTargetDataSource, but that didn't work, either.
Can anyone knowledgeable have a look and see why ShardedDataSource#determineCurrentLookupKey() is not getting called and all calls are being routed to the default/first data source?
TIA,
Matthew