У меня есть публикация Calle Class Class, метод, который называется GetallPublication, который возвращается список , но мой запрос внутри метода имеет список результатов типа , как может Я получаю список объекта публикации из списка < /code>:
-Здесь метод: < /p>
public List getAllPublication() {
List listePublication;
Query q;
em.getTransaction().begin();
q=em.createQuery("SELECT c.titrePublication,
c.datePublication, c.corps,p.login FROM Publication c JOIN c.employee p ");
listePublication = q.getResultList();
//ArrayList results = new ArrayList();
//for (Object[] resultat : listePublication)
//results.add((Publication) resultat[0]);*/
em.getTransaction().commit();
return results;
}
< /code>
package entities;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@NamedQuery(name="Publication.findAll", query="SELECT p FROM Publication p")
public class Publication {
@Id
@Column(name="\"idPublication\"")
private Integer idPublication;
private String corps;
@Column(name="\"datePublication\"")
private String datePublication;
@Column(name="\"titrePublication\"")
private String titrePublication;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="auteur")
private Employee employee;
public Publication() {
}
public Integer getIdPublication() {
return this.idPublication;
}
public void setIdPublication(Integer idPublication) {
this.idPublication = idPublication;
}
public String getCorps() {
return this.corps;
}
public void setCorps(String corps) {
this.corps = corps;
}
public String getDatePublication() {
return this.datePublication;
}
public void setDatePublication(String datePublication) {
this.datePublication = datePublication;
}
public String getTitrePublication() {
return this.titrePublication;
}
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public void setTitrePublication(String titrePublication) {
this.titrePublication = titrePublication;
}
}
Подробнее здесь: https://stackoverflow.com/questions/233 ... object-jpa
Получение списка из списка ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение