enter image description hereenter image description here
`
// init Data Model
private void initDataModel(){
System.out.println("DEBUG START FORM >>> ");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ServiciiJPA");
em = emf.createEntityManager();
List<Client> lst = em
.createQuery("SELECT c FROM Client c ORDER BY c.id", Client.class)
.getResultList();
clienti.addAll(lst);
if (lst != null && !lst.isEmpty()){
Collections.sort(this.clienti, (c1, c2) -> c1.getId().compareTo(c2.getId()));
this.client = clienti.get(0);
System.out.println("DEBUG: client init >>> " + client.getId());
}
我在Eclipse中尝试过,但从未解决。
1条答案
按热度按时间klh5stk11#
如果您使用JPA,请发布Client.class,否则请发布表创建代码以获取更多信息。但是在您的查询中,我建议将select更改为“SELECT c.* FROM Client c Order BY c.id“