How to solve “Temporary ID hasn't been replaced on commit” with Cayenne

StackOverflow https://stackoverflow.com/questions/4784929

  •  24-10-2019
  •  | 
  •  

문제

When committing changes to a Apache Cayenne context, I get an exception like the following.

org.apache.cayenne.CayenneRuntimeException: [v.3.0.1 Sep 06 2010 15:09:38]
Temporary ID hasn't been replaced on commit

Why does this exception occur?

도움이 되었습니까?

해결책

You are trying to commit an object for which Cayenne does not know how to generate a permanent id. This in turn typically happens when the underlying table has no primary key defined.

To solve the problem, do one of the following.

  • Add a primary key to the underlying table, either a surrogate key (new generated id column) or a natural key (combination of existing columns).
  • Set your own permanent id on the object(s) in question using the PersistentObject.setObjectID() method.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top