Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 17:10 Go to next message
Pavel No is currently offline Pavel NoFriend
Messages: 45
Registered: May 2016
Member
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 17:48]

Report message to a moderator

Re: The question about using fetchgraph [message #1731750 is a reply to message #1731549] Mon, 09 May 2016 19:10 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1274
Registered: July 2009
Senior Member
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:EclipseLink: OSGi and inheritance
Goto Forum:
  


Current Time: Wed Nov 22 18:46:48 GMT 2017

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

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