users@glassfish.java.net

Re: JPQL: Retrieving data from a multi select query

From: <glassfish_at_javadesktop.org>
Date: Sat, 20 Mar 2010 18:29:40 PDT

Hi,

It left as follow,

public List&lt;String[]&gt; findAllEmailAddress(long employeeId) {
try {
String query = "SELECT EMAIL_TYPE, EMAIL_ADDRESS FROM EMAIL ea " + "INNER JOIN EMPLOYEE emp " +
"ON ea.EMP_ID = emp.EMP_ID " +
"WHERE emp.EMP_ID = " + Long.toString(employeeId);

Query q = em.createNativeQuery(query);
return (List<String[]>)q.getResultList();
} catch (javax.persistence.NoResultException nre) {
return null;
}
}

And the JSF page is,

&lt;c:forEach items="#{employee.allEmailAddress}" var="emailArray"&gt;
&lt;c:out value="${emailArray[0]}"/&gt;
&lt;br/&gt;
&lt;c:out value="${emailArray[1]}"/&gt;
&lt;/c:forEach&gt;

Regards,
Jose
[Message sent by forum member 'josealvarezdelara']

http://forums.java.net/jive/thread.jspa?messageID=392932