ClassCastException error problem

Hi all,

I am relatively new to java and confused with the following problem. The below code compilers but returns a ClassCastException error when run.

private List<TableOne> query =new ArrayList<TableOne>();

private TableTwo tableTwo;

//create an array of values

for (Double value : array){

query = ..result from sql query (needs to be list using hibernate)

}

for (TableOne queryValue : query ){

//something

}

public List<TableOne> getTableOne(){

return query;

}

public List getQuery()

{

return this.Query;

}

The ClassCastException error occurs on the second for loop? Is this because the wo objects are not of the same type? Any suggetions would be great, thanks in advance

[1414 byte] By [mpcamp80a] at [2007-11-27 4:55:24]
# 1
Apparently the result of the following code> query = ..result from sql query (needs to be list using hibernate)is not a List of TableOne objects
ChuckBinga at 2007-7-12 10:10:21 > top of Java-index,Java Essentials,New To Java...
# 2
not sure i completely understand - could you post an example? thanks
mpcamp80a at 2007-7-12 10:10:21 > top of Java-index,Java Essentials,New To Java...
# 3

Hi,

look, List<TableOne> should mean that You have a list of TableOne objects. It seems like logic mistake. In addition, You are already have instance of query why do You need to assign it once more?

Now about ex. You sayed it is in the second loop and put almost nothing there. It seems like You have a mistake in //something ;)

_Dima_a at 2007-7-12 10:10:21 > top of Java-index,Java Essentials,New To Java...