Hi Andy, thanks for writing.
We do not yet have a good solution in place for dealing with static data, but this is a common request and we definitely need to take care of soon. The easiest thing to do is replicate that data across all your shards and then just be very careful about updating it. However, if it's important that the static data only reside on a single shard then your best bet is probably to make use of ShardedSessionFactory.getSessionFactory(). This method returns you a ShardedSessionFactory that operates on a subset of your shards (identified by ShardId). As long as you know the id of the shard where your static data lives you could do something like this:
Code:
ShardedSessionFactory ssf = (ShardedSessionFactory) sessionFactory;
List<ShardId> shardIds = Collections.singletonList(STATIC_DATA_SHARD_ID);
ShardedSessionFactory staticDataSsf = ssf.getSessionFactory(shardIds, SHARD_STRATEGY_FACTORY);
Session session = staticDataSsf.openSession();
session.createCriteria(...);
I know that managing a separate Session sort of defeats the entire purpose of Shards, but until we get some replication support added I think this is a decent option.
Please let me know how it goes.
Max