Wxffel
03/16/2023, 6:33 PMinteger("Customer_Id").check { it.between(1000, 9999) }.uniqueIndex().entityId().also {
it.defaultValueFun = {
val incrementId = (1000 + Customer.count() + 1).toInt()
EntityIDFunctionProvider.createEntityID(incrementId, this)
}
}
How would one use auto-incrementation within a specified range?
I appreciate any help!Andrew O'Hara
03/16/2023, 6:34 PMWxffel
03/16/2023, 6:41 PM1000 + Customer.count() + 1
and the check check { it.between(1000, 9999) }
acts as the lock.
I thought there would be a safer overall better solution by exposed 😕Andrew O'Hara
03/16/2023, 7:22 PMAndrew O'Hara
03/16/2023, 7:25 PM[1001, 1002, 1003
], and delete row 1001
, then the next generated would be 1000 + 2 + 1
= 1003
, which collides with an existing record