我有两个EntityManagers,用于两个DataSource,包含两个服务,存储库和一些实体。
LocalContainerEntityManagerFactoryBean masterEntiryManager;
LocalContainerEntityManagerFactoryBean replicaEntiryManager;
...
MasterBrickRepository masterBrickRepository;
ReplicaBrickRepsoitory replicaBrickRepository;
...
MasterBrickService masterBrickService;
ReplicaBrickService replicaBrickService;
...
MasterBrcik masterBrick;
ReplicaBrick replicaBrick;
目前,我按如下方式实施CRUD:
masterBrickService.save(masterBrick);
replicaBrickService.findAll();
当实体数量增长时,这是非常困难的!我不确定AOP是否可以通过用户注释来处理?这是可能的,我该怎么做?
BrickService brickService;
...
Brcik brick;
...
@Master
brickService.save(brick);
@Replica
brickService.findAll();