Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Delete Query Redirects in Second time
icon4.gif  Delete Query Redirects in Second time [message #1084254] Sun, 11 August 2013 03:34 Go to next message
Eclipse UserFriend
I've created a queryredirector on Delete in order to use soft delete but it updates database after being called for second time.


@QueryRedirectors(delete = DeleteRedirector.class)
public class EMPLOYEE {

}


public class DeleteRedirector implements QueryRedirector
{
 
    @Override
    public Object invokeQuery(DatabaseQuery query, Record arguments, Session session)
    {
        ClassDescriptor descriptor = session.getDescriptor(query.getReferenceClass());
        DeleteObjectQuery deleteObjectQuery = (DeleteObjectQuery) query;
        EMPLOYEE emp = (EMPLOYEE) deleteObjectQuery.getObject();
        emp.setStatus("deleted");
        UpdateObjectQuery updateObjectQuery = new UpdateObjectQuery(emp);
        descriptor.addDirectQueryKey("status", "STATUS");
        updateObjectQuery.setDescriptor(descriptor);
        deleteObjectQuery.setDescriptor(updateObjectQuery.getDescriptor());
        return updateObjectQuery.execute((AbstractSession) session, (AbstractRecord) arguments);        
    }
 
}


Am I missing sth ?
Re: Delete Query Redirects in Second time [message #1085875 is a reply to message #1084254] Tue, 13 August 2013 09:38 Go to previous message
Eclipse UserFriend
If would set the deleteSQLString is the DescriptorQueryManager to use an update, not use a redirector.
Previous Topic:JPA selecting, what should be lazy loaded, when not necessary
Next Topic:Log Rotation
Goto Forum:
  


Current Time: Mon Jul 07 01:45:30 EDT 2025

Powered by FUDForum. Page generated in 0.07963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top