When checking if my list that is returned from a DB query contains a number with .contains()
it returns false.
Return false:
System.out.println(listaBd); // Output:[1, 2]
listaBd.contains(Long.valueOf(1)) // False
The problem does not seem from the code but from the list, since if I create the list by hand it returns true.
List <Long> listaLong = new ArrayList();
listaLong.add(1L);
listaLong.add(2L);
System.out.println(listaLong); // Output:[1, 2]
listaLong.contains(Long.valueOf(1)) // True
I get the list as follows:
List<Long> results = new ArrayList<Long>();
results = (List<Long>)QueryUtil.list(query, getDialect(), -1, -1); //Liferay
And from what I understand, if it does not give any exception
when casting it, it is because they are Longs
valid
The query
is something like this very simplified (with lots of joins and wheres that I'm going to exclude):
select idIdioma
from mitable;
idIdioma
is one fk
of a kindNUMBER(10,0)