You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <Cr...@Sun.COM> on 2005/11/25 21:52:37 UTC

Issue 147: Unique deletion by query

Hi Michael,

I'd expect a JDOUserException to be thrown.

The spec says

<spec 14.6.11>
void setUnique(boolean unique);
A14.6.11-1 [When the value of the Unique flag is true, then the  
result of a query is a single value, with null used to indicate that  
none of the instances in the candidates satisfied the filter. If more  
than one instance satisfies the filter, and the range is not limited  
to one result, then execute throws a JDOUserException.]
</spec 14.6.11>

I can add a similar description to the deletePersistentAll methods.  
It might require the JDOUserException to be thrown before actually  
deleting anything (the semantics of the method are such that a select  
needs to be executed against the datastore anyway before the delete  
occurs).

Another alternative is to disallow the Unique flag for  
deletePersistentAll. But that's not what I would choose.

Craig

On Nov 25, 2005, at 6:07 AM, Michael Watzek wrote:

> Hi,
>
> I have a question concerning unique deletion by query:
>
> Assuming a unique JDO query would throw a JDOUserException in  
> execute() because the result is not unique, would you expect a  
> JDOUserException thrown in deletePersistentAll()?
>
> The spec does not require this and I'm not sure if we should add a  
> negative test case checking this.
>
> Regards,
> Michael
> -- 
> -------------------------------------------------------------------
> Michael Watzek                  Tech@Spree Engineering GmbH
> mailto:mwa.tech@spree.de        Buelowstr. 66
> Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
> Fax.:  ++49/30/217 520 12       http://www.spree.de/
> -------------------------------------------------------------------

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Issue 147: Unique deletion by query

Posted by Michael Bouschen <mb...@spree.de>.
Hi Wes,

I agree, +1 for the exception.

Regards Michael

> Craig,
> 
> I favor the exception for this case.  The way we've defined setUnique, 
> it acts somewhat like an assertion, and the semantic should remain the 
> same for both execute and delete.
> 
> Regards,
> 
> Wes
> 
> 
> Craig L Russell wrote:
> 
>> Hi Michael,
>>
>> Sounds good.
>>
>> I was thinking some more about this issue and would like some feedback.
>>
>> I think that we should make the query.execute and 
>> query.deletePersistentAll methods as similar as possible, meaning that 
>> they  both should throw an exception if the cardinality of the results 
>> is not zero or one.
>>
>> I'll have a proposed wording for the specification later, but for now 
>> let's go with the patch.
>>
>> Thanks,
>>
>> Craig
>>
>> On Nov 28, 2005, at 5:35 AM, Michael Watzek wrote:
>>
>>> Hi Craig,
>>>
>>> I have added a second patch to JDO-166. It adds a unique query to the 
>>> array of INVALID_QUERIES which is supposed to throw a 
>>> JDOUserException at deletePersistentAll because the number of 
>>> affected rows in the database exceeds 1.
>>>
>>> Regards,
>>> Michael
>>>
>>>> Hi Michael,
>>>> I'd expect a JDOUserException to be thrown.
>>>> The spec says
>>>> <spec 14.6.11>
>>>> void setUnique(boolean unique);
>>>> A14.6.11-1 [When the value of the Unique flag is true, then the  
>>>> result of a query is a single value, with null used to indicate 
>>>> that  none of the instances in the candidates satisfied the filter. 
>>>> If more  than one instance satisfies the filter, and the range is 
>>>> not limited  to one result, then execute throws a JDOUserException.]
>>>> </spec 14.6.11>
>>>> I can add a similar description to the deletePersistentAll methods.  
>>>> It might require the JDOUserException to be thrown before actually  
>>>> deleting anything (the semantics of the method are such that a 
>>>> select  needs to be executed against the datastore anyway before the 
>>>> delete  occurs).
>>>> Another alternative is to disallow the Unique flag for  
>>>> deletePersistentAll. But that's not what I would choose.
>>>> Craig
>>>> On Nov 25, 2005, at 6:07 AM, Michael Watzek wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have a question concerning unique deletion by query:
>>>>>
>>>>> Assuming a unique JDO query would throw a JDOUserException in  
>>>>> execute() because the result is not unique, would you expect a  
>>>>> JDOUserException thrown in deletePersistentAll()?
>>>>>
>>>>> The spec does not require this and I'm not sure if we should add a  
>>>>> negative test case checking this.
>>>>>
>>>>> Regards,
>>>>> Michael
>>>>>
>>


