Looking at the "Common Problems" section I see this:
Quote:
I'm using assigned identifiers, or a <composite-id> with cascades or saveOrUpdate() and Hibernate throws a StaleObjectState exception or SQL insert, update or delete failed (row not found).
Assigned identifiers, including composite identifiers, can't be used to distinguish newly instantiated instances from instances saved or loaded in a previous session. You will need to provide some other way for Hibernate to distinguish.
My problem is that I have a legacy database that's populated with data. I'm tryingb to migrate some nasty C++ code to Java with Hibernate. The structure looks something like this:
Class FOO {
int fooId
String fooName
Set<BAR> bar
}
Class BAR {
int fooId
int non_unique_value
}
I've created a primary key (fooId, non_unique_value) and by using a composite-id I can load the data. However I can't save back- I get "SQL insert, update or delete failed (row not found)."
Not clear what my options are here. I suppose I could add another column to the table, but I'm not sure howthat would affect the legacy code, or how I'd populate it with unique values - I'm not a DBA. Any help would be appreciated.