Loading...

jdo-dev@db.apache.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

[jira] [Commented] (JDO-617) JDOQL : Bulk Update and Delete Operations Craig L Russell (Commented) (JIRA) Fri Apr 06 15:00:29 2012

    [ 
https://issues.apache.org/jira/browse/JDO-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13248893#comment-13248893
 ] 

Craig L Russell commented on JDO-617:
-------------------------------------

I don't see the value in adding update by query to JDO, either in the query 
language or in the typesafe query methods. What we have defined already is 
using a query language to select a number of items to operate on (either read 
into memory or delete). Once you have the list of items, you iterate the list 
and perform some algorithm on the items using the native methods of the memory 
language, Java. Any changes will be reflected in the datastore if you commit 
the transaction. 

In contrast, specifying a Java algorithm to execute on all selected items from 
the datastore is fraught. Simply providing a constant new value for selected 
fields doesn't seem very useful. There are ways of specifying a Java algorithm 
to operate on some items, and passing the algorithm to the query method. For 
example, passing a "function object" (Runnable) to the query, and expecting the 
function object to be applied to each item in the result. The implementation 
would need to read the byte codes of the "function object" to figure out 
exactly what the function was doing and try to apply that function to the 
datastore objects. 

But I suspect that even this small bit of functionality won't be worth the 
considerable effort to implement. 

Bottom line, while I appreciate that there are many places where there is a 
natural mapping between a subset of Java that is useful to filter objects from 
a datastore and the corresponding datastore language, update is not one of 
these places.
                
> JDOQL : Bulk Update and Delete Operations
> -----------------------------------------
>
>                 Key: JDO-617
>                 URL: https://issues.apache.org/jira/browse/JDO-617
>             Project: JDO
>          Issue Type: New Feature
>            Reporter: Eric SULTAN
>
> It would be usefull that the JDO Query Langage could do some UPDATE and 
> DELETE on Persistent Object like this :
> UPDATE [<candidate-class>] SET item1=<newValue>, item2=<newValue> [WHERE 
> <filter>]
> The new_value specified for an update operation must be compatible in type 
> with the state-field to
> which it is assigned.
> Bulk Update must modify the value of the version column and refresh Level1 
> and Level2 cache.
> DELETE FROM [<candidate-class>] [WHERE <filter>]
> By default Bulk Delete is appy on the specified class and its subclasses and 
> doesn't do cascade delete.
> A keyword like CASCADE must be set if we want to does a cascade delete : 
> DELETE CASCADE FROM [<candidate-class>] [WHERE <filter>]

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira