Hello,
I'm writing some integration test and on the BootStrap of the the tests I'd like to insert all the data that I'll use in the test. So far so good, it's almost working.
The problem is that my classes are mapped with
Code:
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SequenceCliFor")
and apparently I can't set the id for this kind of strategy. Is it true?
Only in the test I must do this something like this:
Code:
DomainClass dc = new DomainClass();
dc.setId(2);
// save dc object (insert it in the database)
If I use merge to save the object the id is changed to the next value in SequenceCliFor, and if I use saveOrUpdate I get a
Quote:
StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
IMO I should be able to set the id and hibernate should use the id that I setted, and if I don't set any it uses the sequence. Is it possible?