Jeśli moja lista jest pusta, pojawia się następujący błąd:Hibernate ograniczenie w przyczyny błędu, jeśli lista jest pusta
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
Poniżej jest moje hibernacji związanych metoda:
@Override
public List<SomeThing> findByIds(List<Integer> someIds) {
return sessionFactory.getCurrentSession().createCriteria(SomeClass.class)
.add(Restrictions.in("id", someIds))
.list();
}
co mam zrobić, aby uchronić się przed tym błędem?
wiem mogłyby zwierać połączenie i powrócić pustą listę takich jak:
if(someIds == null || someIds.size() == 0) {
return new List<SomeThing>();
}
Ale czy istnieje bardziej elegancki sposób to zrobić?