lundi 1 juin 2015

NamedQuery resultList returning objects, but all values are null

I have a table in database with these columns:

   id serial NOT NULL, 
   name character varying(255) NOT NULL, 
   url character varying(255)

Netbeans generated the JPA Entity for me. I have 5 records in the database. When I do em.createNamedQuery("MyEntity.findAll").getResultList(); I get a List<MyEntity> with 5 entries, but when I do the following, nothing is returned:

for(MyEntity me : em.createNamedQuery("MyEntity.findAll").getResultList();){
    logger.warn(me.getName());
}

The Named query:

@NamedQuery(name = "MyEntity.findAll", query = "SELECT m FROM MyEntity m")

Output:

2015-06-01 11:23:27,024 WARN com.example.MyEntityBean (MyEntityBean.java:33) -
2015-06-01 11:23:27,034 WARN com.example.MyEntityBean (MyEntityBean.java:33) -
2015-06-01 11:23:27,045 WARN com.example.MyEntityBean (MyEntityBean.java:33) -
2015-06-01 11:23:27,055 WARN com.example.MyEntityBean (MyEntityBean.java:33) -
2015-06-01 11:23:27,066 WARN com.example.MyEntityBean (MyEntityBean.java:33) -

EDIT:

Added the NamedQuery

Aucun commentaire:

Enregistrer un commentaire