Spring Flex 1.5, lazy loading issue with mutual object references
I have objects referencing each-other (Country has a regionProvinceSet, RegionProvince has a Country):
Code:
@RooJavaBean
@RooToString
@RooEntity
public class Country {
private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "country", fetch = FetchType.LAZY)
private Set<RegionProvince> regionProvinceSet = new HashSet<RegionProvince>();
}
@RooJavaBean
@RooToString
@RooEntity(finders = { "findRegionProvincesByCountry" })
public class RegionProvince {
private String name;
@ManyToOne(fetch = FetchType.EAGER)
// @ManyToOne(fetch = FetchType.LAZY) -> tried this as a solution too without success
private Country country;
}
On the Flex side, when I load a Country, e.g. Belgium, and thereafter lazily load the the RegionProvince's of Belgium. There is a second country instance created for the country inside the RegionProvince instances. But this is supposed to be the same Belgium object of course.
(i checked by creating a static counter inside my Country class (on the Flex side) that increments inside the constructor)
I even tried, in Flex, implementing the UID interface and mapping the UID to the id of the Country class. But still a second instance gets created.
Is this normal behavior? If so, what could be best practice here? Manually remapping the value to the original Country instance?
Thanks a whole lot in advance,
Jochen