我试图通过他们的uuids从数据库获取一组值。当我使用hibernate Restrictions.in(字符串字段,集合集合)尝试此操作时,它只返回10个结果。
public List<Player> getPlayersByUuid(List<String> playerUuids) {
DetachedCriteria criteria = DetachedCriteria.forClass(Player.class);
criteria.add(Restrictions.in("playerUuid", playerUuids));
return hibernateTemplate.findByCriteria(criteria);
}
但是,如果我创建一个列表,让每个项目都有单独的操作,我会得到所有这些。
public List<Player> getPlayersByUuid(List<String> playerUuids) {
List<Player> players = new ArrayList<Player>();
for (String playerUuid : playerUuids) {
players.add(getPlayerByUuid(playerUuid));
}
return players;
}
public Player getPlayerByUuid(String playerUuid){
DetachedCriteria criteria = DetachedCriteria.forClass(Player.class);
criteria.add(Restrictions.eq("playerUuid", playerUuid));
List<Player> players = hibernateTemplate.findByCriteria(criteria);
if(players.size() == 0) {
return null;
} else if(players.size() == 1) {
return players.get(0);
} else {
//return exception
return null;
}
}
限制是否有任何限制?如果没有,我做错了吗?
由于