@Test
@Rollback(true)
public void save_cascadeMerge() {
long VALID_PREFERENCE_ID = addPreferenceToRegionWidget(VALID_REGION_WIDGET_ID);
RegionWidget regionWidget = new RegionWidget();
regionWidget.setId(VALID_REGION_WIDGET_ID);
regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
RegionWidgetPreference regionWidgetPreference = new RegionWidgetPreference(VALID_PREFERENCE_ID,
VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME, VALID_PREFERENCE_VALUE);
regionWidget.getPreferences().add(regionWidgetPreference);
RegionWidget saved = repository.save(regionWidget);
manager.flush();
assertThat(saved.getPreferences().size(), is(equalTo(1)));
RegionWidgetPreference actual = saved.getPreferences().get(0);
assertThat(actual, is(not(sameInstance(regionWidgetPreference))));
assertThat(actual.getId(), is(equalTo(regionWidgetPreference.getId())));
}