You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by je...@optonline.net on 2004/11/21 03:35:46 UTC

Unique query without using primary key?

This might be a simple question but I am not getting it.

Question:  How does one retrieve a unique value that is not the primary key?

 I have the following data:
            primaryKey     <-- wish didn't have to have this autonumbered PK.
            serviceId
            searchWord    <-- many for each serviceId

A single searchWord can be repeated across many serviceIds and primaryKeys.  primaryKey is an autonumber pk, but serviceId is not unique.  A service can contain different searchWords and different PKs can all have the same searchWords.

I would like to do:
          select unique(serviceId)
                          where searchWord="A" or searchWord="B" or....

OJB requires a primary key to be returned, but this won't give me a unique serviceId which is what I really need.  How does one manage this?  In this case I really wish I had a table without a primary key, but OJB does not work that way either.  I never need to work with one record, but only collections of same serviceId, many searchwords.  Breaking this easy thing across 2 tables seems silly-wasteful.

I think I am missing something very simple.

JohnE





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org