Question: I have an object hierarchy like this (dismissing all fields like id, setters/getters, etc.):

```
@Entity
class A {
    @OneToOne(cascade=CascadeType.ALL)
    private B b;
}

@Entity
class B {
    @OneToOne(cascade=CascadeType.ALL)
    private A a;

    @OneToOne(cascade=CascadeType.ALL)
    private C c;
}

@Entity
class C {
    private int x;
}

```

All entities have `@Id @GeneratedValue private Long id;`

I use JPA with Hibernate and a MySQL and have a DAO for `A` which does a simple `entityManager.merge(a); entityManager.flush();`

Now, this construct is used in a JSF project, where I create a new `A` with a new `B` but the value for `C` is taken from the database, hence it is an existing entity. This newly filled object is displayed on a page and only saved when I click on a save button, so the creation and the saving are done in two different transactions.

When I try do do a `dao.save(a)`, I get an `org.hibernate.TransientObjectException`, not really surprising since the value for the `c` in class `B` already exists in the database.

The actual question now is: Can I somehow avoid this problem WITHOUT cascading the saving manually? I am talking about dozens of `B`-type classes, each one with dozens of `C`s - this would totally be against my idea of cascading ...

Any ideas appreciated!

Answer: 
```
#include <complex>
#include "complex.h"

```

That's a bad smell. It's possible that both those #include files use the same name for the header guard.

Try changing yours like this.

```
#ifndef MY_COMPLEX_H
#define MY_COMPLEX_H

```

.. And maybe rename your module from "complex" to something else, to avoid clashes with the system header file of the same name.
Try making it as simple as possible. Then add parts back until you find your error.

Does this work?

```
#include "complex.h"

int main()
{
    Complex c(3.0, -1.0);

    return 0;
};

```