I usually use a counter entity bean.  The entity bean's PK is a string,
which uniquely names the counter.  It has a method called, "getNextValue",
which returns a long incrementing from zero.  This may not be the fastest
way, but it's very simple, and you will never get a duplicate (unless you've
exhausted all 2^64 values.)

If wrap-around is a concern, you can always make it into a string, and
append the date. This way, you'd have to use up all 2^64 values in one day
before the value would repeat.

Mike

----- Original Message -----
From: "Frank Morton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 15, 2001 11:40 AM
Subject: [JBoss-user] cmp primary key


> I'm a newbie for sure, but I've been surfing around for
> a solution to assigning unique primary key values with
> CMPs. I have seen lots of vague descriptions of how
> to do it and some specific ones that are all followed by
> other comments from people why that solution doesn't
> work.
>
> Does anyone have a specific solution and the complete
> code to do this they can share? This seems like it must
> be a very common problem that ought to have a standard
> solution.
>
> Help. I'm really getting frustrated.
>
> Frank
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>


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

Reply via email to