Hi Inna,
This topic is also related to this:
What I am trying to do, using Java cloud code, is cascade the deletes of the associated child table rows when a parent row is deleted. I have created multiple event handlers to use for debugging: beforeDelete, beforeFindById, and afterFindById. In all of them I can retrieve the parent table (the event handler asset) row but I am not able to retrieve the objectIDs of the relations to remove them.
Here is the Java class in the event handler download:
package com.higherendeavors.models;
import com.backendless.Backendless;
import com.backendless.BackendlessUser;
public class Movies
{
private java.util.List datesWatched;
private String rating;
private String title;
private String release_year;
private java.util.Date created;
private java.util.Date updated;
private String objectId;
private String ownerId;
private String plot;
public java.util.List getDatesWatched()
{
return this.datesWatched;
}
public String getRating()
{
return this.rating;
}
public String getTitle()
{
return this.title;
}
public String getRelease_year()
{
return this.release_year;
}
public java.util.Date getCreated()
{
return this.created;
}
public java.util.Date getUpdated()
{
return this.updated;
}
public String getObjectId()
{
return this.objectId;
}
public String getOwnerId()
{
return this.ownerId;
}
public String getPlot()
{
return this.plot;
}
public void setDatesWatched( java.util.List datesWatched )
{
this.datesWatched = datesWatched;
}
public void setRating( String rating )
{
this.rating = rating;
}
public void setTitle( String title )
{
this.title = title;
}
public void setRelease_year( String release_year )
{
this.release_year = release_year;
}
public void setCreated( java.util.Date created )
{
this.created = created;
}
public void setUpdated( java.util.Date updated )
{
this.updated = updated;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
public void setOwnerId( String ownerId )
{
this.ownerId = ownerId;
}
public void setPlot( String plot )
{
this.plot = plot;
}
public Movies save()
{
return Backendless.Data.of( Movies.class ).save( this );
}
public Long remove()
{
return Backendless.Data.of( Movies.class ).remove( this );
}
public static Movies findById( String id )
{
return Backendless.Data.of( Movies.class ).findById( id );
}
public static Movies findFirst()
{
return Backendless.Data.of( Movies.class ).findFirst();
}
public static Movies findLast()
{
return Backendless.Data.of( Movies.class ).findLast();
}
}
There are no methods to bulkDelete or loadRelations. I am not understanding how to implement either of your solutions.
As an aside, I have poked around in the Backendless.jar file and see methods implemented there along with “Backendless.Data.of( Movies.class ).findById( id )” which is used in a Movie.class method. Is it standard practice to add your own methods to the generated classes using exposed functionality in the library, or is that subject to change and not advised?
Thanks, Mark