|
|
@ -175,6 +175,14 @@ public class RedissonLiveObjectService implements RLiveObjectService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public <T> List<T> persist(T... detachedObjects) {
|
|
|
|
public <T> List<T> persist(T... detachedObjects) {
|
|
|
|
|
|
|
|
return persist(RCascadeType.PERSIST, detachedObjects);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public <T> List<T> merge(T... detachedObjects) {
|
|
|
|
|
|
|
|
return persist(RCascadeType.MERGE, detachedObjects);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public <T> List<T> persist(RCascadeType type, T... detachedObjects) {
|
|
|
|
CommandBatchService batchService = new CommandBatchService(commandExecutor);
|
|
|
|
CommandBatchService batchService = new CommandBatchService(commandExecutor);
|
|
|
|
|
|
|
|
|
|
|
|
Map<Class<?>, Class<?>> classCache = new HashMap<>();
|
|
|
|
Map<Class<?>, Class<?>> classCache = new HashMap<>();
|
|
|
@ -191,19 +199,21 @@ public class RedissonLiveObjectService implements RLiveObjectService {
|
|
|
|
name2id.put(liveMap.getName(), id);
|
|
|
|
name2id.put(liveMap.getName(), id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CommandBatchService checkExecutor = new CommandBatchService(batchService);
|
|
|
|
if (type == RCascadeType.PERSIST) {
|
|
|
|
for (Entry<String, Object> entry : name2id.entrySet()) {
|
|
|
|
CommandBatchService checkExecutor = new CommandBatchService(batchService);
|
|
|
|
RMap<String, Object> map = new RedissonMap<>(checkExecutor, entry.getKey(), null, null, null);
|
|
|
|
for (Entry<String, Object> entry : name2id.entrySet()) {
|
|
|
|
map.containsKeyAsync("redisson_live_object");
|
|
|
|
RMap<String, Object> map = new RedissonMap<>(checkExecutor, entry.getKey(), null, null, null);
|
|
|
|
}
|
|
|
|
map.containsKeyAsync("redisson_live_object");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BatchResult<?> checkResponse = checkExecutor.execute();
|
|
|
|
BatchResult<?> checkResponse = checkExecutor.execute();
|
|
|
|
for (int i = 0; i < checkResponse.getResponses().size(); i++) {
|
|
|
|
for (int i = 0; i < checkResponse.getResponses().size(); i++) {
|
|
|
|
Boolean value = (Boolean) checkResponse.getResponses().get(i);
|
|
|
|
Boolean value = (Boolean) checkResponse.getResponses().get(i);
|
|
|
|
if (value) {
|
|
|
|
if (value) {
|
|
|
|
List<Object> list = new ArrayList<>(name2id.values());
|
|
|
|
List<Object> list = new ArrayList<>(name2id.values());
|
|
|
|
Object id = list.get(i);
|
|
|
|
Object id = list.get(i);
|
|
|
|
throw new IllegalArgumentException("Object with id=" + id + " already exists.");
|
|
|
|
throw new IllegalArgumentException("Object with id=" + id + " already exists.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|