Note that there are some explanatory texts on larger screens.

plurals
  1. POeclipselink doesn't fetch list
    primarykey
    data
    text
    <p>there are two entity classes:</p> <pre><code>@Entity public class Place implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToMany(mappedBy = "place") private List&lt;Event> events = new ArrayList&lt;Event>(); private String name; //getters setters } @Entity public class Event implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @OneToMany(mappedBy = "event" , cascade={CascadeType.PERSIST}) private List&lt;Participant> participants = new ArrayList&lt;Participant>(); @ManyToOne(optional=false,fetch=FetchType.EAGER) private Place place; private String name; // getters setters } </code></pre> <p>the generated tables: <pre><code>mysql> desc EVENT; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | ID | bigint(20) | NO | PRI | NULL | auto_increment | | NAME | varchar(255) | YES | | NULL | | | PLACE_ID | bigint(20) | YES | MUL | NULL | | +----------+--------------+------+-----+---------+----------------+ mysql> desc PLACE; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | ID | bigint(20) | NO | PRI | NULL | auto_increment | | LOCATION | varchar(255) | YES | | NULL | | | NAME | varchar(255) | YES | | NULL | | +----------+--------------+------+-----+---------+----------------+ </pre></code> Now, I'll code some Java so the Place and Event tables looks in this way:</p> <pre><code>+----+--------+ | ID | NAME | +----+--------+ | 1 | Prague | +----+--------+ +----+-------------+----------+ | ID | NAME | PLACE_ID | +----+-------------+----------+ | 1 | Programming | 1 | +----+-------------+----------+ </code></pre> <p>Now, I would like to pick a place and view all its events: <code><pre> // there's an ejb talking with persistence layer Place p = ejb.getPlaceWithId(1); </pre></code> and I would think that there's something more than empty collection in <code>p.events</code>, but there is not - based on my observations. Why?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload