Hi all
I've recently upgraded to hibernate 3.1.3, and came across an issue I can't seem to figure out. I don't know if it's related to cascading or not. This code was previously working. The only difference is that I've gone from hibernate 3.0 to 3.1. Here's a piece of the code:
Code:
Company company = new Company();
dao.saveObject(company); // this gives me a valid id generated by hibernate
...
User user = new User();
user.setCompany(company);
dao.saveObject(user); // my error is here
The error I get is
Code:
ERROR: insert or update on table "user" violates foreign key constraint "fk9501a78d45fc499f"
Detail: Key (company)=(111) is not present in table "company"
In my User object, the property for Company has cascade=save-update (many user to 1 company), so I would think that when it tries to save User, even if company has not been previously saved, it would attempt to cascade to the company and make it available.
Any thoughts would be greatly appreciated.
Hieu
Env:
Spring 1.2.7
Hibernate 3.1.3
Postgres 8.1[/code]