The only thing to worry about with Anonymous keys and using them on primary
keys is an issue with clustering, there is a warning about it on the
Anonymous keys page docs. If you're not clustering there is no reason why
you can't do what you're describing below.
R
On 11/23/04 4:00 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Thank you so much. I have done lots of crazy queries, but have not done one
> where I was not wanting a primary key in the result. I have some learning to
> do as to which is better way to handle this. I have to look up both
> rowreaders and anonymous keys.
>
> I would prefer if the searchword table didn't even have a primary key, but
> just an indexed sid....since search words will be added and deleted all the
> time.
>
> Thanks for the great nudge,
>
> JohnE
>
>
>
> ----- Original Message -----
> From: Danilo Tommasina <[EMAIL PROTECTED]>
> Date: Tuesday, November 23, 2004 4:44 am
> Subject: Re: Unique query without using primary key?
>
>> A ReportQueryByCriteria should do the job:
>>
>> something like this:
>>
>> Criteria crit = new Criteria();
>> crit.addLike( "state", "somestate" );
>> crit.addLike( "<ref To SearchWords>.searchword", "somesearchword" );
>>
>> ReportQueryByCriteria query = new ReportQueryByCriteria(
>> SearchKeys.class, new String [] { "sid" }, crit, true );
>>
>> PersistenceBroker pb = null;
>> try {
>> pb = PersistenceBrokerFactory.defaultPersistenceBroker();
>>
>> ArrayList results = new ArrayList();
>> for ( Iterator resultsIt = pb.getReportQueryIteratorByQuery(
>> query ); resultsIt.hasNext(); ) {
>> results.add( ((Object []) resultsIt.next())[ 0 ] );
>> }
>>
>> // The results ArrayList now contains all the ids you need
>> // Note: always extact the values from the Iterator before
>> closing the broker.
>>
>> } catch ( Exception e ) {
>> // Do exception handling
>> } finally {
>> if ( pb != null ) {
>> pb.close();
>> }
>> }
>>
>> Replace <ref To SearchWords> with the reference path defined in
>> your repository.xml
>> I didn't tested the code, so there are probably syntax errors...
>>
>>
>>> I am not getting this. I need a nudge in the right direction.
>>>
>>> I want to do this query:
>>> select distinct sk.sid from searchkeys sk, searchwords sw
>>> where sw.searchword="somesearchword"
>>> sw.sid = sk.sid
>>> sk.state="somestate";
>>>
>>> table searchkeys:
>>> sid <-- unique PK
>>> state
>>>
>>> table searchwords:
>>> swid <-- unique PK I wish OJB
>> didn't require
>>> sid <-- sid in searchkey table
>>> searchword
>>>
>>> searchkeys and searchwords having a 1:n relationship.
>>>
>>>
>>> Right now I both tables mapped according to their
>> characteristics which I have done many times before. In the past
>> I have always wanted the primary keys and full records.
>>>
>>> Here I don't want the full records or mapping, but just a
>> collection of the unique sid. I would prefer not to get the full
>> records and I only require this for read and not write. Imagine
>> I am doing a keyword search and I just want to know which services
>> match the search criteria.
>>>
>>> Can anybody nudge me in the right direction? Would be great to
>> get past this problem. I am trying to inprove the searching on my
>> live OJB used site by including parts of the Lucene project, but
>> need to be able to do this for it to work.
>>>
>>> Thanks lots.
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------------------
>> ----
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>>
>> -------------------------------------------------------------------
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]