I have a problem with @manyToMany
. It's giving the error:
org.hibernate.loader.MultipleBagFetchException: can not simultaneously fetch multiple bags
Follow my template:
@Entity
@Table(name = "sar_evento", schema = "sar")
@SequenceGenerator(name = "sequence", sequenceName = "sar.evento_sequence", schema = "sar")
public class Evento implements Serializable, BaseEntity {
@Id
@GeneratedValue(generator = "sequence", strategy = GenerationType.AUTO)
@Column(name = "id_evento", nullable = false, unique = true)
private Long id;
@Column(length = 255)
private String nome;
@Column(columnDefinition = "text")
private String descricao;
@Column(name = "data_inicio")
@Temporal(TemporalType.TIMESTAMP)
private Date dataInicio;
@Column(name = "data_fim")
@Temporal(TemporalType.TIMESTAMP)
private Date dataFim;
@Column(name = "dia_todo")
private boolean diaTodo;
@ManyToOne
@JoinColumn(name = "id_sala", referencedColumnName = "id_sala")
private Sala sala;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
@OrderBy("nome asc")
@JoinTable(name = "sar_evento_recurso", schema = "sar",
joinColumns = {
@JoinColumn(name = "id_evento")},
inverseJoinColumns = {
@JoinColumn(name = "id_recurso")})
private List<Recurso> recursos = new ArrayList<Recurso>();
@ManyToOne
@JoinColumn(name = "id_usuario", referencedColumnName = "id")
private Usuario usuario;
Has anyone ever had this problem?