Managing Unique IDs in stateless (web) DB4O applications
Posted
by Phil.Wheeler
on Stack Overflow
See other posts from Stack Overflow
or by Phil.Wheeler
Published on 2010-05-08T08:03:30Z
Indexed on
2010/05/08
8:08 UTC
Read the original article
Hit count: 370
I'm playing around with building a new web application using DB4O - piles of fun and some really interesting stuff learned. The one thing I'm struggling with is DB4O's current lack of support for stateless applications (i.e. web apps, mostly) and the need for automatically-generated IDs.
There are a number of creative and interesting approaches that I've been able to find that hook into DB4O's events, use GUIDs rather than numeric IDs or for whatever reason avoid using any system of ID at all.
While each approach has its merits, I'm wondering if the less-elegant approach might equally be the best fit. Consider the following pseudo-code:
If ID == 0 or null
Set ID = (typeof(myObject)).Count
myObject.Save
It seems like such a blindingly simple approach, it's usually about here that I start thinking, "I've missed something really obvious". Have I?
© Stack Overflow or respective owner