Hi,
I have got three entity
Code:
@Entity
public class FestivitySource implements Serializable{
...
@ManyToMany(fetch = FetchType.LAZY)
List<Place> listSede;
...}
@Entity
public class Festivity{
@ManyToMany(fetch = FetchType.LAZY)
List<Place> listSede;
}
@Entity
public class Place{
...
}
I use FestibitySource as source of my data. I populate, with my business logic, starting from FestivitySource the FestivityEntity.
so i do this:
Code:
Holiday holiday = new Holiday.Builder().withYear(DateUtils.getYear(festivityYear)).build();
holidayService.save(holiday);
for (FestivitySource festivitySource : list) {
logger.debug("festivitySource {}", festivitySource);
if (festivitySource.isEnable() && festivitySource.isInNextYear()) {
Date currentYearDate;
if (StringUtils.isNotEmpty(festivitySource.getComputingBean())) {
FestivityComputing festivityComputing = (FestivityComputing) applicationContext
.getBean(festivitySource.getComputingBean());
currentYearDate = festivityComputing.getDate(festivityYear, festivitySource);
} else {
currentYearDate = defaultComputing.getDate(festivityYear, festivitySource);
}
Festivity festivity = new Festivity.Builder().withDescrizione(festivitySource.getDescrizione())
.[color=#BF0000]withListSede(festivitySource.getListSede()[/color]).withDataFestivita(currentYearDate).build();
[color=#BF0000]festivityService.save(festivity);
[/color]
}
}
When I save my entity the collection is removed from source, but added to the target, as manual explain.
How can I copy?
I use hibernate 3.6.0.Final with spring 3.0.5 using Spring hibernate template and OpenSessionInView filter.
Does anybody has suggestion?