May i know how to create childClass if my childClass method getInfoFromDB() and saveToDB() need to do different logic?
public abstract class BaseClass {
public abstract Object doTransaction();
public Object executeTrans() {
//do something
tx.begin();
this.doTransaction();
tx.commit();
}
}
public childClass extends BaseClass{
@Override
public Object doTransaction(){
//overide to get something from database so can only be used for getInfoFromDB() and not for saveToDB()
return something;
}
public List<String> getInfoFromDB(){
super.executeTrans();
}
public void saveToDB(){
super.executeTrans() ;
}
}