Hi,

On 2001.06.23 18:11:57 -0400 [EMAIL PROTECTED] wrote:
> On Sat, Jun 23, 2001 at 11:25:32AM -0700, Konstantin Priblouda wrote:
> > 
> > > This interests me. I will be doing a project where I
> > > don't care much
> > > what the primary keys are, only that they are there
> > > and are unique
> > > (obviously). Ideally, I would have the database
> > > autogenerate a
> > > sequence of numbers, but there doesn't seem to be a
> > > way to get the
> > > Container to do this for me?
> > 
> > Using database for it seems messy for me - you insert
> > the row, and everything is fine (assumed your sequence
> > or autonumbering worked), but getting this ID out of
> > database is not convenient (and highly database
> > dependent). That's why I prefer to use separate bean
> > to generate ID's
> 
> I seem to vaguely recall from when I used MS Access years ago that it
> had a special value type for auto-counter coloumns. You'd just define
> a coloumn and set it as a counter and everything happened
> automatically. It's something like this I'd want. It seems to me that
> this is a common thing to want to do and the database manager doing it
> would presumably be a lot more effecient than the application doing
> so.
> 
When I first encountered sequences/generators rather than autoincrement
fields I shared your sentiments.  However, using autoincrement fields has
many problems, and is not necessarily faster.
- You have to read the row again to find outs its only identifying
characteristic.
- There is often (depending on how thoughtless the implementation is) no
way to copy these rows (into another table and back) and get meaningful
results (you get a whole new set of ids, thus totally messing up foreign
keys)

- Using a sequence/generator can reduce db access (in the absence of
triggers modifying the row you just inserted): you can get id's in large
chunks and hand them out, only asking for more when you run out.

davud jencks


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to