-- 
Michael Bouschen		Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de	http://www.tech.spree.de/
Tel.:++49/30/235 520-33		Buelowstr. 66			
Fax.:++49/30/2175 2012		D-10783 Berlin			

Re: Issue 147: Unique deletion by query

Posted by Wes Biggs <we...@tralfamadore.com>.
Craig,

I favor the exception for this case.  The way we've defined setUnique, 
it acts somewhat like an assertion, and the semantic should remain the 
same for both execute and delete.

Regards,

Wes


Craig L Russell wrote:

> Hi Michael,
>
> Sounds good.
>
> I was thinking some more about this issue and would like some feedback.
>
> I think that we should make the query.execute and 
> query.deletePersistentAll methods as similar as possible, meaning that 
> they  both should throw an exception if the cardinality of the results 
> is not zero or one.
>
> I'll have a proposed wording for the specification later, but for now 
> let's go with the patch.
>
> Thanks,
>
> Craig
>
> On Nov 28, 2005, at 5:35 AM, Michael Watzek wrote:
>
>> Hi Craig,
>>
>> I have added a second patch to JDO-166. It adds a unique query to the 
>> array of INVALID_QUERIES which is supposed to throw a 
>> JDOUserException at deletePersistentAll because the number of 
>> affected rows in the database exceeds 1.
>>
>> Regards,
>> Michael
>>
>>> Hi Michael,
>>> I'd expect a JDOUserException to be thrown.
>>> The spec says
>>> <spec 14.6.11>
>>> void setUnique(boolean unique);
>>> A14.6.11-1 [When the value of the Unique flag is true, then the  
>>> result of a query is a single value, with null used to indicate 
>>> that  none of the instances in the candidates satisfied the filter. 
>>> If more  than one instance satisfies the filter, and the range is 
>>> not limited  to one result, then execute throws a JDOUserException.]
>>> </spec 14.6.11>
>>> I can add a similar description to the deletePersistentAll methods.  
>>> It might require the JDOUserException to be thrown before actually  
>>> deleting anything (the semantics of the method are such that a 
>>> select  needs to be executed against the datastore anyway before the 
>>> delete  occurs).
>>> Another alternative is to disallow the Unique flag for  
>>> deletePersistentAll. But that's not what I would choose.
>>> Craig
>>> On Nov 25, 2005, at 6:07 AM, Michael Watzek wrote:
>>>
>>>> Hi,
>>>>
>>>> I have a question concerning unique deletion by query:
>>>>
>>>> Assuming a unique JDO query would throw a JDOUserException in  
>>>> execute() because the result is not unique, would you expect a  
>>>> JDOUserException thrown in deletePersistentAll()?
>>>>
>>>> The spec does not require this and I'm not sure if we should add a  
>>>> negative test case checking this.
>>>>
>>>> Regards,
>>>> Michael
>>>>
>


Re: Issue 147: Unique deletion by query

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Michael,

Sounds good.

I was thinking some more about this issue and would like some feedback.

I think that we should make the query.execute and  
query.deletePersistentAll methods as similar as possible, meaning  
that they  both should throw an exception if the cardinality of the  
results is not zero or one.

I'll have a proposed wording for the specification later, but for now  
let's go with the patch.

Thanks,

Craig

On Nov 28, 2005, at 5:35 AM, Michael Watzek wrote:

