I'm using JPQL
to retrieve data. I can get data using the statement
List persons = null;
persons = em.createQuery("select p.albumName from PhotoAlbum p , Roleuser r
where r = p.userId and r.userID = 1");
Now I can get the album names using this:
int i=0;
for (i=0;i<persons.size(); i++)
{
System.out.println("Testing n "+ i +" " + persons.get(0));
}
Now I want to get the album name and the roleuser's row named firstname
I'm using the query
persons = em.createQuery("select r.firstName , p.albumName from PhotoAlbum p ,
Roleuser r where r = p.userId and r.userID = 1").getResultList();
Now how do I get the rows firstname and albumname as the persons.get(0) is returning a object
by running the code :
for (i=0;i<persons.size(); i++)
{
//r = (Roleuser) persons.get(i);
System.out.println("Testing n "+ i +" " + persons.get(i));
}
I'm getting this:
Testing n 0 [Ljava.lang.Object;@4edb4077
INFO: Testing n 1 [Ljava.lang.Object;@1c656d13
INFO: Testing n 2 [Ljava.lang.Object;@46dc08f5
INFO: Testing n 3 [Ljava.lang.Object;@654c0a43
How do I map the persons.get(0)
and get the firstname
and albumname
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…