The thing that jumps out at me is that you are declaring a variable, x, in your for declaration, but you have hard-coded the value that you are printing out:
For every element in the array, you print out the value of the first element in the array. As for what is printed out, have a look at the java documentation:
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object.
If you want to see something else from toString(), you will have to override it in whatever class you are expecting back from hibernate.
I agree with what Joe said and I would like to add my thoughts.
The following is your code:
The following is what I think you want to do.
In "new line 1", I only declare an array of objects. I don't instantiate the array since the array of objects reference variable, obj, is given a value in line 2.
In "new line 2", an object reference variable named, query, has a method named list() that returns an object that has a method named toArray() that instantiates an array with the same elements as query.list().
In "new line 3", you are using the for-each loop that came out with the Java Language version 5.0 and later. Here, the object reference variable will be assigned as each of the elements of the array called: obj.
In "new line 4", each value that was in the array of objects is converted to a String. The output that you are seeing is the result of the method of the class String called toString().
Like Joe answered, you need to override the method toString() for the objects that are in the query.list().\ [ January 15, 2008: Message edited by: Kaydell Leavitt ]
Joined: Jun 13, 2007
hi kaydell and joe-
thanks for your reply. i am quite sure i can get it to work now.
it is very simple.
create a table in apache derby. generate a pojo class related to the new table. use my iterators to go through the table data.
part of the query was mapped to a table and its fields and the rest of the fields were not mapped.
i cant believe i didnt realize this sooner. i had a funny brain moment(s).
i havent used java in a 1/2 year or so i think.
thanks for encouraging and helping me. i can say with 99% confidence i will get this now.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: cant read the contents of the printed string