I am using JPA EclipseLink to model a one to many relationship between UseCase and PainPoint. I am able to insert the values fine. Thereafter, I am using JAX-RS to retrieve the data using a GET method. The GET method fails with the error - Generating incomplete JSON.
Console Log:
- [EL Fine]: INSERT INTO USECASE (UseCaseID, Description) VALUES (?, ?) bind => [1, Description]
- [EL Fine]: INSERT INTO PAIN_POINT (PainPointID, PainPointDescription, USECASE_ID) VALUES (?, ?, ?) bind => [2, Pain Point 1, 1]
- [EL Fine]: SELECT UseCaseID, Description FROM USECASE
- Nov 17, 2017 7:16:22 PM org.eclipse.yasson.internal.Marshaller marshall SEVERE: Generating incomplete JSON
UseCase:
@NamedQueries({@NamedQuery(name = "getAllUseCases", query = "SELECT c FROM UseCase c")})
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@NotNull
@Column(name = "UseCaseID")
private int UseCaseID;
@Column(name = "Description")
private String Description;
@OneToMany(mappedBy="usecase", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
private Collection<PainPoint> painPoints = new ArrayList<PainPoint>();
PainPoint:
@NamedQueries({@NamedQuery(name = "getAllPainPoints", query = "SELECT c FROM PainPoint c")})
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@NotNull
@Column(name = "PainPointID")
private int PainPointID;
@Column(name = "PainPointDescription")
private String PainPointDescription;
@ManyToOne
@JoinColumn (name="USECASE_ID", referencedColumnName="UseCaseID")
private UseCase usecase;
DataLoader:
UseCase useCase = new UseCase("Description 1");
PainPoint painPoint1 = new PainPoint("Pain Point 1", useCase);
useCase.getPainPoints().add(painPoint1);
em.persist(useCase);
UseCaseService:
@GET
@Path("/")
public List<UseCase> getUseCases() {
List<UseCase> retVal = null;
EntityManagerFactory emf = Utility.getEntityManagerFactory();
EntityManager em = emf.createEntityManager();
retVal = em.createNamedQuery("getAllUseCases").getResultList();
return retVal;
}