[英]Spring Data JPA save list entity return list in same the order?
Does the method in Spring-Data-JPA's CrudRepository
Spring-Data-JPA的
CrudRepository
<S extends T> Iterable<S> saveAll(Iterable<S> entities)
return list in the same order ? 以相同的顺序返回列表?
In that version an actual List is the return type: 在该版本中,实际的List是返回类型:
@Transactional
public <S extends T> List<S> save(Iterable<S> entities) {
List<S> result = new ArrayList<S>();
if (entities == null) {
return result;
}
for (S entity : entities) {
result.add(save(entity));
}
return result;
}
so if you pass a List to the method, you will get the result in the exact same order as the ArrayList is the implementation. 因此,如果将List传递给该方法,则将以与ArrayList实现相同的顺序获得结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.