Hi Michael,

You are using FetchTypeLAZY though - so any relationships won't be loaded
until needed (ie the accessor method is called).  Are you explicitly
enhancing your entities in both environments? I believe subclassing loads
collections eagerly in some circumstances (subclassing would take effect in
JSE if you don't run the enhancer).

-mike


On Mon, Jun 15, 2009 at 12:52 PM, Michael Simons <[email protected]
> wrote:

> Hello,
>
> We've got a weird problem when fetching collections:
> class A {
>  @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="a")
>  private Set<B> bs;
> }
>
> class B {
>  @ManyToOne(fetch=FetchType.LAZY)
>  @JoinColumn(name="a_id", nullable=false)
>  private A a;
> }
>
> Code to fetch instances of A (with collections of B)
> Query query = em.createQuery ("select a from A a");
> for (Object obj : query.getResultList ()) {
>  cache.addA ((A)obj);
> }
>
> When needed we access the A.bs to get one out of the collection.
>
> When done standalone everything works fine, but when running the same
> within a stateful
> SessionBean on an ApplicationServer (Geronimo) the collection is empty.
> Even more weird: I can work-around the problem when iterating the
> collection right after it was
> fetched.
> Any ideas, what I'm doing wrong (it doesn't depend on the FetchType)?
>
> kind regards,
> Michael
>
>

Reply via email to