Description
The description below shows the current behaviour; the core tries to interpret the "Street" reference as a persisted entity.
The workaround is to have explicitly implement ViewModel (rather than annotated with @ViewModel) and to traverse the graph manually. Using XmlSnapshotService could be one way to do this (or at least to provide inspiration on how to accomplish this).
Note though that ISIS-916 is a prereq in order to implement such as workaround.
~~~
Having this ViewModel annotated classes
@org.apache.isis.applib.annotation.ViewModel public class Address2 { public Address2(String lkmsId) { this.lkmsId = lkmsId; } public String title() { return "Address lkmsId:" + lkmsId; } public String iconName() { return "Location_icon"; } // {{ LkmsId (property) private String lkmsId; @MemberOrder(sequence = "1") public String getLkmsId() { return lkmsId; } public void setLkmsId(final String lkmsId) { this.lkmsId = lkmsId; } // }} // {{ Street (property) private Street2 street; @MemberOrder(sequence = "3") public Street2 getStreet() { return street; } public void setStreet(final Street2 street) { this.street = street; } // }} // {{ Housenumber (property) private String houseNumber; @MemberOrder(sequence = "2") public String getHouseNumber() { return houseNumber; } public void setHouseNumber(final String housenumber) { this.houseNumber = housenumber; } // }} }
and
@ViewModel public class Street2 { public Street2(String lkmsId) { this.lkmsId = lkmsId; } public String title() { return "Street lkmsId:" + lkmsId; } // {{ LkmsId (property) private String lkmsId; @MemberOrder(sequence = "1") public String getLkmsId() { return lkmsId; } public void setLkmsId(final String lkmsId) { this.lkmsId = lkmsId; } // }} // {{ Streetname (property) private String streetname; @MemberOrder(sequence = "2") public String getStreetname() { return streetname; } public void setStreetname(final String aName) { this.streetname = aName; } // }} // {{ Plz (property) private String plz; @MemberOrder(sequence = "3") public String getPlz() { return plz; } public void setPlz(final String plz) { this.plz = plz; } // }} }
When calling the domain service method
@Prototype @Render(Type.EAGERLY) public Address2 retreiveAnnotatedAddressModelSample() { Address2 address = new Address2("11"); address.setHouseNumber("12"); Street2 street = new Street2("123"); street.setStreetname("5th street"); street.setPlz("1100"); address.setStreet(street); return address; }
will bring this exception
Handling the following exception
org.apache.isis.core.runtime.persistence.PojoRecreationException: Could not recreate pojo for oid oid *a1.ase.viewmodel.annotated.Address2:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG1lbWVudG8-PGxrbXNJZD4xMTwvbGttc0lkPjxob3VzZU51bWJlcj4xMjwvaG91c2VOdW1iZXI-PHN0cmVldC5ib29rbWFyaz5hMS5hc2Uudmlld21vZGVsLmFubm90YXRlZC5TdHJlZXQyOlBEOTRiV3dnZG1WeWMybHZiajBpTVM0d0lpQmxibU52WkdsdVp6MGlWVlJHTFRnaVB6NEtQRzFsYldWdWRHOC1QR3hyYlhOSlpENHhNak04TDJ4cmJYTkpaRDQ4YzNSeVpXVjBibUZ0WlQ0MWRHZ2djM1J5WldWMFBDOXpkSEpsWlhSdVlXMWxQanh3YkhvLU1URXdNRHd2Y0d4NlBqd3ZiV1Z0Wlc1MGJ6ND08L3N0cmVldC5ib29rbWFyaz48L21lbWVudG8-
at org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault.adapterFor(AdapterManagerDefault.java:311)
...