> Hi Craig,
>
> I have added a second patch to JDO-166. It adds a unique query to  
> the array of INVALID_QUERIES which is supposed to throw a  
> JDOUserException at deletePersistentAll because the number of  
> affected rows in the database exceeds 1.
>
> Regards,
> Michael
>> Hi Michael,
>> I'd expect a JDOUserException to be thrown.
>> The spec says
>> <spec 14.6.11>
>> void setUnique(boolean unique);
>> A14.6.11-1 [When the value of the Unique flag is true, then the   
>> result of a query is a single value, with null used to indicate  
>> that  none of the instances in the candidates satisfied the  
>> filter. If more  than one instance satisfies the filter, and the  
>> range is not limited  to one result, then execute throws a  
>> JDOUserException.]
>> </spec 14.6.11>
>> I can add a similar description to the deletePersistentAll  
>> methods.  It might require the JDOUserException to be thrown  
>> before actually  deleting anything (the semantics of the method  
>> are such that a select  needs to be executed against the datastore  
>> anyway before the delete  occurs).
>> Another alternative is to disallow the Unique flag for   
>> deletePersistentAll. But that's not what I would choose.
>> Craig
>> On Nov 25, 2005, at 6:07 AM, Michael Watzek wrote:
>>> Hi,
>>>
>>> I have a question concerning unique deletion by query:
>>>
>>> Assuming a unique JDO query would throw a JDOUserException in   
>>> execute() because the result is not unique, would you expect a   
>>> JDOUserException thrown in deletePersistentAll()?
>>>
>>> The spec does not require this and I'm not sure if we should add  
>>> a  negative test case checking this.
>>>
>>> Regards,
>>> Michael
>>> -- 
>>> -------------------------------------------------------------------
>>> Michael Watzek                  Tech@Spree Engineering GmbH
>>> mailto:mwa.tech@spree.de        Buelowstr. 66
>>> Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
>>> Fax.:  ++49/30/217 520 12       http://www.spree.de/
>>> -------------------------------------------------------------------
>> Craig Russell
>> Architect, Sun Java Enterprise System http://java.sun.com/products/ 
>> jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>
>
> -- 
> -------------------------------------------------------------------
> Michael Watzek                  Tech@Spree Engineering GmbH
> mailto:mwa.tech@spree.de        Buelowstr. 66
> Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
> Fax.:  ++49/30/217 520 12       http://www.spree.de/
> -------------------------------------------------------------------

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Issue 147: Unique deletion by query

Posted by Michael Watzek <mw...@spree.de>.
Hi Craig,

I have added a second patch to JDO-166. It adds a unique query to the 
array of INVALID_QUERIES which is supposed to throw a JDOUserException 
at deletePersistentAll because the number of affected rows in the 
database exceeds 1.

Regards,
Michael
> Hi Michael,
> 
> I'd expect a JDOUserException to be thrown.
> 
> The spec says
> 
> <spec 14.6.11>
> void setUnique(boolean unique);
> A14.6.11-1 [When the value of the Unique flag is true, then the  result 
> of a query is a single value, with null used to indicate that  none of 
> the instances in the candidates satisfied the filter. If more  than one 
> instance satisfies the filter, and the range is not limited  to one 
> result, then execute throws a JDOUserException.]
> </spec 14.6.11>
> 
> I can add a similar description to the deletePersistentAll methods.  It 
> might require the JDOUserException to be thrown before actually  
> deleting anything (the semantics of the method are such that a select  
> needs to be executed against the datastore anyway before the delete  
> occurs).
> 
> Another alternative is to disallow the Unique flag for  
> deletePersistentAll. But that's not what I would choose.
> 
> Craig
> 
> On Nov 25, 2005, at 6:07 AM, Michael Watzek wrote:
> 
>> Hi,
>>
>> I have a question concerning unique deletion by query:
>>
>> Assuming a unique JDO query would throw a JDOUserException in  
>> execute() because the result is not unique, would you expect a  
>> JDOUserException thrown in deletePersistentAll()?
>>
>> The spec does not require this and I'm not sure if we should add a  
>> negative test case checking this.
>>
>> Regards,
>> Michael
>> -- 
>> -------------------------------------------------------------------
>> Michael Watzek                  Tech@Spree Engineering GmbH
>> mailto:mwa.tech@spree.de        Buelowstr. 66
>> Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
>> Fax.:  ++49/30/217 520 12       http://www.spree.de/
>> -------------------------------------------------------------------
> 
> 
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
> 
> 


-- 
-------------------------------------------------------------------
Michael Watzek                  Tech@Spree Engineering GmbH
mailto:mwa.tech@spree.de        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------