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: 
You may facing a problem with stdafx.h issue

At least you should try to put `#include "stdafx.h` before every other include
Or 
you could try to set your project property to not use stdafx.h

```
1. right click on project and select Properties
2. go to C/C++ -> Precompiled Headers 
3. select "Not Using Precompiled Headers"

```
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;
};

```