Basically, I want to access the sequence values โโin a neutral database. A use case is that I have a field on the entity that I want to set based on the incremental value (except the identifier).
For example, let's say I have an object Shipment. At some point after the shipment is created, it will be shipped. As soon as it is sent, a manifest number is generated for it and assigned. The manifest number looks something like M000009(where the material after "M" is the value to the left of the sequence).
Something similar was asked here in SO , but I am not a fan of this solution, as it needs another table to maintain and seems like a weird attitude towards.
Does anyone know if it is possible to use something like hibernate MultipleHiLoPerTableGeneratoras something other than an ID generator?
If this is not possible, does anyone know of any libraries that can handle this (either using sleep mode, or even just plain JDBC). I would rather not write this myself (and have to deal with pre-fetching values, locking and synchronizing).
Thanks.
source
share