Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Duplicate insert on lazy Set

Hi,

I am getting duplicate database inserts with

@Entity
public class MainEntity{

@OneToMany(fetch=FetchType.LAZY)
private Set<ForeignEntity> foreigners;

when I do mainEntity.getForeigners().add(foreigner);


It works fine when I change to @OneToMany(fetch=FetchType.EAGER), or
when I check with if(! foreigners.contains(foreigner)) before add().

It looks like add() is not fetching the lazy Set from the database.

Is this expected behavior?

Many thanks,

Bernard




Back to the top