you need a unique key generator. Check out theserverside.com (patterns section) for discussion on ways to handle it. JBoss used to come with one but I don't see it any more.
-----Original Message-----
From: Jim Archer [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 02, 2001 11:45 AM
To: JBoss-User
Subject: [jBoss-User] Design question - Checking for an existing
record??
Hi All...
I have what must be a fairly common problem and I was wondering if someone
could suggest what they think the preferred solution might be.
I need to create an EB for a user and I have set the userid up as a primary
jey. Of course, the user ID must be unique. I'm wondering what the best way
to detect that a new user has picked an unavailable user ID.
First, I could just try to create the EB and catch a create exception. The
downside to this seems to be that if I get a create exception I don't know
for sure it was created sue to a non-unique key field without looking at
the message text that might vary accross servers. So it seems that I can
only know that there was some problem.
The next option is to use the finder for primary key and see if I get a
record back. This would answer the question but seems like extra overhead
to introduce. Also, it would result in a FinderException when the userID is
unique and I don't know if that will roll back the transaction I'm in or
not. Of course, I have to check for existance and add the new one in the
same transaction.
Is there a third option? I would appreciate any suggestions!
Thanks lots!
Jim
********************************************
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I -
I took the one less traveled by,
And that has made all the difference.
- Robert Frost, 1916
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
