JPA @OneToMany relation not working (in db or pojo?)

I am using JPA annoitations and have two classes related to each other in a parent/child relationship.

[code]
@Entity
public class TestCase {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;

@OneToMany(mappedBy = "parentcase", fetch=FetchType.EAGER)
private Set<TestSession> sessions;

@Entity
public class TestSession {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne(fetch = FetchType.EAGER)
private TestCase parentcase;

[/code]The actual db structures generated look as follows:
TestCase table:
-id

TestSession table:
-id
-parentcase

My problem is that I get an empty set when I try to get all child sessions from the parent with

testcase.getSessions() I know entries exist in the child database pointing to a parent, but the parent does not seem to see the relation and I need to be able to retrieve results from the parent side.

any suggestions? thanks

This question is not directly related to Vaadin, but more of a pure JPA questions. Thus I’d recommend in the future to ask these kind of questions on forums such as
stackoverflow
to get better answers.

That said, I don’t immediately see anything wrong. Are there any exceptions occurring?

True, other than the fact I am using the vaadin JPAContainer addon I guess this is just a JPA question. sorry.

no error messages no. before I added (fetch = FetchType.EAGER) it gave this, but it isn’t even technically an error message:
{IndirectSet: not instantiated}

everything does appear to be fine, as you said. But that’s why I don’t understand why the method:
testcase.getSessions()
gives me an empty set.
Or more acurately, everything in the code seems fine, but why does the parent db table show nothing about the relation to the child, and therefore give me nothing on the previous method call?

Hi,

I’d suggest to make your life a bit simpler and drop JPAContainer out of the palette. It is easier and more efficient to use JPA based backend without JPAContainer. Read my
recent rant
to get a more detailed explanation.

cheers,
matti