I have the following and I take the error java.lang.String cannot be cast to [Ljava.lang.String;
I have change the Object[] to String[] because before that I took java.lang.Object cannot be cast to [Ljava.lang.String; Any idea?
private Collection queryStatement(String SelectStatement) {
int colcount = 0;
int rowcount = 0;
int rowcounter = 0;
ArrayList a = new ArrayList();
Query query = getEntityManager().createNativeQuery(SelectStatement);
// Query query = getEntityManager().createNativeQuery(SelectStatement, ".findAll");
List<String[]> resultList = (List<String[]>) query.getResultList();
if (!resultList.equals(Collections.emptyList())) {
rowcount = resultList.size();
}
if (rowcount > 0) {
colcount = ((String[]) query.getResultList().get(0)).length;
}
rows = rowcount;
cols = colcount;
String[][] array = new String[rowcount][colcount];
for (String[] obj : resultList) {
String[] record = new String[colcount];
for (int colCounter = 0; colCounter < colcount; colCounter++) {
record[colCounter] = safeValue(obj[colCounter]+"");
}
array[ rowcounter++] = (String[]) record;
}
a.add(array);
return a;
}
List<String[]>
? It looks like it's returning aList<String>
, hence the error. – Jorn Vernee Sep 22 at 12:01