Purpose: To select all the fields from AuditFindigns 1.Query query = session.createQuery("from Auditfinding af ");
System.out.println("select =>"+usrlist.toString()); ========================================== the output is: ========================================== select =>[com.lib.Auditfinding@276, com.lib.Auditfinding@277, com.lib.Auditfinding@278, com.lib.Auditfinding@279] ==========================================
Using the above list i can use display tag. sorting and pagination working fine.
But Purpose : To select the particular Fields from AuditFinding 2. Query query = session.createQuery("select af.id,af.shipname from Auditfinding af "); System.out.println("select =>"+usrlist.toString()); ========================================== the output is: ========================================== select =>[[Ljava.lang.Object;@3c0007, [Ljava.lang.Object;@125fefa, [Ljava.lang.Object;@186df0f, [Ljava.lang.Object;@19e8f17]
Pls tell me the difference between two queries
Thank You<br />Edward
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
did you look at the values in the debugger ? did you loop over the arrays ?
As you can see, the first one is list of auditfinding objects whereas the second one is a list of object[][] arrays of type Integer or Long(id) and String(shipname).
If you are not laughing at yourself, then you just didn't get the joke.
Yes, in hibernate when you do a "projection" query, where you specify the fields in the Select portion, then Hibernate will return an Object[] array instead of instances of the object.