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 Thomas Mahler <th...@web.de> on 2003/04/24 21:45:45 UTC

Re: Problem with QueryByIdentity

Hi Ernst,

The broker.deleteByQuery(query) is only intended for Criteria based 
queries.
As you can see in the log, a QueryByIdentity does no have any criteria.
If you want to delete a single object,
broker.delete(obj) is the perfect solution.

It's not a Problem with QueryByIdentity. It's just a implementation 
glitch in the PersistenceBroker.

I'll have a look at it

cheerio,
Thomas

ernst leonhard wrote:
> Hi,
> 
> does anybody has an idea why this code doesn't run correctly ?
> ( version : ojb1.0-rc1 )
> 
>     Book obj = new Book();
>     obj.setId(id);
>     Identity identity = new Identity(obj, broker);
>     QueryByIdentity query = new QueryByIdentity(identity);
>     log.debug( "criteria: " + query.getCriteria()); // result is 'null' ???
>     broker.deleteByQuery(query);
> 
> Logs:
> =====
> 2003-04-24 14:31:04,122 DEBUG BaseBookManager,87 - criteria: null
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL: DELETE FROM book
> 
> Is there any known problem with QueryByIdentity ?
> 
> 
> Running the code following works correctly:
> 
>     Book obj = new Book();
>     obj.setId(id);  
>     broker.delete(obj);  
> 
> Logs:
> =====
> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL: DELETE FROM book WHERE id = ?
> 
> 
> 
> Descriptor of Book is:
> =======================
>    <class-descriptor
>    	  class="com.audi.gm.model.data.Book"
>    	  table="book"
>    >
>       <field-descriptor
>          name="id"
>          column="id"
>          jdbc-type="VARCHAR"
>          primarykey="true"
>       />
>       <field-descriptor
>          name="name"
>          column="name"
>          jdbc-type="VARCHAR"
>       />
>       <field-descriptor
>          name="headNo"
>          column="head_no"
>          jdbc-type="VARCHAR"
>       />
>    </class-descriptor>
> 
> 


Re: Problem with QueryByIdentity

Posted by Thomas Mahler <th...@web.de>.
It's fixed in CVS now!

Thomas Mahler wrote:
> Hi Ernst,
> 
> The broker.deleteByQuery(query) is only intended for Criteria based 
> queries.
> As you can see in the log, a QueryByIdentity does no have any criteria.
> If you want to delete a single object,
> broker.delete(obj) is the perfect solution.
> 
> It's not a Problem with QueryByIdentity. It's just a implementation 
> glitch in the PersistenceBroker.
> 
> I'll have a look at it
> 
> cheerio,
> Thomas
> 
> ernst leonhard wrote:
> 
>> Hi,
>>
>> does anybody has an idea why this code doesn't run correctly ?
>> ( version : ojb1.0-rc1 )
>>
>>     Book obj = new Book();
>>     obj.setId(id);
>>     Identity identity = new Identity(obj, broker);
>>     QueryByIdentity query = new QueryByIdentity(identity);
>>     log.debug( "criteria: " + query.getCriteria()); // result is 
>> 'null' ???
>>     broker.deleteByQuery(query);
>>
>> Logs:
>> =====
>> 2003-04-24 14:31:04,122 DEBUG BaseBookManager,87 - criteria: null
>> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: 
>> SQL: DELETE FROM book
>>
>> Is there any known problem with QueryByIdentity ?
>>
>>
>> Running the code following works correctly:
>>
>>     Book obj = new Book();
>>     obj.setId(id);      broker.delete(obj); 
>> Logs:
>> =====
>> [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: 
>> SQL: DELETE FROM book WHERE id = ?
>>
>>
>>
>> Descriptor of Book is:
>> =======================
>>    <class-descriptor
>>          class="com.audi.gm.model.data.Book"
>>          table="book"
>>    >
>>       <field-descriptor
>>          name="id"
>>          column="id"
>>          jdbc-type="VARCHAR"
>>          primarykey="true"
>>       />
>>       <field-descriptor
>>          name="name"
>>          column="name"
>>          jdbc-type="VARCHAR"
>>       />
>>       <field-descriptor
>>          name="headNo"
>>          column="head_no"
>>          jdbc-type="VARCHAR"
>>       />
>>    </class-descriptor>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>