RE: Case insensitive primary keys

2001-03-12 Thread KirkYarina

Add a finder (see the advanced finder section in the right-side menu at 
www.orionsupport.com )

Collection findIgnoringCase(String name)

with a where clause of

finder-method query="UPPER(table.name) = UPPER ( $1 )"

If you have "Smith" and "smith" do you want them to be separate entities, 
or do you want to get an exception when you add the second one?  If the 
latter you might want to make the primary key include "SMITH", and add 
"Smith" as another field - i.e. strip case from the primary key, and add a 
field that preserves the original case.  Is there a good portable way to 
make the primary key case-insensitive to the DBMS, so 
findByPrimaryKey("Smith") and ("smith") both return the same row.

Kirk Yarina

At 10:05 AM 3/11/01 -0800, you wrote:
Thanks for everyone's comments.

 From: Rafael Alvarez [mailto:[EMAIL PROTECTED]]
 
 You can do two things:
 .- In the EJBCreate change the user name to Upper or Lower case  when
 setting it. Also in the PK class change it to Upper or Lower case.

Not a good solution for me, because I want to preserve case.  I don't
want to maintain a second field with the correct case; I might as well
use an integer key.

 .- Override the PK class equal() method, to compare the username in
 Upper(Lower)case.

How does this work?  Doesn't the database need to be made aware of the
insensitivity?  How would finders work?

I'm confused about how an app server handles this.  Any information
would be very helpful :-)

Thanks,
Jeff


 Thursday, March 08, 2001, 7:30:39 PM, you wrote:
 
 JS I have a primary key which is a string (user's name), and
 I would like
 JS it to be case-insensitive.  That is, if there is already a
 "bob" entity,
 JS trying to create a "Bob" entity should throw a
 DuplicateKeyException.
 JS Is there a way I can do this with Orion?
 
 JS I vaguely recall reading something in the documentation
 about this, but
 JS now I can't seem to find it.  I'm starting to think that I
 imagined it.
 
 JS Thanks,
 JS Jeff
 
 --
 Best regards,
  Rafaelmailto:[EMAIL PROTECTED]
 
 
 
 





RE: Case insensitive primary keys

2001-03-11 Thread Jeff Schnitzer

Thanks for everyone's comments.

From: Rafael Alvarez [mailto:[EMAIL PROTECTED]]

You can do two things:
.- In the EJBCreate change the user name to Upper or Lower case  when
setting it. Also in the PK class change it to Upper or Lower case.

Not a good solution for me, because I want to preserve case.  I don't
want to maintain a second field with the correct case; I might as well
use an integer key.

.- Override the PK class equal() method, to compare the username in
Upper(Lower)case.

How does this work?  Doesn't the database need to be made aware of the
insensitivity?  How would finders work?

I'm confused about how an app server handles this.  Any information
would be very helpful :-)

Thanks,
Jeff


Thursday, March 08, 2001, 7:30:39 PM, you wrote:

JS I have a primary key which is a string (user's name), and 
I would like
JS it to be case-insensitive.  That is, if there is already a 
"bob" entity,
JS trying to create a "Bob" entity should throw a 
DuplicateKeyException.
JS Is there a way I can do this with Orion?
 
JS I vaguely recall reading something in the documentation 
about this, but
JS now I can't seem to find it.  I'm starting to think that I 
imagined it.
 
JS Thanks,
JS Jeff

-- 
Best regards,
 Rafaelmailto:[EMAIL PROTECTED]








Re: Case insensitive primary keys

2001-03-09 Thread Rafael Alvarez

Hello Jeff,

You can do two things:
.- In the EJBCreate change the user name to Upper or Lower case  when
setting it. Also in the PK class change it to Upper or Lower case.
.- Override the PK class equal() method, to compare the username in
Upper(Lower)case.

Thursday, March 08, 2001, 7:30:39 PM, you wrote:

JS I have a primary key which is a string (user's name), and I would like
JS it to be case-insensitive.  That is, if there is already a "bob" entity,
JS trying to create a "Bob" entity should throw a DuplicateKeyException.
JS Is there a way I can do this with Orion?
 
JS I vaguely recall reading something in the documentation about this, but
JS now I can't seem to find it.  I'm starting to think that I imagined it.
 
JS Thanks,
JS Jeff

-- 
Best regards,
 Rafaelmailto:[EMAIL PROTECTED]






Re: Case insensitive primary keys

2001-03-08 Thread Patrick V. Madden


Can't you just take your input key in the ejb finder method and
always convert it to lower case or uppercase. Then do your search.

Do the same if you provide an ejb create method that takes a string.

Just a quick thought.

At 03:30 PM 3/8/2001 -0800, Jeff Schnitzer wrote:
I have a primary key which is a string (user's name), and I would like
it to be case-insensitive.  That is, if there is already a "bob" entity,
trying to create a "Bob" entity should throw a DuplicateKeyException.
Is there a way I can do this with Orion?

I vaguely recall reading something in the documentation about this, but
now I can't seem to find it.  I'm starting to think that I imagined it.

Thanks,
Jeff