we use the
Lifecycle interface's
onLoad method
i need to ask a question about this method
why this method has 2 param's passed to it.
in
onSave,
onUpdate and
onDelete, they has just 1 parameter passed,
what is the benefit of the second parameter passed for
onLoad method,
to explain this, i have written the code of my pojo:
Code:
public class Course implements Lifecycle
{
private Long id;
private String name;
private Long duration;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setDuration(Long duration)
{
this.duration = duration;
}
public Long getDuration()
{
return duration;
}
public void onLoad(Session s, Serializable id)
{
System.out.println("onLoad.");
System.out.println("id = " + id);
System.out.println("this.id = " + this.id);
}
public boolean onSave(Session s){ }
public boolean onUpdate(Session s){ }
public boolean onDelete(Session s){ }
}
as you can see the onLoad method has the id of the current pojo as a parameter and also has the same id as field variable in it.
why Lifecycle interface's onLoad has the identifier as a parameter?