Regarding preventing two daily entries from being created concurrently, you just need to either a) use the "assigned" id strategy, where you assign the object id yourself, and somehow use the current date to create an object id, or b) create another column to store today's date, and put a unique constraint on it. Either way you will get a unique constraint violation, and you can catch that exception and deal with it.
However, I really think the whole "incrementing a counter" problem is better suited to a direct SQL solution. For example, check out the TableGenerator class in the NH source code.
|