My “ideal” situation would be to have a table that, in production (Oracle) has an oracle trigger generated auto incremented ID. In unit testing, however, I’d like to be able to “just use H2” as my database, and have it auto create the database for me. But then I lose the auto incremented ID. Is it possible to have both through any means? (basically an optional generated ID?)
Thanks for any help.
Looks like you can specify the sequence name itself and it will be “auto created” as a sequence within h2. I think defining it as auto_increment would work as well, though I’m not sure how that would work when there’s also a trigger assigning it a value from a sequence. I guess my fear is that hibernate’s auto increment somehow isn’t good enough for multi process apps, but it might be.
http://www.hibernate-training-guide.com/identifiers-generators.html
https://forums.oracle.com/forums/thread.jspa?threadID=2370530 may also be helpful