Hibernate version: Hibernate 3.0 beta3
What the good way to do that (i just wrote the logic of my business) :
Code:
open hibernate session
while true
component = read data from a stream
storedComponent = query to check if the read component already exists
if component is new
session.save(component)
else
i have to update the component data and store it into database
(my question comes here)
endif
flush hibernate session
end while
? close hibernate session ?
My component has a collection of A (and each A has a collection of B). How update my stored component to correctly consider all A and B children ? :
storedComponent.getAs().removeAll();
storedComponent.getAs().addAll(component.getAs());
With this code, i'll have many B orphans, and the autoincrement of B will grow up quickly.
Any idea ? (i hope to be clear ;-)