cannot simultaneously fetch multiple bags

Error Message: cannot simultaneously fetch multiple bags

Possible Solution:

A bag refers to a java.util.List or java.util.Collection that is annotated with @OneToMany or @ManyToMany. If there is more than one bag in your application that has a non-lazy fetch, then Seam will fail with this error message. For an explanation of why and for additional detail on the workarounds, read Eyal Lupu’s fine blog entry about the issue.

There are three relatively easy workarounds:

  1.    Change all but one of your non-lazy collections to java.util.Set.
  2.    Remove eager fetches on all but one bag:
        @OneToMany(fetch=FetchType.LAZY)
      
    LAZY is the default, so you could also just remove the fetch attribute.
  3.    Add @IndexColumn to replace bag semantics with List semantics:
        @IndexColumn(name=”INDEX_COL”)

 
Trackbacks
  • No trackbacks exist for this post.
Comments

Leave a comment

Submitted comments are subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.