@Parent Initialization not done at persist (Done on loading)

I took the example from the documentation :

But what I understand is that the initialization of the @Parent variable is only performed during the load.

Because if we remove the line from entityManager.clear() it keeps the same instance and therefore the @Parent is null and the test is in error

public class TestITParent {

  public void tester_parent() {
    EntityManager entityManager = Bootstrap.createEntityManager("archi");

    City cluj = new City();
    cluj.setCoordinates(new GPS("46", "23"));

    entityManager.clear(); // If commented the test is in error

    City cluj2 = entityManager.find(City.class, cluj.getIdAsString());
    Assertions.assertEquals(cluj2, cluj2.getCoordinates().getCity());


@Entity(name = "City")
public class City extends HermesBusinessObject {

  private String name;

  private GPS coordinates;

  public String getName() {
    return name;

  public void setName(String name) {
    this.name = name;

  public GPS getCoordinates() {
    return coordinates;

  public void setCoordinates(GPS coordinates) {
    this.coordinates = coordinates;

public class GPS {

  public GPS() {

  public GPS(String latitude, String longitude) {
    this.latitude = latitude;
    this.longitude = longitude;

  private String latitude;
  private String longitude;
  private City city;

  public String getLatitude() {
    return latitude;

  public void setLatitude(String latitude) {
    this.latitude = latitude;

  public String getLongitude() {
    return longitude;

  public void setLongitude(String longitude) {
    this.longitude = longitude;

  public City getCity() {
    return city;

  public void setCity(City city) {
    this.city = city;

That’s correct. I don’t think that any interaction with the object model should happen in this case though, so IMO this is not a bug.

1 Like