This is my entity:
{code:java} public class PersonItem implements Serializable{ @Id @Column(name="col1") private String guid;
@Column(name="col2") private String name;
@Column(name="col3") private String surname;
@Column(name="col4") private Date birthDate; //+getters and setters } {code} This is how I get the list of persons: {code:java} Query query = em.createQuery("Select p from PersonItem p WHERE p.guid IN (:guids)"); EntityGraph<PersonItem> eg = em.createEntityGraph(PersonItem.class); eg.addAttributeNodes("guid"); eg.addAttributeNodes("name"); eg.addAttributeNodes("surname"); query.setHint("javax.persistence.fetchgraph", eg); query.setParameter("guids", guids); List<PersonItem> list=query.getResultList(); em.close(); // And now I iterate result AFTER EM CLOSE ....iterate {code} If I understand fetch graph correcly it must load only those fields, which I specified. However, the field "birthDate" is also loaded. Besides I see that in hibernate sql query 4 columns are selected.
How to fix it? I use hibernate 5.1.0 as JPA provider. |
|