Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » The question about using fetchgraph(The question about using fetchgraph)
The question about using fetchgraph [message #1731549] Fri, 06 May 2016 13:10 Go to next message
Eclipse UserFriend
I have the following entity:
@Entity
@Table(name = "tbl1")
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
}


And I want that only three fields of 4 were loaded from DB. So I do:
Query query = em.createQuery("Select p from PersonItem p");
EntityGraph<PersonItem> eg = em.createEntityGraph(PersonItem.class);
eg.addAttributeNodes("guid");
eg.addAttributeNodes("name");
eg.addAttributeNodes("surname");
query.setHint("javax.persistence.fetchgraph", eg);
 List<PersonItem> list=query.getResultList();


Everything works ok and I see in log that only 3 columns are selected. However, when I try to do item.getBirthDate then istead of null or exception the execution of the thread totally stops, so the next statement after item.getBirthDate is not executed. Why, and how can it be fixed?

[Updated on: Fri, 06 May 2016 13:48] by Moderator

Re: The question about using fetchgraph [message #1731750 is a reply to message #1731549] Mon, 09 May 2016 15:10 Go to previous message
Eclipse UserFriend
Execution should not be stopping or you have a JVM bug/issue. When accessing an unfetched attribute, EclipseLink will attempt to fetch it from the context, so my guess is you are getting an exception that is unhandled or caught and ignored somewhere in your stack, but if this isn't the case (wrap it in a try/catch block for a Throwable), try posting the jvm and how you are starting the application/thread.
Previous Topic:[moxy] Marshalling empty collection as absent elements for XML
Next Topic:LIMIT query not framed correctly when using CompositePU
Goto Forum:
  


Current Time: Sun Jul 27 16:12:19 EDT 2025

Powered by FUDForum. Page generated in 0.03102 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top