Hello,
I'm using JPA+Hibernate with a PostGre SQL database in a J2SE project.
I have 2 entities A and B. A has a @OneToMany relationship to B.
In my domain model A might reference millions of B's. When I add a new object to the collection it takes minutes to complete.
@OneToMany(cascade=CascadeType.PERSIST)
Collection<B> foo = new ArrayList<B>(); // might contain millions of records
//...
// this takes a lot of time
foo.add(new B());
I think that JPA fetches the whole collection before inserting the new object. Is there a possibility to configure the relationship so that by adding a new object to the collection no fetch operation is performed?